Author: sveinung
Date: Mon Aug  3 16:53:03 2015
New Revision: 29307

URL: http://svn.gna.org/viewcvs/freeciv?rev=29307&view=rev
Log:
orders system: allow actions to target a neighbor tile

An action order can already target the tile the actor unit is standing on.
Make it possible to act against a tile next to it too.

See patch #6160

Modified:
    trunk/client/goto.c
    trunk/fc_version
    trunk/server/savegame3.c
    trunk/server/unittools.c

Modified: trunk/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.c?rev=29307&r1=29306&r2=29307&view=diff
==============================================================================
--- trunk/client/goto.c (original)
+++ trunk/client/goto.c Mon Aug  3 16:53:03 2015
@@ -1403,10 +1403,23 @@
   if (p.orders[i - 1] == ORDER_MOVE
       && (is_non_allied_city_tile(old_tile, client_player()) != NULL
           || is_non_allied_unit_tile(old_tile, client_player()) != NULL)) {
-    p.orders[i - 1] = ORDER_ACTION_MOVE;
-  }
-
-  if (final_order) {
+    /* Won't be able to perform a regular move to the target tile... */
+    if (!final_order) {
+      /* ...and no final order exists. Choose what to do when the unit gets
+       * there. */
+      p.orders[i - 1] = ORDER_ACTION_MOVE;
+    } else {
+      /* ...but a final order exist. Try performing it from the neigbor
+       * tile in the unit's path. */
+      p.orders[i - 1] = final_order->order;
+      /* (the direction from the final move is kept) */
+      p.activity[i - 1] = (final_order->order == ORDER_ACTIVITY)
+        ? final_order->activity : ACTIVITY_LAST;
+      p.target[i - 1] = final_order->target;
+      p.action[i - 1] = final_order->action;
+    }
+  } else if (final_order) {
+    /* Append the final order after moving to the target tile. */
     p.orders[i] = final_order->order;
     p.dir[i] = (final_order->order == ORDER_MOVE) ? final_order->dir : -1;
     p.activity[i] = (final_order->order == ORDER_ACTIVITY)

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29307&r1=29306&r2=29307&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Mon Aug  3 16:53:03 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Jul.31d"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Aug.03"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29307&r1=29306&r2=29307&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Mon Aug  3 16:53:03 2015
@@ -5318,6 +5318,10 @@
           break;
         case ORDER_PERFORM_ACTION:
           action_buf[j] = num2char(punit->orders.list[j].action);
+          if (punit->orders.list[j].dir != -1) {
+            /* The action target is on another tile. */
+            dir_buf[j] = dir2char(punit->orders.list[j].dir);
+          }
           break;
         case ORDER_FULL_MP:
         case ORDER_BUILD_CITY:

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29307&r1=29306&r2=29307&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Mon Aug  3 16:53:03 2015
@@ -4129,7 +4129,13 @@
             action_get_target_kind(order.action) == ATK_TILE,
             "Only tile targets are currently supported");
 
-      dst_tile = unit_tile(punit);
+      if (!is_valid_dir(order.dir)) {
+        /* The target of the action is on the actor's tile. */
+        dst_tile = unit_tile(punit);
+      } else {
+        /* The target of the action is on a tile next to the actor. */
+        dst_tile = mapstep(unit_tile(punit), order.dir);
+      }
 
       fc_assert_ret_val_msg(dst_tile, FALSE, "No target tile for action");
 


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

Reply via email to