initial code for converting .map to .map

This commit is contained in:
Rudolf Polzer 2010-10-09 18:25:19 +02:00
parent 43f30dc837
commit 205771e916
6 changed files with 63 additions and 26 deletions

View File

@ -639,7 +639,7 @@ void OnlyEnts( void )
numEntities = 0; numEntities = 0;
LoadShaderInfo(); LoadShaderInfo();
LoadMapFile( name, qfalse ); LoadMapFile( name, qfalse, qfalse );
SetModelNumbers(); SetModelNumbers();
SetLightStyles(); SetLightStyles();
@ -955,9 +955,9 @@ int BSPMain( int argc, char **argv )
/* load original file from temp spot in case it was renamed by the editor on the way in */ /* load original file from temp spot in case it was renamed by the editor on the way in */
if( strlen( tempSource ) > 0 ) if( strlen( tempSource ) > 0 )
LoadMapFile( tempSource, qfalse ); LoadMapFile( tempSource, qfalse, qfalse );
else else
LoadMapFile( name, qfalse ); LoadMapFile( name, qfalse, qfalse );
/* div0: inject command line parameters */ /* div0: inject command line parameters */
InjectCommandLine(argv, 1, argc - 1); InjectCommandLine(argv, 1, argc - 1);

View File

@ -2800,7 +2800,7 @@ int LightMain( int argc, char **argv )
/* load map file */ /* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" ); value = ValueForKey( &entities[ 0 ], "_keepLights" );
if( value[ 0 ] != '1' ) if( value[ 0 ] != '1' )
LoadMapFile( mapSource, qtrue ); LoadMapFile( mapSource, qtrue, qfalse );
/* set the entity/model origins and init yDrawVerts */ /* set the entity/model origins and init yDrawVerts */
SetEntityOrigins(); SetEntityOrigins();

View File

