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

Port From (https://github.com/TrinityCore/TrinityCore/commit/5886bf7484f26deb0e26d3a14791041cc14266be)
This commit is contained in:
hondacrx
2022-02-23 16:11:23 -05:00
parent 9fffef0388
commit 4c883cbc47
@@ -27,6 +27,7 @@ using Game.Networking.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
namespace Game.Chat namespace Game.Chat
@@ -755,6 +756,22 @@ namespace Game.Chat
return true; 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<Creature>().Count()} GameObjects: {map.GetObjectsStore().OfType<GameObject>().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)] [Command("phase", RBACPermissions.CommandDebugPhase)]
static bool HandleDebugPhaseCommand(CommandHandler handler, StringArguments args) static bool HandleDebugPhaseCommand(CommandHandler handler, StringArguments args)
{ {