Merge pull request #102 from H0zen/develop21

Fix crash on taming rare creatures.
This commit is contained in:
Antz 2016-03-17 14:18:18 +00:00
commit f05f21a631
2 changed files with 11 additions and 9 deletions

View File

@ -218,14 +218,16 @@ void Creature::RemoveFromWorld()
Unit::RemoveFromWorld();
}
void Creature::RemoveCorpse()
void Creature::RemoveCorpse(bool inPlace)
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
if (uint16 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetGUIDLow()))
{ sPoolMgr.UpdatePool<Creature>(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); }
if (!IsInWorld()) // can be despawned by update pool
{ return; }
if (!inPlace)
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
if (uint16 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetGUIDLow()))
{ sPoolMgr.UpdatePool<Creature>(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); }
if (!IsInWorld()) // can be despawned by update pool
{ return; }
}
if ((GetDeathState() != CORPSE && !m_IsDeadByDefault) || (GetDeathState() != ALIVE && m_IsDeadByDefault))
{ return; }
@ -1711,7 +1713,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn)
if (IsAlive())
{ SetDeathState(JUST_DIED); }
RemoveCorpse();
RemoveCorpse(true); // force corpse removal in the same grid
SetHealth(0); // just for nice GM-mode view
}

View File

@ -736,7 +736,7 @@ class Creature : public Unit
bool IsVisibleInGridForPlayer(Player* pl) const override;
void RemoveCorpse();
void RemoveCorpse(bool inPlace = false);
bool IsDeadByDefault() const { return m_IsDeadByDefault; };
void ForcedDespawn(uint32 timeMSToDespawn = 0);