From d3ff319c0f006845a99a8be61f398ba4a53f71e2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 28 Oct 2022 04:40:27 +0300 Subject: [PATCH 36/36] 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/savegame/savegame2.c | 5 +++++ server/savegame/savegame3.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index 33eb70a281..cac20a9938 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -5331,6 +5331,11 @@ static void sg_load_sanitycheck(struct loaddata *loading) } unit_list_iterate_safe_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. */ diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index a5a8eee623..611eabc647 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -7809,6 +7809,11 @@ static void sg_load_sanitycheck(struct loaddata *loading) } unit_list_iterate_safe_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