aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-09-26 16:23:26 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-28 12:18:19 +0100
commite7fc68d74b4fe146b37d14f1b73dbbed421b9214 (patch)
tree852105b18761938cb6921a9cad8875dadd68b1e2
parentf3787c6559ba11a4910d24861b70edf4aba8a752 (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 (cherry picked from commit 6f6cec89e598a046e73d48df14be26b053875470)
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp42
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;
}