Prevent lightmapIndex from going below LIGHTMAP_2D

This commit is contained in:
smallmodel 2025-01-19 15:16:35 +01:00
parent 47cd8ccfc8
commit c2bac6d1ef
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -3362,6 +3362,10 @@ shader_t* R_FindShader(const char* name, int lightmapIndex, qboolean mipRawImage
// lightmaps
if ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) {
lightmapIndex = LIGHTMAP_BY_VERTEX;
} else if ( lightmapIndex < LIGHTMAP_2D ) {
// negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex])
ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex );
lightmapIndex = LIGHTMAP_BY_VERTEX;
}
COM_StripExtension( name, strippedName, sizeof(strippedName));