Author: sveinung Date: Mon May 23 03:22:47 2016 New Revision: 32758 URL: http://svn.gna.org/viewcvs/freeciv?rev=32758&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: 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=32758&r1=32757&r2=32758&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 Mon May 23 03:22:47 2016 @@ -471,6 +471,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, @@ -553,8 +555,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); } @@ -648,6 +649,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, @@ -722,7 +725,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: 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=32758&r1=32757&r2=32758&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 Mon May 23 03:22:47 2016 @@ -471,6 +471,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, @@ -558,8 +560,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); } @@ -653,6 +654,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, @@ -732,7 +735,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: branches/S2_6/client/gui-qt/dialogs.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=32758&r1=32757&r2=32758&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/dialogs.cpp (original) +++ branches/S2_6/client/gui-qt/dialogs.cpp Mon May 23 03:22:47 2016 @@ -1524,6 +1524,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; @@ -1567,7 +1568,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); @@ -1943,7 +1944,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: 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=32758&r1=32757&r2=32758&view=diff ============================================================================== --- branches/S2_6/client/gui-sdl/action_dialog.c (original) +++ branches/S2_6/client/gui-sdl/action_dialog.c Mon May 23 03:22:47 2016 @@ -397,6 +397,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(); @@ -533,7 +535,7 @@ /* 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])) { { @@ -541,7 +543,7 @@ /* 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_string16(pStr, astr_str(&str)); astr_free(&str); } 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=32758&r1=32757&r2=32758&view=diff ============================================================================== --- branches/S2_6/client/gui-sdl2/action_dialog.c (original) +++ branches/S2_6/client/gui-sdl2/action_dialog.c Mon May 23 03:22:47 2016 @@ -400,6 +400,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(); @@ -535,14 +537,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); 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=32758&r1=32757&r2=32758&view=diff ============================================================================== --- branches/S2_6/client/gui-xaw/action_dialog.c (original) +++ branches/S2_6/client/gui-xaw/action_dialog.c Mon May 23 03:22:47 2016 @@ -463,7 +463,9 @@ Dimension width1, width2; int j; - static const char *advances_can_steal[A_LAST+1]; + static const char *advances_can_steal[A_LAST+1]; + + struct unit *actor_unit = game_unit_by_number(diplomat_id); spy_tech_shell = I_T(XtVaCreatePopupShell("spystealtechpopup", @@ -524,7 +526,7 @@ static 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(diplomat_id))); + unit_name_translation(actor_unit)); advances_can_steal[j] = astr_str(&str); advance_type[j++] = A_UNSET; } @@ -556,6 +558,8 @@ int j; static const char *improvements_can_sabotage[B_LAST+1]; + + struct unit *actor_unit = game_unit_by_number(diplomat_id); spy_sabotage_shell = I_T(XtVaCreatePopupShell("spysabotageimprovementspopup", @@ -615,7 +619,7 @@ static 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(diplomat_id))); + unit_name_translation(actor_unit)); improvements_can_sabotage[j] = astr_str(&str); improvement_type[j++] = B_LAST; } else { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits