Author: sveinung
Date: Mon May 23 03:22:06 2016
New Revision: 32756

URL: http://svn.gna.org/viewcvs/freeciv?rev=32756&view=rev
Log:
act sel follow ups: use an actor unit variable.

Use a variable with the actor unit in follow up questions to the action
selection dialog. This is more readable than looking it up from its ID.

See patch #7236

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=32756&r1=32755&r2=32756&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Mon May 23 03:22:06 2016
@@ -657,6 +657,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
 
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
+
   spy_tech_shell = gtk_dialog_new_with_buttons(_("Steal Technology"),
     NULL,
     0,
@@ -739,8 +741,7 @@
         struct astring str = ASTRING_INIT;
         /* TRANS: %s is a unit name, e.g., Spy */
         astr_set(&str, _("At %s's Discretion"),
-                 unit_name_translation(game_unit_by_number(
-                                         args->actor_unit_id)));
+                 unit_name_translation(actor_unit));
         g_value_set_string(&value, astr_str(&str));
         astr_free(&str);
       }
@@ -834,6 +835,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
   GtkTreeIter it;
+
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
   
   spy_sabotage_shell = gtk_dialog_new_with_buttons(_("Sabotage Improvements"),
     NULL,
@@ -908,7 +911,7 @@
 
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
-             unit_name_translation(game_unit_by_number(args->actor_unit_id)));
+             unit_name_translation(actor_unit));
     gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
 
     astr_free(&str);

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=32756&r1=32755&r2=32756&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Mon May 23 03:22:06 2016
@@ -657,6 +657,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
 
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
+
   spy_tech_shell = gtk_dialog_new_with_buttons(_("Steal Technology"),
     NULL,
     0,
@@ -744,8 +746,7 @@
         struct astring str = ASTRING_INIT;
         /* TRANS: %s is a unit name, e.g., Spy */
         astr_set(&str, _("At %s's Discretion"),
-                 unit_name_translation(game_unit_by_number(
-                                         args->actor_unit_id)));
+                 unit_name_translation(actor_unit));
         g_value_set_string(&value, astr_str(&str));
         astr_free(&str);
       }
@@ -839,6 +840,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
   GtkTreeIter it;
+
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
   
   spy_sabotage_shell = gtk_dialog_new_with_buttons(_("Sabotage Improvements"),
     NULL,
@@ -918,7 +921,7 @@
 
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
-             unit_name_translation(game_unit_by_number(args->actor_unit_id)));
+             unit_name_translation(actor_unit));
     gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
 
     astr_free(&str);

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=32756&r1=32755&r2=32756&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.x/action_dialog.c    Mon May 23 03:22:06 2016
@@ -657,6 +657,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
 
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
+
   spy_tech_shell = gtk_dialog_new_with_buttons(_("Steal Technology"),
                                                NULL, 0,
                                                _("Cancel"), 
GTK_RESPONSE_CANCEL,
@@ -741,8 +743,7 @@
         struct astring str = ASTRING_INIT;
         /* TRANS: %s is a unit name, e.g., Spy */
         astr_set(&str, _("At %s's Discretion"),
-                 unit_name_translation(game_unit_by_number(
-                                         args->actor_unit_id)));
+                 unit_name_translation(actor_unit));
         g_value_set_string(&value, astr_str(&str));
         astr_free(&str);
       }
@@ -836,6 +837,8 @@
   GtkCellRenderer *rend;
   GtkTreeViewColumn *col;
   GtkTreeIter it;
+
+  struct unit *actor_unit = game_unit_by_number(args->actor_unit_id);
   
   spy_sabotage_shell = gtk_dialog_new_with_buttons(_("Sabotage Improvements"),
                                                    NULL, 0,
@@ -912,7 +915,7 @@
 
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
-             unit_name_translation(game_unit_by_number(args->actor_unit_id)));
+             unit_name_translation(actor_unit));
     gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
 
     astr_free(&str);

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=32756&r1=32755&r2=32756&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Mon May 23 03:22:06 2016
@@ -1743,6 +1743,7 @@
   pfcn_void func;
   int diplomat_id = data1.toInt();
   int diplomat_target_id = data2.toInt();
+  struct unit *actor_unit = game_unit_by_number(diplomat_id);
   struct city *pvcity = game_city_by_number(diplomat_target_id);
   struct player *pvictim = NULL;
   choice_dialog *cd;
@@ -1786,7 +1787,7 @@
 
     if (action_prob_possible(follow_up_act_probs[ACTION_SPY_STEAL_TECH])) {
       astr_set(&stra, _("At %s's Discretion"),
-               unit_name_translation(game_unit_by_number(diplomat_id)));
+               unit_name_translation(actor_unit));
       func = spy_steal_something;
       str = astr_str(&stra);
       cd->add_item(str, func, qv1, A_UNSET);
@@ -2207,7 +2208,7 @@
 
   if (action_prob_possible(follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     astr_set(&stra, _("At %s's Discretion"),
-             unit_name_translation(game_unit_by_number(diplomat_id)));
+             unit_name_translation(actor));
     func = spy_sabotage;
     str = astr_str(&stra);
     cd->add_item(str, func, qv1, B_LAST);

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=32756&r1=32755&r2=32756&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Mon May 23 03:22:06 2016
@@ -482,6 +482,8 @@
   int tech, idx;
   SDL_Rect area;
 
+  struct unit *actor_unit = game_unit_by_number(id);
+
   is_more_user_input_needed = TRUE;
   popdown_diplomat_dialog();
 
@@ -617,14 +619,14 @@
 
   /* Get Spy tech to use for "At Spy's Discretion" -- this will have the
    * side effect of displaying the unit's icon */
-  tech = 
advance_number(unit_type_get(game_unit_by_number(id))->require_advance);
+  tech = advance_number(unit_type_get(actor_unit)->require_advance);
 
   if (action_prob_possible(follow_up_act_probs[ACTION_SPY_STEAL_TECH])) {
     struct astring str = ASTRING_INIT;
 
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
-             unit_name_translation(game_unit_by_number(id)));
+             unit_name_translation(actor_unit));
     copy_chars_to_utf8_str(pstr, astr_str(&str));
     astr_free(&str);
 


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

Reply via email to