feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -62,7 +62,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
uint8 bagIndex, slot, castFlags;
uint8 castCount; // next cast if exists (single or not)
uint64 itemGUID;
ObjectGuid itemGUID;
uint32 glyphIndex; // something to do with glyphs?
uint32 spellId; // casted spell id
@@ -208,8 +208,8 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
if (!(proto->Flags & ITEM_FLAG_HAS_LOOT) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, nullptr);
LOG_ERROR("server", "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
pUser->GetName().c_str(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId);
LOG_ERROR("server", "Possible hacking attempt: Player %s [%s] tried to open item [%s, entry: %u] which is not openable!",
pUser->GetName().c_str(), pUser->GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), proto->ItemId);
return;
}
@@ -222,7 +222,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
if (!lockInfo)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, nullptr);
LOG_ERROR("server", "WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", item->GetGUIDLow(), lockId);
LOG_ERROR("server", "WORLD::OpenItem: item [%s] has an unknown lockId: %u!", item->GetGUID().ToString().c_str(), lockId);
return;
}
@@ -238,18 +238,18 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUID().GetCounter());
_openWrappedItemCallback.SetFirstParam(bagIndex);
_openWrappedItemCallback.SetSecondParam(slot);
_openWrappedItemCallback.SetThirdParam(item->GetGUIDLow());
_openWrappedItemCallback.SetThirdParam(item->GetGUID().GetCounter());
_openWrappedItemCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt));
}
else
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
}
void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, uint32 itemLowGUID)
void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, ObjectGuid::LowType itemLowGUID)
{
if (!GetPlayer())
return;
@@ -258,12 +258,12 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
if (!item)
return;
if (item->GetGUIDLow() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) // during getting result, gift was swapped with another item
if (item->GetGUID().GetCounter() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) // during getting result, gift was swapped with another item
return;
if (!result)
{
LOG_ERROR("server", "Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUIDLow());
LOG_ERROR("server", "Wrapped item %s don't have record in character_gifts table and will deleted", item->GetGUID().ToString().c_str());
GetPlayer()->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
return;
}
@@ -274,7 +274,7 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
uint32 entry = fields[0].GetUInt32();
uint32 flags = fields[1].GetUInt32();
item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Empty);
item->SetEntry(entry);
item->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
item->SetUInt32Value(ITEM_FIELD_MAXDURABILITY, item->GetTemplate()->MaxDurability);
@@ -283,7 +283,7 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
GetPlayer()->SaveInventoryAndGoldToDB(trans);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUID().GetCounter());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
@@ -291,11 +291,11 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
recvData >> guid;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid));
LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_USE Message [%s]", guid.ToString().c_str());
#endif
if (GameObject* obj = GetPlayer()->GetMap()->GetGameObject(guid))
@@ -314,11 +314,11 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData)
void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
{
uint64 guid;
ObjectGuid guid;
recvPacket >> guid;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [in game guid: %u]", GUID_LOPART(guid));
LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [%s]", guid.ToString().c_str());
#endif
// ignore for remote control state
@@ -450,7 +450,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
spellInfo = actualSpellInfo;
}
Spell* spell = new Spell(mover, spellInfo, TRIGGERED_NONE, 0, false);
Spell* spell = new Spell(mover, spellInfo, TRIGGERED_NONE, ObjectGuid::Empty, false);
sScriptMgr->ValidateSpellAtCastSpellResult(_player, mover, spell, oldSpellId, spellId);
@@ -493,12 +493,12 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
}
// maybe should only remove one buff when there are multiple?
_player->RemoveOwnedAura(spellId, 0, 0, AURA_REMOVE_BY_CANCEL);
_player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
}
void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
{
uint64 guid;
ObjectGuid guid;
uint32 spellId;
recvPacket >> guid;
@@ -515,13 +515,13 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
if (!pet)
{
LOG_ERROR("server", "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str());
LOG_ERROR("server", "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %s by player %s", guid.ToString().c_str(), GetPlayer()->GetName().c_str());
return;
}
if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm())
{
LOG_ERROR("server", "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str());
LOG_ERROR("server", "HandlePetCancelAura: Pet %s is not a pet of player %s", guid.ToString().c_str(), GetPlayer()->GetName().c_str());
return;
}
@@ -531,7 +531,7 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
return;
}
pet->RemoveOwnedAura(spellId, 0, 0, AURA_REMOVE_BY_CANCEL);
pet->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
pet->AddSpellCooldown(spellId, 0, 0);
}
@@ -606,7 +606,7 @@ void WorldSession::HandleSelfResOpcode(WorldPacket& /*recvData*/)
void WorldSession::HandleSpellClick(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
recvData >> guid;
// this will get something not in world. crash
@@ -627,11 +627,11 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: CMSG_GET_MIRRORIMAGE_DATA");
#endif
uint64 guid;
ObjectGuid guid;
recvData >> guid;
// Get unit for which data is needed by client
Unit* unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)nullptr);
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
if (!unit)
return;
@@ -644,7 +644,7 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
return;
WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
data << uint64(guid);
data << guid;
data << uint32(creator->GetDisplayId());
data << uint8(creator->getRace());
data << uint8(creator->getGender());
@@ -723,7 +723,7 @@ void WorldSession::HandleUpdateProjectilePosition(WorldPacket& recvPacket)
LOG_DEBUG("network", "WORLD: CMSG_UPDATE_PROJECTILE_POSITION");
#endif
uint64 casterGuid;
ObjectGuid casterGuid;
uint32 spellId;
uint8 castCount;
float x, y, z; // Position of missile hit
@@ -748,7 +748,7 @@ void WorldSession::HandleUpdateProjectilePosition(WorldPacket& recvPacket)
spell->m_targets.ModDst(pos);
WorldPacket data(SMSG_SET_PROJECTILE_POSITION, 21);
data << uint64(casterGuid);
data << casterGuid;
data << uint8(castCount);
data << float(x);
data << float(y);