diff options
author | Haru <haru@dotalux.com> | 2018-11-13 17:16:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 17:16:11 +0100 |
commit | 1e5df06b8a23ea13c3fc1b07339c261a77600bae (patch) | |
tree | 1d6811001638da46108a3e74601e9ff980090f85 /src | |
parent | d564cdaabdb9f1929e58cd68c1208f89100acf90 (diff) | |
parent | 7b45d05bd8e3f476f1d801203f2968993b52a31f (diff) | |
download | hercules-1e5df06b8a23ea13c3fc1b07339c261a77600bae.tar.gz hercules-1e5df06b8a23ea13c3fc1b07339c261a77600bae.tar.bz2 hercules-1e5df06b8a23ea13c3fc1b07339c261a77600bae.tar.xz hercules-1e5df06b8a23ea13c3fc1b07339c261a77600bae.zip |
Merge pull request #2289 from EyesOfAHawk/buildin_getnpcid
Remove type argument from buildin_getnpcid.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/map/script.c b/src/map/script.c index fc1ece663..8c09bb8d8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8698,32 +8698,23 @@ static BUILDIN(getcharid) return true; } + /*========================================== * returns the GID of an NPC *------------------------------------------*/ static BUILDIN(getnpcid) { - int num = script_getnum(st,2); - struct npc_data* nd = NULL; - - if( script_hasdata(st,3) ) - {// unique npc name - if( ( nd = npc->name2id(script_getstr(st,3)) ) == NULL ) - { - ShowError("buildin_getnpcid: No such NPC '%s'.\n", script_getstr(st,3)); - script_pushint(st,0); - return false; + if (script_hasdata(st, 2)) { + if (script_isinttype(st, 2)) { + // Deprecate old form - getnpcid(<type>{, <"npc name">}) + ShowWarning("buildin_getnpcid: Use of type is deprecated. Format - getnpcid({<\"npc name\">})\n"); + script_pushint(st, 0); + } else { + struct npc_data *nd = npc->name2id(script_getstr(st, 2)); + script_pushint(st, (nd != NULL) ? nd->bl.id : 0); } - } - - switch (num) { - case 0: - script_pushint(st,nd ? nd->bl.id : st->oid); - break; - default: - ShowError("buildin_getnpcid: invalid parameter (%d).\n", num); - script_pushint(st,0); - return false; + } else { + script_pushint(st, st->oid); } return true; @@ -25016,7 +25007,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(readparam,"i?"), BUILDIN_DEF(setparam,"ii?"), BUILDIN_DEF(getcharid,"i?"), - BUILDIN_DEF(getnpcid,"i?"), + BUILDIN_DEF(getnpcid, "?"), BUILDIN_DEF(getpartyname,"i"), BUILDIN_DEF(getpartymember,"i?"), BUILDIN_DEF(getpartyleader,"i?"), |