Author: sveinung
Date: Fri Jul 10 15:18:42 2015
New Revision: 29210

URL: http://svn.gna.org/viewcvs/freeciv?rev=29210&view=rev
Log:
Don't tell the player that the move he just watched fail failed.

It is safe to assume that the player is watching a unit if the unit has
moves left and the player just gave the orders. Don't bother him with a
message informing him about what he just watched.

Reported by Caedo on the Freeciv forum.

See bug #23680

Modified:
    trunk/server/unithand.c
    trunk/server/unittools.c
    trunk/server/unittools.h

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29210&r1=29209&r2=29210&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Jul 10 15:18:42 2015
@@ -3508,7 +3508,7 @@
 #endif
 
   if (!is_player_phase(unit_owner(punit), game.info.phase)
-      || execute_orders(punit)) {
+      || execute_orders(punit, TRUE)) {
     /* Looks like the unit survived. */
     send_unit_info(NULL, punit);
   }

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29210&r1=29209&r2=29210&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Fri Jul 10 15:18:42 2015
@@ -603,7 +603,7 @@
 {
   unit_list_iterate_safe(pplayer->units, punit) {
     if (unit_has_orders(punit)) {
-      execute_orders(punit);
+      execute_orders(punit, FALSE);
     }
   } unit_list_iterate_safe_end;
 }
@@ -3773,8 +3773,11 @@
   turn when the unit is back where it started, even if it have moves left.
 
   A unit will attack under orders only on its final action.
+
+  The fresh parameter is true if the order execution happens because the
+  orders just were received.
 ****************************************************************************/
-bool execute_orders(struct unit *punit)
+bool execute_orders(struct unit *punit, const bool fresh)
 {
   struct tile *dst_tile;
   bool res, last_order;
@@ -3797,6 +3800,7 @@
 
   while (TRUE) {
     struct unit_order order;
+    bool player_is_watching;
 
     if (punit->done_moving) {
       log_debug("  stopping because we're done this turn");
@@ -3847,6 +3851,12 @@
       /* 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);
@@ -4017,11 +4027,18 @@
 
       if (!res) {
         fc_assert(0 <= punit->moves_left);
+
         /* Movement failed (ZOC, etc.) */
         cancel_orders(punit, "  attempt to move failed.");
-        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
-                      _("Orders for %s aborted because of failed move."),
-                      unit_link(punit));
+
+        if (!player_is_watching) {
+          /* The player may have missed this. Inform him. */
+          notify_player(pplayer, unit_tile(punit),
+                        E_UNIT_ORDERS, ftc_server,
+                        _("Orders for %s aborted because of failed move."),
+                        unit_link(punit));
+        }
+
         return TRUE;
       }
       break;

Modified: trunk/server/unittools.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.h?rev=29210&r1=29209&r2=29210&view=diff
==============================================================================
--- trunk/server/unittools.h    (original)
+++ trunk/server/unittools.h    Fri Jul 10 15:18:42 2015
@@ -150,7 +150,7 @@
 void unit_transport_load_send(struct unit *punit, struct unit *ptrans);
 void unit_transport_unload_send(struct unit *punit);
 bool unit_move(struct unit *punit, struct tile *ptile, int move_cost);
-bool execute_orders(struct unit *punit);
+bool execute_orders(struct unit *punit, const bool fresh);
 
 bool unit_can_do_action_now(const struct unit *punit);
 void unit_did_action(struct unit *punit);


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

Reply via email to