From a8cf3dd638fc1aecaafaf3ec39cff11d3300ab93 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Tue, 6 Feb 2024 17:24:49 -0600 Subject: [PATCH] Fix Visual Studio crashes related to nans and uninitialized variables. Specifically, this fixes a crash when exploding the gas tank in the inner yard in Chapter 5. --- NOLF2/ClientShellDLL/ClientShellShared/ExplosionFX.cpp | 2 +- NOLF2/ClientShellDLL/ClientShellShared/SFXMgr.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NOLF2/ClientShellDLL/ClientShellShared/ExplosionFX.cpp b/NOLF2/ClientShellDLL/ClientShellShared/ExplosionFX.cpp index 24f6068c..d8ba48c3 100644 --- a/NOLF2/ClientShellDLL/ClientShellShared/ExplosionFX.cpp +++ b/NOLF2/ClientShellDLL/ClientShellShared/ExplosionFX.cpp @@ -82,7 +82,7 @@ LTBOOL CExplosionFX::CreateObject(ILTClient *pClientDE) // Determine what container we're in... - ContainerCode eCode; + ContainerCode eCode = CC_NO_CONTAINER; HLOCALOBJ objList[1]; LTVector vTestPos = m_cs.vPos; uint32 dwNum = ::GetPointContainers(vTestPos, objList, 1, ::GetLiquidFlags()); diff --git a/NOLF2/ClientShellDLL/ClientShellShared/SFXMgr.cpp b/NOLF2/ClientShellDLL/ClientShellShared/SFXMgr.cpp index 3ca279d8..0b4ea9d5 100644 --- a/NOLF2/ClientShellDLL/ClientShellShared/SFXMgr.cpp +++ b/NOLF2/ClientShellDLL/ClientShellShared/SFXMgr.cpp @@ -278,6 +278,12 @@ void CSFXMgr::HandleSFXMsg(HLOCALOBJ hObj, ILTMessage_Read *pMsg) debris.vPos = pMsg->ReadCompPos(); debris.nDebrisId = pMsg->Readuint8(); + if (std::isnan(debris.rRot[0]) || std::isnan(debris.rRot[1]) || + std::isnan(debris.rRot[2]) || std::isnan(debris.rRot[3])) + { + debris.rRot.Identity(); + } + CreateSFX(nId, &debris); } break;