fix(Core/Pets): fixed crash happening when current pet is forcibly removed (#10025)

This commit is contained in:
Kargatum
2022-01-10 19:19:43 +07:00
committed by GitHub
parent b2df4aa970
commit c1ebda66ba
8 changed files with 50 additions and 10 deletions

View File

@@ -10168,10 +10168,15 @@ void Unit::SetMinion(Minion* minion, bool apply)
if (oldPet != minion && (oldPet->IsPet() || minion->IsPet() || oldPet->GetEntry() != minion->GetEntry()))
{
// remove existing minion pet
if (oldPet->IsPet())
((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT);
if (Pet* oldPetAsPet = oldPet->ToPet())
{
oldPetAsPet->Remove(PET_SAVE_NOT_IN_SLOT);
}
else
{
oldPet->UnSummon();
}
SetPetGUID(minion->GetGUID());
SetMinionGUID(ObjectGuid::Empty);
}
@@ -10239,6 +10244,7 @@ void Unit::SetMinion(Minion* minion, bool apply)
{
// All summoned by totem minions must disappear when it is removed.
if (SpellInfo const* spInfo = sSpellMgr->GetSpellInfo(minion->ToTotem()->GetSpell()))
{
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spInfo->Effects[i].Effect != SPELL_EFFECT_SUMMON)
@@ -10246,6 +10252,7 @@ void Unit::SetMinion(Minion* minion, bool apply)
RemoveAllMinionsByEntry(spInfo->Effects[i].MiscValue);
}
}
}
if (GetTypeId() == TYPEID_PLAYER)