From 11b11ed78f2b8a2604c4c4aec28750f42287530d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 30 Mar 2018 19:32:18 -0400 Subject: [PATCH] First batch of schema fixes - Allow for variable substitution in filter tags (mostly) - Fix real not matching numbers like .5 - Support x,y=recall,recall After this commit, there are no schema errors in the tutorial. --- data/schema/core/actionwml.cfg | 4 ++-- data/schema/filters/location.cfg | 10 +++++----- data/schema/filters/side.cfg | 4 ++-- data/schema/filters/unit.cfg | 14 +++++++------- data/schema/filters/weapon.cfg | 10 +++++----- data/schema/game_config.cfg | 15 +++++++++++++-- data/schema/types/basic.cfg | 2 +- src/serialization/tag.cpp | 2 +- 8 files changed, 36 insertions(+), 25 deletions(-) diff --git a/data/schema/core/actionwml.cfg b/data/schema/core/actionwml.cfg index d4bdc2c95e81..7eac647ffcb3 100644 --- a/data/schema/core/actionwml.cfg +++ b/data/schema/core/actionwml.cfg @@ -325,8 +325,8 @@ max=infinite super="$filter_unit" {INSERT_TAG} - {SIMPLE_KEY to_x s_int} - {SIMPLE_KEY to_y s_int} + {SIMPLE_KEY to_x range_list} + {SIMPLE_KEY to_y range_list} {SIMPLE_KEY to_location string} {DEFAULT_KEY fire_event s_bool no} {DEFAULT_KEY check_passability s_bool yes} diff --git a/data/schema/filters/location.cfg b/data/schema/filters/location.cfg index 6f45eff9bf7f..bf3c1c45d1d6 100644 --- a/data/schema/filters/location.cfg +++ b/data/schema/filters/location.cfg @@ -5,13 +5,13 @@ {SIMPLE_KEY time_of_day string} {SIMPLE_KEY time_of_day_id string} {SIMPLE_KEY terrain terrain_list} - {SIMPLE_KEY x range_list} - {SIMPLE_KEY y range_list} + {SIMPLE_KEY x s_coordinates} + {SIMPLE_KEY y s_coordinates} {SIMPLE_KEY area string} - {SIMPLE_KEY include_borders bool} + {SIMPLE_KEY include_borders s_bool} {DEPRECATED_KEY owner_side range_list} {SIMPLE_KEY find_in string} - {SIMPLE_KEY radius int} + {SIMPLE_KEY radius s_int} {SIMPLE_KEY formula formula} {SIMPLE_KEY lua_function string} {SIMPLE_KEY location_id string} @@ -28,6 +28,6 @@ name="$filter_adjacent_location" max=0 super="$filter_location" - {SIMPLE_KEY count int} + {SIMPLE_KEY count s_int} {SIMPLE_KEY adjacent dir_list} [/tag] diff --git a/data/schema/filters/side.cfg b/data/schema/filters/side.cfg index f376e75668d3..9b0732ced19d 100644 --- a/data/schema/filters/side.cfg +++ b/data/schema/filters/side.cfg @@ -19,6 +19,6 @@ name="$filter_vision" max=0 super="$filter_side" - {DEFAULT_KEY visible bool yes} - {DEFAULT_KEY respect_fog bool yes} + {DEFAULT_KEY visible s_bool yes} + {DEFAULT_KEY respect_fog s_bool yes} [/tag] diff --git a/data/schema/filters/unit.cfg b/data/schema/filters/unit.cfg index d85b18d1ea26..1fc8d7b002cf 100644 --- a/data/schema/filters/unit.cfg +++ b/data/schema/filters/unit.cfg @@ -14,14 +14,14 @@ {SIMPLE_KEY status string} {SIMPLE_KEY side range_list} {DEPRECATED_KEY has_weapon string} - {SIMPLE_KEY canrecruit bool} + {SIMPLE_KEY canrecruit s_bool} {SIMPLE_KEY gender gender} {SIMPLE_KEY role string} {SIMPLE_KEY level range_list} - {SIMPLE_KEY defense int} - {SIMPLE_KEY movement_cost int} - {SIMPLE_KEY x range_list} - {SIMPLE_KEY y range_list} + {SIMPLE_KEY defense s_int} + {SIMPLE_KEY movement_cost s_int} + {SIMPLE_KEY x s_coordinates} + {SIMPLE_KEY y s_coordinates} {SIMPLE_KEY find_in string} {SIMPLE_KEY formula formula} {SIMPLE_KEY lua_function string} @@ -44,7 +44,7 @@ name="$filter_adjacent" max=0 super="$filter_unit" - {SIMPLE_KEY count int} + {SIMPLE_KEY count s_int} {SIMPLE_KEY adjacent dir_list} - {SIMPLE_KEY is_enemy bool} + {SIMPLE_KEY is_enemy s_bool} [/tag] diff --git a/data/schema/filters/weapon.cfg b/data/schema/filters/weapon.cfg index 0424c398e57f..6708c54b7e87 100644 --- a/data/schema/filters/weapon.cfg +++ b/data/schema/filters/weapon.cfg @@ -8,10 +8,10 @@ {SIMPLE_KEY special string} {SIMPLE_KEY special_active string} {SIMPLE_KEY formula formula} - {SIMPLE_KEY damage int} - {SIMPLE_KEY number int} - {SIMPLE_KEY parry int} - {SIMPLE_KEY accuracy int} - {SIMPLE_KEY movement_used int} + {SIMPLE_KEY damage s_int} + {SIMPLE_KEY number s_int} + {SIMPLE_KEY parry s_int} + {SIMPLE_KEY accuracy s_int} + {SIMPLE_KEY movement_used s_int} {FILTER_BOOLEAN_OPS weapon} [/tag] diff --git a/data/schema/game_config.cfg b/data/schema/game_config.cfg index da9bcf89d3a9..1e2236088f35 100644 --- a/data/schema/game_config.cfg +++ b/data/schema/game_config.cfg @@ -77,7 +77,6 @@ [/type] [type] name=range_list - # value="\d+(-\d+)?(,\d+(-\d+)?)*" [list] [element] [list] @@ -85,7 +84,7 @@ min=1 max=2 [element] - link="int" + link=unsigned [/element] [/list] [/element] @@ -354,6 +353,18 @@ name="micro_ai_action" value="add|delete|change" [/type] + [type] + name="coordinates" + [union] + [type] + link=range_list + [/type] + [type] + value="recall" + [/type] + [/union] + [/type] + {SUBST_TYPE coordinates} [tag] name="root" min=1 diff --git a/data/schema/types/basic.cfg b/data/schema/types/basic.cfg index abfd98f9bb49..8d92be594c9a 100644 --- a/data/schema/types/basic.cfg +++ b/data/schema/types/basic.cfg @@ -21,7 +21,7 @@ [/type] [type] name=real - value="-?\d+(\.\d+)?" + value="-?\d+(\.\d+)?|-?\.\d+" [/type] [type] diff --git a/src/serialization/tag.cpp b/src/serialization/tag.cpp index 378ba9c8592f..84cd7c7a335a 100644 --- a/src/serialization/tag.cpp +++ b/src/serialization/tag.cpp @@ -56,7 +56,7 @@ std::shared_ptr class_type::from_config(const config& cfg) int list_min = list_cfg["min"].to_int(); int list_max = list_cfg["max"].str() == "infinite" ? -1 : list_cfg["max"].to_int(-1); if(list_max < 0) list_max = INT_MAX; - type = std::make_shared(cfg["name"], list_cfg["split"].str(","), list_min, list_max); + type = std::make_shared(cfg["name"], list_cfg["split"].str("\\s*,\\s*"), list_min, list_max); composite_range.emplace(list_cfg.child_range("element")); } else if(cfg.has_attribute("value")) { type = std::make_shared(cfg["name"], cfg["value"]);