aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Map.cpp16
-rw-r--r--src/game/ObjectGridLoader.cpp5
2 files changed, 16 insertions, 5 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index a3c76c59921..fbe4f32d5b1 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -331,9 +331,21 @@ void Map::RemoveFromGrid(DynamicObject* obj, NGridType *grid, Cell const& cell)
template<class T>
void Map::SwitchGridContainers(T* obj, bool on)
{
- CellPair pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- Cell cell(pair);
+ CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
+ {
+ sLog.outError("Map::SwitchGridContainers: Object " I64FMT " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
+ return;
+ }
+
+ Cell cell(p);
+ if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) )
+ return;
+
+ DEBUG_LOG("Switch object " I64FMT " from grid[%u,%u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
+ assert( ngrid != NULL );
+
GridType &grid = (*ngrid)(cell.CellX(), cell.CellY());
if(on)
diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp
index d14389725b3..d69499d8014 100644
--- a/src/game/ObjectGridLoader.cpp
+++ b/src/game/ObjectGridLoader.cpp
@@ -52,11 +52,10 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m)
// creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
- for(CreatureMapType::iterator iter=m.begin(), next; iter != m.end(); iter = next)
+ for(CreatureMapType::iterator iter = m.begin(); iter != m.end();)
{
- next = iter; ++next;
-
Creature * c = iter->getSource();
+ ++iter;
assert(!c->isPet() && "ObjectGridRespawnMover don't must be called for pets");