From 5886bf7484f26deb0e26d3a14791041cc14266be Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 14 Jun 2020 15:41:01 +0200 Subject: Scripts/Commands: Add .debug objectcount chat command Add .debug objectcount chat command to show the number of Creatures and GameObjects (cherry picked from commit cd37a17103b88a56ec1fde2156c4325b74989e08) --- src/server/scripts/Commands/cs_debug.cpp | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index e66fbe3e573..3ff8463ce56 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -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 commandTable = @@ -1847,6 +1848,39 @@ public: map->GetId(), map->GetMapName(), map->GetInstanceId(), uint64(map->GenerateLowGuid()), uint64(map->GetMaxLowGuid())); } + static bool HandleDebugObjectCountCommand(ChatHandler* handler, CommandArgs* args) + { + auto mapId = args->TryConsume(); + 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()), + uint64(map->GetObjectsStore().Size())); + } + 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."); -- cgit v1.2.3