diff --git a/client/render/gl_deferred.cpp b/client/render/gl_deferred.cpp index 7abffbe35..d672a2015 100644 --- a/client/render/gl_deferred.cpp +++ b/client/render/gl_deferred.cpp @@ -554,7 +554,7 @@ void GL_SetupWorldScenePass( void ) void GL_DrawDeferredPass( void ) { - if( !tr.defSceneShader || !tr.defLightShader ) + if( !tr.defSceneShader[0] || !tr.defSceneShader[1] || !tr.defLightShader ) return; // oops! GL_DEBUG_SCOPE(); diff --git a/client/render/gl_grass.cpp b/client/render/gl_grass.cpp index 8c0af47b3..73346812f 100644 --- a/client/render/gl_grass.cpp +++ b/client/render/gl_grass.cpp @@ -1109,13 +1109,20 @@ R_GrassTextureForName find or add unique texture for grass ================ */ -byte R_GrassTextureForName( const char *name ) +int R_GrassTextureForName( const char *name, byte *tex ) { - byte i; + size_t i; + for( i = 0; i < GRASS_TEXTURES && grasstexs[i].name[0]; i++ ) { if( !Q_stricmp( grasstexs[i].name, name )) - return i; // found + goto end; // found + } + + if( i == GRASS_TEXTURES ) + { + ALERT( at_warning, "limit of grass textures was exceeded %d\n", GRASS_TEXTURES ); + return 1; } // allocate a new one @@ -1128,7 +1135,9 @@ byte R_GrassTextureForName( const char *name ) grasstexs[i].gl_texturenum = tr.defaultTexture; } - return i; +end: + *tex = (byte)i; + return 0; } /* @@ -1692,7 +1701,8 @@ void R_GrassInit( void ) continue; } - entry.texture = R_GrassTextureForName( token ); + if( R_GrassTextureForName( token, &entry.texture )) + break; pfile = COM_ParseLine( pfile, token ); if( !pfile ) diff --git a/client/render/gl_lightmap.cpp b/client/render/gl_lightmap.cpp index e123fc8f8..f7d87d021 100644 --- a/client/render/gl_lightmap.cpp +++ b/client/render/gl_lightmap.cpp @@ -129,6 +129,7 @@ static void LM_GoToNextPage( void ) if( lms->state != LM_DONE ) return; // current atlas not completed + // There may be overflow because type of current_lightmap_texture is byte(uint8_t). if( ++tr.current_lightmap_texture == MAX_LIGHTMAPS ) HOST_ERROR( "MAX_LIGHTMAPS limit exceded\n" ); } @@ -753,4 +754,4 @@ void R_UpdateSurfaceParams( mstudiosurface_t *surf ) // check for lightmap modification if( FBitSet( surf->flags, SURF_LM_UPDATE|SURF_DM_UPDATE )) R_UpdateLightMap( surf ); -} \ No newline at end of file +} diff --git a/client/render/gl_local.h b/client/render/gl_local.h index b4d76090f..5c88e3687 100644 --- a/client/render/gl_local.h +++ b/client/render/gl_local.h @@ -519,7 +519,7 @@ typedef struct CUtlArray cached_state; gl_lightmap_t lightmaps[MAX_LIGHTMAPS]; - byte current_lightmap_texture; + uint32_t current_lightmap_texture; TextureHandle packed_lights_texture; TextureHandle packed_planes_texture; TextureHandle packed_nodes_texture;