Author: sveinung
Date: Sun Aug 31 14:31:19 2014
New Revision: 26158

URL: http://svn.gna.org/viewcvs/freeciv?rev=26158&view=rev
Log:
Let the action enabler know that the target of a spy action must be foreign

Add the requirement that the target of a spy action must be foreign to the
target requirement vector of all spy action enablers.

The C coded restrictions remain in target finding code.

See patch #5147

Modified:
    trunk/common/actions.c
    trunk/common/unit.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=26158&r1=26157&r2=26158&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Sun Aug 31 14:31:19 2014
@@ -264,6 +264,13 @@
                               req_from_str("MaxUnitsOnTile", "Local",
                                            FALSE, TRUE, "1"));
   }
+
+  /* The Freeciv code assumes that all spy actions have foreign targets.
+   * TODO: Move this restriction to the ruleset to prepare for false flag
+   * operations. */
+  requirement_vector_append(&enabler->target_reqs,
+                            req_from_str("DiplRel", "Local", FALSE,
+                                         TRUE, "Is foreign"));
 }
 
 /**************************************************************************

Modified: trunk/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.c?rev=26158&r1=26157&r2=26158&view=diff
==============================================================================
--- trunk/common/unit.c (original)
+++ trunk/common/unit.c Sun Aug 31 14:31:19 2014
@@ -95,8 +95,7 @@
   struct unit *punit;
 
   if ((pcity = tile_city(ptile))) {
-    if (city_owner(pcity) != unit_owner(pdiplomat)
-        && real_map_distance(unit_tile(pdiplomat), pcity->tile) <= 1) {
+    if (real_map_distance(unit_tile(pdiplomat), pcity->tile) <= 1) {
       if ((action == DIPLOMAT_SABOTAGE || action == DIPLOMAT_ANY_ACTION)
           && is_action_enabled_unit_on_city(ACTION_SPY_SABOTAGE_CITY,
                                             pdiplomat, pcity)) {
@@ -155,7 +154,6 @@
 
     if ((action == SPY_SABOTAGE_UNIT || action == DIPLOMAT_ANY_ACTION)
         && can_player_see_unit(unit_owner(pdiplomat), punit)
-        && unit_owner(pdiplomat) != unit_owner(punit)
         && is_action_enabled_unit_on_unit(ACTION_SPY_SABOTAGE_UNIT,
                                           pdiplomat, punit)) {
       return TRUE;
@@ -163,7 +161,6 @@
 
     if ((action == DIPLOMAT_BRIBE || action == DIPLOMAT_ANY_ACTION)
         && can_player_see_unit(unit_owner(pdiplomat), punit)
-        && unit_owner(pdiplomat) != unit_owner(punit)
         && is_action_enabled_unit_on_unit(ACTION_SPY_BRIBE_UNIT,
                                           pdiplomat, punit)) {
       return TRUE;


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

Reply via email to