[7339] Attempt lock spawn grid only for active non-pet creatures.

This commit is contained in:
VladimirMangos 2009-02-26 01:39:45 +03:00
parent f35ffca03e
commit b4dbeb3bc8
4 changed files with 20 additions and 20 deletions

View file

@ -463,6 +463,7 @@ Map::Add(T *obj)
AddToGrid(obj,grid,cell); AddToGrid(obj,grid,cell);
obj->AddToWorld(); obj->AddToWorld();
if(obj->isActiveObject())
AddToActive(obj); AddToActive(obj);
DEBUG_LOG("Object %u enters grid[%u,%u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); DEBUG_LOG("Object %u enters grid[%u,%u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY());
@ -762,6 +763,7 @@ Map::Remove(T *obj, bool remove)
NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
assert( grid != NULL ); assert( grid != NULL );
if(obj->isActiveObject())
RemoveFromActive(obj); RemoveFromActive(obj);
obj->RemoveFromWorld(); obj->RemoveFromWorld();
@ -1623,7 +1625,7 @@ void Map::AddToActive( Creature* c )
AddToActiveHelper(c); AddToActiveHelper(c);
// also not allow unloading spawn grid to prevent creating creature clone at load // also not allow unloading spawn grid to prevent creating creature clone at load
if(c->GetDBTableGUIDLow()) if(!c->isPet() && c->GetDBTableGUIDLow())
{ {
float x,y,z; float x,y,z;
c->GetRespawnCoord(x,y,z); c->GetRespawnCoord(x,y,z);
@ -1644,7 +1646,7 @@ void Map::RemoveFromActive( Creature* c )
RemoveFromActiveHelper(c); RemoveFromActiveHelper(c);
// also allow unloading spawn grid // also allow unloading spawn grid
if(c->GetDBTableGUIDLow()) if(!c->isPet() && c->GetDBTableGUIDLow())
{ {
float x,y,z; float x,y,z;
c->GetRespawnCoord(x,y,z); c->GetRespawnCoord(x,y,z);

View file

@ -358,14 +358,11 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
template<class T> template<class T>
void AddToActiveHelper(T* obj) void AddToActiveHelper(T* obj)
{ {
if(obj->isActiveObject())
m_activeNonPlayers.insert(obj); m_activeNonPlayers.insert(obj);
} }
template<class T> template<class T>
void RemoveFromActiveHelper(T* obj) void RemoveFromActiveHelper(T* obj)
{
if(obj->isActiveObject())
{ {
// Map::Update for active object in proccess // Map::Update for active object in proccess
if(m_activeNonPlayersIter != m_activeNonPlayers.end()) if(m_activeNonPlayersIter != m_activeNonPlayers.end())
@ -378,7 +375,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
else else
m_activeNonPlayers.erase(obj); m_activeNonPlayers.erase(obj);
} }
}
}; };
enum InstanceResetMethod enum InstanceResetMethod

View file

@ -125,6 +125,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &
addUnitState(obj,cell); addUnitState(obj,cell);
obj->AddToWorld(); obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj); map->AddToActive(obj);
++count; ++count;
@ -152,6 +153,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
addUnitState(obj,cell); addUnitState(obj,cell);
obj->AddToWorld(); obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj); map->AddToActive(obj);
++count; ++count;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7338" #define REVISION_NR "7339"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__