Author: sveinung
Date: Wed Jul 29 12:57:31 2015
New Revision: 29263

URL: http://svn.gna.org/viewcvs/freeciv?rev=29263&view=rev
Log:
Find out if the player is watching after the order executed.

Some orders may spend moves while failing.

See patch #6144

Modified:
    trunk/server/unittools.c

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29263&r1=29262&r2=29263&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Wed Jul 29 12:57:31 2015
@@ -3749,6 +3749,22 @@
   return ACTION_COUNT;
 }
 
+/**************************************************************************
+  Returns TRUE iff it is reasonable to assume that the player is wathing
+  the unit.
+
+  Since the player is watching the unit there is no need to inform him
+  about things he could see happening. Remember that it still may
+  be necessary to explain why something happened.
+**************************************************************************/
+static inline bool player_is_watching(struct unit *punit, const bool fresh)
+{
+  /* The player just sent the orders to the unit. The unit has moves left.
+   * It is therefore safe to assume that the player already is paying
+   * attention to the unit. */
+  return fresh && punit->moves_left > 0;
+}
+
 /****************************************************************************
   Executes a unit's orders stored in punit->orders.  The unit is put on idle
   if an action fails or if "patrol" is set and an enemy unit is encountered.
@@ -3791,7 +3807,6 @@
 
   while (TRUE) {
     struct unit_order order;
-    bool player_is_watching;
 
     if (punit->done_moving) {
       log_debug("  stopping because we're done this turn");
@@ -3842,12 +3857,6 @@
       /* Those actions don't require moves left. */
       break;
     }
-
-    /* The player just sent the orders. The unit has moves left. It is
-     * therefore safe to assume that the player is paying attention.
-     * There is no need to inform the player about what he just watched.
-     * Explaining why it happened may still be necessary. */
-    player_is_watching = fresh && punit->moves_left > 0;
 
     last_order = (!punit->orders.repeat
                  && punit->orders.index + 1 == punit->orders.length);
@@ -4022,7 +4031,7 @@
         /* Movement failed (ZOC, etc.) */
         cancel_orders(punit, "  attempt to move failed.");
 
-        if (!player_is_watching) {
+        if (!player_is_watching(punit, fresh)) {
           /* The player may have missed this. Inform him. */
           notify_player(pplayer, unit_tile(punit),
                         E_UNIT_ORDERS, ftc_server,


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

Reply via email to