Author: sveinung
Date: Mon May 11 04:31:06 2015
New Revision: 29044

URL: http://svn.gna.org/viewcvs/freeciv?rev=29044&view=rev
Log:
Move foreign target action requirement to is_action_possible()

Doing certain actions against a domestic target is currently pointless. It
is therefore hard coded that the target must be foreign. Do this hard coding
in is_action_possible() in stead of appending it to each action enabler for
any of those actions.

See patch #6072

Modified:
    branches/S2_6/common/actions.c

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=29044&r1=29043&r2=29044&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Mon May 11 04:31:06 2015
@@ -360,20 +360,6 @@
 **************************************************************************/
 void action_enabler_append_hard(struct action_enabler *enabler)
 {
-  if (enabler->action != ACTION_TRADE_ROUTE
-      && enabler->action != ACTION_MARKETPLACE
-      && enabler->action != ACTION_HELP_WONDER
-      && enabler->action != ACTION_SPY_POISON
-      && enabler->action != ACTION_SPY_SABOTAGE_CITY
-      && enabler->action != ACTION_SPY_TARGETED_SABOTAGE_CITY
-      && enabler->action != ACTION_SPY_SABOTAGE_UNIT) {
-    /* 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->actor_reqs,
-                              req_from_str("DiplRel", "Local", FALSE,
-                                           TRUE, "Is foreign"));
-  }
 }
 
 /**************************************************************************
@@ -439,6 +425,25 @@
      * controlled by action enablers assumes that the acting player can see
      * the target unit. */
     if (!can_player_see_unit(actor_player, target_unit)) {
+      return FALSE;
+    }
+  }
+
+  if (wanted_action == ACTION_ESTABLISH_EMBASSY
+      || wanted_action == ACTION_SPY_INVESTIGATE_CITY
+      || wanted_action == ACTION_SPY_STEAL_GOLD
+      || wanted_action == ACTION_SPY_STEAL_TECH
+      || wanted_action == ACTION_SPY_TARGETED_STEAL_TECH
+      || wanted_action == ACTION_SPY_INCITE_CITY
+      || wanted_action == ACTION_SPY_BRIBE_UNIT) {
+    /* Why this is a hard requirement: There is currently no point in
+     * allowing the listed actions against domestic targets.
+     * (Possible counter argument: crazy hack involving the Lua callback
+     * action_started_callback() to use an action to do something else. */
+    /* Info leak: The actor player knows what targets he owns. */
+    /* TODO: Move this restriction to the ruleset as a part of false flag
+     * operation support. */
+    if (actor_player == target_player) {
       return FALSE;
     }
   }


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

Reply via email to