mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11470] Final cleanup uint64 guid cases
Also drop logout player update fields cleanup that in any cases not saved.
This commit is contained in:
parent
a2b6a6fde5
commit
719e298795
26 changed files with 144 additions and 153 deletions
|
|
@ -11394,7 +11394,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
|
|||
UpdateKnownCurrencies(pItem->GetEntry(), false);
|
||||
|
||||
m_items[slot] = NULL;
|
||||
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
|
||||
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid());
|
||||
|
||||
if ( slot < EQUIPMENT_SLOT_END )
|
||||
{
|
||||
|
|
@ -11486,7 +11486,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
|
|||
|
||||
if( bag == INVENTORY_SLOT_BAG_0 )
|
||||
{
|
||||
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
|
||||
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid());
|
||||
|
||||
// equipment and equipped bags can have applied bonuses
|
||||
if ( slot < INVENTORY_SLOT_BAG_END )
|
||||
|
|
@ -12231,9 +12231,9 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del )
|
|||
m_items[slot] = NULL;
|
||||
|
||||
uint32 eslot = slot - BUYBACK_SLOT_START;
|
||||
SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0 );
|
||||
SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 );
|
||||
SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 );
|
||||
SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid());
|
||||
SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
|
||||
SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
|
||||
|
||||
// if current backslot is filled set to now free slot
|
||||
if (m_items[m_currentBuybackSlot])
|
||||
|
|
@ -15372,7 +15372,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
|
||||
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
{
|
||||
SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0 );
|
||||
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid());
|
||||
SetVisibleItemSlot(slot, NULL);
|
||||
|
||||
if (m_items[slot])
|
||||
|
|
@ -15960,7 +15960,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
ObjectGuid caster_guid = fields[0].GetUInt64();
|
||||
ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64());
|
||||
uint32 item_lowguid = fields[1].GetUInt32();
|
||||
uint32 spellid = fields[2].GetUInt32();
|
||||
uint32 stackcount = fields[3].GetUInt32();
|
||||
|
|
@ -16112,7 +16112,7 @@ void Player::LoadCorpse()
|
|||
void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT data,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow());
|
||||
std::map<uint64, Bag*> bagMap; // fast guid lookup for bags
|
||||
std::map<uint32, Bag*> bagMap; // fast guid lookup for bags
|
||||
//NOTE: the "order by `bag`" is important because it makes sure
|
||||
//the bagMap is filled before items in the bags are loaded
|
||||
//NOTE2: the "order by `slot`" is needed because mainhand weapons are (wrongly?)
|
||||
|
|
@ -16131,34 +16131,34 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
Field *fields = result->Fetch();
|
||||
uint32 bag_guid = fields[2].GetUInt32();
|
||||
uint8 slot = fields[3].GetUInt8();
|
||||
uint32 item_guid = fields[4].GetUInt32();
|
||||
uint32 item_lowguid = fields[4].GetUInt32();
|
||||
uint32 item_id = fields[5].GetUInt32();
|
||||
|
||||
ItemPrototype const * proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
|
||||
if(!proto)
|
||||
if (!proto)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid);
|
||||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_lowguid);
|
||||
sLog.outError( "Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id );
|
||||
continue;
|
||||
}
|
||||
|
||||
Item *item = NewItemOrBag(proto);
|
||||
|
||||
if(!item->LoadFromDB(item_guid, fields, GetObjectGuid()))
|
||||
if (!item->LoadFromDB(item_lowguid, 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);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid);
|
||||
item->FSetState(ITEM_REMOVED);
|
||||
item->SaveToDB(); // it also deletes item object !
|
||||
continue;
|
||||
}
|
||||
|
||||
// not allow have in alive state item limited to another map/zone
|
||||
if(isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone) )
|
||||
if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone))
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid);
|
||||
item->FSetState(ITEM_REMOVED);
|
||||
item->SaveToDB(); // it also deletes item object !
|
||||
continue;
|
||||
|
|
@ -16167,7 +16167,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
// "Conjured items disappear if you are logged out for more than 15 minutes"
|
||||
if (timediff > 15*MINUTE && (item->GetProto()->Flags & ITEM_FLAG_CONJURED))
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid);
|
||||
item->FSetState(ITEM_REMOVED);
|
||||
item->SaveToDB(); // it also deletes item object !
|
||||
continue;
|
||||
|
|
@ -16181,36 +16181,36 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
item->SetContainer( NULL );
|
||||
item->SetSlot(slot);
|
||||
|
||||
if( IsInventoryPos( INVENTORY_SLOT_BAG_0, slot ) )
|
||||
if (IsInventoryPos( INVENTORY_SLOT_BAG_0, slot))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if( CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false ) == EQUIP_ERR_OK )
|
||||
if (CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false) == EQUIP_ERR_OK)
|
||||
item = StoreItem(dest, item, true);
|
||||
else
|
||||
success = false;
|
||||
}
|
||||
else if( IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot ) )
|
||||
else if (IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot))
|
||||
{
|
||||
uint16 dest;
|
||||
if( CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK )
|
||||
if (CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK)
|
||||
QuickEquipItem(dest, item);
|
||||
else
|
||||
success = false;
|
||||
}
|
||||
else if( IsBankPos( INVENTORY_SLOT_BAG_0, slot ) )
|
||||
else if (IsBankPos( INVENTORY_SLOT_BAG_0, slot))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if( CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK )
|
||||
if (CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK)
|
||||
item = BankItem(dest, item, true);
|
||||
else
|
||||
success = false;
|
||||
}
|
||||
|
||||
if(success)
|
||||
if (success)
|
||||
{
|
||||
// store bags that may contain items in them
|
||||
if(item->IsBag() && IsBagPos(item->GetPos()))
|
||||
bagMap[item_guid] = (Bag*)item;
|
||||
if (item->IsBag() && IsBagPos(item->GetPos()))
|
||||
bagMap[item_lowguid] = (Bag*)item;
|
||||
}
|
||||
}
|
||||
// the item/bag in a bag
|
||||
|
|
@ -16218,11 +16218,11 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
{
|
||||
item->SetSlot(NULL_SLOT);
|
||||
// the item is in a bag, find the bag
|
||||
std::map<uint64, Bag*>::const_iterator itr = bagMap.find(bag_guid);
|
||||
if(itr != bagMap.end() && slot < itr->second->GetBagSize())
|
||||
std::map<uint32, Bag*>::const_iterator itr = bagMap.find(bag_guid);
|
||||
if (itr != bagMap.end() && slot < itr->second->GetBagSize())
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if( CanStoreItem( itr->second->GetSlot(), slot, dest, item, false ) == EQUIP_ERR_OK )
|
||||
if (CanStoreItem(itr->second->GetSlot(), slot, dest, item, false) == EQUIP_ERR_OK)
|
||||
item = StoreItem(dest, item, true);
|
||||
else
|
||||
success = false;
|
||||
|
|
@ -16246,8 +16246,8 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
}
|
||||
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);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
|
||||
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_lowguid, item_id, bag_guid, slot);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid);
|
||||
problematicItems.push_back(item);
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue