From 32fdff0a0dec73ba01cab2b0133b6324d2fa077e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 29 Jan 2023 23:51:26 +0200 Subject: [PATCH 43/43] Qt: Correct irrigate/mine menu entry rename Detection if all focus units are on the same tile didn't work. Thus the menu entry was always set based on what is possible in a specific tile, one where the first focus unit is. See osdn #45805 Signed-off-by: Marko Lindqvist --- client/gui-qt/menu.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 22efd7e447..61e6f4a177 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -2090,15 +2090,20 @@ void mr_menu::menus_sensitive() } unit_list_iterate_end; unit_list_iterate(punits, punit) { + const struct unit_type *ntype; + fc_assert((ptile == NULL) == (ptype == NULL)); - if (ptile || ptype) { - if (unit_tile(punit) != ptile) { - units_all_same_tile = false; - } - if (unit_type_get(punit) == ptype) { - ptile = unit_tile(punit); - ptype = unit_type_get(punit); - } + + ntype = unit_type_get(punit); + + // 'ntype == ptype' is correct check even when ptype is still nullptr + if (ptile != nullptr && ntype == ptype && unit_tile(punit) != ptile) { + units_all_same_tile = false; + } + + if (ptype == nullptr || ntype == ptype) { + ptile = unit_tile(punit); + ptype = ntype; } } unit_list_iterate_end; -- 2.39.0