summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorHaruna <haru@dotalux.com>2015-01-01 18:06:10 +0100
committerHaruna <haru@dotalux.com>2015-01-01 18:06:10 +0100
commitff607f15ec14783aed8c0cf2749ac8cbe6d0e7db (patch)
treee121e6c1e25ff47a26090437c937b022d2bfebc6 /src/map/itemdb.c
parentdc6b470e4aaf252cb4f960b8b5585e51da821893 (diff)
parentf70d54001cd1b975db6f4668a6d54dbae7a8ac92 (diff)
downloadhercules-ff607f15ec14783aed8c0cf2749ac8cbe6d0e7db.tar.gz
hercules-ff607f15ec14783aed8c0cf2749ac8cbe6d0e7db.tar.bz2
hercules-ff607f15ec14783aed8c0cf2749ac8cbe6d0e7db.tar.xz
hercules-ff607f15ec14783aed8c0cf2749ac8cbe6d0e7db.zip
Merge pull request #425 from 4144/fixes
Different fixes after automatic checks
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 19cc02d21..8b6dfba63 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1427,7 +1427,7 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
entry->type = IT_ETC;
}
- if (entry->flag.trade_restriction < 0 || entry->flag.trade_restriction > ITR_ALL) {
+ if (entry->flag.trade_restriction > ITR_ALL) {
ShowWarning("itemdb_validate_entry: Invalid trade restriction flag 0x%x for item %d (%s) in '%s', defaulting to none.\n",
entry->flag.trade_restriction, entry->nameid, entry->jname, source);
entry->flag.trade_restriction = ITR_NONE;
@@ -2106,14 +2106,16 @@ void destroy_item_data(struct item_data* self, int free_self)
script->free_code(self->unequip_script);
if( self->combos )
aFree(self->combos);
- for (v = 0; v < self->hdatac; v++ ) {
- if (self->hdata[v]->flag.free ) {
- aFree(self->hdata[v]->data);
- }
- aFree(self->hdata[v]);
- }
if (self->hdata)
+ {
+ for (v = 0; v < self->hdatac; v++ ) {
+ if (self->hdata[v]->flag.free ) {
+ aFree(self->hdata[v]->data);
+ }
+ aFree(self->hdata[v]);
+ }
aFree(self->hdata);
+ }
#if defined(DEBUG)
// trash item
memset(self, 0xDD, sizeof(struct item_data));
@@ -2143,52 +2145,58 @@ void itemdb_clear(bool total) {
itemdb->destroy_item_data(itemdb->array[i], 1);
}
- for( i = 0; i < itemdb->group_count; i++ ) {
- if( itemdb->groups[i].nameid )
- aFree(itemdb->groups[i].nameid);
- }
-
if( itemdb->groups )
+ {
+ for( i = 0; i < itemdb->group_count; i++ ) {
+ if( itemdb->groups[i].nameid )
+ aFree(itemdb->groups[i].nameid);
+ }
aFree(itemdb->groups);
-
+ }
+
itemdb->groups = NULL;
itemdb->group_count = 0;
- for( i = 0; i < itemdb->chain_count; i++ ) {
- if( itemdb->chains[i].items )
- aFree(itemdb->chains[i].items);
- }
-
if( itemdb->chains )
+ {
+ for( i = 0; i < itemdb->chain_count; i++ ) {
+ if( itemdb->chains[i].items )
+ aFree(itemdb->chains[i].items);
+ }
aFree(itemdb->chains);
-
+ }
+
itemdb->chains = NULL;
itemdb->chain_count = 0;
- for( i = 0; i < itemdb->package_count; i++ ) {
- int c;
- for( c = 0; c < itemdb->packages[i].random_qty; c++ )
- aFree(itemdb->packages[i].random_groups[c].random_list);
- if( itemdb->packages[i].random_groups )
- aFree(itemdb->packages[i].random_groups);
- if( itemdb->packages[i].must_items )
- aFree(itemdb->packages[i].must_items);
- }
-
if( itemdb->packages )
+ {
+ for( i = 0; i < itemdb->package_count; i++ ) {
+ int c;
+ if (itemdb->packages[i].random_groups)
+ {
+ for( c = 0; c < itemdb->packages[i].random_qty; c++ )
+ aFree(itemdb->packages[i].random_groups[c].random_list);
+ aFree(itemdb->packages[i].random_groups);
+ }
+ if( itemdb->packages[i].must_items )
+ aFree(itemdb->packages[i].must_items);
+ }
aFree(itemdb->packages);
-
- itemdb->packages = NULL;
+ itemdb->packages = NULL;
+ }
itemdb->package_count = 0;
- for(i = 0; i < itemdb->combo_count; i++) {
- if( itemdb->combos[i]->script ) // Check if script was loaded
- script->free_code(itemdb->combos[i]->script);
- aFree(itemdb->combos[i]);
- }
if( itemdb->combos )
+ {
+ for(i = 0; i < itemdb->combo_count; i++) {
+ if( itemdb->combos[i]->script ) // Check if script was loaded
+ script->free_code(itemdb->combos[i]->script);
+ aFree(itemdb->combos[i]);
+ }
aFree(itemdb->combos);
-
+ }
+
itemdb->combos = NULL;
itemdb->combo_count = 0;