Core/Pet: Fixed possible crash after swapping pet with stable master. Closes #5177
This commit is contained in:
@@ -615,7 +615,7 @@ void WorldSession::HandleStablePet(WorldPacket & recv_data)
|
|||||||
Pet* pet = _player->GetPet();
|
Pet* pet = _player->GetPet();
|
||||||
|
|
||||||
// can't place in stable dead pet
|
// can't place in stable dead pet
|
||||||
if (!pet||!pet->isAlive()||pet->getPetType() != HUNTER_PET)
|
if (!pet || !pet->isAlive() || pet->getPetType() != HUNTER_PET)
|
||||||
{
|
{
|
||||||
SendStableResult(STABLE_ERR_STABLE);
|
SendStableResult(STABLE_ERR_STABLE);
|
||||||
return;
|
return;
|
||||||
@@ -853,16 +853,22 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move alive pet to slot or delete dead pet
|
|
||||||
Pet* pet = _player->GetPet();
|
Pet* pet = _player->GetPet();
|
||||||
|
// The player's pet could have been removed during the delay of the DB callback
|
||||||
|
if (!pet)
|
||||||
|
{
|
||||||
|
SendStableResult(STABLE_ERR_STABLE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move alive pet to slot or delete dead pet
|
||||||
_player->RemovePet(pet, pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
|
_player->RemovePet(pet, pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
|
||||||
|
|
||||||
// summon unstabled pet
|
// summon unstabled pet
|
||||||
Pet* newpet = new Pet(_player);
|
Pet* newPet = new Pet(_player);
|
||||||
if (!newpet->LoadPetFromDB(_player, petEntry, petId))
|
if (!newPet->LoadPetFromDB(_player, petEntry, petId))
|
||||||
{
|
{
|
||||||
delete newpet;
|
delete newPet;
|
||||||
SendStableResult(STABLE_ERR_STABLE);
|
SendStableResult(STABLE_ERR_STABLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user