From 97d09a2f9e4975a9ac966f48faaa1668ffe6f11a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 22 Apr 2022 00:31:13 +0300 Subject: [PATCH 40/40] rssanity: Do not skip enabler requirements check when ruleset is 3.2 one Even in compat (enabling) mode, do the full sanity check if the ruleset to load actually is 3.2 one. See osdn #44386 Signed-off-by: Marko Lindqvist --- server/rssanity.c | 5 +++-- server/rssanity.h | 5 ++++- server/ruleset.c | 2 +- tools/ruledit/tab_misc.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/rssanity.c b/server/rssanity.c index a1d3eec23d..4491fdec17 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -785,7 +785,7 @@ static bool sanity_check_boolean_effects(void) Returns TRUE iff everything ok. **************************************************************************/ -bool sanity_check_ruleset_data(bool ignore_retired) +bool sanity_check_ruleset_data(struct rscompat_info *compat) { int num_utypes; int i; @@ -1235,7 +1235,8 @@ bool sanity_check_ruleset_data(bool ignore_retired) } } requirement_vector_iterate_end; - if (!ignore_retired) { + if (compat == NULL || !compat->compat_mode + || compat->version >= RSFORMAT_3_2) { /* Support for letting some of the following hard requirements be * implicit were retired in Freeciv 3.0. Others were retired later. * Make sure that the opposite of each hard action requirement diff --git a/server/rssanity.h b/server/rssanity.h index 9f24257e5c..dbf0759506 100644 --- a/server/rssanity.h +++ b/server/rssanity.h @@ -20,9 +20,12 @@ extern "C" { /* common */ #include "fc_types.h" +/* server */ +#include "rscompat.h" + bool autoadjust_ruleset_data(void); bool autolock_settings(void); -bool sanity_check_ruleset_data(bool ignore_retired); +bool sanity_check_ruleset_data(struct rscompat_info *compat); bool sanity_check_server_setting_value_in_req(ssetv ssetval); diff --git a/server/ruleset.c b/server/ruleset.c index 4de97522a4..660bbc6705 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -9011,7 +9011,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, actions_rs_pre_san_gen(); ok = autoadjust_ruleset_data() - && sanity_check_ruleset_data(compat_info.compat_mode); + && sanity_check_ruleset_data(&compat_info); } if (ok) { diff --git a/tools/ruledit/tab_misc.cpp b/tools/ruledit/tab_misc.cpp index 76261ebb90..57090667eb 100644 --- a/tools/ruledit/tab_misc.cpp +++ b/tools/ruledit/tab_misc.cpp @@ -285,7 +285,7 @@ void tab_misc::save_now() strncpy(game.control.version, ba_bytes.data(), sizeof(game.control.version) - 1); - if (!autoadjust_ruleset_data() || !sanity_check_ruleset_data(false)) { + if (!autoadjust_ruleset_data() || !sanity_check_ruleset_data(NULL)) { QMessageBox *box = new QMessageBox(); box->setText("Current data fails sanity checks. Save anyway?"); -- 2.35.1