summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-29 00:12:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-29 00:12:30 +0300
commit28fce75298ef95d380e5c9206a26145561933664 (patch)
treeb0cc922d4b810b13fcfba9c5592a0ae629d8c6fa /src
parent9598d5c5079f8d3d4e0b9f78580ba8b763b4498d (diff)
downloadplugin-28fce75298ef95d380e5c9206a26145561933664.tar.gz
plugin-28fce75298ef95d380e5c9206a26145561933664.tar.bz2
plugin-28fce75298ef95d380e5c9206a26145561933664.tar.xz
plugin-28fce75298ef95d380e5c9206a26145561933664.zip
Change script function requestitemindex to return value.
Diffstat (limited to 'src')
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script.c29
2 files changed, 6 insertions, 25 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index 73d7928..33405b0 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -99,7 +99,7 @@ HPExport void plugin_init (void)
addScriptCommand("requestlang", "", requestLang);
addScriptCommand("requestitem", "", requestItem);
addScriptCommand("requestitems", "*", requestItems);
- addScriptCommand("requestitemindex", "v", requestItemIndex);
+ addScriptCommand("requestitemindex", "", requestItemIndex);
addScriptCommand("requestitemsindex", "v*", requestItemsIndex);
addScriptCommand("requestcraft", "*", requestCraft);
addScriptCommand("initcraft", "s", initCraft);
diff --git a/src/emap/script.c b/src/emap/script.c
index 2f853ca..8d5cb44 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -723,28 +723,7 @@ BUILDIN(requestItems)
BUILDIN(requestItemIndex)
{
- 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))
- {
- ShowError("script:requestitemindex: not a variable\n");
- script->reportsrc(st);
- return false;
- }
+ getSessionDataReturn(client, -1);
if (!sd->state.menu_or_input)
{
@@ -763,10 +742,11 @@ BUILDIN(requestItemIndex)
// take received text/value and store it in the designated variable
sd->state.menu_or_input = 0;
- int item = 0;
+ int item = -1;
if (!sd->npc_str)
{
+ script_pushint(st, -1);
ShowWarning("npc string not found\n");
script->reportsrc(st);
return false;
@@ -774,12 +754,13 @@ BUILDIN(requestItemIndex)
if (sscanf (sd->npc_str, "%5d", &item) < 1)
{
+ script_pushint(st, -1);
ShowWarning("input data is not item id\n");
script->reportsrc(st);
return false;
}
- script->set_reg(st, sd, uid, name, (void*)h64BPTRSIZE(item), script_getref(st,2));
+ script_pushint(st, item);
st->state = RUN;
}
return true;