Author: sveinung
Date: Mon Aug  3 16:59:18 2015
New Revision: 29308

URL: http://svn.gna.org/viewcvs/freeciv?rev=29308&view=rev
Log:
orders system: don't try to perform an action known to be illegal

When an illegal action is attempted the rules may punish the player. Don't
try to perform an illegal action in cases where the player has access to
information that proves that the action is illegal.

See patch #6161

Modified:
    trunk/server/unittools.c

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29308&r1=29307&r2=29308&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Mon Aug  3 16:59:18 2015
@@ -4139,6 +4139,22 @@
 
       fc_assert_ret_val_msg(dst_tile, FALSE, "No target tile for action");
 
+      if (!action_prob_possible(action_prob_vs_tile(punit, order.action,
+                                                    dst_tile))) {
+        /* The player has enough information to know that this action is
+         * against the rules. Don't risk any punishment by trying to
+         * perform it. */
+
+        cancel_orders(punit, "  illegal action");
+        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
+                      _("%s could not do %s to %s."),
+                      unit_link(punit),
+                      action_get_ui_name(order.action),
+                      tile_link(dst_tile));
+
+        return TRUE;
+      }
+
       handle_unit_do_action(pplayer,
                             unitid,
                             dst_tile->index,


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

Reply via email to