- don't access invalid sector in DrawView.

Old bug exposed by having operator[] assert on bad access to sector[].
This commit is contained in:
Christoph Oelckers 2021-11-30 21:29:43 +01:00
parent aee560624d
commit 7b84a1464c

View file

@ -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,11 +306,14 @@ void DrawView(double smoothRatio, bool sceneonly)
}
}
}
auto pSector = &sector[nSector];
nCamerax = playerX;
nCameray = playerY;
nCameraz = playerZ;
if (nSector != -1)
{
auto pSector = &sector[nSector];
int Z = pSector->ceilingz + 256;
if (Z <= viewz)
{
@ -321,6 +325,7 @@ void DrawView(double smoothRatio, bool sceneonly)
else {
viewz = Z;
}
}
nCamerapan = pan;