From fe6e21f493a0a8799f3ed3a6d9a1dc56b89c7b28 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 10 Jul 2023 04:45:43 +0300 Subject: [PATCH 19/19] Qt help_widget::uclass_max_values(): Initialize convert_time If whatever value was in memory is bigger than any convert_time to compare to, that random value was considered as the highest actually existing value. See osdn #48377 Signed-off-by: Marko Lindqvist --- client/gui-qt/helpdlg.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index 9085d0dfaa..56bcef9b26 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -1654,11 +1654,13 @@ struct terrain *help_widget::terrain_max_values() struct unit_type *help_widget::uclass_max_values(struct unit_class *uclass) { struct unit_type *max = new struct unit_type; + max->uclass = uclass; max->attack_strength = 0; max->bombard_rate = 0; max->build_cost = 0; max->city_size = 0; + max->convert_time = 0; max->defense_strength = 0; max->firepower = 0; max->fuel = 0; @@ -1673,10 +1675,13 @@ struct unit_type *help_widget::uclass_max_values(struct unit_class *uclass) max->upkeep[O_SHIELD] = 0; max->upkeep[O_TRADE] = 0; max->vision_radius_sq = 0; + unit_type_iterate(utype) { if (utype->uclass == uclass) { -#define SET_MAX(v) \ + +#define SET_MAX(v) \ max->v = max->v > utype->v ? max->v : utype->v + SET_MAX(attack_strength); SET_MAX(bombard_rate); SET_MAX(build_cost); @@ -1696,8 +1701,11 @@ struct unit_type *help_widget::uclass_max_values(struct unit_class *uclass) SET_MAX(upkeep[O_SHIELD]); SET_MAX(upkeep[O_TRADE]); SET_MAX(vision_radius_sq); + #undef SET_MAX + } } unit_type_iterate_end + return max; } -- 2.40.1