diff options
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 919a78ff73e..9039b1e3fbb 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -112,7 +112,7 @@ public: { "los", HandleDebugLoSCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "moveflags", HandleDebugMoveflagsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "transport", HandleDebugTransportCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, - { "loadcells", HandleDebugLoadCellsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, + { "loadcells", HandleDebugLoadCellsCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes }, { "phase", HandleDebugPhaseCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "boundary", HandleDebugBoundaryCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "raidreset", HandleDebugRaidResetCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, @@ -1197,21 +1197,45 @@ public: return true; } - static bool HandleDebugLoadCellsCommand(ChatHandler* handler, Optional<uint32> mapId) + static bool HandleDebugLoadCellsCommand(ChatHandler* handler, Optional<uint32> mapId, Optional<uint32> tileX, Optional<uint32> tileY) { - Player* player = handler->GetPlayer(); - if (!player) - return false; - Map* map = nullptr; if (mapId) + { map = sMapMgr->FindBaseNonInstanceMap(*mapId); + } + else if (Player* player = handler->GetPlayer()) + { + // Fallback to player's map if no map has been specified + map = player->GetMap(); + } if (!map) - map = player->GetMap(); + return false; + + // Load 1 single tile if specified, otherwise load the whole map + if (tileX && tileY) + { + handler->PSendSysMessage("Loading cell (mapId: %u tile: %u, %u). Current GameObjects " SZFMTD ", Creatures " SZFMTD, + map->GetId(), *tileX, *tileY, map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>()); + + // Some unit convertions to go from TileXY to GridXY to WorldXY + float x = ((float(64 - 1 - *tileX) - 0.5f - CENTER_GRID_ID) * SIZE_OF_GRIDS) + (CENTER_GRID_OFFSET * 2); + float y = ((float(64 - 1 - *tileY) - 0.5f - CENTER_GRID_ID) * SIZE_OF_GRIDS) + (CENTER_GRID_OFFSET * 2); + map->LoadGrid(x, y); + + handler->PSendSysMessage("Cell loaded (mapId: %u tile: %u, %u) After load - GameObject " SZFMTD ", Creatures " SZFMTD, + map->GetId(), *tileX, *tileY, map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>()); + } + else + { + handler->PSendSysMessage("Loading all cells (mapId: %u). Current GameObjects " SZFMTD ", Creatures " SZFMTD, map->GetId(), map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>()); + + map->LoadAllCells(); + + handler->PSendSysMessage("Cells loaded (mapId: %u) After load - GameObject " SZFMTD ", Creatures " SZFMTD, map->GetId(), map->GetObjectsStore().Size<GameObject>(), map->GetObjectsStore().Size<Creature>()); + } - map->LoadAllCells(); - handler->PSendSysMessage("Cells loaded (mapId: %u)", map->GetId()); return true; } |