From dde08ba8d857e483699d94073672f04ce59e89ce Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 15 Mar 2022 16:20:22 +0200 Subject: [PATCH 48/48] Inform common/ code about compat mode ruleset loading being in progress See osdn #44101 Signed-off-by: Marko Lindqvist --- common/game.c | 2 ++ common/game.h | 18 ++++++++++++++++++ server/ruleset.c | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/common/game.c b/common/game.c index b7c7c7bde7..f7f144ebef 100644 --- a/common/game.c +++ b/common/game.c @@ -61,6 +61,8 @@ struct world wld; bool am_i_server = FALSE; +bool _ruleset_compat_mode = FALSE; + static void game_defaults(bool keep_ruleset_value); /**********************************************************************//** diff --git a/common/game.h b/common/game.h index 191ab45b19..7f7617ac9b 100644 --- a/common/game.h +++ b/common/game.h @@ -347,6 +347,24 @@ void user_flag_free(struct user_flag *flag); int current_turn_timeout(void); +extern bool _ruleset_compat_mode; + +/**********************************************************************//** + Set ruleset compat mode indicator +**************************************************************************/ +static inline void set_ruleset_compat_mode(bool active) +{ + _ruleset_compat_mode = active; +} + +/**********************************************************************//** + Get ruleset compat mode indicator +**************************************************************************/ +static inline bool is_ruleset_compat_mode(void) +{ + return _ruleset_compat_mode; +} + extern struct civ_game game; extern struct world wld; diff --git a/server/ruleset.c b/server/ruleset.c index aaaa41461e..49101a2d7a 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -8798,8 +8798,11 @@ bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata) { + set_ruleset_compat_mode(compat_mode); + if (load_rulesetdir(game.server.rulesetdir, compat_mode, logger, act, buffer_script, load_luadata)) { + set_ruleset_compat_mode(FALSE); return TRUE; } @@ -8808,6 +8811,7 @@ bool load_rulesets(const char *restore, const char *alt, bool compat_mode, load_luadata)) { sz_strlcpy(game.server.rulesetdir, alt); + set_ruleset_compat_mode(FALSE); return TRUE; } } @@ -8819,6 +8823,8 @@ bool load_rulesets(const char *restore, const char *alt, bool compat_mode, notify_ruleset_fallback(_("Ruleset couldn't be loaded. Keeping previous one.")); + set_ruleset_compat_mode(FALSE); + /* We're in sane state as restoring previous ruleset succeeded, * but return failure to indicate that this is not what caller * wanted. */ @@ -8826,6 +8832,8 @@ bool load_rulesets(const char *restore, const char *alt, bool compat_mode, } } + set_ruleset_compat_mode(FALSE); + /* Fallback to default one, but not if that's what we tried already */ if (strcmp(GAME_DEFAULT_RULESETDIR, game.server.rulesetdir) && (restore == NULL || strcmp(GAME_DEFAULT_RULESETDIR, restore))) { -- 2.35.1