diff options
author | jackpoz <giacomopoz@gmail.com> | 2020-09-26 16:23:26 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2020-09-26 16:23:26 +0200 |
commit | 6f6cec89e598a046e73d48df14be26b053875470 (patch) | |
tree | 20d4c85c94a6e7461441025124893a3025092b69 /src | |
parent | 34af088c9b381db5b5212075f0df486a8593fae3 (diff) |
Core/Commands: Enable .debug loadcells on console and allow to load a specific tile
Specify the tile as XY. Note that this is not Grid XY
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index f92705ac92e..c15a437683e 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -109,7 +109,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 }, { "boundary", HandleDebugBoundaryCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "raidreset", HandleDebugRaidResetCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, { "neargraveyard", HandleDebugNearGraveyard, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No }, @@ -1340,22 +1340,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>()); + } - handler->PSendSysMessage("Loading all cells (mapId: %u). Current next GameObject %u, Creature %u", map->GetId(), map->GetMaxLowGuid<HighGuid::GameObject>(), map->GetMaxLowGuid<HighGuid::Unit>()); - map->LoadAllCells(); - handler->PSendSysMessage("Cells loaded (mapId: %u) After load - Next GameObject %u, Creature %u", map->GetId(), map->GetMaxLowGuid<HighGuid::GameObject>(), map->GetMaxLowGuid<HighGuid::Unit>()); return true; } |