diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 78e19a814..700f4f858 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -634,7 +634,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } // friend status - sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), "", true); + sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true); // Place character in world (and load zone) before some object loading pCurrChar->LoadCorpse(); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 414ec89c8..95dd7b924 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -704,7 +704,7 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) sLog.outDebug( "WORLD: %s Guid not found.", friendName.c_str() ); } - sSocialMgr.SendFriendStatus(GetPlayer(), friendResult, GUID_LOPART(friendGuid), friendName, false); + sSocialMgr.SendFriendStatus(GetPlayer(), friendResult, GUID_LOPART(friendGuid), false); sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); } @@ -721,7 +721,7 @@ void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false); - sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), "", false); + sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), false); sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); } @@ -733,8 +733,6 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) sLog.outDebug( "WORLD: Received CMSG_ADD_IGNORE" ); std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN); - FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; - uint64 IgnoreGuid = 0; recv_data >> IgnoreName; @@ -746,40 +744,40 @@ void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) sLog.outDebug( "WORLD: %s asked to Ignore: '%s'", GetPlayer()->GetName(), IgnoreName.c_str() ); - IgnoreGuid = objmgr.GetPlayerGUIDByName(IgnoreName); + CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str()); +} +void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId) +{ + if(!result) + return; + + uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + + delete result; + + WorldSession * session = sWorld.FindSession(accountId); + if(!session) + return; + + FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; if(IgnoreGuid) { - if(IgnoreGuid==GetPlayer()->GetGUID()) + if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself ignoreResult = FRIEND_IGNORE_SELF; + else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) + ignoreResult = FRIEND_IGNORE_ALREADY; else { - if( GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) - ignoreResult = FRIEND_IGNORE_ALREADY; + ignoreResult = FRIEND_IGNORE_ADDED; + + // ignore list full + if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) + ignoreResult = FRIEND_IGNORE_FULL; } } - if (IgnoreGuid && ignoreResult == FRIEND_IGNORE_NOT_FOUND) - { - ignoreResult = FRIEND_IGNORE_ADDED; - - if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) - ignoreResult = FRIEND_IGNORE_FULL; - } - else if(ignoreResult==FRIEND_IGNORE_ALREADY) - { - sLog.outDebug( "WORLD: %s Guid Already Ignored.", IgnoreName.c_str() ); - } - else if(ignoreResult==FRIEND_IGNORE_SELF) - { - sLog.outDebug( "WORLD: %s Guid can't add himself.", IgnoreName.c_str() ); - } - else - { - sLog.outDebug( "WORLD: %s Guid not found.", IgnoreName.c_str() ); - } - - sSocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), "", false); + sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), false); sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); } @@ -796,7 +794,7 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true); - sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), "", false); + sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), false); sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); } diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index cdb2c3919..6973bc352 100644 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -235,7 +235,7 @@ void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldP *data << uint64(guid); } -void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name, bool broadcast) +void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast) { FriendInfo fi; diff --git a/src/game/SocialMgr.h b/src/game/SocialMgr.h index c4a19295a..8c873d8a0 100644 --- a/src/game/SocialMgr.h +++ b/src/game/SocialMgr.h @@ -145,7 +145,7 @@ class SocialMgr void GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo); // Packet management void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data); - void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name, bool broadcast); + void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast); void BroadcastToFriendListers(Player *player, WorldPacket *packet); // Loading PlayerSocial *LoadFromDB(QueryResult *result, uint32 guid); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 3018f1eb1..59e236c24 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -373,7 +373,7 @@ void WorldSession::LogoutPlayer(bool Save) _player->GetGroup()->SendUpdate(); ///- Broadcast a logout message to the player's friends - sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), "", true); + sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true); ///- Delete the player object _player->CleanupsBeforeDelete(); // do some cleanup before deleting to prevent crash at crossreferences to already deleted data diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index aebc44903..e0ad26567 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -281,6 +281,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleAddFriendOpcode(WorldPacket& recvPacket); void HandleDelFriendOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcode(WorldPacket& recvPacket); + static void HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId); void HandleDelIgnoreOpcode(WorldPacket& recvPacket); void HandleSetFriendNoteOpcode(WorldPacket& recvPacket); void HandleBugOpcode(WorldPacket& recvPacket);