Author: sveinung
Date: Fri Feb 12 16:02:44 2016
New Revision: 31902

URL: http://svn.gna.org/viewcvs/freeciv?rev=31902&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:
    branches/S2_6/client/control.c
    branches/S2_6/common/actions.h
    branches/S2_6/fc_version
    branches/S2_6/server/unithand.c

Modified: branches/S2_6/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.c?rev=31902&r1=31901&r2=31902&view=diff
==============================================================================
--- branches/S2_6/client/control.c      (original)
+++ branches/S2_6/client/control.c      Fri Feb 12 16:02:44 2016
@@ -964,16 +964,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. */
+    request_do_action(ACTION_COUNT, old_actor_id, IDENTITY_NUMBER_ZERO,
+                      ACTSIG_UNQUEUE);
+  }
+
   /* 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: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=31902&r1=31901&r2=31902&view=diff
==============================================================================
--- branches/S2_6/common/actions.h      (original)
+++ branches/S2_6/common/actions.h      Fri Feb 12 16:02:44 2016
@@ -78,6 +78,9 @@
 /* The player wants to be reminded to ask what actions the unit can perform
  * to a certain target tile. */
 #define SPECENUM_VALUE0 ACTSIG_QUEUE
+/* The player no longer wants the reminder to ask what actions the unit can
+ * perform to a certain target tile. */
+#define SPECENUM_VALUE1 ACTSIG_UNQUEUE
 #include "specenum_gen.h"
 
 /*

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=31902&r1=31901&r2=31902&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Fri Feb 12 16:02:44 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-2.6-2016.Feb.11"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2016.Feb.12"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=31902&r1=31901&r2=31902&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Fri Feb 12 16:02:44 2016
@@ -726,18 +726,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) {
@@ -1057,9 +1045,14 @@
   }
 
   if (NULL == actor_unit) {
-    /* Probably died or bribed. */
-    log_verbose("handle_unit_do_action() invalid actor %d",
-                actor_id);
+    /* Being asked to unqueue a "spent" unit because the client haven't
+     * been told that it's gone is expected. */
+    if (!(action_type == ACTION_COUNT && value == ACTSIG_UNQUEUE)) {
+      /* Probably died or bribed. */
+      log_verbose("handle_unit_do_action() invalid actor %d",
+                  actor_id);
+    }
+
     return;
   }
 
@@ -1302,6 +1295,19 @@
 
       /* Let the client know that this unit needs the player to decide
        * what to do. */
+      send_unit_info(player_reply_dest(pplayer), actor_unit);
+
+      break;
+    case ACTSIG_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. */
+
+      actor_unit->action_decision_want = ACT_DEC_NOTHING;
+      actor_unit->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), actor_unit);
 
       break;


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

Reply via email to