summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-07-28 15:04:35 -0400
committergumi <git@gumi.ca>2018-07-28 16:19:17 -0400
commit23e47caef30829c86c80036244732feeaa8d6700 (patch)
tree9166db81ad2e70bdfa4e62726c898a01daedc0c0
parentb30f62468a5e923bf5d9533adec064ada1716459 (diff)
downloadhercules-23e47caef30829c86c80036244732feeaa8d6700.tar.gz
hercules-23e47caef30829c86c80036244732feeaa8d6700.tar.bz2
hercules-23e47caef30829c86c80036244732feeaa8d6700.tar.xz
hercules-23e47caef30829c86c80036244732feeaa8d6700.zip
fix getd not setting the type to C_NAME for new variables
-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;
}