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;
LoadShaderInfo();
LoadMapFile( name, qfalse );
LoadMapFile( name, qfalse, qfalse );
SetModelNumbers();
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 */
if( strlen( tempSource ) > 0 )
LoadMapFile( tempSource, qfalse );
LoadMapFile( tempSource, qfalse, qfalse );
else
LoadMapFile( name, qfalse );
LoadMapFile( name, qfalse, qfalse );
/* div0: inject command line parameters */
InjectCommandLine(argv, 1, argc - 1);

View File

@ -2800,7 +2800,7 @@ int LightMain( int argc, char **argv )
/* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" );
if( value[ 0 ] != '1' )
LoadMapFile( mapSource, qtrue );
LoadMapFile( mapSource, qtrue, qfalse );
/* set the entity/model origins and init yDrawVerts */
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()
@ -1441,11 +1460,14 @@ int ConvertBSPMain( int argc, char **argv )
int i;
int (*convertFunc)( char * );
game_t *convertGame;
qboolean map_allowed;
char ext[1024];
/* set default */
convertFunc = ConvertBSPToASE;
convertGame = NULL;
map_allowed = qfalse;
/* arg checking */
if( argc < 1 )
@ -1462,11 +1484,19 @@ int ConvertBSPMain( int argc, char **argv )
{
i++;
if( !Q_stricmp( argv[ i ], "ase" ) )
{
convertFunc = ConvertBSPToASE;
}
else if( !Q_stricmp( argv[ i ], "map_bp" ) )
{
convertFunc = ConvertBSPToMap_BP;
map_allowed = qtrue;
}
else if( !Q_stricmp( argv[ i ], "map" ) )
{
convertFunc = ConvertBSPToMap;
map_allowed = qtrue;
}
else
{
convertGame = GetGame( argv[ i ] );
@ -1489,23 +1519,29 @@ int ConvertBSPMain( int argc, char **argv )
else if( !strcmp( argv[ i ], "-shadersasbitmap" ) )
shadersAsBitmap = qtrue;
}
/* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
LoadShaderInfo();
Sys_Printf( "Loading %s\n", source );
/* ydnar: load surface file */
//% LoadSurfaceExtraFile( source );
LoadBSPFile( source );
/* parse bsp entities */
ParseEntities();
/* clean up map name */
strcpy(source, ExpandArg(argv[i]));
ExtractFileExtension(source, ext);
if(!Q_stricmp(ext, "map") && map_allowed)
{
StripExtension(source);
DefaultExtension(source, ".map");
Sys_Printf("Loading %s\n", source);
LoadMapFile(name, qfalse, qtrue);
ParseEntities();
PseudoCompileBSP();
}
else
{
StripExtension(source);
DefaultExtension(source, ".bsp");
Sys_Printf("Loading %s\n", source);
LoadBSPFile(source);
ParseEntities();
}
/* bsp format convert? */
if( convertGame != NULL )

View File

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

View File

@ -1576,7 +1576,7 @@ void MakeNormalVectors( vec3_t forward, vec3_t right, vec3_t up );
/* 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 PlaneTypeForNormal( vec3_t normal );
void AddBrushBevels( void );

View File

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