Author: sveinung
Date: Sun Oct  4 01:20:47 2015
New Revision: 30011

URL: http://svn.gna.org/viewcvs/freeciv?rev=30011&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:
    branches/S2_6/server/diplomats.c
    branches/S2_6/server/unithand.c

Modified: branches/S2_6/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/diplomats.c?rev=30011&r1=30010&r2=30011&view=diff
==============================================================================
--- branches/S2_6/server/diplomats.c    (original)
+++ branches/S2_6/server/diplomats.c    Sun Oct  4 01:20:47 2015
@@ -827,8 +827,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.
@@ -907,11 +909,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.
@@ -955,6 +953,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: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=30011&r1=30010&r2=30011&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Sun Oct  4 01:20:47 2015
@@ -1126,9 +1126,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