[9508] Finish impement new functionlity for item 5513 and similar.

* Implement recharge low rank item in inventory.
* Implement recharge item at loading after 15 offline mins
This commit is contained in:
VladimirMangos 2010-03-03 07:32:00 +03:00
parent 4c4629e861
commit 84e5f7520b
8 changed files with 80 additions and 10 deletions

View file

@ -8642,6 +8642,26 @@ Item* Player::GetItemByEntry( uint32 item ) const
return NULL;
}
Item* Player::GetItemByLimitedCategory(uint32 limitedCategory) const
{
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem->GetProto()->ItemLimitCategory == limitedCategory)
return pItem;
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem->GetProto()->ItemLimitCategory == limitedCategory)
return pItem;
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i))
if (Item* itemPtr = pBag->GetItemByLimitedCategory(limitedCategory))
return itemPtr;
return NULL;
}
Item* Player::GetItemByGuid( uint64 guid ) const
{
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
@ -15523,7 +15543,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
}
// "Conjured items disappear if you are logged out for more than 15 minutes"
if ((timediff > 15*60) && (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED)))
if (timediff > 15*MINUTE && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED))
{
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
item->FSetState(ITEM_REMOVED);
@ -15591,7 +15611,13 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
// item's state may have changed after stored
if (success)
{
item->SetState(ITEM_UNCHANGED, this);
// recharged mana gem
if (timediff > 15*MINUTE && proto->ItemLimitCategory ==ITEM_LIMIT_CATEGORY_MANA_GEM)
item->RestoreCharges();
}
else
{
sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_guid, item_id, bag_guid, slot);