diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-29 00:20:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-29 00:20:54 +0300 |
commit | 3d76d08ce39ea9f4d4d4e0f015eec74ec6653cd3 (patch) | |
tree | b34f85e2caac7ebc7ba7d92796e1d8de13e1228f /src/emap | |
parent | 28fce75298ef95d380e5c9206a26145561933664 (diff) | |
download | plugin-3d76d08ce39ea9f4d4d4e0f015eec74ec6653cd3.tar.gz plugin-3d76d08ce39ea9f4d4d4e0f015eec74ec6653cd3.tar.bz2 plugin-3d76d08ce39ea9f4d4d4e0f015eec74ec6653cd3.tar.xz plugin-3d76d08ce39ea9f4d4d4e0f015eec74ec6653cd3.zip |
Change script function requestitemsindex to return value.
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/init.c | 2 | ||||
-rw-r--r-- | src/emap/script.c | 31 | ||||
-rw-r--r-- | src/emap/scriptdefines.h | 18 |
3 files changed, 24 insertions, 27 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 33405b0..47c823d 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -100,7 +100,7 @@ HPExport void plugin_init (void) addScriptCommand("requestitem", "", requestItem); addScriptCommand("requestitems", "*", requestItems); addScriptCommand("requestitemindex", "", requestItemIndex); - addScriptCommand("requestitemsindex", "v*", requestItemsIndex); + addScriptCommand("requestitemsindex", "*", requestItemsIndex); addScriptCommand("requestcraft", "*", requestCraft); addScriptCommand("initcraft", "s", initCraft); addScriptCommand("dumpcraft", "i", dumpCraft); diff --git a/src/emap/script.c b/src/emap/script.c index 8d5cb44..d2281d6 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -768,34 +768,12 @@ BUILDIN(requestItemIndex) BUILDIN(requestItemsIndex) { - getSessionData(client); - struct script_data* data; - int64 uid; - const char* name; - - data = script_getdata(st, 2); - if (!data_isreference(data)) - { - ShowError("script:requestitem: not a variable\n"); - script->reportsrc(st); - st->state = END; - return false; - } - uid = reference_getuid(data); - name = reference_getname(data); - - if (!is_string_variable(name)) - { - ShowWarning("parameter is not variable\n"); - script->reportsrc(st); - return false; - } - + getSessionDataReturnS(client, "-1"); int count = 1; - if (script_hasdata(st, 3)) + if (script_hasdata(st, 2)) { - count = script_getnum(st, 3); + count = script_getnum(st, 2); if (count < 0) count = 1; } @@ -819,12 +797,13 @@ BUILDIN(requestItemsIndex) if (!sd->npc_str) { + script_pushstr(st, aStrdup("-1")); ShowWarning("npc string not found\n"); script->reportsrc(st); return false; } - script->set_reg(st, sd, uid, name, (void*)sd->npc_str, script_getref(st, 2)); + script_pushstr(st, aStrdup(sd->npc_str)); st->state = RUN; } return true; diff --git a/src/emap/scriptdefines.h b/src/emap/scriptdefines.h index 5d462f4..274f8f4 100644 --- a/src/emap/scriptdefines.h +++ b/src/emap/scriptdefines.h @@ -22,6 +22,24 @@ } \ struct SessionExt *data = session_get(sd->fd) +#define getSessionDataReturnS(data, def) \ + if (!st->rid) \ + { \ + ShowWarning("!st->rid\n"); \ + script->reportsrc(st); \ + script_pushstr(st, aStrdup(def)); \ + return false; \ + } \ + TBL_PC *sd = script->rid2sd(st); \ + if (!sd) \ + { \ + ShowWarning("player not attached\n"); \ + script->reportsrc(st); \ + script_pushstr(st, aStrdup(def)); \ + return false; \ + } \ + struct SessionExt *data = session_get(sd->fd) + #define getSessionData(data) \ if (!st->rid) \ { \ |