Author: sveinung
Date: Sun Mar  6 16:16:09 2016
New Revision: 32192

URL: http://svn.gna.org/viewcvs/freeciv?rev=32192&view=rev
Log:
Minimize action_selection_close() side effects.

Calling the client API's action_selection_close() function means that the
common client code wants the client to pop down the action selection dialog.
When the common client code closes the action selection dialog the
individual clients shouldn't do everything they do when the player closes
it.

Popping down the action selection dialog means that the action selection no
longer is in progress. It doesn't means that a decision no longer is wanted.
It doesn't mean that it is time to pop up the action selection dialog for
the next unit in focus.

Don't pop up an action selection dialog for the next selected actor unit.
Don't clear the actor unit's action decision data.

See bug #24493

Modified:
    trunk/client/gui-gtk-2.0/action_dialog.c
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-gtk-3.x/action_dialog.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-sdl2/action_dialog.c

Modified: trunk/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/action_dialog.c?rev=32192&r1=32191&r2=32192&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Sun Mar  6 16:16:09 2016
@@ -63,6 +63,7 @@
 static int actor_unit_id;
 static int target_ids[ATK_COUNT];
 static bool is_more_user_input_needed = FALSE;
+static bool did_not_decide = FALSE;
 static action_probability follow_up_act_probs[ACTION_COUNT];
 
 static GtkWidget  *spy_tech_shell;
@@ -109,9 +110,21 @@
   if (!is_more_user_input_needed) {
     /* The client isn't waiting for information for any unanswered follow
      * up questions. */
+
+    /* The action selection process is over, at least for now. */
     action_selection_no_longer_in_progress(actor_unit_id);
-    action_decision_clear_want(actor_unit_id);
-    action_selection_next_in_focus(actor_unit_id);
+
+    if (did_not_decide) {
+      /* The action selection dialog was closed but the player didn't
+       * decide what the unit should do. */
+
+      /* Reset so the next action selection dialog does the right thing. */
+      did_not_decide = FALSE;
+    } else {
+      /* An action, or no action at all, was selected. */
+      action_decision_clear_want(actor_unit_id);
+      action_selection_next_in_focus(actor_unit_id);
+    }
   }
 }
 
@@ -1572,6 +1585,7 @@
 void action_selection_close(void)
 {
   if (act_sel_dialog != NULL) {
+    did_not_decide = TRUE;
     gtk_widget_destroy(act_sel_dialog);
   }
 }

Modified: trunk/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/action_dialog.c?rev=32192&r1=32191&r2=32192&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Sun Mar  6 16:16:09 2016
@@ -63,6 +63,7 @@
 static int actor_unit_id;
 static int target_ids[ATK_COUNT];
 static bool is_more_user_input_needed = FALSE;
+static bool did_not_decide = FALSE;
 static action_probability follow_up_act_probs[ACTION_COUNT];
 
 static GtkWidget  *spy_tech_shell;
@@ -109,9 +110,21 @@
   if (!is_more_user_input_needed) {
     /* The client isn't waiting for information for any unanswered follow
      * up questions. */
+
+    /* The action selection process is over, at least for now. */
     action_selection_no_longer_in_progress(actor_unit_id);
-    action_decision_clear_want(actor_unit_id);
-    action_selection_next_in_focus(actor_unit_id);
+
+    if (did_not_decide) {
+      /* The action selection dialog was closed but the player didn't
+       * decide what the unit should do. */
+
+      /* Reset so the next action selection dialog does the right thing. */
+      did_not_decide = FALSE;
+    } else {
+      /* An action, or no action at all, was selected. */
+      action_decision_clear_want(actor_unit_id);
+      action_selection_next_in_focus(actor_unit_id);
+    }
   }
 }
 
@@ -1582,6 +1595,7 @@
 void action_selection_close(void)
 {
   if (act_sel_dialog != NULL) {
+    did_not_decide = TRUE;
     gtk_widget_destroy(act_sel_dialog);
   }
 }

Modified: trunk/client/gui-gtk-3.x/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/action_dialog.c?rev=32192&r1=32191&r2=32192&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.x/action_dialog.c    Sun Mar  6 16:16:09 2016
@@ -63,6 +63,7 @@
 static int actor_unit_id;
 static int target_ids[ATK_COUNT];
 static bool is_more_user_input_needed = FALSE;
