From b71f15256feed9aeadee06b712464594be9addbf Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 1 Oct 2018 21:26:04 -0400 Subject: allow buildin_getd to work with constants and params this is highly discouraged, but it should still work --- src/map/script.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/map/script.c b/src/map/script.c index b787d0138..191b32195 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -17870,7 +17870,9 @@ static BUILDIN(getd) id = script->add_variable(varname); - if (script->str_data[id].type != C_NAME) { + if (script->str_data[id].type != C_NAME && // variable + script->str_data[id].type != C_PARAM && // param + script->str_data[id].type != C_INT) { // constant ShowError("script:getd: `%s` is already used by something that is not a variable.\n", varname); st->state = END; return false; -- cgit v1.2.3-70-g09d2 From 55f666602680b10ab0a3966de96d50c088e58865 Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 1 Oct 2018 21:57:34 -0400 Subject: add more unit tests for getd --- npc/dev/test.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/npc/dev/test.txt b/npc/dev/test.txt index bdbc52ed4..c2f07ab2f 100644 --- a/npc/dev/test.txt +++ b/npc/dev/test.txt @@ -651,6 +651,12 @@ function script HerculesSelfTestHelper { setd(".@x", getd(".@y")); callsub(OnCheck, "setd getd", .@x, .@y); + // getd types + callsub(OnCheck, "Getdatatype (getd: param)", getdatatype(getd("Hp")), DATATYPE_INT | DATATYPE_PARAM); + callsub(OnCheck, "Getdatatype (getd: const)", getdatatype(getd("DATATYPE_CONST")), DATATYPE_INT | DATATYPE_CONST); + callsub(OnCheck, "Getdatatype (getd: numeric var)", getdatatype(getd(".@foo")), DATATYPE_INT | DATATYPE_VAR); + callsub(OnCheck, "Getdatatype (getd: string var)", getdatatype(getd(".@foo$")), DATATYPE_STR | DATATYPE_VAR); + // getvariableofnpc .x = 2; set getvariableofnpc(.x, "TestVarOfAnotherNPC"), 1; -- cgit v1.2.3-70-g09d2