Author: sveinung
Date: Sun Oct  4 00:28:05 2015
New Revision: 30010

URL: http://svn.gna.org/viewcvs/freeciv?rev=30010&view=rev
Log:
Signal untargeted sabotage city by the action

If a random target should be sabotaged or if the spy should go for the user
specified target is a consequence of the action. Stop using the target id to
signal it. Signal it with the action in stead.

See patch #6387

Modified:
    trunk/server/diplomats.c
    trunk/server/unithand.c

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=30010&r1=30009&r2=30010&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Sun Oct  4 00:28:05 2015
@@ -890,8 +890,10 @@
 
 /**************************************************************************
   Sabotage enemy city's improvement or production.
-  If "improvement" is B_LAST, sabotage a random improvement or production.
-  Else, if "improvement" is -1, sabotage current production.
+  If this is untargeted sabotage city a random improvement or production is
+  targeted.
+  Targeted sabotage city lets the value of "improvement" decide the target.
+  If "improvement" is -1, sabotage current production.
   Otherwise, sabotage the city improvement whose ID is "improvement".
 
   - Check for infiltration success.  Our saboteur may not survive this.
@@ -976,11 +978,7 @@
   log_debug("sabotage: count of improvements: %d", count);
 
   /* Determine the target (-1 is production). */
-  if (improvement < 0) {
-    /* If told to sabotage production, do so. */
-    ptarget = NULL;
-    log_debug("sabotage: specified target production");
-  } else if (improvement >= B_LAST) {
+  if (action_id == ACTION_SPY_SABOTAGE_CITY) {
     /*
      * Pick random:
      * 50/50 chance to pick production or some improvement.
@@ -1024,6 +1022,10 @@
         log_error("sabotage: random: targeted improvement error!");
       }
     }
+  } else if (improvement < 0) {
+    /* If told to sabotage production, do so. */
+    ptarget = NULL;
+    log_debug("sabotage: specified target production");
   } else {
     struct impr_type *pimprove = improvement_by_number(improvement);
     if (pimprove == NULL) {

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=30010&r1=30009&r2=30010&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Oct  4 00:28:05 2015
@@ -1520,9 +1520,7 @@
     }
     break;
   case ACTION_SPY_TARGETED_SABOTAGE_CITY:
-    if (pcity
-        /* This isn't untargeted sabotage city. */
-        && value != (B_LAST + 1)) {
+    if (pcity) {
       if (is_action_enabled_unit_on_city(action_type, actor_unit, pcity)) {
         ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity);
 


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

Reply via email to