From b6c2fb5444ac605cb6f34be9c913b9835ac0a788 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 8 Oct 2022 15:22:57 +0300 Subject: [PATCH 46/46] Qt: Fix mr_menu::menus_sensitive() unused assignments See osdn #45770 Signed-off-by: Marko Lindqvist --- client/gui-qt/menu.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index adf5d3e0a9..ae52515176 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1999,7 +1999,6 @@ void mr_menu::menus_sensitive() bool city_on_tile = false; bool units_all_same_tile = true; const struct tile *ptile = NULL; - struct terrain *pterrain; const struct unit_type *ptype = NULL; players_iterate(pplayer) { @@ -2129,10 +2128,6 @@ void mr_menu::menus_sensitive() } if (units_all_same_tile) { - struct unit *punit = unit_list_get(punits, 0); - - pterrain = tile_terrain(unit_tile(punit)); - if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) { struct extra_type *pextra = NULL; @@ -2166,10 +2161,6 @@ void mr_menu::menus_sensitive() i.value()->setEnabled(true); } if (units_all_same_tile) { - struct unit *punit = unit_list_get(punits, 0); - - pterrain = tile_terrain(unit_tile(punit)); - if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) { struct extra_type *pextra = NULL; @@ -2204,14 +2195,14 @@ void mr_menu::menus_sensitive() } if (units_all_same_tile) { struct unit *punit = unit_list_get(punits, 0); + struct tile *atile = unit_tile(punit); + struct terrain *pterrain = tile_terrain(atile); - pterrain = tile_terrain(unit_tile(punit)); if (pterrain->cultivate_result != T_NONE) { i.value()->setText( // TRANS: Transform terrain to specific type QString(_("Cultivate to %1")) - .arg(QString(get_tile_change_menu_text - (unit_tile(punit), ACTIVITY_CULTIVATE))) + .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_CULTIVATE))) .replace("&", "&&")); } else { i.value()->setText(QString(_("Cultivate"))); @@ -2227,14 +2218,14 @@ void mr_menu::menus_sensitive() } if (units_all_same_tile) { struct unit *punit = unit_list_get(punits, 0); + struct tile *atile = unit_tile(punit); + struct terrain *pterrain = tile_terrain(atile); - pterrain = tile_terrain(unit_tile(punit)); if (pterrain->plant_result != T_NONE) { i.value()->setText( // TRANS: Transform terrain to specific type QString(_("Plant to %1")) - .arg(QString(get_tile_change_menu_text - (unit_tile(punit), ACTIVITY_PLANT))) + .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_PLANT))) .replace("&", "&&")); } else { i.value()->setText(QString(_("Plant"))); @@ -2252,16 +2243,15 @@ void mr_menu::menus_sensitive() } if (units_all_same_tile) { struct unit *punit = unit_list_get(punits, 0); - pterrain = tile_terrain(unit_tile(punit)); - punit = unit_list_get(punits, 0); - pterrain = tile_terrain(unit_tile(punit)); + struct tile *atile = unit_tile(punit); + struct terrain *pterrain = tile_terrain(atile); + if (pterrain->transform_result != T_NONE && pterrain->transform_result != pterrain) { i.value()->setText( // TRANS: Transform terrain to specific type QString(_("Transform to %1")) - .arg(QString(get_tile_change_menu_text - (unit_tile(punit), ACTIVITY_TRANSFORM))) + .arg(QString(get_tile_change_menu_text(atile, ACTIVITY_TRANSFORM))) .replace("&", "&&")); } else { i.value()->setText(_("Transform Terrain")); -- 2.35.1