diff options
author | Asheraf <acheraf1998@gmail.com> | 2018-09-21 13:20:29 +0100 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-09-23 03:17:25 +0100 |
commit | a2f18fad8e066fce131a9481bdf822d88eb91abf (patch) | |
tree | d1047031d99dc4b6ed45e13ec809160f4eec931a /src/map/script.c | |
parent | 41ca3c7cc304cac90ae4df32217bd3237e035773 (diff) | |
download | hercules-a2f18fad8e066fce131a9481bdf822d88eb91abf.tar.gz hercules-a2f18fad8e066fce131a9481bdf822d88eb91abf.tar.bz2 hercules-a2f18fad8e066fce131a9481bdf822d88eb91abf.tar.xz hercules-a2f18fad8e066fce131a9481bdf822d88eb91abf.zip |
Add support for item amount range in setquestinfo
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/map/script.c b/src/map/script.c index 65ffc1a6d..31930c2dc 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21114,17 +21114,26 @@ static BUILDIN(setquestinfo) } case QINFO_ITEM: { - struct item item = { 0 }; + struct questinfo_itemreq item = { 0 }; item.nameid = script_getnum(st, 3); - item.amount = script_getnum(st, 4); + item.min = script_hasdata(st, 4) ? script_getnum(st, 4) : 0; + item.max = script_hasdata(st, 5) ? script_getnum(st, 5) : 0; if (itemdb->exists(item.nameid) == NULL) { ShowWarning("buildin_setquestinfo: non existing item (%d) have been given.\n", item.nameid); return false; } - if (item.amount <= 0 || item.amount > MAX_AMOUNT) { - ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than 0 and smaller than %d.\n", item.amount, MAX_AMOUNT + 1); + if (item.min > item.max) { + ShowWarning("buildin_setquestinfo: minimal amount (%d) is bigger than the maximal amount (%d).\n", item.min, item.max); + return false; + } + if (item.min < 0 || item.min > MAX_AMOUNT) { + ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than or equal to 0 and smaller than %d.\n", item.min, MAX_AMOUNT + 1); + return false; + } + if (item.max < 0 || item.max > MAX_AMOUNT) { + ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than or equal to 0 and smaller than %d.\n", item.max, MAX_AMOUNT + 1); return false; } if (VECTOR_LENGTH(qi->items) == 0) @@ -25447,7 +25456,7 @@ static void script_parse_builtin(void) //Quest Log System [Inkfish] BUILDIN_DEF(questinfo, "i?"), - BUILDIN_DEF(setquestinfo, "i??"), + BUILDIN_DEF(setquestinfo, "i???"), BUILDIN_DEF(setquest, "i?"), BUILDIN_DEF(erasequest, "i?"), BUILDIN_DEF(completequest, "i?"), |