[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:
VladimirMangos 2010-11-19 23:43:06 +03:00
parent bbd34562a8
commit 2601022b9f
14 changed files with 173 additions and 110 deletions

View file

@ -318,7 +318,7 @@ void AuctionHouseMgr::LoadAuctionItems()
Item *item = NewItemOrBag(proto);
if(!item->LoadFromDB(item_guid,0, fields))
if(!item->LoadFromDB(item_guid, fields))
{
delete item;
continue;

View file

@ -69,8 +69,8 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
SetEntry(itemid);
SetObjectScale(DEFAULT_OBJECT_SCALE);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetObjectGuid() : ObjectGuid());
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetObjectGuid() : ObjectGuid());
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
@ -82,7 +82,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
// Cleaning 20 slots
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid());
m_bagslot[i] = NULL;
}
@ -94,15 +94,15 @@ void Bag::SaveToDB()
Item::SaveToDB();
}
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field *fields)
bool Bag::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
{
if(!Item::LoadFromDB(guid, owner_guid, fields))
if (!Item::LoadFromDB(guidLow, fields, ownerGuid))
return false;
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (int i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid());
if (m_bagslot[i])
{
delete m_bagslot[i];
@ -140,7 +140,7 @@ void Bag::RemoveItem( uint8 slot, bool /*update*/ )
m_bagslot[slot]->SetContainer(NULL);
m_bagslot[slot] = NULL;
SetUInt64Value( CONTAINER_FIELD_SLOT_1 + (slot * 2), 0 );
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot*2), ObjectGuid());
}
void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
@ -150,9 +150,9 @@ void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
if( pItem )
{
m_bagslot[slot] = pItem;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetOwnerGUID() );
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetObjectGuid());
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetObjectGuid());
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetOwnerGuid());
pItem->SetContainer(this);
pItem->SetSlot(slot);
}

View file

@ -57,7 +57,7 @@ class Bag : public Item
// overwrite virtual Item::SaveToDB
void SaveToDB();
// overwrite virtual Item::LoadFromDB
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field *fields);
bool LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid = ObjectGuid());
// overwrite virtual Item::DeleteFromDB
void DeleteFromDB();

View file

@ -1174,7 +1174,7 @@ void Guild::LoadGuildBankFromDB()
}
Item *pItem = NewItemOrBag(proto);
if (!pItem->LoadFromDB(ItemGuid, 0, fields))
if (!pItem->LoadFromDB(ItemGuid, fields))
{
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", m_Id, uint32(TabId), uint32(SlotId));
sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid);
@ -1705,8 +1705,8 @@ Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool
m_TabListMap[tab]->Slots[slot] = pItem;
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0);
pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid());
pItem->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid());
AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry());
pItem->FSetState(ITEM_NEW);
pItem->SaveToDB(); // not in inventory and can be save standalone

View file

