Author: sveinung
Date: Fri Jul 10 15:28:28 2015
New Revision: 29212

URL: http://svn.gna.org/viewcvs/freeciv?rev=29212&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:
    branches/S2_6/server/unithand.c
    branches/S2_6/server/unittools.c
    branches/S2_6/server/unittools.h

Modified: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=29212&r1=29211&r2=29212&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Fri Jul 10 15:28:28 2015
@@ -3217,7 +3217,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: branches/S2_6/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=29212&r1=29211&r2=29212&view=diff
==============================================================================
--- branches/S2_6/server/unittools.c    (original)
+++ branches/S2_6/server/unittools.c    Fri Jul 10 15:28:28 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;
 }
@@ -3759,8 +3759,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;
@@ -3783,6 +3786,7 @@
 
   while (TRUE) {
     struct unit_order order;
+    bool player_is_watching;
 
     if (punit->done_moving) {
       log_debug("  stopping because we're done this turn");
@@ -3833,6 +3837,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);
@@ -3991,11 +4001,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: branches/S2_6/server/unittools.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.h?rev=29212&r1=29211&r2=29212&view=diff
==============================================================================
--- branches/S2_6/server/unittools.h    (original)
+++ branches/S2_6/server/unittools.h    Fri Jul 10 15:28:28 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