mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-13 07:23:44 +00:00
refactor(Core): Make ObjectGuid const (#23170)
* cherry-pick commit (a7883380ce)
Co-Authored-By: Lucas Nascimento <keader.android@gmail.com>
This commit is contained in:
@@ -121,7 +121,7 @@ void Corpse::DeleteFromDB(CharacterDatabaseTransaction trans)
|
||||
DeleteFromDB(GetOwnerGUID(), trans);
|
||||
}
|
||||
|
||||
void Corpse::DeleteFromDB(ObjectGuid const ownerGuid, CharacterDatabaseTransaction trans)
|
||||
void Corpse::DeleteFromDB(ObjectGuid const& ownerGuid, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
|
||||
stmt->SetData(0, ownerGuid.GetCounter());
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields);
|
||||
|
||||
void DeleteFromDB(CharacterDatabaseTransaction trans);
|
||||
static void DeleteFromDB(ObjectGuid const ownerGuid, CharacterDatabaseTransaction trans);
|
||||
static void DeleteFromDB(ObjectGuid const& ownerGuid, CharacterDatabaseTransaction trans);
|
||||
|
||||
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(CORPSE_FIELD_OWNER); }
|
||||
|
||||
|
||||
@@ -3051,13 +3051,13 @@ SpellInfo const* GameObject::GetSpellForLock(Player const* player) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GameObject::AddToSkillupList(ObjectGuid playerGuid)
|
||||
void GameObject::AddToSkillupList(ObjectGuid const& playerGuid)
|
||||
{
|
||||
int32 timer = GetMap()->IsDungeon() ? -1 : 10 * MINUTE * IN_MILLISECONDS;
|
||||
m_SkillupList[playerGuid] = timer;
|
||||
}
|
||||
|
||||
bool GameObject::IsInSkillupList(ObjectGuid playerGuid) const
|
||||
bool GameObject::IsInSkillupList(ObjectGuid const& playerGuid) const
|
||||
{
|
||||
for (auto const& itr : m_SkillupList)
|
||||
{
|
||||
|
||||
@@ -231,8 +231,8 @@ public:
|
||||
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
|
||||
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
|
||||
|
||||
void AddToSkillupList(ObjectGuid playerGuid);
|
||||
[[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const;
|
||||
void AddToSkillupList(ObjectGuid const& playerGuid);
|
||||
[[nodiscard]] bool IsInSkillupList(ObjectGuid const& playerGuid) const;
|
||||
|
||||
void AddUniqueUse(Player* player);
|
||||
void AddUse() { ++m_usetimes; }
|
||||
|
||||
@@ -269,7 +269,7 @@ class PackedGuid
|
||||
explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
|
||||
|
||||
void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
|
||||
void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
|
||||
void Set(ObjectGuid const& guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
|
||||
|
||||
[[nodiscard]] std::size_t size() const { return _packedGuid.size(); }
|
||||
|
||||
|
||||
@@ -2088,7 +2088,7 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver)
|
||||
return false;
|
||||
}
|
||||
|
||||
Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
|
||||
Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask)
|
||||
{
|
||||
// unit checks
|
||||
if (!guid)
|
||||
@@ -2145,7 +2145,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
|
||||
return creature;
|
||||
}
|
||||
|
||||
GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const
|
||||
GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const
|
||||
{
|
||||
if (GameObject* go = GetMap()->GetGameObject(guid))
|
||||
{
|
||||
@@ -4616,7 +4616,7 @@ void Player::KillPlayer()
|
||||
//UpdateObjectVisibility(); // pussywizard: not needed
|
||||
}
|
||||
|
||||
void Player::OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans)
|
||||
void Player::OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
Corpse::DeleteFromDB(guid, trans);
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
|
||||
|
||||
@@ -1128,8 +1128,8 @@ public:
|
||||
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap);
|
||||
|
||||
bool CanInteractWithQuestGiver(Object* questGiver);
|
||||
Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
|
||||
[[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const;
|
||||
Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask);
|
||||
[[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const;
|
||||
|
||||
void ToggleAFK();
|
||||
void ToggleDND();
|
||||
@@ -2033,7 +2033,7 @@ public:
|
||||
Corpse* CreateCorpse();
|
||||
void RemoveCorpse();
|
||||
void KillPlayer();
|
||||
static void OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans);
|
||||
static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans);
|
||||
[[nodiscard]] bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; }
|
||||
[[nodiscard]] WorldLocation GetCorpseLocation() const { return _corpseLocation; }
|
||||
uint32 GetResurrectionSpellId();
|
||||
|
||||
@@ -37,7 +37,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) const
|
||||
return counter;
|
||||
}
|
||||
|
||||
bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
||||
bool PlayerSocial::AddToSocialList(ObjectGuid const& friendGuid, SocialFlag flag)
|
||||
{
|
||||
// check client limits
|
||||
if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT))
|
||||
@@ -71,7 +71,7 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
||||
void PlayerSocial::RemoveFromSocialList(ObjectGuid const& friendGuid, SocialFlag flag)
|
||||
{
|
||||
auto itr = m_playerSocialMap.find(friendGuid);
|
||||
if (itr == m_playerSocialMap.end()) // not exist
|
||||
@@ -102,7 +102,7 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerSocial::SetFriendNote(ObjectGuid friendGuid, std::string note)
|
||||
void PlayerSocial::SetFriendNote(ObjectGuid const& friendGuid, std::string note)
|
||||
{
|
||||
auto itr = m_playerSocialMap.find(friendGuid);
|
||||
if (itr == m_playerSocialMap.end()) // not exist
|
||||
@@ -176,7 +176,7 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
|
||||
LOG_DEBUG("network", "WORLD: Sent SMSG_CONTACT_LIST");
|
||||
}
|
||||
|
||||
bool PlayerSocial::_checkContact(ObjectGuid guid, SocialFlag flags) const
|
||||
bool PlayerSocial::_checkContact(ObjectGuid const& guid, SocialFlag flags) const
|
||||
{
|
||||
auto const& itr = m_playerSocialMap.find(guid);
|
||||
if (itr != m_playerSocialMap.end())
|
||||
@@ -185,12 +185,12 @@ bool PlayerSocial::_checkContact(ObjectGuid guid, SocialFlag flags) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlayerSocial::HasFriend(ObjectGuid friend_guid) const
|
||||
bool PlayerSocial::HasFriend(ObjectGuid const& friend_guid) const
|
||||
{
|
||||
return _checkContact(friend_guid, SOCIAL_FLAG_FRIEND);
|
||||
}
|
||||
|
||||
bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid) const
|
||||
bool PlayerSocial::HasIgnore(ObjectGuid const& ignore_guid) const
|
||||
{
|
||||
return _checkContact(ignore_guid, SOCIAL_FLAG_IGNORED);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ SocialMgr* SocialMgr::instance()
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo)
|
||||
void SocialMgr::GetFriendInfo(Player* player, ObjectGuid const& friendGUID, FriendInfo& friendInfo)
|
||||
{
|
||||
if (!player)
|
||||
return;
|
||||
@@ -247,14 +247,14 @@ void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo&
|
||||
}
|
||||
}
|
||||
|
||||
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid guid, WorldPacket* data)
|
||||
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid const& guid, WorldPacket* data)
|
||||
{
|
||||
data->Initialize(SMSG_FRIEND_STATUS, 9);
|
||||
*data << uint8(result);
|
||||
*data << guid;
|
||||
}
|
||||
|
||||
void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friendGuid, bool broadcast)
|
||||
void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid const& friendGuid, bool broadcast)
|
||||
{
|
||||
FriendInfo fi;
|
||||
GetFriendInfo(player, friendGuid, fi);
|
||||
@@ -316,7 +316,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid guid)
|
||||
PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid const& guid)
|
||||
{
|
||||
PlayerSocial* social = &m_socialMap[guid];
|
||||
social->SetPlayerGUID(guid);
|
||||
|
||||
@@ -104,19 +104,19 @@ class PlayerSocial
|
||||
public:
|
||||
PlayerSocial();
|
||||
// adding/removing
|
||||
bool AddToSocialList(ObjectGuid friend_guid, SocialFlag flag);
|
||||
void RemoveFromSocialList(ObjectGuid friend_guid, SocialFlag flag);
|
||||
void SetFriendNote(ObjectGuid friendGuid, std::string note);
|
||||
bool AddToSocialList(ObjectGuid const& friend_guid, SocialFlag flag);
|
||||
void RemoveFromSocialList(ObjectGuid const& friend_guid, SocialFlag flag);
|
||||
void SetFriendNote(ObjectGuid const& friendGuid, std::string note);
|
||||
// Packet send's
|
||||
void SendSocialList(Player* player, uint32 flags);
|
||||
// Misc
|
||||
bool HasFriend(ObjectGuid friend_guid) const;
|
||||
bool HasIgnore(ObjectGuid ignore_guid) const;
|
||||
ObjectGuid GetPlayerGUID() const { return m_playerGUID; }
|
||||
void SetPlayerGUID(ObjectGuid guid) { m_playerGUID = guid; }
|
||||
bool HasFriend(ObjectGuid const& friend_guid) const;
|
||||
bool HasIgnore(ObjectGuid const& ignore_guid) const;
|
||||
ObjectGuid const& GetPlayerGUID() const { return m_playerGUID; }
|
||||
void SetPlayerGUID(ObjectGuid const& guid) { m_playerGUID = guid; }
|
||||
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag) const;
|
||||
private:
|
||||
bool _checkContact(ObjectGuid guid, SocialFlag flags) const;
|
||||
bool _checkContact(ObjectGuid const& guid, SocialFlag flags) const;
|
||||
typedef std::map<ObjectGuid, FriendInfo> PlayerSocialMap;
|
||||
PlayerSocialMap m_playerSocialMap;
|
||||
ObjectGuid m_playerGUID;
|
||||
@@ -131,14 +131,14 @@ class SocialMgr
|
||||
public:
|
||||
static SocialMgr* instance();
|
||||
// Misc
|
||||
void RemovePlayerSocial(ObjectGuid guid) { m_socialMap.erase(guid); }
|
||||
static void GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo);
|
||||
void RemovePlayerSocial(ObjectGuid const& guid) { m_socialMap.erase(guid); }
|
||||
static void GetFriendInfo(Player* player, ObjectGuid const& friendGUID, FriendInfo& friendInfo);
|
||||
// Packet management
|
||||
void MakeFriendStatusPacket(FriendsResult result, ObjectGuid friend_guid, WorldPacket* data);
|
||||
void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast);
|
||||
void MakeFriendStatusPacket(FriendsResult result, ObjectGuid const& friend_guid, WorldPacket* data);
|
||||
void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid const& friend_guid, bool broadcast);
|
||||
void BroadcastToFriendListers(Player* player, WorldPacket* packet);
|
||||
// Loading
|
||||
PlayerSocial* LoadFromDB(PreparedQueryResult result, ObjectGuid guid);
|
||||
PlayerSocial* LoadFromDB(PreparedQueryResult result, ObjectGuid const& guid);
|
||||
private:
|
||||
typedef std::map<ObjectGuid, PlayerSocial> SocialMap;
|
||||
SocialMap m_socialMap;
|
||||
|
||||
Reference in New Issue
Block a user