*Only use m_isWorldObject to check if an object is in grid or world.
--HG-- branch : trunk
This commit is contained in:
+8
-3
@@ -29,6 +29,7 @@
|
||||
#include "World.h"
|
||||
|
||||
Corpse::Corpse(CorpseType type) : WorldObject()
|
||||
, m_type(type)
|
||||
{
|
||||
m_objectType |= TYPEMASK_CORPSE;
|
||||
m_objectTypeId = TYPEID_CORPSE;
|
||||
@@ -37,13 +38,14 @@ Corpse::Corpse(CorpseType type) : WorldObject()
|
||||
|
||||
m_valuesCount = CORPSE_END;
|
||||
|
||||
m_type = type;
|
||||
|
||||
m_mapId = 0;
|
||||
|
||||
m_time = time(NULL);
|
||||
|
||||
lootForBody = false;
|
||||
|
||||
if(type != CORPSE_BONES)
|
||||
m_isWorldObject = true;
|
||||
}
|
||||
|
||||
Corpse::~Corpse()
|
||||
@@ -203,7 +205,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
SetInstanceId(fields[8].GetUInt32());
|
||||
|
||||
m_time = time_t(fields[6].GetUInt64());
|
||||
m_type = CorpseType(fields[7].GetUInt32());
|
||||
const_cast<CorpseType>(m_type) = CorpseType(fields[7].GetUInt32());
|
||||
|
||||
if(m_type >= MAX_CORPSE_TYPE)
|
||||
{
|
||||
@@ -211,6 +213,9 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_type != CORPSE_BONES)
|
||||
m_isWorldObject = true;
|
||||
|
||||
uint32 phaseMask = fields[9].GetUInt32();
|
||||
|
||||
// overwrite possible wrong/corrupted guid
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ class Corpse : public WorldObject
|
||||
private:
|
||||
GridReference<Corpse> m_gridRef;
|
||||
|
||||
CorpseType m_type;
|
||||
const CorpseType m_type;
|
||||
time_t m_time;
|
||||
GridPair m_grid; // gride for corpse position for fast search
|
||||
uint32 m_mapId; // map id for fast corpse check at packet requests and in other situations with unloaded map of corpse.
|
||||
|
||||
@@ -509,7 +509,6 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
bool isHunterPet() const{ return m_summonMask & SUMMON_MASK_HUNTER_PET; }
|
||||
bool isVehicle() const { return m_summonMask & SUMMON_MASK_VEHICLE; }
|
||||
bool isTotem() const { return m_summonMask & SUMMON_MASK_TOTEM; }
|
||||
bool isWorldCreature() const { return m_summonMask & SUMMON_MASK_PET; }
|
||||
|
||||
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
||||
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
|
||||
|
||||
@@ -100,6 +100,9 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
|
||||
m_effIndex = effIndex;
|
||||
m_spellId = spellId;
|
||||
m_updateTimer = 0;
|
||||
|
||||
if(m_effIndex == 4)
|
||||
m_isWorldObject = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+13
-87
@@ -221,106 +221,32 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
|
||||
template<class T>
|
||||
void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::AddToGrid(Player* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::AddToGrid(Corpse *obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
// add to world object registry in grid
|
||||
if(obj->GetType()!=CORPSE_BONES)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID());
|
||||
}
|
||||
// add to grid object store
|
||||
if(obj->m_isWorldObject)
|
||||
(*grid)(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj, obj->GetGUID());
|
||||
else
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID());
|
||||
}
|
||||
(*grid)(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
// add to world object registry in grid
|
||||
if(obj->isWorldCreature() || obj->IsTempWorldObject)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject<Creature>(obj, obj->GetGUID());
|
||||
}
|
||||
// add to grid object store
|
||||
if(obj->m_isWorldObject)
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID());
|
||||
else
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddGridObject<Creature>(obj, obj->GetGUID());
|
||||
}
|
||||
obj->SetCurrentCell(cell);
|
||||
}
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID());
|
||||
|
||||
template<>
|
||||
void Map::AddToGrid(DynamicObject* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
if(obj->isActiveObject()) // only farsight
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject<DynamicObject>(obj, obj->GetGUID());
|
||||
else
|
||||
(*grid)(cell.CellX(), cell.CellY()).AddGridObject<DynamicObject>(obj, obj->GetGUID());
|
||||
obj->SetCurrentCell(cell);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
if(obj->m_isWorldObject)
|
||||
(*grid)(cell.CellX(), cell.CellY()).template RemoveWorldObject<T>(obj, obj->GetGUID());
|
||||
else
|
||||
(*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject<T>(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::RemoveFromGrid(Player* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::RemoveFromGrid(Corpse *obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
// remove from world object registry in grid
|
||||
if(obj->GetType()!=CORPSE_BONES)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID());
|
||||
}
|
||||
// remove from grid object store
|
||||
else
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
// remove from world object registry in grid
|
||||
if(obj->isWorldCreature() || obj->IsTempWorldObject)
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject<Creature>(obj, obj->GetGUID());
|
||||
}
|
||||
// remove from grid object store
|
||||
else
|
||||
{
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveGridObject<Creature>(obj, obj->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void Map::RemoveFromGrid(DynamicObject* obj, NGridType *grid, Cell const& cell)
|
||||
{
|
||||
if(obj->isActiveObject()) // only farsight
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject<DynamicObject>(obj, obj->GetGUID());
|
||||
else
|
||||
(*grid)(cell.CellX(), cell.CellY()).RemoveGridObject<DynamicObject>(obj, obj->GetGUID());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Map::SwitchGridContainers(T* obj, bool on)
|
||||
{
|
||||
@@ -361,11 +287,11 @@ void Map::SwitchGridContainers(T* obj, bool on)
|
||||
assert(false);
|
||||
}*/
|
||||
}
|
||||
obj->IsTempWorldObject = on;
|
||||
obj->m_isWorldObject = on;
|
||||
}
|
||||
|
||||
template void Map::SwitchGridContainers(Creature *, bool);
|
||||
template void Map::SwitchGridContainers(DynamicObject *, bool);
|
||||
//template void Map::SwitchGridContainers(DynamicObject *, bool);
|
||||
|
||||
template<class T>
|
||||
void Map::DeleteFromWorld(T* obj)
|
||||
@@ -2223,7 +2149,7 @@ void Map::RemoveAllObjectsInRemoveList()
|
||||
switch(obj->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if(!((Creature*)obj)->isWorldCreature())
|
||||
if(!((Creature*)obj)->isPet())
|
||||
SwitchGridContainers((Creature*)obj, on);
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1069,7 +1069,7 @@ WorldObject::WorldObject()
|
||||
: m_phaseMask(PHASEMASK_NORMAL),
|
||||
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f), m_currMap(NULL)
|
||||
, m_zoneScript(NULL)
|
||||
, m_isActive(false), IsTempWorldObject(false)
|
||||
, m_isActive(false), m_isWorldObject(false)
|
||||
, m_name("")
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -557,7 +557,6 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
template<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
|
||||
template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
|
||||
template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
|
||||
bool IsTempWorldObject;
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
int32 irand(int32 min, int32 max) const { return int32 (GetMap()->mtRand.randInt(max - min)) + min; }
|
||||
@@ -567,6 +566,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
double rand_chance() const { return GetMap()->mtRand.randExc(100.0);}
|
||||
#endif
|
||||
|
||||
bool m_isWorldObject;
|
||||
protected:
|
||||
explicit WorldObject();
|
||||
std::string m_name;
|
||||
|
||||
@@ -58,6 +58,8 @@ m_declinedname(NULL), m_owner(owner)
|
||||
|
||||
m_name = "Pet";
|
||||
m_regenTimer = 4000;
|
||||
|
||||
m_isWorldObject = true;
|
||||
}
|
||||
|
||||
Pet::~Pet()
|
||||
|
||||
@@ -472,6 +472,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
||||
m_lastFallZ = 0;
|
||||
|
||||
m_ControlledByPlayer = true;
|
||||
m_isWorldObject = true;
|
||||
|
||||
sWorld.IncreasePlayerCount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user