From ba87f08c37d05eac4728f023a1b8802121b9db7f Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 26 May 2022 20:20:18 -0400 Subject: [PATCH] Core/Player: Log more information when Player::StopCastingCharm() fails Port From (https://github.com/TrinityCore/TrinityCore/commit/89ea13ed46744414f74686cf2126dc637188180d) --- Source/Game/Entities/Player/Player.cs | 2 +- Source/Game/Entities/Unit/Unit.cs | 2 +- Source/Game/Entities/Vehicle.cs | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 3ef159ed6..adae983ff 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -990,7 +990,7 @@ namespace Game.Entities Log.outFatal(LogFilter.Player, "Player {0} (GUID: {1} is not able to uncharm unit (GUID: {2} Entry: {3}, Type: {4})", GetName(), GetGUID(), GetCharmedGUID(), charm.GetEntry(), charm.GetTypeId()); if (!charm.GetCharmerGUID().IsEmpty()) { - Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID()); + Log.outFatal(LogFilter.Player, $"Player::StopCastingCharm: Charmed unit has charmer {charm.GetCharmerGUID()}\nPlayer debug info: {GetDebugInfo()}\nCharm debug info: {charm.GetDebugInfo()}"); Cypher.Assert(false); } diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 999ce42bb..812368dd1 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -862,7 +862,7 @@ namespace Game.Entities public override string GetDebugInfo() { return $"{base.GetDebugInfo()}\nIsAIEnabled: {IsAIEnabled()} DeathState: {GetDeathState()} UnitMovementFlags: {GetUnitMovementFlags()} UnitMovementFlags2: {GetUnitMovementFlags2()} Class: {GetClass()}\n" + - $" {(MoveSpline != null ? MoveSpline.ToString() : "Movespline: ")}"; + $" {(MoveSpline != null ? MoveSpline.ToString() : "Movespline: \n")} GetCharmedGUID(): {GetCharmedGUID()}\nGetCharmerGUID(): {GetCharmerGUID()}\n{(GetVehicleKit() != null ? GetVehicleKit().GetDebugInfo() : "No vehicle kit")}"; } public Guardian GetGuardianPet() diff --git a/Source/Game/Entities/Vehicle.cs b/Source/Game/Entities/Vehicle.cs index f9ed2dee7..9bdbdee23 100644 --- a/Source/Game/Entities/Vehicle.cs +++ b/Source/Game/Entities/Vehicle.cs @@ -24,6 +24,7 @@ using Game.Movement; using System; using System.Collections.Generic; using System.Linq; +using System.Text; namespace Game.Entities { @@ -559,6 +560,26 @@ namespace Game.Entities return TimeSpan.FromMilliseconds(1); } + public string GetDebugInfo() + { + StringBuilder str = new StringBuilder("Vehicle seats:\n"); + foreach (var (id, seat) in Seats) + str.Append($"seat {id}: {(seat.IsEmpty() ? "empty" : seat.Passenger.Guid)}\n"); + + str.Append("Vehicle pending events:"); + + if (_pendingJoinEvents.Empty()) + str.Append(" none"); + else + { + str.Append("\n"); + foreach (var joinEvent in _pendingJoinEvents) + str.Append($"seat {joinEvent.Seat.Key}: {joinEvent.Passenger.GetGUID()}\n"); + } + + return str.ToString(); + } + public Unit GetBase() { return _me; } public VehicleRecord GetVehicleInfo() { return _vehicleInfo; } public uint GetCreatureEntry() { return _creatureEntry; }