mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[10751] Use objectguids in item code.
Also * Fixed unexpected container updated state after inventory load * Make .debug getitemstate command more friendly by args.
This commit is contained in:
parent
bbd34562a8
commit
2601022b9f
14 changed files with 173 additions and 110 deletions
|
|
@ -4252,7 +4252,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
|||
}
|
||||
|
||||
Item *pItem = NewItemOrBag(itemProto);
|
||||
if (!pItem->LoadFromDB(item_guidlow, playerguid.GetRawValue(), fields2))
|
||||
if (!pItem->LoadFromDB(item_guidlow, fields2, playerguid))
|
||||
{
|
||||
pItem->FSetState(ITEM_REMOVED);
|
||||
pItem->SaveToDB(); // it also deletes item object !
|
||||
|
|
@ -10932,9 +10932,9 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
|
|||
if (bag == INVENTORY_SLOT_BAG_0)
|
||||
{
|
||||
m_items[slot] = pItem;
|
||||
SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() );
|
||||
pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() );
|
||||
pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() );
|
||||
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetObjectGuid());
|
||||
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetObjectGuid());
|
||||
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetObjectGuid());
|
||||
|
||||
pItem->SetSlot( slot );
|
||||
pItem->SetContainer( NULL );
|
||||
|
|
@ -10991,7 +10991,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
|
|||
RemoveEnchantmentDurations(pItem);
|
||||
RemoveItemDurations(pItem);
|
||||
|
||||
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
|
||||
pItem->SetOwnerGuid(GetObjectGuid()); // prevent error at next SetState in case trade/mail/buy from vendor
|
||||
pItem->SetState(ITEM_REMOVED, this);
|
||||
}
|
||||
|
||||
|
|
@ -11101,7 +11101,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
|
|||
RemoveEnchantmentDurations(pItem);
|
||||
RemoveItemDurations(pItem);
|
||||
|
||||
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
|
||||
pItem->SetOwnerGuid(GetObjectGuid()); // prevent error at next SetState in case trade/mail/buy from vendor
|
||||
pItem->SetState(ITEM_REMOVED, this);
|
||||
pItem2->SetState(ITEM_CHANGED, this);
|
||||
|
||||
|
|
@ -11171,9 +11171,9 @@ void Player::VisualizeItem( uint8 slot, Item *pItem)
|
|||
DEBUG_LOG( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry());
|
||||
|
||||
m_items[slot] = pItem;
|
||||
SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID() );
|
||||
pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() );
|
||||
pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() );
|
||||
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetObjectGuid());
|
||||
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetObjectGuid());
|
||||
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetObjectGuid());
|
||||
pItem->SetSlot( slot );
|
||||
pItem->SetContainer( NULL );
|
||||
|
||||
|
|
@ -11260,8 +11260,8 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
|
|||
if( pBag )
|
||||
pBag->RemoveItem(slot, update);
|
||||
}
|
||||
pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 );
|
||||
// pItem->SetUInt64Value( ITEM_FIELD_OWNER, 0 ); not clear owner at remove (it will be set at store). This used in mail and auction code
|
||||
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid());
|
||||
// pItem->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid()); not clear owner at remove (it will be set at store). This used in mail and auction code
|
||||
pItem->SetSlot( NULL_SLOT );
|
||||
if( IsInWorld() && update )
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
|
|
@ -11298,8 +11298,8 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool
|
|||
if(pLastItem == pItem)
|
||||
{
|
||||
// update owner for last item (this can be original item with wrong owner
|
||||
if(pLastItem->GetOwnerGUID() != GetGUID())
|
||||
pLastItem->SetOwnerGUID(GetGUID());
|
||||
if(pLastItem->GetOwnerGuid() != GetObjectGuid())
|
||||
pLastItem->SetOwnerGuid(GetObjectGuid());
|
||||
|
||||
// if this original item then it need create record in inventory
|
||||
// in case trade we already have item in other player inventory
|
||||
|
|
@ -11381,7 +11381,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
|
|||
}
|
||||
|
||||
//pItem->SetOwnerGUID(0);
|
||||
pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 );
|
||||
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid());
|
||||
pItem->SetSlot( NULL_SLOT );
|
||||
pItem->SetState(ITEM_REMOVED, this);
|
||||
}
|
||||
|
|
@ -15927,7 +15927,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
|
||||
Item *item = NewItemOrBag(proto);
|
||||
|
||||
if(!item->LoadFromDB(item_guid, GetGUID(), fields))
|
||||
if(!item->LoadFromDB(item_guid, fields, GetObjectGuid()))
|
||||
{
|
||||
sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id );
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
|
||||
|
|
@ -16017,6 +16017,10 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
{
|
||||
item->SetState(ITEM_UNCHANGED, this);
|
||||
|
||||
// restore container unchanged state also
|
||||
if (item->GetContainer())
|
||||
item->GetContainer()->SetState(ITEM_UNCHANGED, this);
|
||||
|
||||
// recharged mana gem
|
||||
if (timediff > 15*MINUTE && proto->ItemLimitCategory ==ITEM_LIMIT_CATEGORY_MANA_GEM)
|
||||
item->RestoreCharges();
|
||||
|
|
@ -16117,7 +16121,7 @@ void Player::_LoadMailedItems(QueryResult *result)
|
|||
|
||||
Item *item = NewItemOrBag(proto);
|
||||
|
||||
if(!item->LoadFromDB(item_guid_low, 0, fields))
|
||||
if(!item->LoadFromDB(item_guid_low, fields))
|
||||
{
|
||||
sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
|
||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue