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

@@ -114,7 +114,6 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8
recruiterId(recruiter),
isRecruiter(isARecruiter),
m_currentVendorEntry(0),
m_currentBankerGUID(0),
timeWhoCommandAllowed(0),
_calendarEventCreationCooldown(0),
_timeSyncClockDeltaQueue(6),
@@ -191,9 +190,9 @@ std::string WorldSession::GetPlayerInfo() const
}
/// Get player guid if available. Use for logging purposes only
uint32 WorldSession::GetGuidLow() const
ObjectGuid::LowType WorldSession::GetGuidLow() const
{
return GetPlayer() ? GetPlayer()->GetGUIDLow() : 0;
return GetPlayer() ? GetPlayer()->GetGUID().GetCounter() : 0;
}
/// Send a packet to the client
@@ -472,7 +471,7 @@ void WorldSession::HandleTeleportTimeout(bool updateInSessions)
if (!plMover)
break;
WorldPacket pkt(MSG_MOVE_TELEPORT_ACK, 20);
pkt.append(plMover->GetPackGUID());
pkt << plMover->GetPackGUID();
pkt << uint32(0); // flags
pkt << uint32(0); // time
HandleMoveTeleportAck(pkt);
@@ -493,7 +492,7 @@ void WorldSession::LogoutPlayer(bool save)
if (_player)
{
if (uint64 lguid = _player->GetLootGUID())
if (ObjectGuid lguid = _player->GetLootGUID())
DoLootRelease(lguid);
///- If the player just died before logging out, make him appear as a ghost
@@ -540,7 +539,7 @@ void WorldSession::LogoutPlayer(bool save)
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT);
CharacterDatabase.Execute(stmt);
}
@@ -585,7 +584,7 @@ void WorldSession::LogoutPlayer(bool save)
for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j)
{
eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0);
_player->SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid::Empty);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
}
@@ -609,13 +608,14 @@ void WorldSession::LogoutPlayer(bool save)
}
//! Broadcast a logout message to the player's friends
sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true);
sSocialMgr->RemovePlayerSocial(_player->GetGUIDLow());
sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUID(), true);
sSocialMgr->RemovePlayerSocial(_player->GetGUID());
//! Call script hook before deletion
sScriptMgr->OnPlayerLogout(_player);
LOG_INFO("entities.player", "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel());
LOG_INFO("entities.player", "Account: %d (IP: %s) Logout Character:[%s] (%s) Level: %d",
GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), _player->getLevel());
//! Remove the player from the world
// the player may not be in the world when logging out
@@ -865,7 +865,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
if (mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
data.readPackGUID(mi->transport.guid);
data >> mi->transport.guid.ReadAsPacked();
data >> mi->transport.pos.PositionXYZOStream();
data >> mi->transport.time;
@@ -899,8 +899,8 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
if (check) \
{ \
LOG_DEBUG("entities.unit", "WorldSession::ReadMovementInfo: Violation of MovementFlags found (%s). " \
"MovementFlags: %u, MovementFlags2: %u for player GUID: %u. Mask %u will be removed.", \
STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetPlayer()->GetGUIDLow(), maskToRemove); \
"MovementFlags: %u, MovementFlags2: %u for player %s. Mask %u will be removed.", \
STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetPlayer()->GetGUID().ToString().c_str(), maskToRemove); \
mi->RemoveMovementFlag((maskToRemove)); \
} \
}
@@ -972,7 +972,7 @@ void WorldSession::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi)
{
data->appendPackGUID(mi->guid);
*data << mi->guid.WriteAsPacked();
*data << mi->flags;
*data << mi->flags2;
@@ -981,7 +981,7 @@ void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi)
if (mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
data->appendPackGUID(mi->transport.guid);
*data << mi->transport.guid.WriteAsPacked();
*data << mi->transport.pos.PositionXYZOStream();
*data << mi->transport.time;
@@ -1174,7 +1174,7 @@ void WorldSession::SetPlayer(Player* player)
{
_player = player;
if (_player)
m_GUIDLow = _player->GetGUIDLow();
m_GUIDLow = _player->GetGUID().GetCounter();
}
void WorldSession::InitializeQueryCallbackParameters()
@@ -1211,7 +1211,7 @@ void WorldSession::ProcessQueryCallbackPlayer()
{
uint8 bagIndex = _openWrappedItemCallback.GetFirstParam();
uint8 slot = _openWrappedItemCallback.GetSecondParam();
uint32 itemLowGUID = _openWrappedItemCallback.GetThirdParam();
ObjectGuid::LowType itemLowGUID = _openWrappedItemCallback.GetThirdParam();
_openWrappedItemCallback.GetResult(result);
HandleOpenWrappedItemCallback(result, bagIndex, slot, itemLowGUID);
_openWrappedItemCallback.FreeResult();
@@ -1233,7 +1233,7 @@ void WorldSession::ProcessQueryCallbackPet()
//- SendStabledPet
if (_sendStabledPetCallback.IsReady())
{
uint64 param = _sendStabledPetCallback.GetParam();
ObjectGuid param = _sendStabledPetCallback.GetParam();
_sendStabledPetCallback.GetResult(result);
SendStablePetCallback(result, param);
_sendStabledPetCallback.FreeResult();

View File

@@ -232,7 +232,7 @@ public:
uint32 GetCurrentVendor() const { return m_currentVendorEntry; }
void SetCurrentVendor(uint32 vendorEntry) { m_currentVendorEntry = vendorEntry; }
uint32 GetGuidLow() const;
ObjectGuid::LowType GetGuidLow() const;
void SetSecurity(AccountTypes security) { _security = security; }
std::string const& GetRemoteAddress() { return m_Address; }
void SetPlayer(Player* player);
@@ -271,38 +271,38 @@ public:
/// Handle the authentication waiting queue (to be completed)
void SendAuthWaitQue(uint32 position);
//void SendTestCreatureQueryOpcode(uint32 entry, uint64 guid, uint32 testvalue);
void SendNameQueryOpcode(uint64 guid);
//void SendTestCreatureQueryOpcode(uint32 entry, ObjectGuid guid, uint32 testvalue);
void SendNameQueryOpcode(ObjectGuid guid);
void SendTrainerList(uint64 guid);
void SendTrainerList(uint64 guid, std::string const& strTitle);
void SendListInventory(uint64 guid, uint32 vendorEntry = 0);
void SendShowBank(uint64 guid);
bool CanOpenMailBox(uint64 guid);
void SendShowMailBox(uint64 guid);
void SendTabardVendorActivate(uint64 guid);
void SendTrainerList(ObjectGuid guid);
void SendTrainerList(ObjectGuid guid, std::string const& strTitle);
void SendListInventory(ObjectGuid guid, uint32 vendorEntry = 0);
void SendShowBank(ObjectGuid guid);
bool CanOpenMailBox(ObjectGuid guid);
void SendShowMailBox(ObjectGuid guid);
void SendTabardVendorActivate(ObjectGuid guid);
void SendSpiritResurrect();
void SendBindPoint(Creature* npc);
void SendAttackStop(Unit const* enemy);
void SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB);
void SendBattleGroundList(ObjectGuid guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB);
void SendTradeStatus(TradeStatus status);
void SendUpdateTrade(bool trader_data = true);
void SendCancelTrade();
void SendPetitionQueryOpcode(uint64 petitionguid);
void SendPetitionQueryOpcode(ObjectGuid petitionguid);
// Spell
void HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets);
// Pet
void SendPetNameQuery(uint64 guid, uint32 petnumber);
void SendStablePet(uint64 guid);
void SendStablePetCallback(PreparedQueryResult result, uint64 guid);
void SendPetNameQuery(ObjectGuid guid, uint32 petnumber);
void SendStablePet(ObjectGuid guid);
void SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid);
void SendStableResult(uint8 guid);
bool CheckStableMaster(uint64 guid);
bool CheckStableMaster(ObjectGuid guid);
// Account Data
AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; }
@@ -324,17 +324,17 @@ public:
}
}
//auction
void SendAuctionHello(uint64 guid, Creature* unit);
void SendAuctionHello(ObjectGuid guid, Creature* unit);
void SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
void SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionBidderNotification(uint32 location, uint32 auctionId, ObjectGuid bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification(AuctionEntry* auction);
//Item Enchantment
void SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId);
void SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, uint32 slot, uint32 Duration);
void SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId);
void SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration);
//Taxi
void SendTaxiStatus(uint64 guid);
void SendTaxiStatus(ObjectGuid guid);
void SendTaxiMenu(Creature* unit);
void SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathNode = 0);
bool SendLearnNewTaxiNode(Creature* unit);
@@ -343,11 +343,11 @@ public:
// Guild/Arena Team
void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id = 0);
void SendNotInArenaTeamPacket(uint8 type);
void SendPetitionShowList(uint64 guid);
void SendPetitionShowList(ObjectGuid guid);
void BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data);
void DoLootRelease(uint64 lguid);
void DoLootRelease(ObjectGuid lguid);
// Account mute time
time_t m_muteTime;
@@ -594,7 +594,7 @@ public: // opcodes handlers
void HandleStableRevivePet(WorldPacket& recvPacket);
void HandleStableSwapPet(WorldPacket& recvPacket);
void HandleStableSwapPetCallback(PreparedQueryResult result, uint32 petId);
void HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, uint32 itemLowGUID);
void HandleOpenWrappedItemCallback(PreparedQueryResult result, uint8 bagIndex, uint8 slot, ObjectGuid::LowType itemLowGUID);
void HandleLoadActionsSwitchSpec(PreparedQueryResult result);
void HandleCharacterAuraFrozen(PreparedQueryResult result);
uint8 HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, uint8 asynchLoadType);
@@ -620,7 +620,7 @@ public: // opcodes handlers
void HandleAuctionSellItem(WorldPacket& recvData);
void HandleAuctionRemoveItem(WorldPacket& recvData);
void HandleAuctionListOwnerItems(WorldPacket& recvData);
void HandleAuctionListOwnerItemsEvent(uint64 creatureGuid);
void HandleAuctionListOwnerItemsEvent(ObjectGuid creatureGuid);
void HandleAuctionPlaceBid(WorldPacket& recvData);
void HandleAuctionListPendingSales(WorldPacket& recvData);
@@ -736,7 +736,7 @@ public: // opcodes handlers
//Pet
void HandlePetAction(WorldPacket& recvData);
void HandlePetStopAttack(WorldPacket& recvData);
void HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2);
void HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint16 spellid, uint16 flag, ObjectGuid guid2);
void HandlePetNameQuery(WorldPacket& recvData);
void HandlePetSetAction(WorldPacket& recvData);
void HandlePetAbandon(WorldPacket& recvData);
@@ -810,7 +810,7 @@ public: // opcodes handlers
void SendLfgUpdatePlayer(lfg::LfgUpdateData const& updateData);
void SendLfgUpdateParty(lfg::LfgUpdateData const& updateData);
void SendLfgRoleChosen(uint64 guid, uint8 roles);
void SendLfgRoleChosen(ObjectGuid guid, uint8 roles);
void SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& pRoleCheck);
void SendLfgLfrList(bool update);
void SendLfgJoinResult(lfg::LfgJoinResultData const& joinData);
@@ -942,7 +942,7 @@ private:
QueryCallback<PreparedQueryResult, std::string> _charRenameCallback;
QueryCallback<PreparedQueryResult, uint32> _unstablePetCallback;
QueryCallback<PreparedQueryResult, uint32> _stableSwapCallback;
QueryCallback<PreparedQueryResult, uint64> _sendStabledPetCallback;
QueryCallback<PreparedQueryResult, ObjectGuid> _sendStabledPetCallback;
QueryCallback<PreparedQueryResult, CharacterCreateInfo*, true> _charCreateCallback;
QueryResultHolderFuture _charLoginCallback;
@@ -993,21 +993,21 @@ private:
// private trade methods
void moveItems(Item* myItems[], Item* hisItems[]);
bool CanUseBank(uint64 bankerGUID = 0) const;
bool CanUseBank(ObjectGuid bankerGUID = ObjectGuid::Empty) const;
bool recoveryItem(Item* pItem);
// EnumData helpers
bool IsLegitCharacterForAccount(uint32 lowGUID)
bool IsLegitCharacterForAccount(ObjectGuid guid)
{
return _legitCharacters.find(lowGUID) != _legitCharacters.end();
return _legitCharacters.find(guid) != _legitCharacters.end();
}
// this stores the GUIDs of the characters who can login
// characters who failed on Player::BuildEnumData shouldn't login
std::set<uint32> _legitCharacters;
GuidSet _legitCharacters;
uint32 m_GUIDLow;
ObjectGuid::LowType m_GUIDLow;
Player* _player;
WorldSocket* m_Socket;
std::string m_Address;
@@ -1040,7 +1040,7 @@ private:
bool isRecruiter;
LockedQueue<WorldPacket*> _recvQueue;
uint32 m_currentVendorEntry;
uint64 m_currentBankerGUID;
ObjectGuid m_currentBankerGUID;
time_t timeWhoCommandAllowed;
uint32 _offlineTime;
bool _kicked;

View File

@@ -478,7 +478,8 @@ int WorldSocket::handle_input_header(void)
if ((header.size < 4) || (header.size > 10240) || (header.cmd > 10240))
{
Player* _player = m_Session ? m_Session->GetPlayer() : nullptr;
LOG_ERROR("server", "WorldSocket::handle_input_header(): client (account: %u, char [GUID: %u, name: %s]) sent malformed packet (size: %d, cmd: %d)", m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUIDLow() : 0, _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd);
LOG_ERROR("server", "WorldSocket::handle_input_header(): client (account: %u, char [%s, name: %s]) sent malformed packet (size: %d, cmd: %d)",
m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUID().ToString().c_str() : "", _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd);
errno = EINVAL;
return -1;
@@ -1053,9 +1054,9 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
if (m_Session && AccountMgr::IsPlayerAccount(m_Session->GetSecurity()))
{
Player* _player = m_Session->GetPlayer();
LOG_ERROR("server", "WorldSocket::HandlePing: Player (account: %u, GUID: %u, name: %s) kicked for over-speed pings (address: %s)",
LOG_ERROR("server", "WorldSocket::HandlePing: Player (account: %u, %s, name: %s) kicked for over-speed pings (address: %s)",
m_Session->GetAccountId(),
_player ? _player->GetGUIDLow() : 0,
_player ? _player->GetGUID().ToString().c_str() : "",
_player ? _player->GetName().c_str() : "<none>",
GetRemoteAddress().c_str());