@ -247,13 +247,13 @@ Item::Item( )
bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
{
Object::_Create( guidlow, 0, HIGHGUID_ITEM );
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
SetEntry(itemid);
SetObjectScale(DEFAULT_OBJECT_SCALE);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetObjectGuid() : ObjectGuid());
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetObjectGuid() : ObjectGuid());
ItemPrototype const *itemProto = ObjectMgr::GetItemPrototype(itemid);
if(!itemProto)
@ -299,7 +299,7 @@ void Item::SaveToDB()
CharacterDatabase.escape_string(text);
CharacterDatabase.PExecute( "DELETE FROM item_instance WHERE guid = '%u'", guid );
std::ostringstream ss;
ss << "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
ss << "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (" << guid << "," << GetOwnerGuid().GetCounter() << ",'";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', '" << text << "')";
@ -313,13 +313,13 @@ void Item::SaveToDB()
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID());
ss << "', owner_guid = '" << GetOwnerGuid().GetCounter();
ss << "', text = '" << text << "' WHERE guid = '" << guid << "'";
CharacterDatabase.Execute( ss.str().c_str() );
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()),GetGUIDLow());
CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GetOwnerGuid().GetCounter(), GetGUIDLow());
} break;
case ITEM_REMOVED:
{
@ -377,7 +377,7 @@ void Item::SaveToDB()
SetState(ITEM_UNCHANGED);
}
bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
bool Item::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
{
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
@ -435,9 +435,9 @@ bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
}
// set correct owner
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
if (!ownerGuid.IsEmpty() && GetOwnerGuid() != ownerGuid)
{
SetOwnerGUID(owner_guid);
SetOwnerGuid(ownerGuid);
need_save = true;
}
@ -461,7 +461,7 @@ bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guidLow << "'";
ss << "', owner_guid = '" << GetOwnerGuid().GetCounter() << "' WHERE guid = '" << guidLow << "'";
CharacterDatabase.Execute( ss.str().c_str() );
}
@ -490,7 +490,7 @@ void Item::LoadLootFromDB(Field *fields)
if(!proto)
{
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", ObjectGuid(GetOwnerGUID()).GetString().c_str(), item_id);
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id);
return;
}
@ -517,7 +517,7 @@ ItemPrototype const *Item::GetProto() const
Player* Item::GetOwner()const
{
return sObjectMgr.GetPlayer(GetOwnerGUID());
return sObjectMgr.GetPlayer(GetOwnerGuid());
}
uint32 Item::GetSkill()
@ -717,25 +717,29 @@ void Item::SetState(ItemUpdateState state, Player *forplayer)
void Item::AddToUpdateQueueOf(Player *player)
{
if (IsInUpdateQueue()) return;
if (IsInUpdateQueue())
return;
if (!player)
{
player = GetOwner();
if (!player)
{
sLog.outError("Item::AddToUpdateQueueOf - GetPlayer didn't find a player matching owner's guid (%u)!", GUID_LOPART(GetOwnerGUID()));
sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) not in world!",
GetObjectGuid().GetString().c_str(), GetOwnerGuid().GetString().c_str());
return;
}
}
if (player->GetGUID() != GetOwnerGUID())
if (player->GetObjectGuid() != GetOwnerGuid())
{
sLog.outError("Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!",
GetObjectGuid().GetString().c_str(), GetOwnerGuid().GetString().c_str(), player->GetObjectGuid().GetString().c_str());
return;
}
if (player->m_itemUpdateQueueBlocked) return;
if (player->m_itemUpdateQueueBlocked)
return;
player->m_itemUpdateQueue.push_back(this);
uQueuePos = player->m_itemUpdateQueue.size()-1;
@ -743,25 +747,29 @@ void Item::AddToUpdateQueueOf(Player *player)
void Item::RemoveFromUpdateQueueOf(Player *player)
{
if (!IsInUpdateQueue()) return;
if (!IsInUpdateQueue())
return;
if (!player)
{
player = GetOwner();
if (!player)
{
sLog.outError("Item::RemoveFromUpdateQueueOf - GetPlayer didn't find a player matching owner's guid (%u)!", GUID_LOPART(GetOwnerGUID()));
sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) not in world!",
GetObjectGuid().GetString().c_str(), GetOwnerGuid().GetString().c_str());
return;
}
}
if (player->GetGUID() != GetOwnerGUID())
if (player->GetObjectGuid() != GetOwnerGuid())
{
sLog.outError("Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!",
GetObjectGuid().GetString().c_str(), GetOwnerGuid().GetString().c_str(), player->GetObjectGuid().GetString().c_str());
return;
}
if (player->m_itemUpdateQueueBlocked) return;
if (player->m_itemUpdateQueueBlocked)
return;
player->m_itemUpdateQueue[uQueuePos] = NULL;
uQueuePos = -1;
@ -1051,11 +1059,11 @@ Item* Item::CloneItem( uint32 count, Player const* player ) const
bool Item::IsBindedNotWith( Player const* player ) const
{
// not binded item
if(!IsSoulBound())
if (!IsSoulBound())
return false;
// own item
if(GetOwnerGUID()== player->GetGUID())
if (GetOwnerGuid() == player->GetObjectGuid())
return false;
// has loot with diff owner
@ -1063,18 +1071,18 @@ bool Item::IsBindedNotWith( Player const* player ) const
return true;
// not BOA item case
if(!IsBoundAccountWide())
if (!IsBoundAccountWide())
return true;
// online
if(Player* owner = sObjectMgr.GetPlayer(GetOwnerGUID()))
if (Player* owner = GetOwner())
{
return owner->GetSession()->GetAccountId() != player->GetSession()->GetAccountId();
}
// offline slow case
else
{
return sObjectMgr.GetPlayerAccountIdByGUID(GetOwnerGUID()) != player->GetSession()->GetAccountId();
return sObjectMgr.GetPlayerAccountIdByGUID(GetOwnerGuid()) != player->GetSession()->GetAccountId();
}
}

