Skip to content

Commit 1dd147b

Browse files
authored
[rend2] fixed crash without causing clumping
See issue #1189 The game will crash, if a map features weather (e.g. vjun1) and you noclip far enough beneath the map. This was caused by an out-of-bounds exception caused by chunkIndex sometimes being negative. The code change ensures the result is always in the range [0, 2] for each axis. This makes sure chunkIndex is always in [0, 8], which is safe for zoneOffsets[9].
1 parent e934a34 commit 1dd147b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

codemp/rd-rend2/tr_weather.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,8 @@ void RB_SurfaceWeather( srfWeather_t *surf )
11411141
{
11421142
for (int x = -1; x <= 1; ++x, ++currentIndex)
11431143
{
1144-
chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3;
1145-
chunkIndex += (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3;
1144+
chunkIndex = ((int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3 + 3) % 3;
1145+
chunkIndex += (((int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 + 3) % 3) * 3;
11461146
VectorSet2(
11471147
zoneOffsets[chunkIndex],
11481148
x,

0 commit comments

Comments
 (0)