From e165f6dbe6621475e0ab1956ede8d9629ef71256 Mon Sep 17 00:00:00 2001 From: TEDERIs Date: Tue, 23 Sep 2025 14:20:02 +0700 Subject: [PATCH 1/3] Crashfix --- Client/game_sa/CWorldSA.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CWorldSA.cpp b/Client/game_sa/CWorldSA.cpp index b7e6828d1cb..30139efa97d 100644 --- a/Client/game_sa/CWorldSA.cpp +++ b/Client/game_sa/CWorldSA.cpp @@ -275,7 +275,13 @@ auto CWorldSA::ProcessLineAgainstMesh(CEntitySAInterface* targetEntity, CVector } // Get matrix, and it's inverse - c.entity->matrix->ConvertToMatrix(c.entMat); + if (c.entity->matrix) + c.entity->matrix->ConvertToMatrix(c.entMat); + else + { + c.entMat.SetPosition(c.entity->m_transform.m_translate); + c.entMat.SetRotation(CVector{0.0f, 0.0f, c.entity->m_transform.m_heading}); + } c.entInvMat = c.entMat.Inverse(); // ...to transform the line origin and end into object space From f5ff12d15db8b5ee0887e7c75df1f1a074b0424e Mon Sep 17 00:00:00 2001 From: TEDERIs Date: Wed, 24 Sep 2025 09:48:59 +0700 Subject: [PATCH 2/3] Fix testSphereAgainstWorld as well --- Client/game_sa/CWorldSA.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Client/game_sa/CWorldSA.cpp b/Client/game_sa/CWorldSA.cpp index 30139efa97d..10e81119845 100644 --- a/Client/game_sa/CWorldSA.cpp +++ b/Client/game_sa/CWorldSA.cpp @@ -539,9 +539,18 @@ CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float rad return nullptr; result.collisionDetected = true; - result.modelID = entity->m_nModelIndex; - result.entityPosition = entity->matrix->vPos; - ConvertMatrixToEulerAngles(*entity->matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ); + result.modelID = entity->m_nModelIndex; + if (entity->matrix) + { + result.entityPosition = entity->matrix->vPos; + ConvertMatrixToEulerAngles(*entity->matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ); + } + else + { + result.entityPosition = entity->m_transform.m_translate; + result.entityRotation.fX = result.entityRotation.fY = 0.0f; + result.entityRotation.fZ = entity->m_transform.m_heading; + } result.entityRotation = -result.entityRotation; result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0; result.type = static_cast(entity->nType); From d8eb6964e214bcfa0342a731b5e79e81674cb1c7 Mon Sep 17 00:00:00 2001 From: TEDERIs Date: Wed, 24 Sep 2025 10:28:07 +0700 Subject: [PATCH 3/3] Return result in degrees --- Client/game_sa/CWorldSA.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CWorldSA.cpp b/Client/game_sa/CWorldSA.cpp index 10e81119845..175ccc5dcc0 100644 --- a/Client/game_sa/CWorldSA.cpp +++ b/Client/game_sa/CWorldSA.cpp @@ -10,6 +10,7 @@ *****************************************************************************/ #include "StdInc.h" +#include #include #include #include "CGameSA.h" @@ -549,7 +550,7 @@ CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float rad { result.entityPosition = entity->m_transform.m_translate; result.entityRotation.fX = result.entityRotation.fY = 0.0f; - result.entityRotation.fZ = entity->m_transform.m_heading; + result.entityRotation.fZ = entity->m_transform.m_heading * (180.0f/std::numbers::pi); } result.entityRotation = -result.entityRotation; result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0;