static void CopyDrawSurfacesLump(xbspHeader_t * header) { int i, j; xbspDrawSurface_t *in; bspDrawSurface_t *out; /* get count */ numBSPDrawSurfaces = GetLumpElements((bspHeader_t *) header, LUMP_SURFACES, sizeof(*in)); SetDrawSurfaces(numBSPDrawSurfaces); /* copy */ in = GetLump((bspHeader_t *) header, LUMP_SURFACES); out = bspDrawSurfaces; for(i = 0; i < numBSPDrawSurfaces; i++) { out->shaderNum = in->shaderNum; out->fogNum = in->fogNum; out->surfaceType = in->surfaceType; out->firstVert = in->firstVert; out->numVerts = in->numVerts; out->firstIndex = in->firstIndex; out->numIndexes = in->numIndexes; out->lightmapStyles[0] = LS_NORMAL; out->vertexStyles[0] = LS_NORMAL; out->lightmapNum[0] = in->lightmapNum; out->lightmapX[0] = in->lightmapX; out->lightmapY[0] = in->lightmapY; for(j = 1; j < MAX_LIGHTMAPS; j++) { out->lightmapStyles[j] = LS_NONE; out->vertexStyles[j] = LS_NONE; out->lightmapNum[j] = -3; out->lightmapX[j] = 0; out->lightmapY[j] = 0; } out->lightmapWidth = in->lightmapWidth; out->lightmapHeight = in->lightmapHeight; VectorCopy(in->lightmapOrigin, out->lightmapOrigin); VectorCopy(in->lightmapVecs[0], out->lightmapVecs[0]); VectorCopy(in->lightmapVecs[1], out->lightmapVecs[1]); VectorCopy(in->lightmapVecs[2], out->lightmapVecs[2]); out->patchWidth = in->patchWidth; out->patchHeight = in->patchHeight; in++; out++; } }
void LoadRBSPFile( const char *filename ) { rbspHeader_t *header; /* load the file header */ LoadFile( filename, (void**) &header ); /* swap the header (except the first 4 bytes) */ SwapBlock( (int*) ((byte*) header + sizeof( int )), sizeof( *header ) - sizeof( int ) ); /* make sure it matches the format we're trying to load */ if( force == qfalse && *((int*) header->ident) != *((int*) game->bspIdent) ) Error( "%s is not a %s file", filename, game->bspIdent ); if( force == qfalse && header->version != game->bspVersion ) Error( "%s is version %d, not %d", filename, header->version, game->bspVersion ); /* load/convert lumps */ numBSPShaders = CopyLump( (bspHeader_t*) header, LUMP_SHADERS, bspShaders, sizeof( bspShader_t ) ); numBSPModels = CopyLump( (bspHeader_t*) header, LUMP_MODELS, bspModels, sizeof( bspModel_t ) ); numBSPPlanes = CopyLump( (bspHeader_t*) header, LUMP_PLANES, bspPlanes, sizeof( bspPlane_t ) ); numBSPLeafs = CopyLump( (bspHeader_t*) header, LUMP_LEAFS, bspLeafs, sizeof( bspLeaf_t ) ); numBSPNodes = CopyLump( (bspHeader_t*) header, LUMP_NODES, bspNodes, sizeof( bspNode_t ) ); numBSPLeafSurfaces = CopyLump( (bspHeader_t*) header, LUMP_LEAFSURFACES, bspLeafSurfaces, sizeof( bspLeafSurfaces[ 0 ] ) ); numBSPLeafBrushes = CopyLump( (bspHeader_t*) header, LUMP_LEAFBRUSHES, bspLeafBrushes, sizeof( bspLeafBrushes[ 0 ] ) ); numBSPBrushes = CopyLump( (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, sizeof( bspBrush_t ) ); numBSPBrushSides = CopyLump( (bspHeader_t*) header, LUMP_BRUSHSIDES, bspBrushSides, sizeof( bspBrushSide_t ) ); numBSPDrawVerts = GetLumpElements( (bspHeader_t*) header, LUMP_DRAWVERTS, sizeof( bspDrawVerts[ 0 ] ) ); SetDrawVerts( numBSPDrawVerts ); CopyLump( (bspHeader_t*) header, LUMP_DRAWVERTS, bspDrawVerts, sizeof( bspDrawVerts[ 0 ] ) ); numBSPDrawSurfaces = GetLumpElements( (bspHeader_t*) header, LUMP_SURFACES, sizeof( bspDrawSurfaces[ 0 ] ) ); SetDrawSurfaces( numBSPDrawSurfaces ); CopyLump( (bspHeader_t*) header, LUMP_SURFACES, bspDrawSurfaces, sizeof( bspDrawSurfaces[ 0 ] ) ); numBSPFogs = CopyLump( (bspHeader_t*) header, LUMP_FOGS, bspFogs, sizeof( bspFogs[ 0 ] ) ); numBSPDrawIndexes = CopyLump( (bspHeader_t*) header, LUMP_DRAWINDEXES, bspDrawIndexes, sizeof( bspDrawIndexes[ 0 ] ) ); numBSPVisBytes = CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, 1 ); numBSPLightBytes = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTMAPS, 1 ); bspLightBytes = safe_malloc( numBSPLightBytes ); CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, 1 ); bspEntDataSize = CopyLump( (bspHeader_t*) header, LUMP_ENTITIES, bspEntData, 1); CopyLightGridLumps( header ); /* free the file buffer */ free( header ); }