]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/lightmaps_ydnar.c
fux segv
[xonotic/netradiant.git] / tools / quake3 / q3map2 / lightmaps_ydnar.c
index e680fc0ce98d2c9b96472f306d63c0cfff8681cb..3c1eed65c84d05f0027f95e9da655dcefdda2707 100644 (file)
@@ -2016,7 +2016,11 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                        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 ];
@@ -2075,7 +2079,7 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                        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;