Author: sveinung
Date: Tue Feb  9 17:48:49 2016
New Revision: 31838

URL: http://svn.gna.org/viewcvs/freeciv?rev=31838&view=rev
Log:
Forbid long range actions in orders.

A unit order stores an action's target as the tile it is located on. The
tile is stored as a direction when the target is at a tile adjacent to the
actor unit's tile and as no direction when the target is at the actor unit's
tile. The order system will pick a suitable target at the specified tile
during order execution. This makes it impossible to target something that
isn't at or next to the actors tile.

No currently existing action can target anything outside the range allowed
by a unit order. Future actions will. Sending one of those in a unit order
packet will severely handicap it. A client should therefore send them in the
unit_do_action packet. Forbid actions with a max distance above 1 in unit
order packets.

See patch #6926

Modified:
    trunk/client/gui-qt/menu.cpp
    trunk/server/unithand.c

Modified: trunk/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.cpp?rev=31838&r1=31837&r2=31838&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.cpp        (original)
+++ trunk/client/gui-qt/menu.cpp        Tue Feb  9 17:48:49 2016
@@ -385,6 +385,14 @@
         /* This menu doesn't support specifying a detailed target (think
          * "Go to and..."->"Industrial Sabotage"->"City Walls") for the
          * action order. */
+        continue;
+      }
+
+      if (action_by_number(action_id)->max_distance > 1) {
+        /* The order system doesn't support actions that can be done to a
+         * target that isn't at or next to the actor unit's tile.
+         *
+         * Full explanation in handle_unit_orders(). */
         continue;
       }
 

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31838&r1=31837&r2=31838&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Feb  9 17:48:49 2016
@@ -4084,6 +4084,33 @@
         return;
       }
 
+      if (action_by_number(packet->action[i])->max_distance > 1) {
+        /* Long range actions aren't supported in unit orders. Clients
+         * should order them performed via the unit_do_action packet.
+         *
+         * Reason: A unit order stores an action's target as the tile it is
+         * located on. The tile is stored as a direction (when the target
+         * is at a tile adjacent to the actor unit tile) or as no
+         * direction (when the target is at the same tile as the actor
+         * unit). The order system will pick a suitable target at the
+         * specified tile during order execution. This makes it impossible
+         * to target something that isn't at or next to the actors tile.
+         * Being unable to exploit the full range of an action handicaps
+         * it.
+         *
+         * A patch that allows a distant target in an order should remove
+         * this check and update the comment in the Qt client's
+         * go_act_menu::create(). */
+
+        log_error("handle_unit_orders() the action %s isn't supported in "
+                  "unit orders. "
+                  "Sent in order number %d from %s to unit number %d.",
+                  action_get_ui_name(packet->action[i]), i,
+                  player_name(pplayer), packet->unit_id);
+
+        return;
+      }
+
       /* Validate individual actions. */
       switch ((enum gen_action) packet->action[i]) {
       case ACTION_FOUND_CITY:


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

Reply via email to