summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-10-07 18:27:58 +0200
committerGitHub <noreply@github.com>2018-10-07 18:27:58 +0200
commit71205691cb441e398355944cdad992b6b60053ba (patch)
tree41b209c2ec38393c7e3f965d8fe5ab2f57f92889
parentc0543f29c2f85fdcfa431063ea785a389d140199 (diff)
parent55f666602680b10ab0a3966de96d50c088e58865 (diff)
downloadhercules-71205691cb441e398355944cdad992b6b60053ba.tar.gz
hercules-71205691cb441e398355944cdad992b6b60053ba.tar.bz2
hercules-71205691cb441e398355944cdad992b6b60053ba.tar.xz
hercules-71205691cb441e398355944cdad992b6b60053ba.zip
Merge pull request #2240 from Helianthella/getd-const
allow buildin_getd to work with constants and params
-rw-r--r--npc/dev/test.txt6
-rw-r--r--src/map/script.c4
2 files changed, 9 insertions, 1 deletions
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;
diff --git a/src/map/script.c b/src/map/script.c
index be608830f..421def5f9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17847,7 +17847,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;