From b81f94518a76b29369881759c406877b89555cdd Mon Sep 17 00:00:00 2001 From: mittorn Date: Mon, 16 Oct 2023 16:28:17 +0300 Subject: [PATCH] ref_gl: fix out-by-one when all lightstyles are used. Also fix broken in this case in vbo after previous fix --- ref/gl/gl_rsurf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ref/gl/gl_rsurf.c b/ref/gl/gl_rsurf.c index 9a6704fd..86962757 100644 --- a/ref/gl/gl_rsurf.c +++ b/ref/gl/gl_rsurf.c @@ -1182,7 +1182,7 @@ dynamic: if( is_dynamic ) { - if(( fa->styles[maps] >= 32 || fa->styles[maps] == 0 || fa->styles[maps] == 20 ) && ( fa->dlightframe != tr.framecount )) + if(( maps < MAXLIGHTMAPS ) && ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 || fa->styles[maps] == 20 ) && ( fa->dlightframe != tr.framecount )) { byte temp[132*132*4]; mextrasurf_t *info = fa->info; @@ -2878,11 +2878,11 @@ static qboolean R_CheckLightMap( msurface_t *fa ) } // already up to date - if( !is_dynamic && ( fa->dlightframe != tr.framecount || maps == MAXLIGHTMAPS ) ) + if( !is_dynamic && ( fa->dlightframe != tr.framecount )) return false; // build lightmap - if(( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != tr.framecount )) + if(( maps < MAXLIGHTMAPS ) && ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != tr.framecount )) { byte temp[132*132*4]; int smax, tmax;