diff options
| author | megamage <none@none> | 2009-04-08 12:28:41 -0500 |
|---|---|---|
| committer | megamage <none@none> | 2009-04-08 12:28:41 -0500 |
| commit | 74d553bc4caad3e35922463ec9d327c7fb741496 (patch) | |
| tree | 7cfd1767e7fa09d5384a97b5feb7d0c3f59b5036 /src/game/Map.cpp | |
| parent | fc7d2a5393175c460c325f9f778a95aaf67388d3 (diff) | |
| parent | 2ebeb198add74c6d4bf73bf687e7e747355dbfe3 (diff) | |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Map.cpp')
| -rw-r--r-- | src/game/Map.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 7fa60ed8ebc..9d3db63b954 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -307,9 +307,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) |
