Core/Social: properly remove deleted character from social list of online players (by Emtec)

--HG--
branch : trunk
This commit is contained in:
azazel
2010-12-15 14:44:41 +06:00
parent 0fdea34a8a
commit ddf06c086e
+18 -6
View File
@@ -4570,20 +4570,32 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
}
// Unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet.
// Get guids of character's pets, will deleted in transaction
QueryResult resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid);
// NOW we can finally clear other DB data related to character
if (resultPets)
if (QueryResult resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'", guid))
{
do
{
Field *fields3 = resultPets->Fetch();
uint32 petguidlow = fields3[0].GetUInt32();
uint32 petguidlow = (*resultPets)[0].GetUInt32();
Pet::DeleteFromDB(petguidlow);
} while (resultPets->NextRow());
}
// Delete char from social list of online chars
if (QueryResult resultFriends = CharacterDatabase.PQuery("SELECT DISTINCT guid FROM character_social WHERE friend = '%u'", guid))
{
do
{
if (Player* pFriend = sObjectAccessor.FindPlayer(MAKE_NEW_GUID((*resultFriends)[0].GetUInt32(), 0, HIGHGUID_PLAYER)))
{
if (pFriend->IsInWorld())
{
pFriend->GetSocial()->RemoveFromSocialList(guid, false);
sSocialMgr.SendFriendStatus(pFriend, FRIEND_REMOVED, guid, false);
}
}
} while (resultFriends->NextRow());
}
trans->PAppend("DELETE FROM characters WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_account_data WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_declinedname WHERE guid = '%u'",guid);