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