From 442abe3ee312a9603169be3121da736512842933 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:02:37 +0100 Subject: [PATCH 1/3] [rend2] Fix out-of-bounds crash with weather Thanks @kuvirah for this fix. --- shared/rd-rend2/tr_weather.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared/rd-rend2/tr_weather.cpp b/shared/rd-rend2/tr_weather.cpp index a9d15767d2..02058c1914 100644 --- a/shared/rd-rend2/tr_weather.cpp +++ b/shared/rd-rend2/tr_weather.cpp @@ -1153,6 +1153,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 += 9; + } + VectorSet2( zoneOffsets[chunkIndex], x, From 9a61f07f2763612c33d5948d13fb32344a66c6dc Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 2 Mar 2024 09:52:29 +0100 Subject: [PATCH 2/3] [rend2] Fix sprites related compiler warning rd-rend2/tr_bsp.cpp:4020:25: warning: comparison between NULL and non-pointer ('GLuint' (aka 'unsigned int') and NULL) [-Wnull-arithmetic] Thanks to @ensiform for reporing --- shared/rd-rend2/tr_bsp.cpp | 2 +- shared/rd-rend2/tr_shader.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/rd-rend2/tr_bsp.cpp b/shared/rd-rend2/tr_bsp.cpp index ded23514c8..7cb1d9dc35 100644 --- a/shared/rd-rend2/tr_bsp.cpp +++ b/shared/rd-rend2/tr_bsp.cpp @@ -4024,7 +4024,7 @@ static void R_GenerateSurfaceSprites( const world_t *world, int worldIndex ) for (int i = 0; i < tr.numShaders; i++) { const shader_t *shader = tr.shaders[i]; - if (shader->spriteUbo != NULL) + if (shader->spriteUbo != -1) continue; numSpriteStages += shader->numSurfaceSpriteStages; diff --git a/shared/rd-rend2/tr_shader.cpp b/shared/rd-rend2/tr_shader.cpp index 68e7a9df58..2429d28c73 100644 --- a/shared/rd-rend2/tr_shader.cpp +++ b/shared/rd-rend2/tr_shader.cpp @@ -3802,6 +3802,7 @@ static shader_t *GeneratePermanentShader( void ) { } RB_AddShaderToShaderInstanceUBO(newShader); + newShader->spriteUbo = -1; SortNewShader(); From 857fda5da2eaa376e8f265b66d3b1f37f69b6081 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:26:51 +0100 Subject: [PATCH 3/3] [rend2] Reset output in R_LoadHDRImage Fixes https://github.com/SomaZ/OpenJK/issues/59 --- shared/rd-rend2/tr_image_stb.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared/rd-rend2/tr_image_stb.cpp b/shared/rd-rend2/tr_image_stb.cpp index 5a95a28278..60b241a8b8 100644 --- a/shared/rd-rend2/tr_image_stb.cpp +++ b/shared/rd-rend2/tr_image_stb.cpp @@ -66,6 +66,11 @@ void R_LoadHDRImage( const char *filename, byte **data, int *width, int *height int len = ri.FS_ReadFile (filename, (void **)&buf); if ( len <= 0 || buf == NULL ) { + // reset output varialbes + *data = NULL; + *width = 0; + *height = 0; + return; } stbi_set_flip_vertically_on_load(0);