Make guid lookup for adding ignore async.

This commit is contained in:
hunuza 2008-11-02 20:23:25 +01:00
parent c6eadf5565
commit e9fc699d86
6 changed files with 33 additions and 34 deletions

View file

@ -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();

View file

@ -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)" );
}

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -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);