From eca8b0b3b493ccb6acba85a490f9b702e5157d02 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 28 Oct 2022 04:48:59 +0300 Subject: [PATCH 21/21] Limit players to max rates after loading savegame The rules may have changed since the time game was saved. See osdn #44186 Signed-off-by: Marko Lindqvist --- server/legacysave.c | 5 +++++ server/savegame2.c | 5 +++++ server/savegame3.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/server/legacysave.c b/server/legacysave.c index 7017a6d007..b23b51f5ae 100644 --- a/server/legacysave.c +++ b/server/legacysave.c @@ -4371,6 +4371,11 @@ static void game_load_internal(struct section_file *file) assign_player_colors(); } + /* Check max rates (rules may have changed since saving) */ + players_iterate(pplayer) { + pplayer->economic = player_limit_to_max_rates(pplayer); + } players_iterate_end; + /* Restore game random state, just in case various initialization code * inexplicably altered the previously existing state. */ if (!game.info.is_new_game) { diff --git a/server/savegame2.c b/server/savegame2.c index c33111f064..8ff782035a 100644 --- a/server/savegame2.c +++ b/server/savegame2.c @@ -5253,6 +5253,11 @@ static void sg_load_sanitycheck(struct loaddata *loading) } } researches_iterate_end; + /* Check max rates (rules may have changed since saving) */ + players_iterate(pplayer) { + pplayer->economic = player_limit_to_max_rates(pplayer); + } players_iterate_end; + if (0 == strlen(server.game_identifier) || !is_base64url(server.game_identifier)) { /* This uses fc_rand(), so random state has to be initialized before. */ diff --git a/server/savegame3.c b/server/savegame3.c index ab4daeaf50..5cecbb2a4d 100644 --- a/server/savegame3.c +++ b/server/savegame3.c @@ -7214,6 +7214,11 @@ static void sg_load_sanitycheck(struct loaddata *loading) } unit_type_iterate_end; } players_iterate_end; + /* Check max rates (rules may have changed since saving) */ + players_iterate(pplayer) { + pplayer->economic = player_limit_to_max_rates(pplayer); + } players_iterate_end; + if (0 == strlen(server.game_identifier) || !is_base64url(server.game_identifier)) { /* This uses fc_rand(), so random state has to be initialized before. */ -- 2.35.1