]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bspfile_rbsp.c
fix drawindexes crash when loading BSP files
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bspfile_rbsp.c
index 6868f97467ba5f3e4574b5199384d5f13282d2d7..22ead1844b626d02e5e0259012143f8fa90ec6ee 100644 (file)
@@ -146,7 +146,7 @@ static void AddLightGridLumps( FILE *file, rbspHeader_t *header )
                        out = &gridPoints[ j ];
                        
                        /* compare styles */
-                       if( *((unsigned int*) in->styles) != *((unsigned int*) out->styles) )
+                       if( memcmp(in->styles, out->styles, MAX_LIGHTMAPS) )
                                continue;
                        
                        /* compare direction */
@@ -243,9 +243,9 @@ void LoadRBSPFile( const char *filename )
        
        numBSPLeafBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_LEAFBRUSHES, (void **) &bspLeafBrushes, sizeof( bspLeafBrushes[ 0 ] ), &allocatedBSPLeafBrushes );
        
-       numBSPBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHES, &bspBrushes, sizeof( bspBrush_t ), &allocatedBSPLeafBrushes );
+       numBSPBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHES, (void **) &bspBrushes, sizeof( bspBrush_t ), &allocatedBSPLeafBrushes );
        
-       numBSPBrushSides = CopyLump( (bspHeader_t*) header, LUMP_BRUSHSIDES, bspBrushSides, sizeof( bspBrushSide_t ) );
+       numBSPBrushSides = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHSIDES, (void **) &bspBrushSides, sizeof( bspBrushSide_t ), &allocatedBSPBrushSides );
        
        numBSPDrawVerts = GetLumpElements( (bspHeader_t*) header, LUMP_DRAWVERTS, sizeof( bspDrawVerts[ 0 ] ) );
                SetDrawVerts( numBSPDrawVerts );
@@ -257,7 +257,7 @@ void LoadRBSPFile( const char *filename )
        
        numBSPFogs = CopyLump( (bspHeader_t*) header, LUMP_FOGS, bspFogs, sizeof( bspFogs[ 0 ] ) );
        
-       numBSPDrawIndexes = CopyLump( (bspHeader_t*) header, LUMP_DRAWINDEXES, bspDrawIndexes, sizeof( bspDrawIndexes[ 0 ] ) );
+       numBSPDrawIndexes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_DRAWINDEXES, (void **) &bspDrawIndexes, sizeof( bspDrawIndexes[ 0 ] ), &allocatedBSPDrawIndexes );
        
        numBSPVisBytes = CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, 1 );
        
@@ -265,7 +265,7 @@ void LoadRBSPFile( const char *filename )
                bspLightBytes = safe_malloc( numBSPLightBytes );
                CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, 1 );
        
-       bspEntDataSize = CopyLump( (bspHeader_t*) header, LUMP_ENTITIES, bspEntData, 1);
+       bspEntDataSize = CopyLump_Allocate( (bspHeader_t*) header, LUMP_ENTITIES, (void **) &bspEntData, 1, &allocatedBSPEntData);
        
        CopyLightGridLumps( header );