From 7a3ade68063e0dd55cb68444453774f82c294c40 Mon Sep 17 00:00:00 2001 From: Syrr Date: Wed, 15 Nov 2023 21:07:10 +0100 Subject: [PATCH 1/2] fix: added small sanity check to fix out-of-bounds --- codemp/rd-rend2/tr_weather.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index f3a5620673..9f700a7f31 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -1143,6 +1143,11 @@ void RB_SurfaceWeather( srfWeather_t *surf ) { chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3; chunkIndex += (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3; + + if (chunkIndex < 0) { + chunkIndex *= -1; + } + VectorSet2( zoneOffsets[chunkIndex], x, From 258a23423cd541a7993b97444a68904c8f8e9463 Mon Sep 17 00:00:00 2001 From: Syrr Date: Fri, 24 Nov 2023 13:22:20 +0100 Subject: [PATCH 2/2] Removed simple negation and added offsetting so -7 => 2, ... --- codemp/rd-rend2/tr_weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 9f700a7f31..e3f38c3473 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -1145,7 +1145,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) chunkIndex += (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3; if (chunkIndex < 0) { - chunkIndex *= -1; + chunkIndex += 9; } VectorSet2(