From d9e1937a58314d98aed9106f00b21099aecee2e5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 31 May 2023 09:04:27 +0300 Subject: [PATCH 24/24] Fix client crash receiving counters for city on unknown tile City can exist on the client, but have it's location unknown, i.e., when it works known tile. See osdn #48118 Signed-off-by: Marko Lindqvist --- client/packhand.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index a6387ca27f..0a17110f70 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -5555,8 +5555,8 @@ void handle_diplomacy_remove_clause(int counterpart, int giver, } /**********************************************************************//** -Handle each counter ruleset's packet send from server instance to this -client. + Handle each counter's ruleset packet sent from server instance to this + client. **************************************************************************/ void handle_ruleset_counter(const struct packet_ruleset_counter *packet) { @@ -5570,8 +5570,7 @@ void handle_ruleset_counter(const struct packet_ruleset_counter *packet) curr->def = packet->def; if (!counter_behaviour_is_valid(curr->type) - || curr->target != CTGT_CITY) { - + || curr->target != CTGT_CITY) { return; } @@ -5580,30 +5579,31 @@ void handle_ruleset_counter(const struct packet_ruleset_counter *packet) } /**********************************************************************//** -Handle updating city's counter, when server request + Handle updating city's counters, when server request **************************************************************************/ void handle_city_update_counters(const struct packet_city_update_counters *packet) { - uint8_t i; - uint8_t counters_count = counters_get_city_counters_count(); - + int i; + int counters_count; struct city *pcity = game_city_by_number(packet->city); if (NULL == pcity) { - return; } + counters_count = counters_get_city_counters_count(); if (counters_count != packet->count) { - return; } - counters_count = counters_get_city_counters_count(); for (i = 0; i < counters_count; i++) { pcity->counter_values[i] = packet->counters[i]; } - update_city_description(pcity); + if (pcity->tile != NULL) { + /* City's location known */ + update_city_description(pcity); + } + city_report_dialog_update_city(pcity); } -- 2.39.2