View file

@ -282,8 +282,8 @@ class MANGOS_DLL_SPEC Item : public Object
ItemPrototype const* GetProto() const;
uint64 const& GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(ITEM_FIELD_OWNER); }
void SetOwnerGuid(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
Player* GetOwner()const;
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED,val); }
@ -292,7 +292,7 @@ class MANGOS_DLL_SPEC Item : public Object
bool IsBindedNotWith(Player const* player) const;
bool IsBoundByEnchant() const;
virtual void SaveToDB();
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field *fields);
virtual bool LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid = ObjectGuid());
virtual void DeleteFromDB();
void DeleteFromInventoryDB();
void LoadLootFromDB(Field *fields);

View file

@ -513,10 +513,10 @@ void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data )
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
Item *pItem = _player->GetItemByGuid( itemguid );
if( pItem )
if (pItem)
{
// prevent sell not owner item
if(_player->GetGUID() != pItem->GetOwnerGUID())
if (_player->GetObjectGuid() != pItem->GetOwnerGuid())
{
_player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0);
return;
@ -1189,7 +1189,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
}
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", item->GetOwnerGuid().GetCounter(), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
item->SetEntry(gift->GetEntry());
switch (item->GetEntry())

View file

@ -1683,7 +1683,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
// prepare static data
uint64 sourceGUID = source->GetGUID();
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
///- Schedule script execution for all scripts in the script map
ScriptMap const *s2 = &(s->second);
@ -1693,7 +1693,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
ScriptAction sa;
sa.sourceGUID = sourceGUID;
sa.targetGUID = targetGUID;
sa.ownerGUID = ownerGUID;
sa.ownerGUID = ownerGuid.GetRawValue();
sa.script = &iter->second;
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + iter->first), sa));
@ -1714,12 +1714,12 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
// prepare static data
uint64 sourceGUID = source->GetGUID();
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
ScriptAction sa;
sa.sourceGUID = sourceGUID;
sa.targetGUID = targetGUID;
sa.ownerGUID = ownerGUID;
sa.ownerGUID = ownerGuid.GetRawValue();
sa.script = &script;
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + delay), sa));

View file

@ -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);

View file

@ -5741,7 +5741,7 @@ bool Spell::IgnoreItemRequirements() const
{
/// Not own traded item (in trader trade slot) req. reagents including triggered spell case
if (Item* targetItem = m_targets.getItemTarget())
if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
if (targetItem->GetOwnerGuid() != m_caster->GetObjectGuid())
return false;
return true;
@ -6032,7 +6032,7 @@ SpellCastResult Spell::CheckItems()
return SPELL_FAILED_CANT_BE_DISENCHANTED;
// prevent disenchanting in trade slot
if( m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID() )
if( m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid() )
return SPELL_FAILED_CANT_BE_DISENCHANTED;
ItemPrototype const* itemProto = m_targets.getItemTarget()->GetProto();
@ -6057,7 +6057,7 @@ SpellCastResult Spell::CheckItems()
if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_FLAG_PROSPECTABLE))
return SPELL_FAILED_CANT_BE_PROSPECTED;
// prevent prospecting in trade slot
if (m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID())
if (m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid())
return SPELL_FAILED_CANT_BE_PROSPECTED;
// Check for enough skill in jewelcrafting
uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank;
@ -6080,7 +6080,7 @@ SpellCastResult Spell::CheckItems()
if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_FLAG_MILLABLE))
return SPELL_FAILED_CANT_BE_MILLED;
// prevent milling in trade slot
if (m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID())
if (m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid())
return SPELL_FAILED_CANT_BE_MILLED;
// Check for enough skill in inscription
uint32 item_millingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank;

View file

@ -3897,7 +3897,7 @@ void Spell::EffectSummonChangeItem(SpellEffectIndex eff_idx)
return;
// ... only to item in own inventory/bank/equip_slot
if (m_CastItem->GetOwnerGUID()!=player->GetGUID())
if (m_CastItem->GetOwnerGuid() != player->GetObjectGuid())
return;
uint32 newitemid = m_spellInfo->EffectItemType[eff_idx];

View file

