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

@@ -39,14 +39,14 @@ enum StableResultCode
void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
recvData >> guid;
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER);
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: HandleTabardVendorActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -58,7 +58,7 @@ void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recvData)
SendTabardVendorActivate(guid);
}
void WorldSession::SendTabardVendorActivate(uint64 guid)
void WorldSession::SendTabardVendorActivate(ObjectGuid guid)
{
WorldPacket data(MSG_TABARDVENDOR_ACTIVATE, 8);
data << guid;
@@ -67,7 +67,7 @@ void WorldSession::SendTabardVendorActivate(uint64 guid)
void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Received CMSG_BANKER_ACTIVATE");
@@ -79,7 +79,7 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: HandleBankerActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -91,7 +91,7 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData)
SendShowBank(guid);
}
void WorldSession::SendShowBank(uint64 guid)
void WorldSession::SendShowBank(ObjectGuid guid)
{
WorldPacket data(SMSG_SHOW_BANK, 8);
data << guid;
@@ -99,7 +99,7 @@ void WorldSession::SendShowBank(uint64 guid)
SendPacket(&data);
}
void WorldSession::SendShowMailBox(uint64 guid)
void WorldSession::SendShowMailBox(ObjectGuid guid)
{
WorldPacket data(SMSG_SHOW_MAILBOX, 8);
data << guid;
@@ -108,19 +108,19 @@ void WorldSession::SendShowMailBox(uint64 guid)
void WorldSession::HandleTrainerListOpcode(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
recvData >> guid;
SendTrainerList(guid);
}
void WorldSession::SendTrainerList(uint64 guid)
void WorldSession::SendTrainerList(ObjectGuid guid)
{
std::string str = GetAcoreString(LANG_NPC_TAINER_HELLO);
SendTrainerList(guid, str);
}
void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: SendTrainerList");
@@ -130,7 +130,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: SendTrainerList - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: SendTrainerList - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -144,7 +144,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
if (!ci)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: SendTrainerList - (GUID: %u) NO CREATUREINFO!", GUID_LOPART(guid));
LOG_DEBUG("network", "WORLD: SendTrainerList - (%s) NO CREATUREINFO!", guid.ToString().c_str());
#endif
return;
}
@@ -153,7 +153,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
if (!trainer_spells)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)", GUID_LOPART(guid), unit->GetEntry());
LOG_DEBUG("network", "WORLD: SendTrainerList - Training spells not found for creature (%s)", guid.ToString().c_str());
#endif
return;
}
@@ -243,19 +243,19 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData)
{
uint64 guid;
ObjectGuid guid;
uint32 spellId = 0;
recvData >> guid >> spellId;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u", uint32(GUID_LOPART(guid)), spellId);
LOG_DEBUG("network", "WORLD: Received CMSG_TRAINER_BUY_SPELL Npc %s, learn spell id is: %u", guid.ToString().c_str(), spellId);
#endif
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: HandleTrainerBuySpellOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -297,7 +297,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData)
_player->learnSpell(spellId);
WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, 12);
data << uint64(guid);
data << guid;
data << uint32(spellId); // should be same as in packet from client
SendPacket(&data);
}
@@ -308,14 +308,14 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData)
LOG_DEBUG("network", "WORLD: Received CMSG_GOSSIP_HELLO");
#endif
uint64 guid;
ObjectGuid guid;
recvData >> guid;
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: HandleGossipHelloOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -373,7 +373,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData)
uint32 option;
uint32 unk;
uint64 guid;
ObjectGuid guid;
std::string code = "";
recvData >> guid >> unk >> option;
@@ -393,7 +393,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network.opcode", "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network.opcode", "WORLD: HandleGossipSelectOptionOpcode - Unit (%s) not found or you can't interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -420,7 +420,7 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData)
LOG_DEBUG("network", "WORLD: CMSG_SPIRIT_HEALER_ACTIVATE");
#endif
uint64 guid;
ObjectGuid guid;
recvData >> guid;
@@ -428,7 +428,7 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
LOG_DEBUG("network", "WORLD: HandleSpiritHealerActivateOpcode - Unit (%s) not found or you can not interact with him.", guid.ToString().c_str());
#endif
return;
}
@@ -448,9 +448,12 @@ void WorldSession::SendSpiritResurrect()
// get corpse nearest graveyard
GraveyardStruct const* corpseGrave = nullptr;
Corpse* corpse = _player->GetCorpse();
if (corpse)
corpseGrave = sGraveyard->GetClosestGraveyard(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeamId());
WorldLocation corpseLocation = _player->GetCorpseLocation();
if (_player->HasCorpse())
{
corpseGrave = sGraveyard->GetClosestGraveyard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(),
corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeamId());
}
// now can spawn bones
_player->SpawnCorpseBones();
@@ -473,7 +476,7 @@ void WorldSession::SendSpiritResurrect()
void WorldSession::HandleBinderActivateOpcode(WorldPacket& recvData)
{
uint64 npcGUID;
ObjectGuid npcGUID;
recvData >> npcGUID;
if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive())
@@ -483,7 +486,7 @@ void WorldSession::HandleBinderActivateOpcode(WorldPacket& recvData)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleBinderActivateOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
LOG_DEBUG("network", "WORLD: HandleBinderActivateOpcode - Unit (%s) not found or you can not interact with him.", npcGUID.ToString().c_str());
#endif
return;
}
@@ -507,7 +510,7 @@ void WorldSession::SendBindPoint(Creature* npc)
npc->CastSpell(_player, bindspell, true);
WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8 + 4));
data << uint64(npc->GetGUID());
data << npc->GetGUID();
data << uint32(bindspell);
SendPacket(&data);
@@ -519,7 +522,7 @@ void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recv MSG_LIST_STABLED_PETS");
#endif
uint64 npcGUID;
ObjectGuid npcGUID;
recvData >> npcGUID;
@@ -537,11 +540,11 @@ void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recvData)
SendStablePet(npcGUID);
}
void WorldSession::SendStablePet(uint64 guid)
void WorldSession::SendStablePet(ObjectGuid guid)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS_DETAIL);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT);
@@ -549,7 +552,7 @@ void WorldSession::SendStablePet(uint64 guid)
_sendStabledPetCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt));
}
void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid)
void WorldSession::SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid)
{
if (!GetPlayer())
return;
@@ -560,7 +563,7 @@ void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid
WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size
data << uint64 (guid);
data << guid;
Pet* pet = _player->GetPet();
@@ -584,7 +587,7 @@ void WorldSession::SendStablePetCallback(PreparedQueryResult result, uint64 guid
else if (_player->IsPetDismissed() || _player->GetTemporaryUnsummonedPetNumber())
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT));
if (PreparedQueryResult _result = CharacterDatabase.AsyncQuery(stmt))
@@ -632,7 +635,7 @@ void WorldSession::HandleStablePet(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_PET");
#endif
uint64 npcGUID;
ObjectGuid npcGUID;
recvData >> npcGUID;
@@ -675,7 +678,7 @@ void WorldSession::HandleStablePet(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT);
@@ -720,7 +723,7 @@ void WorldSession::HandleStablePetCallback(PreparedQueryResult result)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT);
stmt->setUInt8(0, freeSlot);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(1, _player->GetGUID().GetCounter());
stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT));
trans->Append(stmt);
@@ -739,7 +742,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recv CMSG_UNSTABLE_PET.");
#endif
uint64 npcGUID;
ObjectGuid npcGUID;
uint32 petnumber;
recvData >> npcGUID >> petnumber;
@@ -756,7 +759,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_ENTRY);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt32(1, petnumber);
stmt->setUInt8(2, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(3, PET_SAVE_LAST_STABLE_SLOT);
@@ -822,7 +825,7 @@ void WorldSession::HandleUnstablePetCallback(PreparedQueryResult result, uint32
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT);
stmt->setUInt8(0, slot);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(1, _player->GetGUID().GetCounter());
stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT));
trans->Append(stmt);
@@ -842,7 +845,7 @@ void WorldSession::HandleBuyStableSlot(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recv CMSG_BUY_STABLE_SLOT.");
#endif
uint64 npcGUID;
ObjectGuid npcGUID;
recvData >> npcGUID;
@@ -884,7 +887,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_SWAP_PET.");
#endif
uint64 npcGUID;
ObjectGuid npcGUID;
uint32 petId;
recvData >> npcGUID >> petId;
@@ -923,7 +926,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData)
// Find swapped pet slot in stable
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOT_BY_ID);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt32(1, petId);
_stableSwapCallback.SetParam(petId);
@@ -975,7 +978,7 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT);
stmt->setUInt8(0, slot);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(1, _player->GetGUID().GetCounter());
stmt->setUInt8(2, uint8(_player->GetTemporaryUnsummonedPetNumber() ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT));
trans->Append(stmt);
@@ -998,7 +1001,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData)
LOG_DEBUG("network", "WORLD: CMSG_REPAIR_ITEM");
#endif
uint64 npcGUID, itemGUID;
ObjectGuid npcGUID, itemGUID;
uint8 guildBank; // new in 2.3.2, bool that means from guild bank money
recvData >> npcGUID >> itemGUID >> guildBank;
@@ -1007,7 +1010,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData)
if (!unit)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: HandleRepairItemOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
LOG_DEBUG("network", "WORLD: HandleRepairItemOpcode - Unit (%s) not found or you can not interact with him.", npcGUID.ToString().c_str());
#endif
return;
}
@@ -1024,7 +1027,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData)
if (itemGUID)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "ITEM: Repair item, itemGUID = %u, npcGUID = %u", GUID_LOPART(itemGUID), GUID_LOPART(npcGUID));
LOG_DEBUG("network", "ITEM: Repair item, item %s, npc %s", itemGUID.ToString().c_str(), npcGUID.ToString().c_str());
#endif
Item* item = _player->GetItemByGuid(itemGUID);
@@ -1034,7 +1037,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData)
else
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "ITEM: Repair all items, npcGUID = %u", GUID_LOPART(npcGUID));
LOG_DEBUG("network", "ITEM: Repair all items, npc %s", npcGUID.ToString().c_str());
#endif
_player->DurabilityRepairAll(true, discountMod, guildBank);
}