+static bool did_not_decide = FALSE;
 static action_probability follow_up_act_probs[ACTION_COUNT];
 
 static GtkWidget  *spy_tech_shell;
@@ -109,9 +110,21 @@
   if (!is_more_user_input_needed) {
     /* The client isn't waiting for information for any unanswered follow
      * up questions. */
+
+    /* The action selection process is over, at least for now. */
     action_selection_no_longer_in_progress(actor_unit_id);
-    action_decision_clear_want(actor_unit_id);
-    action_selection_next_in_focus(actor_unit_id);
+
+    if (did_not_decide) {
+      /* The action selection dialog was closed but the player didn't
+       * decide what the unit should do. */
+
+      /* Reset so the next action selection dialog does the right thing. */
+      did_not_decide = FALSE;
+    } else {
+      /* An action, or no action at all, was selected. */
+      action_decision_clear_want(actor_unit_id);
+      action_selection_next_in_focus(actor_unit_id);
+    }
   }
 }
 
@@ -1576,6 +1589,7 @@
 void action_selection_close(void)
 {
   if (act_sel_dialog != NULL) {
+    did_not_decide = TRUE;
     gtk_widget_destroy(act_sel_dialog);
   }
 }

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=32192&r1=32191&r2=32192&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Sun Mar  6 16:16:09 2016
@@ -110,6 +110,10 @@
 static bool is_more_user_input_needed = FALSE;
 static action_probability follow_up_act_probs[ACTION_COUNT];
 
+/* Don't remove a unit's action decision want or move on to the next actor
+ unit that wants a decision in the current unit selection. */
+static bool did_not_decide = false;
+
 /**********************************************************************
   Initialize a mapping between an action and the function to call if
   the action's button is pushed.
@@ -1274,9 +1278,21 @@
   if (!is_more_user_input_needed) {
     /* The client isn't waiting for information for any unanswered follow
      * up questions. */
+
+     /* The action selection process is over, at least for now. */
     action_selection_no_longer_in_progress(actor_unit_id);
-    action_decision_clear_want(actor_unit_id);
-    action_selection_next_in_focus(actor_unit_id);
+
+    if (did_not_decide) {
+      /* The action selection dialog was closed but the player didn't
+       * decide what the unit should do. */
+
+      /* Reset so the next action selection dialog does the right thing. */
+      did_not_decide = false;
+    } else {
+      /* An action, or no action at all, was selected. */
+      action_decision_clear_want(actor_unit_id);
+      action_selection_next_in_focus(actor_unit_id);
+    }
   }
 }
 
@@ -2522,6 +2538,7 @@
 
   cd = gui()->get_diplo_dialog();
   if (cd != NULL){
+    did_not_decide = true;
     cd->close();
   }
 }

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=32192&r1=32191&r2=32192&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Sun Mar  6 16:16:09 2016
@@ -69,6 +69,7 @@
 
 static struct diplomat_dialog *pDiplomat_Dlg = NULL;
 static bool is_more_user_input_needed = FALSE;
+static bool did_not_decide = FALSE;
 static action_probability follow_up_act_probs[ACTION_COUNT];
 
 /**************************************************************************
@@ -79,9 +80,21 @@
   if (!is_more_user_input_needed) {
     /* The client isn't waiting for information for any unanswered follow
      * up questions. */
+
+    /* The action selection process is over, at least for now. */
     action_selection_no_longer_in_progress(actor_unit_id);
-    action_decision_clear_want(actor_unit_id);
-    action_selection_next_in_focus(actor_unit_id);
+
+    if (did_not_decide) {
+      /* The action selection dialog was closed but the player didn't
+       * decide what the unit should do. */
+
+      /* Reset so the next action selection dialog does the right thing. */
+      did_not_decide = FALSE;
+    } else {
+      /* An action, or no action at all, was selected. */
+      action_decision_clear_want(actor_unit_id);
+      action_selection_next_in_focus(actor_unit_id);
+    }
   }
 }
 
@@ -1394,6 +1407,7 @@
 ****************************************************************/
 void action_selection_close(void)
 {
+  did_not_decide = TRUE;
   popdown_diplomat_dialog();
 }
 


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

Reply via email to