*Fix a crash caused by pet.

*Make pet class derived from guardian class.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-25 21:32:34 -06:00
parent ebf53a4820
commit 1c2eab4110
11 changed files with 130 additions and 141 deletions

View File

@@ -1156,33 +1156,35 @@ void WorldObject::SetWorldObject(bool on)
void WorldObject::setActive( bool on )
{
if(m_isActive==on)
if(m_isActive == on)
return;
if(GetTypeId() == TYPEID_PLAYER)
return;
bool world = IsInWorld();
Map* map;
if(world)
{
map = GetMap();
if(GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
}
m_isActive = on;
if(world)
if(!IsInWorld())
return;
Map *map = FindMap();
if(!map)
return;
if(on)
{
if(GetTypeId() == TYPEID_UNIT)
map->AddToActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->AddToActive((DynamicObject*)this);
}
else
{
if(GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
}
}
void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask )
@@ -1767,7 +1769,7 @@ Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, flo
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
{
Pet* pet = new Pet(petType);
Pet* pet = new Pet(this, petType);
if(petType == SUMMON_PET && pet->LoadPetFromDB(this, entry))
{