Skip to content

Commit

Permalink
[10870] Properly remove deleted character from friends of online play…
Browse files Browse the repository at this point in the history
…ers.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
  • Loading branch information
Emtec authored and VladimirMangos committed Dec 13, 2010
1 parent aa491b4 commit 1ab7f02
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4288,6 +4288,9 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
// Get guids of character's pets, will deleted in transaction
QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'", lowguid);

// delete char from friends list when selected chars is online (non existing - error)
QueryResult *resultFriend = CharacterDatabase.PQuery("SELECT DISTINCT guid FROM character_social WHERE friend = '%u'", lowguid);

// NOW we can finally clear other DB data related to character
CharacterDatabase.BeginTransaction();
if (resultPets)
Expand All @@ -4301,6 +4304,24 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
delete resultPets;
}

// cleanup friends for online players, offline case will cleanup later in code
if (resultFriend)
{
do
{
Field* fieldsFriend = resultFriend->Fetch();
if (Player* sFriend = sObjectAccessor.FindPlayer(ObjectGuid(HIGHGUID_PLAYER, fieldsFriend[0].GetUInt32())))
{
if (sFriend->IsInWorld())
{
sFriend->GetSocial()->RemoveFromSocialList(playerguid, false);
sSocialMgr.SendFriendStatus(sFriend, FRIEND_REMOVED, playerguid, false);
}
}
} while (resultFriend->NextRow());
delete resultFriend;
}

CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'", lowguid);
CharacterDatabase.PExecute("DELETE FROM character_account_data WHERE guid = '%u'", lowguid);
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", lowguid);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10869"
#define REVISION_NR "10870"
#endif // __REVISION_NR_H__

0 comments on commit 1ab7f02

Please sign in to comment.