From 2a60688487f89f755006a47c7b13a605ead706ed Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 15 Jul 2022 02:46:57 +0300 Subject: [PATCH 28/28] Sanity check that terrain resource is a resource Reported by dark-ether See osdn #45099 Signed-off-by: Marko Lindqvist --- server/rssanity.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/rssanity.c b/server/rssanity.c index bdd0143ff6..6a5ae265de 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -1368,6 +1368,8 @@ bool sanity_check_ruleset_data(struct rscompat_info *compat) } music_styles_iterate_end; terrain_type_iterate(pterr) { + struct extra_type **pres; + if (pterr->animal != NULL) { if (!is_native_to_class(utype_class(pterr->animal), pterr, NULL)) { ruleset_error(LOG_ERROR, @@ -1376,6 +1378,15 @@ bool sanity_check_ruleset_data(struct rscompat_info *compat) ok = FALSE; } } + + for (pres = pterr->resources; *pres != NULL; pres++) { + if (!is_extra_caused_by((*pres), EC_RESOURCE)) { + ruleset_error(LOG_ERROR, + "%s has %s as a resource, but it's not a resource extra.", + terrain_rule_name(pterr), extra_rule_name(*pres)); + ok = FALSE; + } + } } terrain_type_iterate_end; /* Check that all unit classes can exist somewhere */ -- 2.35.1