Author: sveinung
Date: Tue Jun 28 12:39:55 2016
New Revision: 33082

URL: http://svn.gna.org/viewcvs/freeciv?rev=33082&view=rev
Log:
Action not enabled explain hard war requirements.

Some hard war requirements can't be put in an action enabler because it
isn't against the target. Examples are a city blocking an action with a unit
stack target or a unit blocking an action with a tile target.

Reported by Marko Lindqvist <cazfi>

See bug #24797

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=33082&r1=33081&r2=33082&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Jun 28 12:39:55 2016
@@ -514,6 +514,69 @@
     return NULL;
   }
 
+  /* Look for hard coded war requirements that can't be an action enabler
+   * requirement. */
+  switch ((enum gen_action)act) {
+  case ACTION_BOMBARD:
+  case ACTION_NUKE:
+  case ACTION_ATTACK:
+    /* Target is tile or unit stack but a city (or unit) can block it. */
+    if ((act != ACTION_NUKE || unit_tile(actor) != target_tile)
+        && target_tile) {
+      /* This isn't nuking the actor's own tile so hard coded restrictions
+       * do apply. */
+
+      struct city *tcity;
+      struct unit *tunit;
+
+      if ((tcity = tile_city(target_tile))
+          && player_diplstate_get(unit_owner(actor),
+                                  city_owner(tcity))->type != DS_WAR) {
+        return city_owner(tcity);
+      }
+
+      if ((tunit = is_non_attack_unit_tile(target_tile, unit_owner(actor)))
+          && player_diplstate_get(unit_owner(actor),
+                                  unit_owner(tunit))->type != DS_WAR) {
+        return unit_owner(tunit);
+      }
+    }
+    break;
+  case ACTION_ESTABLISH_EMBASSY:
+  case ACTION_SPY_INVESTIGATE_CITY:
+  case ACTION_SPY_POISON:
+  case ACTION_SPY_STEAL_GOLD:
+  case ACTION_SPY_SABOTAGE_CITY:
+  case ACTION_SPY_TARGETED_SABOTAGE_CITY:
+  case ACTION_SPY_STEAL_TECH:
+  case ACTION_SPY_TARGETED_STEAL_TECH:
+  case ACTION_SPY_INCITE_CITY:
+  case ACTION_TRADE_ROUTE:
+  case ACTION_MARKETPLACE:
+  case ACTION_HELP_WONDER:
+  case ACTION_SPY_BRIBE_UNIT:
+  case ACTION_SPY_SABOTAGE_UNIT:
+  case ACTION_CAPTURE_UNITS: /* Only foreign is a hard req. */
+  case ACTION_FOUND_CITY:
+  case ACTION_JOIN_CITY:
+  case ACTION_STEAL_MAPS:
+  case ACTION_SPY_NUKE:
+  case ACTION_DESTROY_CITY:
+  case ACTION_EXPEL_UNIT:
+  case ACTION_RECYCLE_UNIT:
+  case ACTION_DISBAND_UNIT:
+  case ACTION_HOME_CITY:
+  case ACTION_UPGRADE_UNIT:
+  case ACTION_PARADROP:
+  case ACTION_AIRLIFT:
+    /* No special help. */
+    break;
+  case ACTION_COUNT:
+    /* Invalid. */
+    break;
+  }
+
+  /* Look for war requirements from the action enablers. */
   if (can_utype_do_act_if_tgt_diplrel(unit_type_get(actor),
                                       act, DS_WAR, FALSE)) {
     /* The unit can do the action even if there isn't war. */


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to