diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-09-01 15:01:01 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-04-15 11:46:35 -0400 |
commit | f3dd34b5172f2bcb4f79d472e4c8ba2dbfe9cce0 (patch) | |
tree | 68e4507bc2aa8e66d4770876a45276b617028f6b /src | |
parent | cf6f557700db4f88050674468a70a38f93441e98 (diff) | |
download | tmwa-f3dd34b5172f2bcb4f79d472e4c8ba2dbfe9cce0.tar.gz tmwa-f3dd34b5172f2bcb4f79d472e4c8ba2dbfe9cce0.tar.bz2 tmwa-f3dd34b5172f2bcb4f79d472e4c8ba2dbfe9cce0.tar.xz tmwa-f3dd34b5172f2bcb4f79d472e4c8ba2dbfe9cce0.zip |
convert unhandled types for scope vars
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script-call-internal.hpp | 2 | ||||
-rw-r--r-- | src/map/script-call.cpp | 10 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 10 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/map/script-call-internal.hpp b/src/map/script-call-internal.hpp index b3dfb5a..da6c082 100644 --- a/src/map/script-call-internal.hpp +++ b/src/map/script-call-internal.hpp @@ -83,7 +83,7 @@ void get_val(dumb_ptr<block_list> sd, struct script_data *data); __attribute__((deprecated)) void get_val(ScriptState *st, struct script_data *data); struct script_data get_val2(ScriptState *st, SIR reg); -void set_scope_reg(ScriptState *, SIR, struct script_data); +void set_scope_reg(ScriptState *, SIR, struct script_data *); void set_reg(dumb_ptr<block_list> sd, VariableCode type, SIR reg, struct script_data vd); void set_reg(dumb_ptr<block_list> sd, VariableCode type, SIR reg, int id); void set_reg(dumb_ptr<block_list> sd, VariableCode type, SIR reg, RString zd); diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index b397fb4..0164c2a 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -270,12 +270,12 @@ void set_reg(dumb_ptr<block_list> sd, VariableCode type, SIR reg, struct script_ } } -void set_scope_reg(ScriptState *st, SIR reg, struct script_data vd) +void set_scope_reg(ScriptState *st, SIR reg, struct script_data *vd) { ZString name = variable_names.outtern(reg.base()); if (name.back() == '$') { - if (auto *u = vd.get_if<ScriptDataStr>()) + if (auto *u = vd->get_if<ScriptDataStr>()) { if (!u->str) { @@ -285,10 +285,12 @@ void set_scope_reg(ScriptState *st, SIR reg, struct script_data vd) st->regstrm.insert(reg, u->str); } else - st->regstrm.erase(reg); + st->regstrm.insert(reg, conv_str(st, vd)); } - else if (auto *u = vd.get_if<ScriptDataInt>()) + else if (auto *u = vd->get_if<ScriptDataInt>()) st->regm.put(reg, u->numi); + else + st->regm.put(reg, conv_num(st, vd)); } void set_reg(dumb_ptr<block_list> sd, VariableCode type, SIR reg, int id) diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 75df30f..7e55565 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -1059,7 +1059,7 @@ void builtin_set(ScriptState *st) { if (name_[1] == '@') { - set_scope_reg(st, reg, AARG(1)); + set_scope_reg(st, reg, &AARG(1)); return; } bl = map_id2bl(st->oid)->is_npc(); @@ -1106,13 +1106,13 @@ void builtin_setarray(ScriptState *st) } if (prefix == '.' && name[1] != '@') bl = map_id2bl(st->oid)->is_npc(); - else if (prefix != '$') + else if (prefix != '$' && !(prefix == '.' && name[1] == '@')) bl = map_id2bl(st->rid)->is_player(); for (int j = 0, i = 1; i < st->end - st->start - 2 && j < 256; i++, j++) { if (prefix == '.' && name[1] == '@') - set_scope_reg(st, reg.iplus(j), AARG(i)); + set_scope_reg(st, reg.iplus(j), &AARG(i)); else if (postfix == '$') set_reg(bl, VariableCode::VARIABLE, reg.iplus(j), conv_str(st, &AARG(i))); else @@ -1141,13 +1141,13 @@ void builtin_cleararray(ScriptState *st) } if (prefix == '.' && name[1] != '@') bl = map_id2bl(st->oid)->is_npc(); - else if (prefix != '$') + else if (prefix != '$' && !(prefix == '.' && name[1] == '@')) bl = map_id2bl(st->rid)->is_player(); for (int i = 0; i < sz; i++) { if (prefix == '.' && name[1] == '@') - set_scope_reg(st, reg.iplus(i), AARG(i)); + set_scope_reg(st, reg.iplus(i), &AARG(i)); else if (postfix == '$') set_reg(bl, VariableCode::VARIABLE, reg.iplus(i), conv_str(st, &AARG(1))); else |