summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-04-11 15:40:35 -0300
committershennetsind <ind@henn.et>2013-04-11 15:40:35 -0300
commitd8f0ee4c476102066268e6376f6544b57dbf5b71 (patch)
tree41b56b235d7d1e375b663a689010048a0d1f1dc6 /src/map/script.c
parent39790db451bf767bea78e843a4663d9e2b05beaf (diff)
downloadhercules-d8f0ee4c476102066268e6376f6544b57dbf5b71.tar.gz
hercules-d8f0ee4c476102066268e6376f6544b57dbf5b71.tar.bz2
hercules-d8f0ee4c476102066268e6376f6544b57dbf5b71.tar.xz
hercules-d8f0ee4c476102066268e6376f6544b57dbf5b71.zip
Follow up 1a4d3fcf403745de60eb5d7648342cdfa1388af8
Improved Fix. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 4f98fff09..182b04f86 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17263,10 +17263,17 @@ BUILDIN_FUNC(getrandgroupitem) {
ShowError("getrandgroupitem: qty is <= 0!\n");
return 1;
}
- if( (nameid = itemdb_searchrandomid(group)) == UNKNOWN_ITEM_ID ) {
- return 1;/* itemdb_searchrandomid will already scream a error */
+
+ if(group < 1 || group >= MAX_ITEMGROUP) {
+ ShowError("getrandgroupitem: Invalid group id %d\n", group);
+ return 1;
+ }
+ if (!itemgroup_db[group].qty) {
+ ShowError("getrandgroupitem: group id %d is empty!\n", group);
+ return 1;
}
+ nameid = itemdb_searchrandomid(group);
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = nameid;