From 23e47caef30829c86c80036244732feeaa8d6700 Mon Sep 17 00:00:00 2001 From: gumi Date: Sat, 28 Jul 2018 15:04:35 -0400 Subject: fix getd not setting the type to C_NAME for new variables --- src/map/script.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3-60-g2f50