From f87f58e35f86426d5746f2990d62d28807de125d Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 20 Jan 2022 12:31:56 -0500 Subject: [PATCH] Core/Commands: Add .debug guidlimits chat command Port From (https://github.com/TrinityCore/TrinityCore/commit/e7b94603f256386eae8a9724c830d37593c0f0e1) --- Source/Game/Chat/Commands/DebugCommands.cs | 52 +++++++++++++++------- Source/Game/Maps/Map.cs | 7 ++- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index ff38d3699..909ce15ac 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -106,6 +106,28 @@ namespace Game.Chat return true; } + [Command("combat", RBACPermissions.CommandDebugCombat)] + static bool HandleDebugCombatListCommand(CommandHandler handler, StringArguments args) + { + Unit target = handler.GetSelectedUnit(); + if (!target) + target = handler.GetSession().GetPlayer(); + + handler.SendSysMessage($"Combat refs: (Combat state: {target.IsInCombat()} | Manager state: {target.GetCombatManager().HasCombat()})"); + foreach (var refe in target.GetCombatManager().GetPvPCombatRefs()) + { + Unit unit = refe.Value.GetOther(target); + handler.SendSysMessage($"[PvP] {unit.GetName()} (SpawnID {(unit.IsCreature() ? unit.ToCreature().GetSpawnId() : 0)})"); + } + foreach (var refe in target.GetCombatManager().GetPvECombatRefs()) + { + Unit unit = refe.Value.GetOther(target); + handler.SendSysMessage($"[PvE] {unit.GetName()} (SpawnID {(unit.IsCreature() ? unit.ToCreature().GetSpawnId() : 0)})"); + } + + return true; + } + [Command("conversation", RBACPermissions.CommandDebugConversation)] static bool HandleDebugConversationCommand(CommandHandler handler, StringArguments args) { @@ -443,25 +465,16 @@ namespace Game.Chat return true; } - [Command("combat", RBACPermissions.CommandDebugCombat)] - static bool HandleDebugCombatListCommand(CommandHandler handler, StringArguments args) + [Command("guidlimits", RBACPermissions.CommandDebug, true)] + static bool HandleDebugGuidLimitsCommand(CommandHandler handler, uint mapId) { - Unit target = handler.GetSelectedUnit(); - if (!target) - target = handler.GetSession().GetPlayer(); - - handler.SendSysMessage($"Combat refs: (Combat state: {target.IsInCombat()} | Manager state: {target.GetCombatManager().HasCombat()})"); - foreach (var refe in target.GetCombatManager().GetPvPCombatRefs()) - { - Unit unit = refe.Value.GetOther(target); - handler.SendSysMessage($"[PvP] {unit.GetName()} (SpawnID {(unit.IsCreature() ? unit.ToCreature().GetSpawnId() : 0)})"); - } - foreach (var refe in target.GetCombatManager().GetPvECombatRefs()) - { - Unit unit = refe.Value.GetOther(target); - handler.SendSysMessage($"[PvE] {unit.GetName()} (SpawnID {(unit.IsCreature() ? unit.ToCreature().GetSpawnId() : 0)})"); - } + if (mapId != 0) + Global.MapMgr.DoForAllMapsWithMapId(mapId, map => HandleDebugGuidLimitsMap(handler, map)); + else + Global.MapMgr.DoForAllMaps(map => HandleDebugGuidLimitsMap(handler, map)); + handler.SendSysMessage($"Guid Warn Level: {WorldConfig.GetIntValue(WorldCfg.RespawnGuidWarnLevel)}"); + handler.SendSysMessage($"Guid Alert Level: {WorldConfig.GetIntValue(WorldCfg.RespawnGuidAlertLevel)}"); return true; } @@ -1439,5 +1452,10 @@ namespace Game.Chat return true; } } + + static void HandleDebugGuidLimitsMap(CommandHandler handler, Map map) + { + handler.SendSysMessage($"Map Id: {map.GetId()} Name: '{map.GetMapName()}' Instance Id: {map.GetInstanceId()} Highest Guid Creature: {map.GenerateLowGuid(HighGuid.Creature)} GameObject: {map.GetMaxLowGuid(HighGuid.GameObject)}"); + } } } diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index cfab136ff..3ab10232c 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -4087,11 +4087,14 @@ namespace Game.Maps public ulong GenerateLowGuid(HighGuid high) { - //Cypher.Assert(!ObjectGuid.IsMapSpecific(high), "Only map specific guid can be generated in Map context"); - return GetGuidSequenceGenerator(high).Generate(); } + public ulong GetMaxLowGuid(HighGuid high) + { + return GetGuidSequenceGenerator(high).GetNextAfterMaxUsed(); + } + ObjectGuidGenerator GetGuidSequenceGenerator(HighGuid high) { if (!_guidGenerators.ContainsKey(high))