Skip to content

Commit

Permalink
First batch of schema fixes
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
CelticMinstrel committed Mar 31, 2018
1 parent f4f017a commit 11b11ed
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
4 changes: 2 additions & 2 deletions data/schema/core/actionwml.cfg
Expand Up @@ -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}
Expand Down
10 changes: 5 additions & 5 deletions data/schema/filters/location.cfg
Expand Up @@ -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}
Expand All @@ -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]
4 changes: 2 additions & 2 deletions data/schema/filters/side.cfg
Expand Up @@ -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]
14 changes: 7 additions & 7 deletions data/schema/filters/unit.cfg
Expand Up @@ -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}
Expand All @@ -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]
10 changes: 5 additions & 5 deletions data/schema/filters/weapon.cfg
Expand Up @@ -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]
15 changes: 13 additions & 2 deletions data/schema/game_config.cfg
Expand Up @@ -77,15 +77,14 @@
[/type]
[type]
name=range_list
# value="\d+(-\d+)?(,\d+(-\d+)?)*"
[list]
[element]
[list]
split="-"
min=1
max=2
[element]
link="int"
link=unsigned
[/element]
[/list]
[/element]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/schema/types/basic.cfg
Expand Up @@ -21,7 +21,7 @@
[/type]
[type]
name=real
value="-?\d+(\.\d+)?"
value="-?\d+(\.\d+)?|-?\.\d+"
[/type]

[type]
Expand Down
2 changes: 1 addition & 1 deletion src/serialization/tag.cpp
Expand Up @@ -56,7 +56,7 @@ std::shared_ptr<class_type> 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<class_type_list>(cfg["name"], list_cfg["split"].str(","), list_min, list_max);
type = std::make_shared<class_type_list>(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<class_type_simple>(cfg["name"], cfg["value"]);
Expand Down

0 comments on commit 11b11ed

Please sign in to comment.