diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-24 21:02:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-24 21:02:25 +0300 |
commit | 78816fc57d05c56b4cbf2f920b5679051e593197 (patch) | |
tree | 7f3f440bbc68831ceb57e7f97291fdcd2cdc734c /src/emap/script.c | |
parent | 0537167c95056c57e926d4207c3f614b8382a797 (diff) | |
download | plugin-78816fc57d05c56b4cbf2f920b5679051e593197.tar.gz plugin-78816fc57d05c56b4cbf2f920b5679051e593197.tar.bz2 plugin-78816fc57d05c56b4cbf2f920b5679051e593197.tar.xz plugin-78816fc57d05c56b4cbf2f920b5679051e593197.zip |
Add support for cards in script funciton getitemlink.
Example: getitemlink(1301, 5002)
Diffstat (limited to 'src/emap/script.c')
-rw-r--r-- | src/emap/script.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/src/emap/script.c b/src/emap/script.c index bc8c7b2..26a0246 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -530,24 +530,27 @@ BUILDIN(shop) return true; } +#define paramToItem(param) \ + if (script_isstringtype(st, param)) \ + { \ + i_data = itemdb->search_name (script_getstr(st, param)); \ + } \ + else \ + { \ + item_id = script_getnum (st, param); \ + if (item_id) \ + i_data = itemdb->search (item_id); \ + } + BUILDIN(getItemLink) { struct item_data *i_data = NULL; char *item_name; int item_id = 0; - if (script_isstringtype(st, 2)) - { - i_data = itemdb->search_name (script_getstr(st, 2)); - } - else - { - item_id = script_getnum (st, 2); - if (item_id) - i_data = itemdb->search (item_id); - } + paramToItem(2); - item_name = (char *) aCalloc (100, sizeof (char)); + item_name = (char *) aCalloc (1000, sizeof (char)); TBL_PC *sd = script->rid2sd(st); if (sd) @@ -558,13 +561,40 @@ BUILDIN(getItemLink) version = data->clientVersion; if (i_data && version >= 7) - sprintf(item_name, "[@@%u|@@]", (unsigned)i_data->nameid); + { + if (!script_hasdata(st, 3)) + { + sprintf(item_name, "[@@%u|@@]", (unsigned)i_data->nameid); + } + else + { + sprintf(item_name, "[@@%u", (unsigned)i_data->nameid); + int f; + for (f = 3; f < 7 && script_hasdata(st, f); f ++) + { + paramToItem(f); + if (i_data) + { + char buf[100]; + sprintf(buf, ",%u", (unsigned)i_data->nameid); + strcat(item_name, buf); + } + } + strcat(item_name, "|@@]"); + } + } else if (i_data) + { sprintf(item_name, "[@@%u|%s@@]", (unsigned)i_data->nameid, lang_pctrans (i_data->jname, sd)); + } else if (item_id > 0) + { sprintf(item_name, "[@@%u|Unknown Item@@]", (unsigned)item_id); + } else + { sprintf(item_name, "[Unknown Item]"); + } } else { @@ -579,6 +609,8 @@ BUILDIN(getItemLink) return true; } +#undef paramToItem + BUILDIN(requestLang) { getSD(); |