diff options
author | Ibrahim Hossam <ibrahem.h.basyone@gmail.com> | 2014-08-20 04:53:47 +0300 |
---|---|---|
committer | Ibrahim Hossam <ibrahem.h.basyone@gmail.com> | 2014-08-20 05:07:10 +0300 |
commit | 49d60479ac8a7ad2a9e51a9c2afd699f3fac8069 (patch) | |
tree | d41ee79d43cbe232f4141831a7f94977ee9ec8d8 | |
parent | d1e9675419e79f5015ba4666ec525b2954cb374d (diff) | |
download | hercules-49d60479ac8a7ad2a9e51a9c2afd699f3fac8069.tar.gz hercules-49d60479ac8a7ad2a9e51a9c2afd699f3fac8069.tar.bz2 hercules-49d60479ac8a7ad2a9e51a9c2afd699f3fac8069.tar.xz hercules-49d60479ac8a7ad2a9e51a9c2afd699f3fac8069.zip |
Extended item_check to also add unique_ids to any non-stackable items that lack it
- This is useful in case an old server that didn't have the unique_id feature enabled is updated to the latest version.
- It'll only have effect if item_check is enabled in the configuration files.
-rw-r--r-- | src/map/pc.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 29fb7b2b7..7c49730c9 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9148,28 +9148,50 @@ int pc_checkitem(struct map_session_data *sd) for( i = 0; i < MAX_INVENTORY; i++ ) { id = sd->status.inventory[i].nameid; - if( id && !itemdb_available(id) ) { + if (!id) + continue; + + if( !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).\n", id, sd->status.inventory[i].amount, sd->status.char_id); pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); + continue; } + + if ( !sd->status.inventory[i].unique_id && !itemdb->isstackable(id) ) + sd->status.inventory[i].unique_id = itemdb->unique_id(sd); } for( i = 0; i < MAX_CART; i++ ) { id = sd->status.cart[i].nameid; - if( id && !itemdb_available(id) ) { + if (!id) + continue; + + if( !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from cart (amount=%d, char_id=%d).\n", id, sd->status.cart[i].amount, sd->status.char_id); pc->cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER); + continue; } + + if ( !sd->status.cart[i].unique_id && !itemdb->isstackable(id) ) + sd->status.cart[i].unique_id = itemdb->unique_id(sd); } for( i = 0; i < MAX_STORAGE; i++ ) { id = sd->status.storage.items[i].nameid; + + if (!id) + continue; + if( id && !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from storage (amount=%d, char_id=%d).\n", id, sd->status.storage.items[i].amount, sd->status.char_id); storage->delitem(sd, i, sd->status.storage.items[i].amount); - storage->close(sd); // force closing + storage->close(sd); + continue; } + + if ( !sd->status.storage.items[i].unique_id && !itemdb->isstackable(id) ) + sd->status.storage.items[i].unique_id = itemdb->unique_id(sd); } if (sd->guild) { @@ -9177,11 +9199,19 @@ int pc_checkitem(struct map_session_data *sd) if (guild_storage) { for( i = 0; i < MAX_GUILD_STORAGE; i++ ) { id = guild_storage->items[i].nameid; - if( id && !itemdb_available(id) ) { + + if (!id) + continue; + + if( !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from guild storage (amount=%d, char_id=%d, guild_id=%d).\n", id, guild_storage->items[i].amount, sd->status.char_id, sd->guild->guild_id); gstorage->delitem(sd, guild_storage, i, guild_storage->items[i].amount); gstorage->close(sd); // force closing + continue; } + + if (!guild_storage->items[i].unique_id && !itemdb->isstackable(id)) + guild_storage->items[i].unique_id = itemdb->unique_id(sd); } } } |