diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/itemdb.c | 2 | ||||
-rw-r--r-- | src/map/itemdb.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 11 |
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; |