Author: sveinung
Date: Wed Sep 30 03:30:59 2015
New Revision: 29995

URL: http://svn.gna.org/viewcvs/freeciv?rev=29995&view=rev
Log:
orders system: support targeted sabotage city

See patch #6382

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

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29995&r1=29994&r2=29995&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Wed Sep 30 03:30:59 2015
@@ -5223,6 +5223,18 @@
 
         if (order->order == ORDER_PERFORM_ACTION) {
           switch (order->action) {
+          case ACTION_SPY_TARGETED_SABOTAGE_CITY:
+            /* Sabotage target is production (-1) or a building. */
+            if (!(order_tgt == -1
+                  || improvement_by_number(order_tgt))) {
+              /* Sabotage target is invalid. */
+              log_sg("Cannot find building %d for %s to sabotage",
+                     order_tgt, unit_rule_name(punit));
+              order->target = EXTRA_NONE;
+            } else {
+              order->target = order_tgt;
+            }
+            break;
           case ACTION_SPY_TARGETED_STEAL_TECH:
             if (order_tgt == A_NONE
                 || (!valid_advance_by_number(order_tgt)
@@ -5240,7 +5252,6 @@
           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_INCITE_CITY:
           case ACTION_TRADE_ROUTE:

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29995&r1=29994&r2=29995&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Sep 30 03:30:59 2015
@@ -3915,6 +3915,20 @@
           return;
         }
         break;
+      case ACTION_SPY_TARGETED_SABOTAGE_CITY:
+        /* Sabotage target is production (-1) or a building. */
+        if (!(packet->target[i] == -1
+              || improvement_by_number(packet->target[i]))) {
+          /* Sabotage target is invalid. */
+
+          log_error("handle_unit_orders() can't do %s without a target. "
+                    "Sent in order number %d from %s to unit number %d.",
+                    action_get_rule_name(packet->action[i]), i,
+                    player_name(pplayer), packet->unit_id);
+
+          return;
+        }
+        break;
       case ACTION_SPY_TARGETED_STEAL_TECH:
         if (packet->target[i] == A_NONE
             || (!valid_advance_by_number(packet->target[i])
@@ -3951,15 +3965,6 @@
       case ACTION_EXPEL_UNIT:
         /* No validation required. */
         break;
-      /* Needs additional target information. */
-      case ACTION_SPY_TARGETED_SABOTAGE_CITY:
-        log_error("handle_unit_orders() the action %s isn't allowed in "
-                  "orders. "
-                  "Sent in order number %d from %s to unit number %d.",
-                  action_get_rule_name(packet->action[i]), i,
-                  player_name(pplayer), packet->unit_id);
-
-        return;
       /* Invalid action. Should have been caught above. */
       case ACTION_COUNT:
         fc_assert_ret_msg(packet->action[i] != ACTION_COUNT,


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

Reply via email to