Skip to content

Commit

Permalink
[7339] Attempt lock spawn grid only for active non-pet creatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Feb 25, 2009
1 parent e6d7b49 commit 2bc86af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/game/Map.cpp
Expand Up @@ -463,7 +463,8 @@ Map::Add(T *obj)
AddToGrid(obj,grid,cell);
obj->AddToWorld();

AddToActive(obj);
if(obj->isActiveObject())
AddToActive(obj);

DEBUG_LOG("Object %u enters grid[%u,%u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY());

Expand Down Expand Up @@ -762,7 +763,8 @@ Map::Remove(T *obj, bool remove)
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
assert( grid != NULL );

RemoveFromActive(obj);
if(obj->isActiveObject())
RemoveFromActive(obj);

obj->RemoveFromWorld();
RemoveFromGrid(obj,grid,cell);
Expand Down Expand Up @@ -1623,7 +1625,7 @@ void Map::AddToActive( Creature* c )
AddToActiveHelper(c);

// 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;
c->GetRespawnCoord(x,y,z);
Expand All @@ -1644,7 +1646,7 @@ void Map::RemoveFromActive( Creature* c )
RemoveFromActiveHelper(c);

// also allow unloading spawn grid
if(c->GetDBTableGUIDLow())
if(!c->isPet() && c->GetDBTableGUIDLow())
{
float x,y,z;
c->GetRespawnCoord(x,y,z);
Expand Down
22 changes: 9 additions & 13 deletions src/game/Map.h
Expand Up @@ -358,26 +358,22 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
template<class T>
void AddToActiveHelper(T* obj)
{
if(obj->isActiveObject())
m_activeNonPlayers.insert(obj);
m_activeNonPlayers.insert(obj);
}

template<class T>
void RemoveFromActiveHelper(T* obj)
{
if(obj->isActiveObject())
// Map::Update for active object in proccess
if(m_activeNonPlayersIter != m_activeNonPlayers.end())
{
// Map::Update for active object in proccess
if(m_activeNonPlayersIter != m_activeNonPlayers.end())
{
ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
if(itr==m_activeNonPlayersIter)
++m_activeNonPlayersIter;
m_activeNonPlayers.erase(itr);
}
else
m_activeNonPlayers.erase(obj);
ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
if(itr==m_activeNonPlayersIter)
++m_activeNonPlayersIter;
m_activeNonPlayers.erase(itr);
}
else
m_activeNonPlayers.erase(obj);
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/game/ObjectGridLoader.cpp
Expand Up @@ -125,7 +125,8 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &

addUnitState(obj,cell);
obj->AddToWorld();
map->AddToActive(obj);
if(obj->isActiveObject())
map->AddToActive(obj);

++count;

Expand All @@ -152,7 +153,8 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType

addUnitState(obj,cell);
obj->AddToWorld();
map->AddToActive(obj);
if(obj->isActiveObject())
map->AddToActive(obj);

++count;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7338"
#define REVISION_NR "7339"
#endif // __REVISION_NR_H__

0 comments on commit 2bc86af

Please sign in to comment.