diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-13 14:55:49 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-27 11:29:45 -0700 |
commit | 9951ad78c80e144c166a7d476cad7ffdf84332a9 (patch) | |
tree | 9f5498a9a3c23b62dc928288e72081e99f958f46 /src/map | |
parent | 749fec734c4583153fb2dbc80f1d21db2c2ab457 (diff) | |
download | tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.gz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.bz2 tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.xz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.zip |
Debug debugging
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.cpp | 1 | ||||
-rw-r--r-- | src/map/magic-expr.cpp | 27 | ||||
-rw-r--r-- | src/map/magic-expr.py | 32 | ||||
-rw-r--r-- | src/map/magic-interpreter.hpp | 8 | ||||
-rw-r--r-- | src/map/magic-interpreter.py | 335 | ||||
-rw-r--r-- | src/map/magic-stmt.hpp | 4 | ||||
-rw-r--r-- | src/map/magic-stmt.py | 31 | ||||
-rw-r--r-- | src/map/main.cpp | 11 | ||||
-rw-r--r-- | src/map/map.hpp | 2 | ||||
-rw-r--r-- | src/map/map.py | 125 | ||||
-rw-r--r-- | src/map/mapflag.py | 54 | ||||
-rw-r--r-- | src/map/script.py | 74 |
12 files changed, 429 insertions, 275 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index fb4041c..3b6c772 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3697,6 +3697,7 @@ RecvResult clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> send_fpacket<0x0095, 30>(s, fixed_95); } break; + // case BL::SPELL default: if (battle_config.error_log) PRINTF("clif_parse_GetCharNameRequest : bad type %d (%d)\n"_fmt, diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index a453c05..9a44fa9 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -75,22 +75,22 @@ dumb_ptr<area_t> dup_area(dumb_ptr<area_t> area) { CASE (const location_t&, loc) { - return dumb_ptr<area_t>::make(loc, area->size); + return dumb_ptr<area_t>::make(loc); } CASE (const AreaUnion&, a) { AreaUnion u; u.a_union[0] = dup_area(a.a_union[0]); u.a_union[1] = dup_area(a.a_union[1]); - return dumb_ptr<area_t>::make(u, area->size); + return dumb_ptr<area_t>::make(u); } CASE (const AreaRect&, rect) { - return dumb_ptr<area_t>::make(rect, area->size); + return dumb_ptr<area_t>::make(rect); } CASE (const AreaBar&, bar) { - return dumb_ptr<area_t>::make(bar, area->size); + return dumb_ptr<area_t>::make(bar); } } @@ -290,8 +290,7 @@ dumb_ptr<area_t> area_union(dumb_ptr<area_t> area, dumb_ptr<area_t> other_area) AreaUnion a; a.a_union[0] = area; a.a_union[1] = other_area; - int size = area->size + other_area->size; /* Assume no overlap */ - return dumb_ptr<area_t>::make(a, size); + return dumb_ptr<area_t>::make(a); } /** @@ -302,7 +301,7 @@ void make_area(val_t *v) { if (ValLocation *l = v->get_if<ValLocation>()) { - auto a = dumb_ptr<area_t>::make(l->v_location, 1); + auto a = dumb_ptr<area_t>::make(l->v_location); *v = ValArea{a}; } } @@ -1211,7 +1210,7 @@ int fun_rbox(dumb_ptr<env_t>, val_t *result, Slice<val_t> args) a_rect.loc.y = loc.y - radius; a_rect.width = radius * 2 + 1; a_rect.height = radius * 2 + 1; - *result = ValArea{dumb_ptr<area_t>::make(a_rect, a_rect.width * a_rect.height)}; + *result = ValArea{dumb_ptr<area_t>::make(a_rect)}; return 0; } @@ -1539,14 +1538,13 @@ dumb_ptr<area_t> eval_area(dumb_ptr<env_t> env, const e_area_t& expr_) CASE (const e_location_t&, a_loc) { location_t loc; - int size = 1; if (eval_location(env, &loc, &a_loc)) { return nullptr; } else { - return dumb_ptr<area_t>::make(loc, size); + return dumb_ptr<area_t>::make(loc); } } CASE (const ExprAreaUnion&, a) @@ -1569,8 +1567,7 @@ dumb_ptr<area_t> eval_area(dumb_ptr<env_t> env, const e_area_t& expr_) } return nullptr; } - int size = u.a_union[0]->size + u.a_union[1]->size; - return dumb_ptr<area_t>::make(u, size); + return dumb_ptr<area_t>::make(u); } CASE (const ExprAreaRect&, a_rect) { @@ -1587,10 +1584,9 @@ dumb_ptr<area_t> eval_area(dumb_ptr<env_t> env, const e_area_t& expr_) a_rect_.width = width.get_if<ValInt>()->v_int; a_rect_.height = height.get_if<ValInt>()->v_int; - int size = a_rect_.width * a_rect_.height; magic_clear_var(&width); magic_clear_var(&height); - return dumb_ptr<area_t>::make(a_rect_, size); + return dumb_ptr<area_t>::make(a_rect_); } else { @@ -1617,11 +1613,10 @@ dumb_ptr<area_t> eval_area(dumb_ptr<env_t> env, const e_area_t& expr_) a_bar_.depth = depth.get_if<ValInt>()->v_int; a_bar_.dir = dir.get_if<ValDir>()->v_dir; - int size = (a_bar_.width * 2 + 1) * a_bar_.depth; magic_clear_var(&width); magic_clear_var(&depth); magic_clear_var(&dir); - return dumb_ptr<area_t>::make(a_bar_, size); + return dumb_ptr<area_t>::make(a_bar_); } else { diff --git a/src/map/magic-expr.py b/src/map/magic-expr.py new file mode 100644 index 0000000..cdb2bcf --- /dev/null +++ b/src/map/magic-expr.py @@ -0,0 +1,32 @@ +class fun_t(object): + __slots__ = ('_value') + + name = 'tmwa::magic::fun_t' + depth = 1 + enabled = True + + def __init__(self, value): + if not value: + value = None + self._value = value + + def to_string(self): + value = self._value + if value is None: + return '(fun_t *) nullptr' + return '(fun_t *)' + + def children(self): + value = self._value + if value is None: + return + value = value.dereference() + yield '->name', value['name'] + yield '->signature', value['signature'] + yield '->ret_ty', value['ret_ty'] + yield '->fun', value['fun'] + + tests = [ + ('static_cast<tmwa::magic::fun_t *>(nullptr)', '(fun_t *) nullptr'), + ('new tmwa::magic::fun_t{"name"_s, "sig"_s, \'\\0\', nullptr}', '(fun_t *) = {->name = "name", ->signature = "sig", ->ret_ty = 0 \'\\000\', ->fun = 0x0}'), + ] diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp index 526617f..3bb600c 100644 --- a/src/map/magic-interpreter.hpp +++ b/src/map/magic-interpreter.hpp @@ -87,10 +87,10 @@ struct area_t : AreaVariantBase area_t& operator = (area_t&&) = default; area_t& operator = (const area_t&) = delete; - area_t(location_t v, int sz) : AreaVariantBase(std::move(v)), size(sz) {} - area_t(AreaUnion v, int sz) : AreaVariantBase(std::move(v)), size(sz) {} - area_t(AreaRect v, int sz) : AreaVariantBase(std::move(v)), size(sz) {} - area_t(AreaBar v, int sz) : AreaVariantBase(std::move(v)), size(sz) {} + area_t(location_t v) : AreaVariantBase(std::move(v)), size(1) {} + area_t(AreaUnion v) : AreaVariantBase(std::move(v)), size(v.a_union[0]->size + v.a_union[1]->size) {} + area_t(AreaRect v) : AreaVariantBase(std::move(v)), size(v.width * v.height) {} + area_t(AreaBar v) : AreaVariantBase(std::move(v)), size((v.width * 2 + 1) * v.depth) {} }; struct ValUndef diff --git a/src/map/magic-interpreter.py b/src/map/magic-interpreter.py index f6fa4c9..cf17b1c 100644 --- a/src/map/magic-interpreter.py +++ b/src/map/magic-interpreter.py @@ -1,224 +1,215 @@ -class area_t(object): - ''' print an area_t - ''' +class AreaUnion(object): __slots__ = ('_value') - name = 'tmwa::area_t' + name = 'tmwa::magic::AreaUnion' enabled = True def __init__(self, value): self._value = value + def display_hint(self): + return 'array' + def to_string(self): return None def children(self): v = self._value - yield 'size', v['size'] - ty = v['ty'] - yield 'ty', ty - a = v['a'] - if ty == 0: - yield 'a.a_loc', a['a_loc'] - elif ty == 1: - yield 'a.a_union', a['a_union'] - elif ty == 2: - yield 'a.a_rect', a['a_rect'] - elif ty == 3: - yield 'a.a_bar', a['a_bar'] + for i in [0, 1]: + yield '[%d]', v['a_union'][i]['impl'].dereference() + tests = [] -class val_t(object): - ''' print a val_t - ''' - __slots__ = ('_value') - name = 'tmwa::val_t' +class area_t(object): enabled = True - def __init__(self, value): - self._value = value + test_extra = ''' + #include "../strings/fwd.hpp" + using tmwa::operator "" _s; + + inline + tmwa::map_local *fake_map_local_x_dup_for_area_t(tmwa::ZString name) + { + auto *p = new tmwa::map_local{}; + p->name_ = tmwa::stringish<tmwa::MapName>(name); + return p; + } + ''' - def to_string(self): - return None + tests = [ + ('tmwa::magic::area_t(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456})', + '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}'), + ('tmwa::magic::area_t(tmwa::magic::AreaUnion{{tmwa::dumb_ptr<tmwa::magic::area_t>::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}), tmwa::dumb_ptr<tmwa::magic::area_t>::make(tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 321, 654})}})', + '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaUnion) = {{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}}, size = 1}, {<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::location_t) = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 321, y = 654}}, size = 1}}}, size = 2}'), + ('tmwa::magic::area_t(tmwa::magic::AreaRect{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 123, 456}, 789, 102})', + '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaRect) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 123, y = 456}, width = 789, height = 102}}, size = 80478}'), + ('tmwa::magic::area_t(tmwa::magic::AreaBar{tmwa::magic::location_t{fake_map_local_x_dup_for_area_t("map"_s), 42, 43}, 123, 456, tmwa::DIR::NW})', + '{<tmwa::sexpr::Variant<tmwa::magic::location_t, tmwa::magic::AreaUnion, tmwa::magic::AreaRect, tmwa::magic::AreaBar>> = {(tmwa::magic::AreaBar) = {loc = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 43}, width = 123, depth = 456, dir = tmwa::DIR::NW}}, size = 112632}'), + ] - def children(self): - v = self._value - ty = v['ty'] - yield 'ty', ty - u = v['v'] - if ty == 1: - yield 'v.v_int', u['v_int'] - elif ty == 2: - yield 'v.v_dir', u['v_dir'] - elif ty == 3: - yield 'v.v_string', u['v_string'] - elif ty == 4: - yield 'v.v_int', u['v_int'] - yield 'v.v_entity', u['v_entity'] - elif ty == 5: - yield 'v.v_location', u['v_location'] - elif ty == 6: - yield 'v.v_area', u['v_area'] - elif ty == 7: - yield 'v.v_spell', u['v_spell'] - elif ty == 8: - yield 'v.v_int', u['v_int'] - yield 'v.v_invocation', u['v_invocation'] +class val_t(object): + enabled = True -class e_area_t(object): - ''' print an e_area_t + test_extra = ''' + #include "../strings/fwd.hpp" + using tmwa::operator "" _s; + + inline + tmwa::map_local *fake_map_local_x_dup_for_val_t(tmwa::ZString name) + { + auto *p = new tmwa::map_local{}; + p->name_ = tmwa::stringish<tmwa::MapName>(name); + return p; + } ''' + + tests = [ + ('tmwa::magic::val_t(tmwa::magic::ValUndef{})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValUndef) = {<No data fields>}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValInt{42})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInt) = {v_int = 42}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValDir{tmwa::DIR::NW})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValDir) = {v_dir = tmwa::DIR::NW}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValString{"Hello"_s})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValString) = {v_string = "Hello"}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValEntityInt{tmwa::wrap<tmwa::BlockId>(123)})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValEntityInt) = {v_eid = 123}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValEntityPtr{tmwa::dumb_ptr<tmwa::block_list>()})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValEntityPtr) = {v_entity = 0x0}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValLocation{tmwa::magic::location_t{fake_map_local_x_dup_for_val_t("map"_s), 42, 123}})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValLocation) = {v_location = {m = (map_local *) = {->name = "map", ->xs = 0, ->ys = 0}, x = 42, y = 123}}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValArea{tmwa::dumb_ptr<tmwa::magic::area_t>()})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValArea) = {v_area = 0x0}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValSpell{tmwa::dumb_ptr<tmwa::magic::spell_t>()})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValSpell) = {v_spell = 0x0}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValInvocationInt{tmwa::wrap<tmwa::BlockId>(123)})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInvocationInt) = {v_iid = 123}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValInvocationPtr{})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValInvocationPtr) = {v_invocation = 0x0}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValFail{})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValFail) = {<No data fields>}}, <No data fields>}'), + ('tmwa::magic::val_t(tmwa::magic::ValNegative1{})', + '{<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValNegative1) = {<No data fields>}}, <No data fields>}'), + ] + + +class ExprAreaUnion(object): __slots__ = ('_value') - name = 'tmwa::e_area_t' + name = 'tmwa::magic::ExprAreaUnion' enabled = True def __init__(self, value): self._value = value + def display_hint(self): + return 'array' + def to_string(self): return None def children(self): v = self._value - ty = v['ty'] - yield 'ty', ty - a = v['a'] - if ty == 0: - yield 'a.a_loc', a['a_loc'] - elif ty == 1: - yield 'a.a_union', a['a_union'] - elif ty == 2: - yield 'a.a_rect', a['a_rect'] - elif ty == 3: - yield 'a.a_bar', a['a_bar'] + for i in [0, 1]: + yield '[%d]', v['a_union'][i]['impl'].dereference() + tests = [] -class expr_t(object): - ''' print an expr_t - ''' - __slots__ = ('_value') - name = 'tmwa::expr_t' - enabled = True - def __init__(self, value): - self._value = value +class e_area_t(object): + enabled = True - def to_string(self): - return None + tests = [ + ('tmwa::magic::e_area_t(tmwa::magic::e_location_t())', + '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaUnion{{tmwa::dumb_ptr<tmwa::magic::e_area_t>::make(tmwa::magic::e_location_t()), tmwa::dumb_ptr<tmwa::magic::e_area_t>::make(tmwa::magic::e_location_t())}})', + '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaUnion) = {{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}, {<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}}, <No data fields>}'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaRect{tmwa::magic::e_location_t(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>()})', + '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaRect) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, height = 0x0}}, <No data fields>}'), + ('tmwa::magic::e_area_t(tmwa::magic::ExprAreaBar{tmwa::magic::e_location_t(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>()})', + '{<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::ExprAreaBar) = {loc = {m = 0x0, x = 0x0, y = 0x0}, width = 0x0, depth = 0x0, dir = 0x0}}, <No data fields>}'), + ] - def children(self): - v = self._value - ty = v['ty'] - yield 'ty', ty - u = v['e'] - if ty == 0: - yield 'e.e_val', u['e_val'] - elif ty == 1: - yield 'e.e_location', u['e_location'] - elif ty == 2: - yield 'e.e_area', u['e_area'] - elif ty == 3: - yield 'e.e_funapp', u['e_funapp'] - elif ty == 4: - yield 'e.e_id', u['e_id'] - elif ty == 5: - yield 'e.e_field', u['e_field'] -class effect_t(object): - ''' print an effect_t - ''' - __slots__ = ('_value') - name = 'tmwa::effect_t' +class expr_t(object): enabled = True - def __init__(self, value): - self._value = value + tests = [ + ('tmwa::magic::expr_t(tmwa::magic::val_t(tmwa::magic::ValUndef()))', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::val_t) = {<tmwa::sexpr::Variant<tmwa::magic::ValUndef, tmwa::magic::ValInt, tmwa::magic::ValDir, tmwa::magic::ValString, tmwa::magic::ValEntityInt, tmwa::magic::ValEntityPtr, tmwa::magic::ValLocation, tmwa::magic::ValArea, tmwa::magic::ValSpell, tmwa::magic::ValInvocationInt, tmwa::magic::ValInvocationPtr, tmwa::magic::ValFail, tmwa::magic::ValNegative1>> = {(tmwa::magic::ValUndef) = {<No data fields>}}, <No data fields>}}, <No data fields>}'), + ('tmwa::magic::expr_t(tmwa::magic::e_location_t())', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}'), + ('tmwa::magic::expr_t(tmwa::magic::e_area_t(tmwa::magic::e_location_t()))', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::e_area_t) = {<tmwa::sexpr::Variant<tmwa::magic::e_location_t, tmwa::magic::ExprAreaUnion, tmwa::magic::ExprAreaRect, tmwa::magic::ExprAreaBar>> = {(tmwa::magic::e_location_t) = {m = 0x0, x = 0x0, y = 0x0}}, <No data fields>}}, <No data fields>}'), + ('tmwa::magic::expr_t(tmwa::magic::ExprFunApp())', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprFunApp) = {funp = (fun_t *) nullptr, line_nr = 0, column = 0, args_nr = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, <No data fields>}'), + ('tmwa::magic::expr_t(tmwa::magic::ExprId{123})', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprId) = {e_id = 123}}, <No data fields>}'), + ('tmwa::magic::expr_t(tmwa::magic::ExprField{tmwa::dumb_ptr<tmwa::magic::expr_t>(), 42})', + '{<tmwa::sexpr::Variant<tmwa::magic::val_t, tmwa::magic::e_location_t, tmwa::magic::e_area_t, tmwa::magic::ExprFunApp, tmwa::magic::ExprId, tmwa::magic::ExprField>> = {(tmwa::magic::ExprField) = {expr = 0x0, id = 42}}, <No data fields>}'), + ] - def to_string(self): - return None - def children(self): - v = self._value - yield 'next', v['next'] - ty = v['ty'] - yield 'ty', ty - u = v['e'] - if ty == 2: - yield 'e.e_assign', u['e_assign'] - elif ty == 3: - yield 'e.e_foreach', u['e_foreach'] - elif ty == 4: - yield 'e.e_for', u['e_for'] - elif ty == 5: - yield 'e.e_if', u['e_if'] - elif ty == 6: - yield 'e.e_sleep', u['e_sleep'] - elif ty == 7: - yield 'e.e_script', u['e_script'] - elif ty == 9: - yield 'e.e_op', u['e_op'] - elif ty == 11: - yield 'e.e_call', u['e_call'] +class effect_t(object): + enabled = True + + tests = [ + ('tmwa::magic::effect_t(tmwa::magic::EffectSkip{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectSkip) = {<No data fields>}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectAbort{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectAbort) = {<No data fields>}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectAssign{42, tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectAssign) = {id = 42, expr = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectForEach{123, tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::magic::FOREACH_FILTER::PC}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectForEach) = {id = 123, area = 0x0, body = 0x0, filter = tmwa::magic::FOREACH_FILTER::PC}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectFor{42, tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectFor) = {id = 42, start = 0x0, stop = 0x0, body = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectIf{tmwa::dumb_ptr<tmwa::magic::expr_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectIf) = {cond = 0x0, true_branch = 0x0, false_branch = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectSleep{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectSleep) = {e_sleep = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectScript{tmwa::dumb_ptr<const tmwa::ScriptBuffer>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectScript) = {e_script = 0x0}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectBreak{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectBreak) = {<No data fields>}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectOp(), tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectOp) = {opp = (op_t *) nullptr, args_nr = 0, line_nr = 0, column = 0, args = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectEnd{}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectEnd) = {<No data fields>}}, next = 0x0}'), + ('tmwa::magic::effect_t(tmwa::magic::EffectCall{nullptr, tmwa::dumb_ptr<std::vector<tmwa::dumb_ptr<tmwa::magic::expr_t>>>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::EffectSkip, tmwa::magic::EffectAbort, tmwa::magic::EffectAssign, tmwa::magic::EffectForEach, tmwa::magic::EffectFor, tmwa::magic::EffectIf, tmwa::magic::EffectSleep, tmwa::magic::EffectScript, tmwa::magic::EffectBreak, tmwa::magic::EffectOp, tmwa::magic::EffectEnd, tmwa::magic::EffectCall>> = {(tmwa::magic::EffectCall) = {formalv = 0x0, actualvp = 0x0, body = 0x0}}, next = 0x0}'), + ] class spellguard_t(object): - ''' print a spellguard_t - ''' - __slots__ = ('_value') - name = 'tmwa::spellguard_t' enabled = True - def __init__(self, value): - self._value = value - - def to_string(self): - return None - - def children(self): - v = self._value - yield 'next', v['next'] - ty = v['ty'] - yield 'ty', ty - u = v['s'] - if ty == 0: - yield 's.s_condition', u['s_condition'] - elif ty == 1: - yield 's.s_components', u['s_components'] - elif ty == 2: - yield 's.s_catalysts', u['s_catalysts'] - elif ty == 3: - yield 's.s_alt', u['s_alt'] - elif ty == 4: - yield 's.s_mana', u['s_mana'] - elif ty == 5: - yield 's.s_casttime', u['s_casttime'] - elif ty == 6: - yield 's.s_effect', u['s_effect'] + tests = [ + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCondition{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCondition) = {s_condition = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardMana{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardMana) = {s_mana = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCastTime{tmwa::dumb_ptr<tmwa::magic::expr_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCastTime) = {s_casttime = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardComponents{tmwa::dumb_ptr<tmwa::magic::component_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardComponents) = {s_components = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardCatalysts{tmwa::dumb_ptr<tmwa::magic::component_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardCatalysts) = {s_catalysts = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::GuardChoice{tmwa::dumb_ptr<tmwa::magic::spellguard_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::GuardChoice) = {s_alt = 0x0}}, next = 0x0}'), + ('tmwa::magic::spellguard_t(tmwa::magic::effect_set_t{tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<tmwa::magic::effect_t>()}, tmwa::dumb_ptr<tmwa::magic::spellguard_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::GuardCondition, tmwa::magic::GuardMana, tmwa::magic::GuardCastTime, tmwa::magic::GuardComponents, tmwa::magic::GuardCatalysts, tmwa::magic::GuardChoice, tmwa::magic::effect_set_t>> = {(tmwa::magic::effect_set_t) = {effect = 0x0, at_trigger = 0x0, at_end = 0x0}}, next = 0x0}'), + ] class cont_activation_record_t(object): - ''' print a cont_activation_record_t - ''' - __slots__ = ('_value') - name = 'tmwa::cont_activation_record_t' enabled = True - def __init__(self, value): - self._value = value - - def to_string(self): - return None - - def children(self): - v = self._value - yield 'return_location', v['return_location'] - ty = v['ty'] - yield 'ty', ty - u = v['c'] - if ty == 0: - yield 'c.c_foreach', u['c_foreach'] - elif ty == 1: - yield 'c.c_for', u['c_for'] - elif ty == 2: - yield 'c.c_proc', u['c_proc'] + tests = [ + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarForEach{42, true, tmwa::dumb_ptr<tmwa::magic::effect_t>(), tmwa::dumb_ptr<std::vector<tmwa::BlockId>>(), 123}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarForEach) = {id = 42, ty_is_spell_not_entity = true, body = 0x0, entities_vp = 0x0, index = 123}}, return_location = 0x0}'), + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarFor{42, tmwa::dumb_ptr<tmwa::magic::effect_t>(), 123, 456}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarFor) = {id = 42, body = 0x0, current = 123, stop = 456}}, return_location = 0x0}'), + ('tmwa::magic::cont_activation_record_t(tmwa::magic::CarProc{123, nullptr, tmwa::dumb_ptr<tmwa::magic::val_t[]>()}, tmwa::dumb_ptr<tmwa::magic::effect_t>())', + '{<tmwa::sexpr::Variant<tmwa::magic::CarForEach, tmwa::magic::CarFor, tmwa::magic::CarProc>> = {(tmwa::magic::CarProc) = {args_nr = 123, formalap = 0x0, old_actualpa = 0x0 = {sz = 0}}}, return_location = 0x0}'), + ] diff --git a/src/map/magic-stmt.hpp b/src/map/magic-stmt.hpp index 28af140..0385858 100644 --- a/src/map/magic-stmt.hpp +++ b/src/map/magic-stmt.hpp @@ -36,8 +36,8 @@ namespace magic { struct op_t { - ZString name; - ZString signature; + LString name; + LString signature; int (*op)(dumb_ptr<env_t> env, Slice<val_t> arga); }; diff --git a/src/map/magic-stmt.py b/src/map/magic-stmt.py new file mode 100644 index 0000000..6e34bb0 --- /dev/null +++ b/src/map/magic-stmt.py @@ -0,0 +1,31 @@ +class op_t(object): + __slots__ = ('_value') + + name = 'tmwa::magic::op_t' + depth = 1 + enabled = True + + def __init__(self, value): + if not value: + value = None + self._value = value + + def to_string(self): + value = self._value + if value is None: + return '(op_t *) nullptr' + return '(op_t *)' + + def children(self): + value = self._value + if value is None: + return + value = value.dereference() + yield '->name', value['name'] + yield '->signature', value['signature'] + yield '->op', value['op'] + + tests = [ + ('static_cast<tmwa::magic::op_t *>(nullptr)', '(op_t *) nullptr'), + ('new tmwa::magic::op_t{"name"_s, "sig"_s, nullptr}', '(op_t *) = {->name = "name", ->signature = "sig", ->op = 0x0}'), + ] diff --git a/src/map/main.cpp b/src/map/main.cpp index 8e8e9d5..c16f642 100644 --- a/src/map/main.cpp +++ b/src/map/main.cpp @@ -1,6 +1,6 @@ -// map/main.cpp - dummy file to make Make dependencies work +// map/main.cpp - entry point to tmwa-map server // -// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com> +// Copyright © 2013-2014 Ben Longbons <b.r.longbons@gmail.com> // // This file is part of The Mana World (Athena server) // @@ -17,6 +17,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. +#include "../mmo/core.hpp" + #include "map.hpp" #include "../poison.hpp" @@ -25,3 +27,8 @@ namespace tmwa { } // namespace tmwa + +int main(int argc, char **argv) +{ + return tmwa_main(argc, argv); +} diff --git a/src/map/map.hpp b/src/map/map.hpp index 55f4823..d88ff54 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -511,7 +511,7 @@ struct BlockLists struct map_abstract { MapName name_; - // gat is nullptr for map_remote and non-nullptr or map_local + // gat is nullptr for map_remote and non-nullptr for map_local std::unique_ptr<MapCell[]> gat; virtual ~map_abstract() {} diff --git a/src/map/map.py b/src/map/map.py new file mode 100644 index 0000000..dc70782 --- /dev/null +++ b/src/map/map.py @@ -0,0 +1,125 @@ +class map_local(object): + __slots__ = ('_value') + + name = 'tmwa::map_local' + depth = 1 + enabled = True + + def __init__(self, value): + if not value: + value = None + self._value = value + + def to_string(self): + value = self._value + if value is None: + return '(map_local *) nullptr' + return '(map_local *)' + + def children(self): + value = self._value + if value is None: + return + value = value.dereference() + yield '->name', value['name_'] + yield '->xs', value['xs'] + yield '->ys', value['ys'] + + tests = [ + ('static_cast<tmwa::map_local *>(nullptr)', '(map_local *) nullptr'), + ('fake_map_local("map"_s, 42, 404)', '(map_local *) = {->name = "map", ->xs = 42, ->ys = 404}'), + ] + +class map_remote(object): + __slots__ = ('_value') + + name = 'tmwa::map_remote' + depth = 1 + enabled = True + + def __init__(self, value): + if not value: + value = None + self._value = value + + def to_string(self): + value = self._value + if value is None: + return '(map_remote *) nullptr' + return '(map_remote *)' + + def children(self): + value = self._value + if value is None: + return + value = value.dereference() + yield '->name', value['name_'] + yield '->ip', value['ip'] + yield '->port', value['port'] + + tests = [ + ('static_cast<tmwa::map_remote *>(nullptr)', '(map_remote *) nullptr'), + ('fake_map_remote("map"_s, tmwa::IP4Address({8, 8, 8, 8}), 6667)', '(map_remote *) = {->name = "map", ->ip = 8.8.8.8, ->port = 6667}'), + ] + +class map_abstract(object): + __slots__ = ('_value') + + name = 'tmwa::map_abstract' + depth = 1 + enabled = True + + def __init__(self, value): + if not value: + value = None + self._value = value + + def to_string(self): + value = self._value + if value is None: + return '(map_abstract *) nullptr' + gat = value.dereference()['gat'] + gat = gat.address.cast(gdb.lookup_type('tmwa::map_abstract').pointer().pointer()).dereference() + if gat: + return value.cast(gdb.lookup_type('tmwa::map_local').pointer()) + else: + return value.cast(gdb.lookup_type('tmwa::map_remote').pointer()) + + tests = [ + ('static_cast<tmwa::map_abstract *>(nullptr)', '(map_abstract *) nullptr'), + ] + [ + ('static_cast<tmwa::map_abstract *>(%s); value->gat.reset(new tmwa::MapCell[1])' % expr, expected) + for (expr, expected) in map_local.tests[1:] + ] + [ + ('static_cast<tmwa::map_abstract *>(%s)' % expr, expected) + for (expr, expected) in map_remote.tests[1:] + ] + + test_extra = ''' + inline + tmwa::map_local *fake_map_local(tmwa::ZString name, int xs, int ys) + { + auto *p = new tmwa::map_local{}; + p->name_ = tmwa::stringish<tmwa::MapName>(name); + p->xs = xs; + p->ys = ys; + return p; + } + + inline + tmwa::map_remote *fake_map_remote(tmwa::ZString name, tmwa::IP4Address ip, uint16_t port) + { + auto *p = new tmwa::map_remote{}; + p->name_ = tmwa::stringish<tmwa::MapName>(name); + p->ip = ip; + p->port = port; + return p; + } + + void fake_delete(tmwa::map_abstract *); + void fake_delete(tmwa::map_abstract *map) + { + delete map; + } + + ''' diff --git a/src/map/mapflag.py b/src/map/mapflag.py index fec8c05..fe5b016 100644 --- a/src/map/mapflag.py +++ b/src/map/mapflag.py @@ -1,6 +1,4 @@ class MapFlags(object): - ''' print a set of map flags - ''' __slots__ = ('_value') name = 'tmwa::MapFlags' enabled = True @@ -11,29 +9,38 @@ class MapFlags(object): def to_string(self): i = int(self._value) s = [] - for n, v in [ - ('ALIAS', 21), - ('NOMEMO', 0), + for n, v in MapFlags.junk: + v = 1 << v + if i & v: + i -= v + s.append(n) + if i or not s: + s.append('%#08x' % i) + return 'MapFlags(%s)' % (' | '.join(s)) + + junk = [ + #('ALIAS', 21), + #('NOMEMO', 0), ('NOTELEPORT', 1), ('NORETURN', 22), ('MONSTER_NOTELEPORT', 23), ('NOSAVE', 2), - ('NOBRANCH', 3), + #('NOBRANCH', 3), ('NOPENALTY', 4), ('PVP', 6), ('PVP_NOPARTY', 7), - ('PVP_NOGUILD', 8), - ('PVP_NIGHTMAREDROP', 24), + #('PVP_NOGUILD', 8), + #('PVP_NIGHTMAREDROP', 24), ('PVP_NOCALCRANK', 25), - ('GVG', 9), - ('GVG_NOPARTY', 10), - ('NOZENYPENALTY', 5), - ('NOTRADE', 11), - ('NOSKILL', 12), + #('GVG', 9), + #('GVG_NOPARTY', 10), + #('NOZENYPENALTY', 5), + #('NOTRADE', 11), + #('NOSKILL', 12), ('NOWARP', 13), ('NOWARPTO', 26), ('NOPVP', 14), - ('NOICEWALL', 15), + #('NOICEWALL', 15), ('SNOW', 16), ('FOG', 17), ('SAKURA', 18), @@ -43,11 +50,14 @@ class MapFlags(object): ('TOWN', 28), ('OUTSIDE', 29), ('RESAVE', 30), - ]: - v = 1 << v - if i & v: - i -= v - s.append(n) - if i or not s: - s.append('%#08x' % i) - return 'MapFlags(%s)' % (' | '.join(s)) + ] + tests = [ + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0x80000000))', 'MapFlags(0x80000000)'), + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0xf0000000))', 'MapFlags(TOWN | OUTSIDE | RESAVE | 0x80000000)'), + ] + [ + ('tmwa::MapFlags(); value.set(tmwa::MapFlag::%s, true)' % n, 'MapFlags(%s)' % n) + for (n, _) in junk + ] + [ + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(1 << %d))' % i, 'MapFlags(%s)' % n) + for (n, i) in junk + ] diff --git a/src/map/script.py b/src/map/script.py index dcde08d..e3029d5 100644 --- a/src/map/script.py +++ b/src/map/script.py @@ -1,59 +1,21 @@ -class ByteCode: - ''' print a ByteCode - (workaround for gcc bug 58150) - ''' - __slots__ = ('_value') - name = 'tmwa::ByteCode' - enabled = True - - def __init__(self, value): - self._value = value - - def to_string(self): - val = int(self._value) - try: - return 'ByteCode::' + self.types[val] - except IndexError: - return 'ByteCode(%x)' % val - - types = [ - 'NOP', 'POS', 'INT', 'PARAM', 'FUNC', 'STR', 'CONSTSTR', 'ARG', - 'VARIABLE', 'EOL', 'RETINFO', - - 'LOR', 'LAND', 'LE', 'LT', 'GE', 'GT', 'EQ', 'NE', - 'XOR', 'OR', 'AND', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD', - 'NEG', 'LNOT', 'NOT', 'R_SHIFT', 'L_SHIFT', - - 'FUNC_REF', - ] -for i, n in enumerate(ByteCode.types): - setattr(ByteCode, n, i) -del i, n - class script_data(object): - ''' print a script_data - ''' - __slots__ = ('_value') - name = 'tmwa::script_data' enabled = True - def __init__(self, value): - self._value = value - - def children(self): - v = self._value - t = v['type'] - yield 'type', ByteCode(t).to_string() # why does this not work? - v = v['u'] - t = int(t) - if t == ByteCode.PARAM: - yield 'reg', v['reg'] - elif t == ByteCode.RETINFO: - yield 'script', v['script'] - elif t in (ByteCode.STR, ByteCode.CONSTSTR): - yield 'str', v['str'] - else: - yield 'numi', v['numi'] - - def to_string(self): - return None + tests = [ + ('tmwa::script_data(tmwa::ScriptDataPos{42})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataPos) = {numi = 42}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataInt{123})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataInt) = {numi = 123}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataParam{tmwa::SIR()})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataParam) = {reg = {impl = 0}}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataStr{"Hello"_s})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataStr) = {str = "Hello"}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataArg{0})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataArg) = {numi = 0}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataVariable{tmwa::SIR()})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataVariable) = {reg = {impl = 0}}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataRetInfo{static_cast<const tmwa::ScriptBuffer *>(nullptr)})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataRetInfo) = {script = 0x0}}, <No data fields>}'), + ('tmwa::script_data(tmwa::ScriptDataFuncRef{404})', + '{<tmwa::sexpr::Variant<tmwa::ScriptDataPos, tmwa::ScriptDataInt, tmwa::ScriptDataParam, tmwa::ScriptDataStr, tmwa::ScriptDataArg, tmwa::ScriptDataVariable, tmwa::ScriptDataRetInfo, tmwa::ScriptDataFuncRef>> = {(tmwa::ScriptDataFuncRef) = {numi = 404}}, <No data fields>}'), + ] |