From 8c01c384671fa3d92e57a19f2128d640212f5bf6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 1 May 2021 03:21:04 +0300 Subject: [PATCH 50/50] Sanity check cultivate|plant_result in relation to _time Reported by Sveinung Kvilhaugsvik See osdn #42124 Signed-off-by: Marko Lindqvist --- server/ruleset.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/ruleset.c b/server/ruleset.c index 5759399516..73fda09f4b 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -3256,6 +3256,15 @@ static bool load_ruleset_terrain(struct section_file *file, ok = FALSE; break; } + if ((pterrain->cultivate_result != NULL + && pterrain->cultivate_time <= 0) + || (pterrain->cultivate_result == NULL + && pterrain->cultivate_time > 0)) { + ruleset_error(LOG_ERROR, "%s: cultivate_result and cultivate_time disagree " + "whether cultivating is enabled", tsection); + ok = FALSE; + break; + } if (!lookup_time(file, &pterrain->plant_time, tsection, "plant_time", filename, NULL, &ok)) { @@ -3263,6 +3272,15 @@ static bool load_ruleset_terrain(struct section_file *file, ok = FALSE; break; } + if ((pterrain->plant_result != NULL + && pterrain->plant_time <= 0) + || (pterrain->plant_result == NULL + && pterrain->plant_time > 0)) { + ruleset_error(LOG_ERROR, "%s: plant_result and plant_time disagree " + "whether planting is enabled", tsection); + ok = FALSE; + break; + } if (!lookup_unit_type(file, tsection, "animal", &pterrain->animal, filename, -- 2.30.2