Skip to content

Commit

Permalink
client: render: fix wrong checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Oct 31, 2023
1 parent f950005 commit ecc40af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/render/gl_deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 15 additions & 5 deletions client/render/gl_grass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1128,7 +1135,9 @@ byte R_GrassTextureForName( const char *name )
grasstexs[i].gl_texturenum = tr.defaultTexture;
}

return i;
end:
*tex = (byte)i;
return 0;
}

/*
Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion client/render/gl_lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
}
Expand Down Expand Up @@ -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 );
}
}
2 changes: 1 addition & 1 deletion client/render/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ typedef struct
CUtlArray<gl_state_t> 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;
Expand Down

0 comments on commit ecc40af

Please sign in to comment.