*Fix a crash.
--HG-- branch : trunk
This commit is contained in:
+30
-4
@@ -330,14 +330,14 @@ void Map::RemoveFromGrid(DynamicObject* obj, NGridType *grid, Cell const& cell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Map::SwitchGridContainers(T* obj, bool apply)
|
void Map::SwitchGridContainers(T* obj, bool on)
|
||||||
{
|
{
|
||||||
CellPair pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
|
CellPair pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
|
||||||
Cell cell(pair);
|
Cell cell(pair);
|
||||||
NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
|
NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
|
||||||
GridType &grid = (*ngrid)(cell.CellX(), cell.CellY());
|
GridType &grid = (*ngrid)(cell.CellX(), cell.CellY());
|
||||||
|
|
||||||
if(apply)
|
if(on)
|
||||||
{
|
{
|
||||||
if(!grid.RemoveGridObject<T>(obj, obj->GetGUID())
|
if(!grid.RemoveGridObject<T>(obj, obj->GetGUID())
|
||||||
|| !grid.AddWorldObject<T>(obj, obj->GetGUID()))
|
|| !grid.AddWorldObject<T>(obj, obj->GetGUID()))
|
||||||
@@ -1589,10 +1589,36 @@ void Map::AddObjectToRemoveList(WorldObject *obj)
|
|||||||
//sLog.outDebug("Object (GUID: %u TypeId: %u ) added to removing list.",obj->GetGUIDLow(),obj->GetTypeId());
|
//sLog.outDebug("Object (GUID: %u TypeId: %u ) added to removing list.",obj->GetGUIDLow(),obj->GetTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::AddObjectToSwitchList(WorldObject *obj, bool on)
|
||||||
|
{
|
||||||
|
assert(obj->GetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId());
|
||||||
|
|
||||||
|
std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);
|
||||||
|
if(itr == i_objectsToSwitch.end())
|
||||||
|
i_objectsToSwitch.insert(itr, std::make_pair(obj, on));
|
||||||
|
else if(itr->second != on)
|
||||||
|
i_objectsToSwitch.erase(itr);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
void Map::RemoveAllObjectsInRemoveList()
|
void Map::RemoveAllObjectsInRemoveList()
|
||||||
{
|
{
|
||||||
if(i_objectsToRemove.empty())
|
while(!i_objectsToSwitch.empty())
|
||||||
return;
|
{
|
||||||
|
std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.begin();
|
||||||
|
WorldObject *obj = itr->first;
|
||||||
|
bool on = itr->second;
|
||||||
|
i_objectsToSwitch.erase(itr);
|
||||||
|
|
||||||
|
switch(obj->GetTypeId())
|
||||||
|
{
|
||||||
|
case TYPEID_UNIT:
|
||||||
|
if(!((Creature*)obj)->isPet())
|
||||||
|
SwitchGridContainers((Creature*)obj, on);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//sLog.outDebug("Object remover 1 check.");
|
//sLog.outDebug("Object remover 1 check.");
|
||||||
while(!i_objectsToRemove.empty())
|
while(!i_objectsToRemove.empty())
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
|||||||
bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); }
|
bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); }
|
||||||
|
|
||||||
void AddObjectToRemoveList(WorldObject *obj);
|
void AddObjectToRemoveList(WorldObject *obj);
|
||||||
|
void AddObjectToSwitchList(WorldObject *obj, bool on);
|
||||||
void DoDelayedMovesAndRemoves();
|
void DoDelayedMovesAndRemoves();
|
||||||
|
|
||||||
virtual bool RemoveBones(uint64 guid, float x, float y);
|
virtual bool RemoveBones(uint64 guid, float x, float y);
|
||||||
@@ -343,6 +344,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
|||||||
bool i_lock;
|
bool i_lock;
|
||||||
std::vector<uint64> i_unitsToNotify;
|
std::vector<uint64> i_unitsToNotify;
|
||||||
std::set<WorldObject *> i_objectsToRemove;
|
std::set<WorldObject *> i_objectsToRemove;
|
||||||
|
std::map<WorldObject*, bool> i_objectsToSwitch;
|
||||||
|
|
||||||
// Type specific code for add/remove to/from grid
|
// Type specific code for add/remove to/from grid
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
+1
-9
@@ -1075,15 +1075,7 @@ void WorldObject::SetWorldObject(bool on)
|
|||||||
if(!IsInWorld())
|
if(!IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(GetTypeId() == TYPEID_UNIT)
|
GetMap()->AddObjectToSwitchList(this, on);
|
||||||
{
|
|
||||||
if(!((Creature*)this)->isPet())
|
|
||||||
GetMap()->SwitchGridContainers((Creature*)this, on);
|
|
||||||
}
|
|
||||||
/*else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
|
|
||||||
{
|
|
||||||
GetMap()->SwitchGridContainers((DynamicObject*)this, on);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObject::setActive( bool on )
|
void WorldObject::setActive( bool on )
|
||||||
|
|||||||
Reference in New Issue
Block a user