From 93eabd1b4f4229da8f01ece604f457418bd23726 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 27 Jun 2023 23:35:57 +0100 Subject: [PATCH] Fix crash when clipping through into non-sector areas --- source/core/rendering/hw_entrypoint.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index 5a82bcfbe..b8ea39d58 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -176,10 +176,15 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float // Stereo mode specific viewpoint adjustment if (eye.mShiftFactor != 0) { - vp.Pos += eye.GetViewShift(vp.HWAngles); + DVector3 newpos = vp.Pos; + newpos += eye.GetViewShift(vp.HWAngles); sectortype* sect = §or[vp.SectCount]; - updatesector(DVector2(vp.Pos.X, -vp.Pos.Y), §); - vp.SectCount = sectindex(sect); + updatesector(DVector2(newpos.X, -newpos.Y), §); + if (sect != nullptr) + { + vp.Pos = newpos; + vp.SectCount = sectindex(sect); + } } di->SetupView(RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);