diff options
author | megamage <none@none> | 2009-08-14 14:09:57 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-14 14:09:57 -0500 |
commit | b3c9916177064f968b43a4caa17e13a2489d7284 (patch) | |
tree | 4eef5449a274000d0399741456b64d4129ab474a /src | |
parent | ce21d65aa29e96da160998750da96cba69eefb57 (diff) |
*Fix the crash caused by map::removing does not really resetmap
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Map.cpp | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 1d6f1d2b5da..3e658361145 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -733,36 +733,27 @@ void Map::Update(const uint32 &t_diff) void Map::Remove(Player *player, bool remove) { + player->RemoveFromWorld(); + SendRemoveTransports(player); + CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) - { sLog.outCrash("Map::Remove: Player is in invalid cell!"); - // invalid coordinates - player->RemoveFromWorld(); - - if( remove ) - DeleteFromWorld(player); - - return; - } - - Cell cell(p); - - if( !getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y) ) + else { - sLog.outError("Map::Remove() i_grids was NULL x:%d, y:%d",cell.data.Part.grid_x,cell.data.Part.grid_y); - return; - } - - DEBUG_LOG("Remove player %s from grid[%u,%u]", player->GetName(), cell.GridX(), cell.GridY()); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - assert(grid != NULL); - - player->RemoveFromWorld(); - RemoveFromGrid(player,grid,cell); + Cell cell(p); + if( !getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y) ) + sLog.outError("Map::Remove() i_grids was NULL x:%d, y:%d",cell.data.Part.grid_x,cell.data.Part.grid_y); + else + { + DEBUG_LOG("Remove player %s from grid[%u,%u]", player->GetName(), cell.GridX(), cell.GridY()); + NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); + assert(grid != NULL); - SendRemoveTransports(player); - UpdateObjectVisibility(player,cell,p); + RemoveFromGrid(player,grid,cell); + UpdateObjectVisibility(player,cell,p); + } + } if( remove ) DeleteFromWorld(player); @@ -785,29 +776,29 @@ template<class T> void Map::Remove(T *obj, bool remove) { - 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::Remove: 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("Remove object " I64FMT " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - assert( grid != NULL ); - obj->RemoveFromWorld(); if(obj->isActiveObject()) RemoveFromActive(obj); - RemoveFromGrid(obj,grid,cell); - UpdateObjectVisibility(obj,cell,p); + 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::Remove: 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); + else + { + Cell cell(p); + if(loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) + { + DEBUG_LOG("Remove object " I64FMT " from grid[%u,%u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y); + NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); + assert( grid != NULL ); + + RemoveFromGrid(obj,grid,cell); + UpdateObjectVisibility(obj,cell,p); + } + } obj->ResetMap(); + if( remove ) { // if option set then object already saved at this moment |