Author: sveinung
Date: Fri Feb 12 15:56:19 2016
New Revision: 31899

URL: http://svn.gna.org/viewcvs/freeciv?rev=31899&view=rev
Log:
Keep action decision data until taken.

The fact that an action decision dialog is open doesn't guarantee that the
player will have a chance to respond. His network connection may go down.
An admin may save the game and later restart it from that save game.

See patch #6946

Modified:
    trunk/client/control.c
    trunk/common/unit.h
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=31899&r1=31898&r2=31899&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Fri Feb 12 15:56:19 2016
@@ -994,16 +994,18 @@
 {
   struct unit *old;
 
-  /* There is a risk of a loop unless the old unit is done. */
-  fc_assert(!(old = game_unit_by_number(old_actor_id))
-            || old->action_decision_want == ACT_DEC_NOTHING);
-
   /* This was called because the queue can move on. */
   have_asked_server_for_actions = FALSE;
 
+  if ((old = game_unit_by_number(old_actor_id))) {
+    /* Have the server record that a decision no longer is wanted. */
+    dsend_packet_unit_sscs_set(&client.conn, old_actor_id,
+                               USSDT_UNQUEUE, IDENTITY_NUMBER_ZERO);
+  }
+
   /* Go to the next unit in focus that needs a decision. */
   unit_list_iterate(get_units_in_focus(), funit) {
-    if (should_ask_server_for_actions(funit)) {
+    if (old != funit && should_ask_server_for_actions(funit)) {
       ask_server_for_actions(funit);
       return;
     }

Modified: trunk/common/unit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.h?rev=31899&r1=31898&r2=31899&view=diff
==============================================================================
--- trunk/common/unit.h (original)
+++ trunk/common/unit.h Fri Feb 12 15:56:19 2016
@@ -100,9 +100,12 @@
 /* The player wants to be reminded to ask what actions the unit can perform
  * to a certain target tile. */
 #define SPECENUM_VALUE0 USSDT_QUEUE
+/* The player no longer wants the reminder to ask what actions the unit can
+ * perform to a certain target tile. */
+#define SPECENUM_VALUE1 USSDT_UNQUEUE
 /* The player wants to record that the unit now belongs to the specified
  * battle group. */
-#define SPECENUM_VALUE1 USSDT_BATTLE_GROUP
+#define SPECENUM_VALUE2 USSDT_BATTLE_GROUP
 #include "specenum_gen.h"
 
 struct unit;

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=31899&r1=31898&r2=31899&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Fri Feb 12 15:56:19 2016
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Feb.11"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Feb.12"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31899&r1=31898&r2=31899&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Feb 12 15:56:19 2016
@@ -973,18 +973,6 @@
   actor_unit = game_unit_by_number(actor_unit_id);
   target_tile = index_to_tile(target_tile_id);
 
-  if (disturb_player
-      && actor_unit
-      && actor_unit->action_decision_want
-      && actor_unit->action_decision_tile == target_tile) {
-    /* The client has now asked for alternatives to show the player. */
-    actor_unit->action_decision_want = ACT_DEC_NOTHING;
-    actor_unit->action_decision_tile = NULL;
-
-    /* Let the client know so future changes are seen as changes. */
-    send_unit_info(player_reply_dest(actor_player), actor_unit);
-  }
-
   /* Check if the request is valid. */
   if (!target_tile || !actor_unit || !actor_player
       || actor_unit->owner != actor_player) {
@@ -3630,8 +3618,13 @@
   struct unit *punit = player_unit_by_number(pplayer, unit_id);
 
   if (NULL == punit) {
-    /* Probably died or bribed. */
-    log_verbose("handle_unit_sscs_set() invalid unit %d", unit_id);
+    /* Being asked to unqueue a "spent" unit because the client haven't
+     * been told that it's gone is expected. */
+    if (type != USSDT_UNQUEUE) {
+      /* Probably died or bribed. */
+      log_verbose("handle_unit_sscs_set() invalid unit %d", unit_id);
+    }
+
     return;
   }
 
@@ -3654,6 +3647,19 @@
 
     /* Let the client know that this unit needs the player to decide
      * what to do. */
+    send_unit_info(player_reply_dest(pplayer), punit);
+
+    break;
+  case USSDT_UNQUEUE:
+    /* Delete the reminder for the client to ask the server about what
+     * actions the unit can perform against a certain target tile.
+     * Action decision state can be set by the server it self too. */
+
+    punit->action_decision_want = ACT_DEC_NOTHING;
+    punit->action_decision_tile = NULL;
+
+    /* Let the client know that this unit no longer needs the player to
+     * decide what to do. */
     send_unit_info(player_reply_dest(pplayer), punit);
 
     break;


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

Reply via email to