From 4c883cbc47d97c2cf785ba70bb6053b1d121f606 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 23 Feb 2022 16:11:23 -0500 Subject: [PATCH] Scripts/Commands: Add .debug objectcount chat command Port From (https://github.com/TrinityCore/TrinityCore/commit/5886bf7484f26deb0e26d3a14791041cc14266be) --- Source/Game/Chat/Commands/DebugCommands.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index 75cd75012..6c72a6d5f 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -27,6 +27,7 @@ using Game.Networking.Packets; using Game.Spells; using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace Game.Chat @@ -754,6 +755,22 @@ namespace Game.Chat return true; } + + [Command("objectcount", RBACPermissions.CommandDebug, true)] + static bool HandleDebugObjectCountCommand(CommandHandler handler, uint? mapId) + { + void HandleDebugObjectCountMap(Map map) + { + handler.SendSysMessage($"Map Id: {map.GetId()} Name: '{map.GetMapName()}' Instance Id: {map.GetInstanceId()} Creatures: {map.GetObjectsStore().OfType().Count()} GameObjects: {map.GetObjectsStore().OfType().Count()}"); + } + + if (mapId.HasValue) + Global.MapMgr.DoForAllMapsWithMapId(mapId.Value, map => HandleDebugObjectCountMap(map)); + else + Global.MapMgr.DoForAllMaps(map => HandleDebugObjectCountMap(map)); + + return true; + } [Command("phase", RBACPermissions.CommandDebugPhase)] static bool HandleDebugPhaseCommand(CommandHandler handler, StringArguments args)