From 476377208516e5569dbefe1870b349690f88f6d6 Mon Sep 17 00:00:00 2001 From: Ihnatus Date: Tue, 31 May 2022 21:24:42 +0300 Subject: [PATCH] Fix range checking for city_size in units.ruleset. Check for city founders, not for "Settlers". Check the upper bound. See OSDN#44730 Signed-off-by: Ihnatus --- server/rssanity.c | 10 ++++++++++ server/ruleset.c | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/rssanity.c b/server/rssanity.c index 71006b41d4..fd8f1219f6 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -942,6 +942,16 @@ bool sanity_check_ruleset_data(bool ignore_retired) putype->paratroopers_range, UNIT_MAX_PARADROP_RANGE); ok = FALSE; } + /* never fires if game.scenario.prevent_new_cities is TRUE */ + if ((putype->city_size <= 0 || putype->city_size > MAX_CITY_SIZE) + && utype_is_cityfounder(putype)) { + ruleset_error(LOG_ERROR, + "Unit type '%s' would build size %d cities. " + "City sizes must be from 1 to %d.", + utype_rule_name(putype), putype->city_size, + MAX_CITY_SIZE); + ok = FALSE; + } } unit_type_iterate_end; /* Check requirement sets against conflicting requirements. diff --git a/server/ruleset.c b/server/ruleset.c index 9b0419c4db..b9c80fdba4 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -2191,15 +2191,6 @@ static bool load_ruleset_units(struct section_file *file, ok = FALSE; break; } - - if (utype_has_flag(u, UTYF_SETTLERS) - && u->city_size <= 0) { - ruleset_error(LOG_ERROR, "\"%s\": Unit %s would build size %d cities", - filename, utype_rule_name(u), u->city_size); - u->city_size = 1; - ok = FALSE; - break; - } } unit_type_iterate_end; } -- 2.34.1