Scripts/Commands: Add .debug objectcount <optional map id> chat command

Add .debug objectcount <optional map id> chat command to show the number of Creatures and GameObjects

(cherry picked from commit cd37a17103b88a56ec1fde2156c4325b74989e08)
This commit is contained in:
jackpoz
2022-01-06 20:49:28 +01:00
committed by Shauren
parent 1fc9e0172d
commit 5886bf7484
2 changed files with 40 additions and 0 deletions
+34
View File
@@ -132,6 +132,7 @@ public:
{ "dummy", rbac::RBAC_PERM_COMMAND_DEBUG_DUMMY, false, &HandleDebugDummyCommand, "" },
{ "asan", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, nullptr, "", debugAsanCommandTable },
{ "guidlimits", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugGuidLimitsCommand, "" },
{ "objectcount", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugObjectCountCommand, "" },
{ "questreset", rbac::RBAC_PERM_COMMAND_DEBUG_QUESTRESET, true, &HandleDebugQuestResetCommand, "" }
};
static std::vector<ChatCommand> commandTable =
@@ -1847,6 +1848,39 @@ public:
map->GetId(), map->GetMapName(), map->GetInstanceId(), uint64(map->GenerateLowGuid<HighGuid::Creature>()), uint64(map->GetMaxLowGuid<HighGuid::GameObject>()));
}
static bool HandleDebugObjectCountCommand(ChatHandler* handler, CommandArgs* args)
{
auto mapId = args->TryConsume<uint32>();
if (mapId)
{
sMapMgr->DoForAllMapsWithMapId(mapId.get(),
[handler](Map* map) -> void
{
HandleDebugObjectCountMap(handler, map);
}
);
}
else
{
sMapMgr->DoForAllMaps(
[handler](Map* map) -> void
{
HandleDebugObjectCountMap(handler, map);
}
);
}
return true;
}
static void HandleDebugObjectCountMap(ChatHandler* handler, Map* map)
{
handler->PSendSysMessage("Map Id: %u Name: '%s' Instance Id: %u Creatures: " UI64FMTD " GameObjects: " UI64FMTD,
map->GetId(), map->GetMapName(), map->GetInstanceId(),
uint64(map->GetObjectsStore().Size<Creature>()),
uint64(map->GetObjectsStore().Size<GameObject>()));
}
static bool HandleDebugDummyCommand(ChatHandler* handler, CommandArgs* /*args*/)
{
handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing.");