std::vector<char> bspEntData
This commit is contained in:
parent
58911934e0
commit
6267f1d0af
|
|
@ -986,10 +986,7 @@ int repackBSPMain( Args& args ){
|
|||
|
||||
bspShaders.clear();
|
||||
|
||||
free( bspEntData );
|
||||
bspEntData = NULL;
|
||||
bspEntDataSize = 0;
|
||||
allocatedBSPEntData = 0;
|
||||
bspEntData.clear();
|
||||
|
||||
numBSPFogs = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,8 +474,8 @@ void PrintBSPFileSizes( void ){
|
|||
numBSPFogs, (int) ( numBSPFogs * sizeof( bspFog_t ) ) );
|
||||
Sys_Printf( "%9d planes %9d\n",
|
||||
numBSPPlanes, (int) ( numBSPPlanes * sizeof( bspPlane_t ) ) );
|
||||
Sys_Printf( "%9zu entdata %9d\n",
|
||||
entities.size(), bspEntDataSize );
|
||||
Sys_Printf( "%9zu entdata %9zu\n",
|
||||
entities.size(), bspEntData.size() );
|
||||
Sys_Printf( "\n" );
|
||||
|
||||
Sys_Printf( "%9d nodes %9d\n",
|
||||
|
|
@ -597,7 +597,7 @@ bool ParseEntity( void ){
|
|||
|
||||
void ParseEntities( void ){
|
||||
entities.clear();
|
||||
ParseFromMemory( bspEntData, bspEntDataSize );
|
||||
ParseFromMemory( bspEntData.data(), bspEntData.size() );
|
||||
while ( ParseEntity() ) ;
|
||||
|
||||
/* ydnar: set number of bsp entities in case a map is loaded on top */
|
||||
|
|
@ -666,9 +666,7 @@ void UnparseEntities( void ){
|
|||
}
|
||||
|
||||
/* save out */
|
||||
bspEntDataSize = data.end() - data.begin() + 1;
|
||||
AUTOEXPAND_BY_REALLOC( bspEntData, bspEntDataSize, allocatedBSPEntData, 1024 );
|
||||
strcpy( bspEntData, data );
|
||||
bspEntData = { data.begin(), data.end() + 1 }; // include '\0'
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ void LoadIBSPFile( const char *filename ){
|
|||
bspLightBytes = safe_malloc( numBSPLightBytes );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, 1 );
|
||||
|
||||
bspEntDataSize = CopyLump_Allocate( (bspHeader_t*) header, LUMP_ENTITIES, (void **) &bspEntData, 1, &allocatedBSPEntData );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_ENTITIES, bspEntData );
|
||||
|
||||
CopyLightGridLumps( header );
|
||||
|
||||
|
|
@ -511,7 +511,7 @@ void PartialLoadIBSPFile( const char *filename ){
|
|||
|
||||
numBSPFogs = CopyLump( (bspHeader_t*) header, LUMP_FOGS, bspFogs, sizeof( bspFog_t ) ); // TODO fix overflow
|
||||
|
||||
bspEntDataSize = CopyLump_Allocate( (bspHeader_t*) header, LUMP_ENTITIES, (void **) &bspEntData, 1, &allocatedBSPEntData );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_ENTITIES, bspEntData );
|
||||
|
||||
/* free the file buffer */
|
||||
free( header );
|
||||
|
|
@ -565,7 +565,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
AddLump( file, (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, numBSPVisBytes );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, numBSPLightBytes );
|
||||
AddLightGridLumps( file, header );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_ENTITIES, bspEntData, bspEntDataSize );
|
||||
AddLump( file, header->lumps[LUMP_ENTITIES], bspEntData );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_FOGS, bspFogs, numBSPFogs * sizeof( bspFog_t ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_DRAWINDEXES, bspDrawIndexes, numBSPDrawIndexes * sizeof( bspDrawIndexes[ 0 ] ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void LoadRBSPFile( const char *filename ){
|
|||
bspLightBytes = safe_malloc( numBSPLightBytes );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, 1 );
|
||||
|
||||
bspEntDataSize = CopyLump_Allocate( (bspHeader_t*) header, LUMP_ENTITIES, (void **) &bspEntData, 1, &allocatedBSPEntData );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_ENTITIES, bspEntData );
|
||||
|
||||
CopyLightGridLumps( header );
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ void WriteRBSPFile( const char *filename ){
|
|||
AddLump( file, (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, numBSPVisBytes );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes, numBSPLightBytes );
|
||||
AddLightGridLumps( file, header );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_ENTITIES, bspEntData, bspEntDataSize );
|
||||
AddLump( file, header->lumps[LUMP_ENTITIES], bspEntData );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_FOGS, bspFogs, numBSPFogs * sizeof( bspFog_t ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_DRAWINDEXES, bspDrawIndexes, numBSPDrawIndexes * sizeof( bspDrawIndexes[ 0 ] ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void ExportEntities( void ){
|
|||
Sys_FPrintf( SYS_VRB, "--- ExportEntities ---\n" );
|
||||
|
||||
/* sanity check */
|
||||
if ( bspEntData == NULL || bspEntDataSize == 0 ) {
|
||||
if ( bspEntData.empty() ) {
|
||||
Sys_Warning( "No BSP entity data. aborting...\n" );
|
||||
return;
|
||||
}
|
||||
|
|
@ -58,10 +58,10 @@ void ExportEntities( void ){
|
|||
/* write it */
|
||||
auto filename = StringOutputStream( 256 )( PathExtensionless( source ), ".ent" );
|
||||
Sys_Printf( "Writing %s\n", filename.c_str() );
|
||||
Sys_FPrintf( SYS_VRB, "(%d bytes)\n", bspEntDataSize );
|
||||
Sys_FPrintf( SYS_VRB, "(%zu bytes)\n", bspEntData.size() );
|
||||
FILE *file = SafeOpenWrite( filename, "wt" );
|
||||
|
||||
fprintf( file, "%s\n", bspEntData );
|
||||
fprintf( file, "%s\n", bspEntData.data() );
|
||||
fclose( file );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2338,9 +2338,7 @@ Q_EXTERN std::vector<bspModel_t> bspModels;
|
|||
|
||||
Q_EXTERN std::vector<bspShader_t> bspShaders;
|
||||
|
||||
Q_EXTERN int bspEntDataSize Q_ASSIGN( 0 );
|
||||
Q_EXTERN int allocatedBSPEntData Q_ASSIGN( 0 );
|
||||
Q_EXTERN char *bspEntData Q_ASSIGN( 0 );
|
||||
Q_EXTERN std::vector<char> bspEntData;
|
||||
|
||||
Q_EXTERN int numBSPLeafs Q_ASSIGN( 0 );
|
||||
Q_EXTERN bspLeaf_t bspLeafs[ MAX_MAP_LEAFS ];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user