mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 04:37:04 +00:00
[10363] More wide use ObjectGuid in way remove MAKE_NEW_GUID uses.
Also * Fixed some amount wrong uses low guids as full player guids. * Add private without body ObjectGuid(uint32 const&) for catch wrong assigns low guids to ObjectGuid. In some cases need assign "0" guid, then use ObjectGuid() instead. * Fixed .pdump commands work.
This commit is contained in:
parent
db7db6382a
commit
5f44c4da21
41 changed files with 369 additions and 323 deletions
|
|
@ -31,7 +31,6 @@ INSTANTIATE_SINGLETON_1( SocialMgr );
|
|||
|
||||
PlayerSocial::PlayerSocial()
|
||||
{
|
||||
m_playerGUID = 0;
|
||||
}
|
||||
|
||||
PlayerSocial::~PlayerSocial()
|
||||
|
|
@ -50,7 +49,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
|
|||
return counter;
|
||||
}
|
||||
|
||||
bool PlayerSocial::AddToSocialList(uint32 friend_guid, bool ignore)
|
||||
bool PlayerSocial::AddToSocialList(uint32 friend_lowguid, bool ignore)
|
||||
{
|
||||
// check client limits
|
||||
if(ignore)
|
||||
|
|
@ -68,25 +67,25 @@ bool PlayerSocial::AddToSocialList(uint32 friend_guid, bool ignore)
|
|||
if(ignore)
|
||||
flag = SOCIAL_FLAG_IGNORED;
|
||||
|
||||
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
|
||||
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_lowguid);
|
||||
if(itr != m_playerSocialMap.end())
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, GetPlayerGUID(), friend_guid);
|
||||
m_playerSocialMap[friend_guid].Flags |= flag;
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_lowguid);
|
||||
m_playerSocialMap[friend_lowguid].Flags |= flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO character_social (guid, friend, flags) VALUES ('%u', '%u', '%u')", GetPlayerGUID(), friend_guid, flag);
|
||||
CharacterDatabase.PExecute("INSERT INTO character_social (guid, friend, flags) VALUES ('%u', '%u', '%u')", m_playerLowGuid, friend_lowguid, flag);
|
||||
FriendInfo fi;
|
||||
fi.Flags |= flag;
|
||||
m_playerSocialMap[friend_guid] = fi;
|
||||
m_playerSocialMap[friend_lowguid] = fi;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlayerSocial::RemoveFromSocialList(uint32 friend_guid, bool ignore)
|
||||
void PlayerSocial::RemoveFromSocialList(uint32 friend_lowguid, bool ignore)
|
||||
{
|
||||
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid);
|
||||
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_lowguid);
|
||||
if(itr == m_playerSocialMap.end()) // not exist
|
||||
return;
|
||||
|
||||
|
|
@ -97,18 +96,18 @@ void PlayerSocial::RemoveFromSocialList(uint32 friend_guid, bool ignore)
|
|||
itr->second.Flags &= ~flag;
|
||||
if(itr->second.Flags == 0)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", GetPlayerGUID(), friend_guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", m_playerLowGuid, friend_lowguid);
|
||||
m_playerSocialMap.erase(itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags & ~%u) WHERE guid = '%u' AND friend = '%u'", flag, GetPlayerGUID(), friend_guid);
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags & ~%u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_lowguid);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
|
||||
void PlayerSocial::SetFriendNote(uint32 friend_lowguid, std::string note)
|
||||
{
|
||||
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
|
||||
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_lowguid);
|
||||
if(itr == m_playerSocialMap.end()) // not exist
|
||||
return;
|
||||
|
||||
|
|
@ -116,13 +115,13 @@ void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
|
|||
|
||||
std::string safe_note = note;
|
||||
CharacterDatabase.escape_string(safe_note);
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET note = '%s' WHERE guid = '%u' AND friend = '%u'", safe_note.c_str(), GetPlayerGUID(), friend_guid);
|
||||
m_playerSocialMap[friend_guid].Note = note;
|
||||
CharacterDatabase.PExecute("UPDATE character_social SET note = '%s' WHERE guid = '%u' AND friend = '%u'", safe_note.c_str(), m_playerLowGuid, friend_lowguid);
|
||||
m_playerSocialMap[friend_lowguid].Note = note;
|
||||
}
|
||||
|
||||
void PlayerSocial::SendSocialList()
|
||||
{
|
||||
Player *plr = sObjectMgr.GetPlayer(GetPlayerGUID());
|
||||
Player *plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));
|
||||
if(!plr)
|
||||
return;
|
||||
|
||||
|
|
@ -136,7 +135,7 @@ void PlayerSocial::SendSocialList()
|
|||
{
|
||||
sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);
|
||||
|
||||
data << uint64(itr->first); // player guid
|
||||
data << ObjectGuid(HIGHGUID_PLAYER, itr->first); // player guid
|
||||
data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
|
||||
data << itr->second.Note; // string note
|
||||
if(itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
|
||||
|
|
@ -181,19 +180,19 @@ SocialMgr::~SocialMgr()
|
|||
|
||||
}
|
||||
|
||||
void SocialMgr::GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo)
|
||||
void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo &friendInfo)
|
||||
{
|
||||
if(!player)
|
||||
return;
|
||||
|
||||
Player *pFriend = ObjectAccessor::FindPlayer(friendGUID);
|
||||
Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid));
|
||||
|
||||
uint32 team = player->GetTeam();
|
||||
AccountTypes security = player->GetSession()->GetSecurity();
|
||||
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
|
||||
AccountTypes gmLevelInWhoList = AccountTypes (sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));
|
||||
|
||||
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID);
|
||||
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friend_lowguid);
|
||||
if(itr != player->GetSocial()->m_playerSocialMap.end())
|
||||
friendInfo.Note = itr->second.Note;
|
||||
|
||||
|
|
@ -226,16 +225,16 @@ void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldP
|
|||
{
|
||||
data->Initialize(SMSG_FRIEND_STATUS, 5);
|
||||
*data << uint8(result);
|
||||
*data << uint64(guid);
|
||||
*data << ObjectGuid(HIGHGUID_PLAYER, guid);
|
||||
}
|
||||
|
||||
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast)
|
||||
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_lowguid, bool broadcast)
|
||||
{
|
||||
FriendInfo fi;
|
||||
|
||||
WorldPacket data;
|
||||
MakeFriendStatusPacket(result, friend_guid, &data);
|
||||
GetFriendInfo(player, friend_guid, fi);
|
||||
MakeFriendStatusPacket(result, friend_lowguid, &data);
|
||||
GetFriendInfo(player, friend_lowguid, fi);
|
||||
switch(result)
|
||||
{
|
||||
case FRIEND_ADDED_OFFLINE:
|
||||
|
|
@ -296,10 +295,10 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
|
|||
}
|
||||
}
|
||||
|
||||
PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, uint32 guid)
|
||||
PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, ObjectGuid guid)
|
||||
{
|
||||
PlayerSocial *social = &m_socialMap[guid];
|
||||
social->SetPlayerGUID(guid);
|
||||
PlayerSocial *social = &m_socialMap[guid.GetCounter()];
|
||||
social->SetPlayerGuid(guid);
|
||||
|
||||
if(!result)
|
||||
return social;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue