*First remove object from world then unregister it. This may fix some crashes.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-28 16:04:37 -06:00
parent 3c624f7c63
commit eb894f39e8
5 changed files with 15 additions and 12 deletions

View File

@@ -37,17 +37,21 @@ Vehicle::~Vehicle()
void Vehicle::AddToWorld()
{
///- Register the vehicle for guid lookup
if(!IsInWorld()) ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
if(!IsInWorld())
{
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
}
}
void Vehicle::RemoveFromWorld()
{
///- Remove the vehicle from the accessor
if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this);
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
if(IsInWorld())
{
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
}
}
void Vehicle::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState