Author: sveinung
Date: Tue Mar  8 15:27:48 2016
New Revision: 32205

URL: http://svn.gna.org/viewcvs/freeciv?rev=32205&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:
    branches/S2_6/client/gui-gtk-2.0/action_dialog.c
    branches/S2_6/client/gui-gtk-3.0/action_dialog.c
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-sdl/action_dialog.c
    branches/S2_6/client/gui-sdl2/action_dialog.c
    branches/S2_6/client/gui-xaw/action_dialog.c

Modified: branches/S2_6/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/action_dialog.c?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/action_dialog.c    Tue Mar  8 15:27:48 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);
+    }
   }
 }
 
@@ -1318,6 +1331,7 @@
 void action_selection_close(void)
 {
   if (act_sel_dialog != NULL) {
+    did_not_decide = TRUE;
     gtk_widget_destroy(act_sel_dialog);
   }
 }

Modified: branches/S2_6/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/action_dialog.c?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/action_dialog.c    Tue Mar  8 15:27:48 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);
+    }
   }
 }
 
@@ -1328,6 +1341,7 @@
 void action_selection_close(void)
 {
   if (act_sel_dialog != NULL) {
+    did_not_decide = TRUE;
     gtk_widget_destroy(act_sel_dialog);
   }
 }

Modified: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Tue Mar  8 15:27:48 2016
@@ -97,6 +97,10 @@
  * follow up question is asked. */
 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
@@ -1210,9 +1214,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);
+    }
   }
 }
 
@@ -2242,6 +2258,7 @@
 
   cd = gui()->get_diplo_dialog();
   if (cd != NULL){
+    did_not_decide = true;
     cd->close();
   }
 }

Modified: branches/S2_6/client/gui-sdl/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/action_dialog.c?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/action_dialog.c        (original)
+++ branches/S2_6/client/gui-sdl/action_dialog.c        Tue Mar  8 15:27:48 2016
@@ -68,6 +68,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];
 
 /**************************************************************************
@@ -78,9 +79,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);
+    }
   }
 }
 
@@ -1095,6 +1108,7 @@
 ****************************************************************/
 void action_selection_close(void)
 {
+  did_not_decide = TRUE;
   popdown_diplomat_dialog();
 }
 

Modified: branches/S2_6/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/action_dialog.c?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/action_dialog.c       (original)
+++ branches/S2_6/client/gui-sdl2/action_dialog.c       Tue Mar  8 15:27:48 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);
+    }
   }
 }
 
@@ -1099,6 +1112,7 @@
 ****************************************************************/
 void action_selection_close(void)
 {
+  did_not_decide = TRUE;
   popdown_diplomat_dialog();
 }
 

Modified: branches/S2_6/client/gui-xaw/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-xaw/action_dialog.c?rev=32205&r1=32204&r2=32205&view=diff
==============================================================================
--- branches/S2_6/client/gui-xaw/action_dialog.c        (original)
+++ branches/S2_6/client/gui-xaw/action_dialog.c        Tue Mar  8 15:27:48 2016
@@ -1040,6 +1040,8 @@
 void action_selection_close(void)
 {
   if (diplomat_dialog != NULL) {
+    action_selection_no_longer_in_progress(diplomat_id);
+
     XtDestroyWidget(diplomat_dialog);
   }
 }


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

Reply via email to