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 6f6cec89e5)
This commit is contained in:
jackpoz
2020-09-26 16:23:26 +02:00
committed by Shauren
parent f3787c6559
commit e7fc68d74b

View File

@@ -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;
}