diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-09-23 22:37:11 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-09-23 22:37:11 +0200 |
commit | d29274f3a142545a386420e54f6169e4f7ed6eda (patch) | |
tree | 8dfff9cceb9d9947cf47364cc1709f47c818d032 /src | |
parent | 24018b7a74ec8e68e43895e0e57f6397f59ea890 (diff) |
Core/Pets: Fixed crash happening when summoning a different pet than one that was unsummoned by summoning a guardian (imp -> infernal -> felhunter)
Closes #25478
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3e3a39c16a5..8e682bc0cb0 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5903,8 +5903,8 @@ 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()); @@ -5959,13 +5959,15 @@ void Unit::SetMinion(Minion *minion, bool apply) else if (minion->IsTotem()) { // 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 (SpellInfo const* spInfo = sSpellMgr->GetSpellInfo(minion->ToTotem()->GetSpell())) { - if (spInfo->Effects[i].Effect != SPELL_EFFECT_SUMMON) - continue; + for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (spInfo->Effects[i].Effect != SPELL_EFFECT_SUMMON) + continue; - RemoveAllMinionsByEntry(spInfo->Effects[i].MiscValue); + RemoveAllMinionsByEntry(spInfo->Effects[i].MiscValue); + } } } |