@ -1430,6 +1430,25 @@ int ScaleBSPMain( int argc, char **argv )
} }
void PseudoCompileBSP()
{
// a stripped down ProcessModels
BeginBSPFile();
for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
{
/* get entity */
entity = &entities[ mapEntityNum ];
if( entity->brushes == NULL && entity->patches == NULL )
continue;
/* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
BeginModel();
entity>firstDrawSurf = 0;
EmitBrushes(entity->brushes, &entity>firstBrush, &entity>numBrushes );
EndModel(entity, NULL);
}
}
/* /*
ConvertBSPMain() ConvertBSPMain()
@ -1441,11 +1460,14 @@ int ConvertBSPMain( int argc, char **argv )
int i; int i;
int (*convertFunc)( char * ); int (*convertFunc)( char * );
game_t *convertGame; game_t *convertGame;
qboolean map_allowed;
char ext[1024];
/* set default */ /* set default */
convertFunc = ConvertBSPToASE; convertFunc = ConvertBSPToASE;
convertGame = NULL; convertGame = NULL;
map_allowed = qfalse;
/* arg checking */ /* arg checking */
if( argc < 1 ) if( argc < 1 )
@ -1462,11 +1484,19 @@ int ConvertBSPMain( int argc, char **argv )
{ {
i++; i++;
if( !Q_stricmp( argv[ i ], "ase" ) ) if( !Q_stricmp( argv[ i ], "ase" ) )
{
convertFunc = ConvertBSPToASE; convertFunc = ConvertBSPToASE;
}
else if( !Q_stricmp( argv[ i ], "map_bp" ) ) else if( !Q_stricmp( argv[ i ], "map_bp" ) )
{
convertFunc = ConvertBSPToMap_BP; convertFunc = ConvertBSPToMap_BP;
map_allowed = qtrue;
}
else if( !Q_stricmp( argv[ i ], "map" ) ) else if( !Q_stricmp( argv[ i ], "map" ) )
{
convertFunc = ConvertBSPToMap; convertFunc = ConvertBSPToMap;
map_allowed = qtrue;
}
else else
{ {
convertGame = GetGame( argv[ i ] ); convertGame = GetGame( argv[ i ] );
@ -1490,22 +1520,28 @@ int ConvertBSPMain( int argc, char **argv )
shadersAsBitmap = qtrue; shadersAsBitmap = qtrue;
} }
/* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
LoadShaderInfo(); LoadShaderInfo();
Sys_Printf( "Loading %s\n", source ); /* clean up map name */
strcpy(source, ExpandArg(argv[i]));
/* ydnar: load surface file */ ExtractFileExtension(source, ext);
//% LoadSurfaceExtraFile( source ); if(!Q_stricmp(ext, "map") && map_allowed)
{
LoadBSPFile( source ); StripExtension(source);
DefaultExtension(source, ".map");
/* parse bsp entities */ Sys_Printf("Loading %s\n", source);
ParseEntities(); LoadMapFile(name, qfalse, qtrue);
ParseEntities();
PseudoCompileBSP();
}
else
{
StripExtension(source);
DefaultExtension(source, ".bsp");
Sys_Printf("Loading %s\n", source);
LoadBSPFile(source);
ParseEntities();
}
/* bsp format convert? */ /* bsp format convert? */
if( convertGame != NULL ) if( convertGame != NULL )

View File

@ -1418,7 +1418,7 @@ ParseMapEntity()
parses a single entity out of a map file parses a single entity out of a map file
*/ */
static qboolean ParseMapEntity( qboolean onlyLights ) static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
{ {
epair_t *ep; epair_t *ep;
const char *classname, *value; const char *classname, *value;
@ -1664,14 +1664,14 @@ static qboolean ParseMapEntity( qboolean onlyLights )
AdjustBrushesForOrigin( mapEnt ); AdjustBrushesForOrigin( mapEnt );
/* group_info entities are just for editor grouping (fixme: leak!) */ /* group_info entities are just for editor grouping (fixme: leak!) */
if( !Q_stricmp( "group_info", classname ) ) if( !noCollapseGroups && !Q_stricmp( "group_info", classname ) )
{ {
numEntities--; numEntities--;
return qtrue; return qtrue;
} }
/* group entities are just for editor convenience, toss all brushes into worldspawn */ /* group entities are just for editor convenience, toss all brushes into worldspawn */
if( funcGroup ) if( !noCollapseGroups && funcGroup )
{ {
MoveBrushesToWorld( mapEnt ); MoveBrushesToWorld( mapEnt );
numEntities--; numEntities--;
@ -1689,7 +1689,7 @@ LoadMapFile()
loads a map file into a list of entities loads a map file into a list of entities
*/ */
void LoadMapFile( char *filename, qboolean onlyLights ) void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups )
{ {
FILE *file; FILE *file;
brush_t *b; brush_t *b;
@ -1722,7 +1722,7 @@ void LoadMapFile( char *filename, qboolean onlyLights )
buildBrush = AllocBrush( MAX_BUILD_SIDES ); buildBrush = AllocBrush( MAX_BUILD_SIDES );
/* parse the map file */ /* parse the map file */
while( ParseMapEntity( onlyLights ) ); while( ParseMapEntity( onlyLights, noCollapseGroups ) );
/* light loading */ /* light loading */
if( onlyLights ) if( onlyLights )

View File

@ -1576,7 +1576,7 @@ void MakeNormalVectors( vec3_t forward, vec3_t right, vec3_t up );
/* map.c */ /* map.c */
void LoadMapFile( char *filename, qboolean onlyLights ); void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups );
int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ); int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points );
int PlaneTypeForNormal( vec3_t normal ); int PlaneTypeForNormal( vec3_t normal );
void AddBrushBevels( void ); void AddBrushBevels( void );

View File

@ -630,7 +630,8 @@ void EndModel( entity_t *e, node_t *headnode )
/* emit the bsp */ /* emit the bsp */
mod = &bspModels[ numBSPModels ]; mod = &bspModels[ numBSPModels ];
EmitDrawNode_r( headnode ); if(headnode)
EmitDrawNode_r( headnode );
/* set surfaces and brushes */ /* set surfaces and brushes */
mod->numBSPSurfaces = numBSPDrawSurfaces - mod->firstBSPSurface; mod->numBSPSurfaces = numBSPDrawSurfaces - mod->firstBSPSurface;