From e1d1157f87cb96925be9727f635461973c8fbe57 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 7 Dec 2021 20:20:39 -0500 Subject: [PATCH] Core/GameObjects: Validate rotation quaternion at startup Port From (https://github.com/TrinityCore/TrinityCore/commit/9005bdc684eb37718371f921bd570692375a6c7a) --- Source/Game/Globals/ObjectManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index d30a9830e..13eef2715 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -4214,6 +4214,12 @@ namespace Game continue; } + if (!(Math.Abs(Quaternion.Dot(data.rotation, data.rotation) - 1) < 1e-5)) + { + Log.outError(LogFilter.Sql, $"Table `gameobject` has gameobject (GUID: {guid} Entry: {data.Id}) with invalid rotation quaternion (non-unit), defaulting to orientation on Z axis only"); + data.rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(data.spawnPoint.GetOrientation(), 0f, 0f)); + } + if (WorldConfig.GetBoolValue(WorldCfg.CalculateGameobjectZoneAreaData)) { PhasingHandler.InitDbVisibleMapId(phaseShift, data.terrainSwapMap);