y = 0;
/* walk the list of lightmap pages */
- for( i = noLightmapSearch ? numOutLightmaps - LIGHTMAP_RESERVE_COUNT : 0; i < numOutLightmaps; i++ )
+ if(lightmapSearchBlockSize <= 0 || numOutLightmaps < LIGHTMAP_RESERVE_COUNT)
+ i = 0;
+ else
+ i = ((numOutLightmaps - LIGHTMAP_RESERVE_COUNT) / lightmapSearchBlockSize) * lightmapSearchBlockSize;
+ for( ; i < numOutLightmaps; i++ )
{
/* get the output lightmap */
olm = &outLightmaps[ i ];
olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
if( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT )
{
- memcpy( olm, outLightmaps, (numOutLightmaps - 2) * sizeof( outLightmap_t ) );
+ memcpy( olm, outLightmaps, (numOutLightmaps - LIGHTMAP_RESERVE_COUNT) * sizeof( outLightmap_t ) );
free( outLightmaps );
}
outLightmaps = olm;