From 7b84a1464cffef84645c1ceec56e438b1f9d142e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 30 Nov 2021 21:29:43 +0100 Subject: [PATCH] - don't access invalid sector in DrawView. Old bug exposed by having operator[] assert on bad access to sector[]. --- source/games/exhumed/src/view.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index b38ac6fee..a71d9000d 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -251,6 +251,7 @@ void DrawView(double smoothRatio, bool sceneonly) nSector = PlayerList[nLocalPlayer].nPlayerViewSect; updatesector(playerX, playerY, &nSector); + if (nSector == -1) PlayerList[nLocalPlayer].nPlayerViewSect; if (!SyncInput()) { @@ -305,21 +306,25 @@ void DrawView(double smoothRatio, bool sceneonly) } } } - auto pSector = §or[nSector]; nCamerax = playerX; nCameray = playerY; nCameraz = playerZ; - int Z = pSector->ceilingz + 256; - if (Z <= viewz) + if (nSector != -1) { - Z = pSector->floorz - 256; + auto pSector = §or[nSector]; - if (Z < viewz) + int Z = pSector->ceilingz + 256; + if (Z <= viewz) + { + Z = pSector->floorz - 256; + + if (Z < viewz) + viewz = Z; + } + else { viewz = Z; - } - else { - viewz = Z; + } } nCamerapan = pan;