Skip to content

Commit

Permalink
Pet: Tryfix double unsummon crash due to visibility
Browse files Browse the repository at this point in the history
Close cmangos/mangos-wotlk#508

Credit @insunaa for the general idea
  • Loading branch information
killerwife committed Mar 24, 2024
1 parent fa7c9be commit f2a596b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/game/Entities/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,17 @@ void Pet::ForcedDespawn(uint32 timeMSToDespawn, bool onlyAlive)
if (IsAlive())
SetDeathState(JUST_DIED);

RemoveCorpse(true); // force corpse removal in the same grid
if (GetDeathState() == CORPSE) // rest of despawn cleanup meant to be done by Unsummon
{
if (AI())
{
uint32 respawnDelay = 0;
AI()->CorpseRemoved(respawnDelay);
}

if (InstanceData* mapInstance = GetInstanceData())
mapInstance->OnCreatureDespawn(this);
}

Unsummon(PET_SAVE_NOT_IN_SLOT, owner);
}

0 comments on commit f2a596b

Please sign in to comment.