summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-07-29 20:45:20 +0200
committerGitHub <noreply@github.com>2018-07-29 20:45:20 +0200
commitf1daa094ff2d95b3c6a5c079d636156ea994c2bc (patch)
tree35e9b4530a00949dffb2873fb175a23c2c325d36 /src
parentf3c05e7622cc9fda10f45a92eba47df255b369b2 (diff)
parent23e47caef30829c86c80036244732feeaa8d6700 (diff)
downloadhercules-f1daa094ff2d95b3c6a5c079d636156ea994c2bc.tar.gz
hercules-f1daa094ff2d95b3c6a5c079d636156ea994c2bc.tar.bz2
hercules-f1daa094ff2d95b3c6a5c079d636156ea994c2bc.tar.xz
hercules-f1daa094ff2d95b3c6a5c079d636156ea994c2bc.zip
Merge pull request #2158 from mekolat/getd
fix getd not setting the type to C_NAME for new variables
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/map/script.c b/src/map/script.c
index e38aae562..01c4f148b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17784,14 +17784,26 @@ static BUILDIN(getd)
char varname[100];
const char *buffer;
int elem;
+ int id;
buffer = script_getstr(st, 2);
if (sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
elem = 0;
+ id = script->search_str(varname);
+
+ if (id < 0) {
+ id = script->add_str(varname);
+ script->str_data[id].type = C_NAME;
+ } else if (script->str_data[id].type != C_NAME) {
+ ShowError("script:getd: `%s` is already used by something that is not a variable.\n", varname);
+ st->state = END;
+ return false;
+ }
+
// Push the 'pointer' so it's more flexible [Lance]
- script->push_val(st->stack, C_NAME, reference_uid(script->add_str(varname), elem),NULL);
+ script->push_val(st->stack, C_NAME, reference_uid(id, elem),NULL);
return true;
}