From 498c5b133cae6ca4dbf0c1250a4e0de059fbfb7a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 8 May 2023 23:15:58 +0300 Subject: [PATCH 20/20] rscompat: Convert "Clean..." extra rmcause to "Clean" See osdn #47997 Signed-off-by: Marko Lindqvist --- server/rscompat.c | 13 +++++++++++++ server/rscompat.h | 1 + server/ruleset.c | 6 +++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/server/rscompat.c b/server/rscompat.c index 0f2d801800..fd11cdfe21 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -564,6 +564,19 @@ int add_user_extra_flags_3_2(int start) return i; } +/**********************************************************************//** + Adjust rmcause name of an extra loaded from a 3.1 ruleset. +**************************************************************************/ +const char *rscompat_extra_rmcause_3_2(const char *old_name) +{ + if (!fc_strcasecmp("CleanPollution", old_name) + || !fc_strcasecmp("CleanFallout", old_name)) { + return "Clean"; + } + + return old_name; +} + /**********************************************************************//** Adjust values of an extra loaded from a 3.1 ruleset. **************************************************************************/ diff --git a/server/rscompat.h b/server/rscompat.h index 9161146f75..935ac94050 100644 --- a/server/rscompat.h +++ b/server/rscompat.h @@ -67,6 +67,7 @@ void rscompat_req_adjust_3_2(const struct rscompat_info *compat, const char **ptype, const char **pname, bool *ppresent, const char *sec_name); int add_user_extra_flags_3_2(int start); +const char *rscompat_extra_rmcause_3_2(const char *old_name); void rscompat_extra_adjust_3_2(struct extra_type *pextra); bool rscompat_setting_needs_special_handling(const char *name); void rscompat_settings_do_special_handling(struct section_file *file, diff --git a/server/ruleset.c b/server/ruleset.c index 1af6508206..433736eda7 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -3721,6 +3721,10 @@ static bool load_ruleset_terrain(struct section_file *file, for (j = 0; j < nval; j++) { const char *sval = slist[j]; + if (compat->compat_mode && compat->version < RSFORMAT_3_2) { + sval = rscompat_extra_rmcause_3_2(sval); + } + rmcause = extra_rmcause_by_name(sval, fc_strcasecmp); if (!extra_rmcause_is_valid(rmcause)) { @@ -3926,7 +3930,7 @@ static bool load_ruleset_terrain(struct section_file *file, BV_SET(pextra2->conflicts, extra_index(pextra)); } } - + free(slist); if (!ok) { -- 2.39.2