summaryrefslogtreecommitdiff
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
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>
-rw-r--r--src/map/itemdb.c2
-rw-r--r--src/map/itemdb.h2
-rw-r--r--src/map/script.c11
3 files changed, 11 insertions, 4 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 2b7d27c8a..22ac031ee 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -20,8 +20,6 @@
static struct item_data* itemdb_array[MAX_ITEMDB];
static DBMap* itemdb_other;// int nameid -> struct item_data*
-static struct item_group itemgroup_db[MAX_ITEMGROUP];
-
struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex]
/**
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 06c95da8a..4c8847705 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -155,6 +155,8 @@ struct item_combo {
bool isRef;/* whether this struct is a reference or the master */
};
+struct item_group itemgroup_db[MAX_ITEMGROUP];
+
struct item_data* itemdb_searchname(const char *name);
int itemdb_searchname_array(struct item_data** data, int size, const char *str);
struct item_data* itemdb_load(int nameid);
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;