[11819] move SetActiveObjectState to WorldObject level

This commit is contained in:
SilverIce 2011-10-13 20:08:25 +03:00
parent 012be82c86
commit df0715284f
7 changed files with 23 additions and 29 deletions

View file

@ -2403,26 +2403,6 @@ void Creature::ClearTemporaryFaction()
setFaction(GetCreatureInfo()->faction_A);
}
void Creature::SetActiveObjectState( bool on )
{
if(m_isActiveObject==on)
return;
bool world = IsInWorld();
Map* map;
if(world)
{
map = GetMap();
map->Remove(this,false);
}
m_isActiveObject = on;
if(world)
map->Add(this);
}
void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl)
{
uint32 next_resurrect = 0;

View file

@ -682,8 +682,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
void SetActiveObjectState(bool on);
void SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags = TEMPFACTION_ALL);
void ClearTemporaryFaction();
uint32 GetTemporaryFactionFlags() { return m_temporaryFactionFlags; }

View file

@ -1081,9 +1081,11 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
void Map::AddToActive( WorldObject* obj )
{
m_activeNonPlayers.insert(obj);
Cell cell = Cell(MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
EnsureGridLoaded(cell);
// also not allow unloading spawn grid to prevent creating creature clone at load
if (obj->GetTypeId()==TYPEID_UNIT)
if (obj->GetTypeId() == TYPEID_UNIT)
{
Creature* c= (Creature*)obj;

View file

@ -1878,4 +1878,19 @@ bool WorldObject::PrintCoordinatesError(float x, float y, float z, char const* d
{
sLog.outError("%s with invalid %s coordinates: mapid = %uu, x = %f, y = %f, z = %f", GetGuidStr().c_str(), descr, GetMapId(), x, y, z);
return false; // always false for continue assert fail
}
}
void WorldObject::SetActiveObjectState(bool active)
{
if (m_isActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never
return;
if (IsInWorld())
{
if (isActiveObject() && !active)
GetMap()->RemoveFromActive(this);
else if (!isActiveObject() && active)
GetMap()->AddToActive(this);
}
m_isActiveObject = active;
}

View file

@ -580,6 +580,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject = false);
bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }
void SetActiveObjectState(bool active);
ViewPoint& GetViewPoint() { return m_viewPoint; }
@ -596,7 +597,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object
std::string m_name;
bool m_isActiveObject;
private:
Map * m_currMap; //current object's Map location
@ -605,10 +605,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object
uint32 m_phaseMask; // in area phase state
Position m_position;
ViewPoint m_viewPoint;
WorldUpdateCounter m_updateTracker;
bool m_isActiveObject;
};
#endif

View file

@ -387,7 +387,7 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m
m_valuesCount = PLAYER_END;
m_isActiveObject = true; // player is always active object
SetActiveObjectState(true); // player is always active object
m_session = session;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11818"
#define REVISION_NR "11819"
#endif // __REVISION_NR_H__