Author: sveinung
Date: Sun Aug  9 15:12:43 2015
New Revision: 29421

URL: http://svn.gna.org/viewcvs/freeciv?rev=29421&view=rev
Log:
order system: validate action target tile

The perform action unit order can target a neighbor tile. If the unit is
located at the edge of the map the neighbor tile in the specified direction
may be non existing.

Always check that the target tile exists when executing the perform action
order.

See bug #23763

Modified:
    trunk/server/unittools.c

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29421&r1=29420&r2=29421&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Sun Aug  9 15:12:43 2015
@@ -4141,7 +4141,18 @@
         dst_tile = mapstep(unit_tile(punit), order.dir);
       }
 
-      fc_assert_ret_val_msg(dst_tile, FALSE, "No target tile for action");
+      if (dst_tile == NULL) {
+        /* Could be at the edge of the map while trying to target a tile
+         * outside of it. */
+
+        cancel_orders(punit, "  target location doesn't exist");
+        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
+                      _("%s could not do %s. No target tile."),
+                      unit_link(punit),
+                      action_get_ui_name(order.action));
+
+        return TRUE;
+      }
 
       /* Get the target city from the target tile. */
       tgt_city = tile_city(dst_tile);


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

Reply via email to