From 40ef3c6b0fb0e0e07f4e335a98f946878e86e35f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 10 Jan 2023 18:48:50 +0200 Subject: [PATCH 33/46] Update founder information of cities when a player removed Do not leave illegal reference to the removed player to any city in the game as the founder See osdn #46503 Signed-off-by: Marko Lindqvist --- common/player.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/player.c b/common/player.c index d0b2a49ceb..68d0a998c1 100644 --- a/common/player.c +++ b/common/player.c @@ -751,11 +751,20 @@ void player_destroy(struct player *pplayer) conn_list_destroy(pplayer->connections); players_iterate(aplayer) { - /* destroy the diplomatics states of this player with others ... */ + /* Destroy the diplomatic states of this player with others ... */ player_diplstate_destroy(pplayer, aplayer); - /* and of others with this player. */ + /* ...and of others with this player. */ if (aplayer != pplayer) { player_diplstate_destroy(aplayer, pplayer); + + /* Check if any cities of the other player have been founded + * by the removed player. */ + city_list_iterate(aplayer->cities, pcity) { + if (pcity->original == pplayer) { + /* Current owner is a sane value, at least */ + pcity->original = aplayer; + } + } city_list_iterate_end; } } players_iterate_end; free(pplayer->diplstates); -- 2.39.0