From 07f5610b15e268b031460d232991adef23a22ed1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 5 Jan 2022 04:12:41 +0200 Subject: [PATCH 31/32] Sanity check transform_result and transform_time consistency No longer just correct inconsistent transform_result and transform_time from the ruleset, but consider it an error. See osdn #42256 Signed-off-by: Marko Lindqvist --- data/alien/terrain.ruleset | 2 +- data/civ1/terrain.ruleset | 2 +- data/civ2/terrain.ruleset | 2 +- data/civ2civ3/terrain.ruleset | 2 +- data/classic/terrain.ruleset | 2 +- data/goldkeep/terrain.ruleset | 2 +- data/granularity/terrain.ruleset | 2 +- data/multiplayer/terrain.ruleset | 2 +- data/ruledit/comments-3.2.txt | 2 +- data/sandbox/terrain.ruleset | 2 +- data/stub/terrain.ruleset | 2 +- data/webperimental/terrain.ruleset | 2 +- server/ruleset.c | 17 ++++++++--------- 13 files changed, 20 insertions(+), 21 deletions(-) diff --git a/data/alien/terrain.ruleset b/data/alien/terrain.ruleset index 3eacb35f79..f8a3ecb785 100644 --- a/data/alien/terrain.ruleset +++ b/data/alien/terrain.ruleset @@ -137,7 +137,7 @@ ocean_resources = TRUE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/civ1/terrain.ruleset b/data/civ1/terrain.ruleset index f6fa90f693..e70b9bdc87 100644 --- a/data/civ1/terrain.ruleset +++ b/data/civ1/terrain.ruleset @@ -131,7 +131,7 @@ igter_cost = 1 ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/civ2/terrain.ruleset b/data/civ2/terrain.ruleset index aecab13455..46a039f99e 100644 --- a/data/civ2/terrain.ruleset +++ b/data/civ2/terrain.ruleset @@ -131,7 +131,7 @@ pythagorean_diagonal = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/civ2civ3/terrain.ruleset b/data/civ2civ3/terrain.ruleset index 1adfb1c098..37d746c0e1 100644 --- a/data/civ2civ3/terrain.ruleset +++ b/data/civ2civ3/terrain.ruleset @@ -143,7 +143,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/classic/terrain.ruleset b/data/classic/terrain.ruleset index f7aace38bb..a066b32140 100644 --- a/data/classic/terrain.ruleset +++ b/data/classic/terrain.ruleset @@ -136,7 +136,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/goldkeep/terrain.ruleset b/data/goldkeep/terrain.ruleset index 0f761775dd..46f84dd877 100644 --- a/data/goldkeep/terrain.ruleset +++ b/data/goldkeep/terrain.ruleset @@ -138,7 +138,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/granularity/terrain.ruleset b/data/granularity/terrain.ruleset index c6ff201bf7..f29bd016ce 100644 --- a/data/granularity/terrain.ruleset +++ b/data/granularity/terrain.ruleset @@ -133,7 +133,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/multiplayer/terrain.ruleset b/data/multiplayer/terrain.ruleset index d0f36b8801..55d3730e23 100644 --- a/data/multiplayer/terrain.ruleset +++ b/data/multiplayer/terrain.ruleset @@ -136,7 +136,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt index ff2d62079b..5586283b2b 100644 --- a/data/ruledit/comments-3.2.txt +++ b/data/ruledit/comments-3.2.txt @@ -618,7 +618,7 @@ terrains = "\ ; \"no\" -- cannot transform\n\ ; terrain rule_name -- transformation changes to that\n\ ; terrain\n\ -; transform_time = time to transform; if 0, cannot transform\n\ +; transform_time = time to transform\n\ ; placing_time = time for \'placing\' an extra; if 0, cannot place\n\ ; Nonzero values only affect extras with build_time 0.\n\ ; Such extras can modify time with build_time_factor.\n\ diff --git a/data/sandbox/terrain.ruleset b/data/sandbox/terrain.ruleset index 108824737e..96670aea1a 100644 --- a/data/sandbox/terrain.ruleset +++ b/data/sandbox/terrain.ruleset @@ -144,7 +144,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/stub/terrain.ruleset b/data/stub/terrain.ruleset index d3d54e6dc8..a731df353b 100644 --- a/data/stub/terrain.ruleset +++ b/data/stub/terrain.ruleset @@ -124,7 +124,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/data/webperimental/terrain.ruleset b/data/webperimental/terrain.ruleset index fddbb5d3af..18168e73b7 100644 --- a/data/webperimental/terrain.ruleset +++ b/data/webperimental/terrain.ruleset @@ -136,7 +136,7 @@ ocean_resources = FALSE ; "no" -- cannot transform ; terrain rule_name -- transformation changes to that ; terrain -; transform_time = time to transform; if 0, cannot transform +; transform_time = time to transform ; placing_time = time for 'placing' an extra; if 0, cannot place ; Nonzero values only affect extras with build_time 0. ; Such extras can modify time with build_time_factor. diff --git a/server/ruleset.c b/server/ruleset.c index ace0660577..6f854a77fc 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -3302,15 +3302,14 @@ static bool load_ruleset_terrain(struct section_file *file, ok = FALSE; break; } - if (pterrain->transform_time <= 0) { - /* Transform time of zero is documented to disable the transform - * regardless of given transform result. That's fine, but in the - * future we may consider it an error to give combination of - * transform_result and transform_time where one indicates it's - * enabled and the other that it's not. - * Note that we already strip transform_result when doing ruleup - * from older ruleset that has such a construct. */ - pterrain->transform_result = NULL; + if ((pterrain->transform_result != NULL + && pterrain->transform_time <= 0) + || (pterrain->transform_result == NULL + && pterrain->transform_time > 0)) { + ruleset_error(LOG_ERROR, "%s: transform_result and transform_time disagree " + "whether transforming is enabled", tsection); + ok = FALSE; + break; } pterrain->placing_time = 1; /* default */ -- 2.34.1