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