@ -216,7 +216,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item **m
{
if (Item* item = myTrade->GetItem(TradeSlots(i)))
{
DEBUG_LOG("player trade item %s bag: %u slot: %u", item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot());
DEBUG_LOG("player trade %s bag: %u slot: %u", item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot());
//Can return NULL
myItems[i] = item;
myItems[i]->SetInTrade();
@ -224,7 +224,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item **m
if (Item* item = hisTrade->GetItem(TradeSlots(i)))
{
DEBUG_LOG("partner trade item %s bag: %u slot: %u", item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot());
DEBUG_LOG("partner trade %s bag: %u slot: %u", item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot());
hisItems[i] = item;
hisItems[i]->SetInTrade();
}

View file

@ -353,17 +353,37 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (!*args)
return false;
std::string state_str = args;
ItemUpdateState state = ITEM_UNCHANGED;
bool list_queue = false, check_all = false;
if (state_str == "unchanged") state = ITEM_UNCHANGED;
else if (state_str == "changed") state = ITEM_CHANGED;
else if (state_str == "new") state = ITEM_NEW;
else if (state_str == "removed") state = ITEM_REMOVED;
else if (state_str == "queue") list_queue = true;
else if (state_str == "check_all") check_all = true;
else return false;
std::string state_str;
if (strncmp(args, "unchanged", strlen(args)) == 0)
{
state = ITEM_UNCHANGED;
state_str = "unchanged";
}
else if (strncmp(args, "changed", strlen(args)) == 0)
{
state = ITEM_CHANGED;
state_str = "changed";
}
else if (strncmp(args, "new", strlen(args)) == 0)
{
state = ITEM_NEW;
state_str = "new";
}
else if (strncmp(args, "removed", strlen(args)) == 0)
{
state = ITEM_REMOVED;
state_str = "removed";
}
else if (strncmp(args, "queue", strlen(args)) == 0)
list_queue = true;
else if (strncmp(args, "all", strlen(args)) == 0)
check_all = true;
else
return false;
Player* player = getSelectedPlayer();
if (!player) player = m_session->GetPlayer();
@ -382,7 +402,8 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (!item->IsBag())
{
if (item->GetState() == state)
PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()));
PSendSysMessage("%s bag: 255 slot: %u owner: %s",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(), item->GetOwnerGuid().GetString().c_str());
}
else
{
@ -391,7 +412,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
{
Item* item2 = bag->GetItemByPos(j);
if (item2 && item2->GetState() == state)
PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()));
PSendSysMessage("%s bag: %u slot: %u owner: %s",
item2->GetObjectGuid().GetString().c_str(), item2->GetBagSlot(), item2->GetSlot(),
item2->GetOwnerGuid().GetString().c_str());
}
}
}
@ -417,7 +440,8 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
case ITEM_REMOVED: st = "removed"; break;
}
PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
PSendSysMessage("%s bag: %u slot: %u - state: %s",
item->GetObjectGuid().GetString().c_str(), bag_slot, item->GetSlot(), st.c_str());
}
if (updateQueue.empty())
PSendSysMessage("updatequeue empty");
@ -437,19 +461,24 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (item->GetSlot() != i)
{
PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
PSendSysMessage("%s at slot %u has an incorrect slot value: %d",
item->GetObjectGuid().GetString().c_str(), i, item->GetSlot());
error = true; continue;
}
if (item->GetOwnerGUID() != player->GetGUID())
if (item->GetOwnerGuid() != player->GetObjectGuid())
{
PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
PSendSysMessage("%s at slot %u owner (%s) and inventory owner (%s) don't match!",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(),
item->GetOwnerGuid().GetString().c_str(), player->GetObjectGuid().GetString().c_str());
error = true; continue;
}
if (Bag *container = item->GetContainer())
{
PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
PSendSysMessage("%s at slot %u has a container %s from slot %u but shouldnt!",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(),
container->GetObjectGuid().GetString().c_str(), container->GetSlot());
error = true; continue;
}
@ -458,25 +487,30 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
uint16 qp = item->GetQueuePos();
if (qp > updateQueue.size())
{
PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp);
PSendSysMessage("%s at slot %u has a queuepos (%d) larger than the update queue size! ",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(), qp);
error = true; continue;
}
if (updateQueue[qp] == NULL)
{
PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp);
PSendSysMessage("%s at slot %u has a queuepos (%d) that points to NULL in the queue!",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(), qp);
error = true; continue;
}
if (updateQueue[qp] != item)
{
PSendSysMessage("item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
PSendSysMessage("%s at slot %u has a queuepos (%d) that points to %s in the queue (bag %u, slot %u)",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(), qp,
updateQueue[qp]->GetObjectGuid().GetString().c_str(), updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot());
error = true; continue;
}
}
else if (item->GetState() != ITEM_UNCHANGED)
{
PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState());
PSendSysMessage("%s at slot %u is not in queue but should be (state: %d)!",
item->GetObjectGuid().GetString().c_str(), item->GetSlot(), item->GetState());
error = true; continue;
}
@ -490,26 +524,32 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (item2->GetSlot() != j)
{
PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot());
PSendSysMessage("%s in bag %u at slot %u has an incorrect slot value: %u",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), j, item2->GetSlot());
error = true; continue;
}
if (item2->GetOwnerGUID() != player->GetGUID())
if (item2->GetOwnerGuid() != player->GetGUID())
{
PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow());
PSendSysMessage("%s in bag %u at slot %u owner (%s) and inventory owner (%s) don't match!",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(),
item2->GetOwnerGuid().GetString().c_str(), player->GetObjectGuid().GetString().c_str());
error = true; continue;
}
Bag *container = item2->GetContainer();
if (!container)
{
PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow());
PSendSysMessage("%s in bag %u at slot %u has no container!",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot());
error = true; continue;
}
if (container != bag)
{
PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
PSendSysMessage("%s in bag %u at slot %u has a different container %s from slot %u!",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(),
container->GetObjectGuid().GetString().c_str(), container->GetSlot());
error = true; continue;
}
@ -518,25 +558,30 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
uint16 qp = item2->GetQueuePos();
if (qp > updateQueue.size())
{
PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
PSendSysMessage("%s in bag %u at slot %u has a queuepos (%d) larger than the update queue size! ",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(), qp);
error = true; continue;
}
if (updateQueue[qp] == NULL)
{
PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
PSendSysMessage("%s in bag %u at slot %u has a queuepos (%d) that points to NULL in the queue!",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(), qp);
error = true; continue;
}
if (updateQueue[qp] != item2)
{
PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
PSendSysMessage("%s in bag %u at slot %u has a queuepos (%d) that points to %s in the queue (bag %u slot %u)",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(), qp,
updateQueue[qp]->GetObjectGuid().GetString().c_str(), updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot());
error = true; continue;
}
}
else if (item2->GetState() != ITEM_UNCHANGED)
{
PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState());
PSendSysMessage("%s in bag %u at slot %u is not in queue but should be (state: %d)!",
item2->GetObjectGuid().GetString().c_str(), bag->GetSlot(), item2->GetSlot(), item2->GetState());
error = true; continue;
}
}
@ -548,15 +593,18 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
Item *item = updateQueue[i];
if(!item) continue;
if (item->GetOwnerGUID() != player->GetGUID())
if (item->GetOwnerGuid() != player->GetObjectGuid())
{
PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
PSendSysMessage("queue(" SIZEFMTD "): %s has the owner (%s) and inventory owner (%s) don't match!",
i, item->GetObjectGuid().GetString().c_str(),
item->GetOwnerGuid().GetString().c_str(), player->GetObjectGuid().GetString().c_str());
error = true; continue;
}
if (item->GetQueuePos() != i)
{
PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow());
PSendSysMessage("queue(" SIZEFMTD "): %s has queuepos doesn't match it's position in the queue!",
i, item->GetObjectGuid().GetString().c_str());
error = true; continue;
}
@ -565,13 +613,16 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (test == NULL)
{
PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow());
PSendSysMessage("queue(" SIZEFMTD "): %s has incorrect (bag %u slot %u) values, the player doesn't have an item at that position!",
i, item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot());
error = true; continue;
}
if (test != item)
{
PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow());
PSendSysMessage("queue(" SIZEFMTD "): %s has incorrect (bag %u slot %u) values, the %s is there instead!",
i, item->GetObjectGuid().GetString().c_str(), item->GetBagSlot(), item->GetSlot(),
test->GetObjectGuid().GetString().c_str());
error = true; continue;
}
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10750"
#define REVISION_NR "10751"
#endif // __REVISION_NR_H__