]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bsp.c
reduce more diff noise
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bsp.c
index da7374605d32fa698044fbeae938d254628d045e..bbab3f25ee101fa57b3db1955a4b2330a4421649 100644 (file)
@@ -44,6 +44,7 @@
 
    ------------------------------------------------------------------------------- */
 
+
 /*
    ProcessAdvertisements()
    copies advertisement info into the BSP structures
@@ -193,7 +194,7 @@ static void SetCloneModelNumbers( void ){
                                /* get the model num */
                                value3 = ValueForKey( &entities[ j ], "model" );
                                if ( value3[ 0 ] == '\0' ) {
-                                       Sys_Printf( "WARNING: Cloned entity %s referenced entity without model\n", value2 );
+                                       Sys_FPrintf( SYS_WRN, "WARNING: Cloned entity %s referenced entity without model\n", value2 );
                                        continue;
                                }
                                models = atoi( &value2[ 1 ] );
@@ -265,7 +266,7 @@ static void FixBrushSides( entity_t *e ){
    creates a full bsp + surfaces for the worldspawn entity
  */
 
-void ProcessWorldModel( void ){
+void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){
        int i, s;
        entity_t    *e;
        tree_t      *tree;
@@ -343,7 +344,7 @@ void ProcessWorldModel( void ){
                Sys_FPrintf( SYS_NOXML, "**********************\n" );
                Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
                Sys_FPrintf( SYS_NOXML, "**********************\n" );
-               polyline = LeakFile( tree );
+               polyline = LeakFile( tree, lineFilePath );
                leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
                xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
                xmlAddChild( leaknode, polyline );
@@ -380,7 +381,7 @@ void ProcessWorldModel( void ){
        /* save out information for visibility processing */
        NumberClusters( tree );
        if ( !leaked ) {
-               WritePortalFile( tree );
+               WritePortalFile( tree, portalFilePath );
        }
 
        /* flood from entities */
@@ -592,7 +593,7 @@ void ProcessSubModel( void ){
    process world + other models into the bsp
  */
 
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
        qboolean oldVerbose;
        entity_t    *entity;
 
@@ -618,7 +619,7 @@ void ProcessModels( void ){
                /* process the model */
                Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
                if ( mapEntityNum == 0 ) {
-                       ProcessWorldModel();
+                       ProcessWorldModel(portalFilePath, lineFilePath);
                }
                else{
                        ProcessSubModel();
@@ -645,17 +646,14 @@ void ProcessModels( void ){
    this is probably broken unless teamed with a radiant version that preserves entity order
  */
 
-void OnlyEnts( void ){
-       char out[ 1024 ];
-
+void OnlyEnts( const char *BSPFilePath ){
        char save_cmdline[1024], save_version[1024], save_gridsize[1024];
        const char *p;
 
        /* note it */
        Sys_Printf( "--- OnlyEnts ---\n" );
 
-       sprintf( out, "%s.bsp", source );
-       LoadBSPFile( out );
+       LoadBSPFile( BSPFilePath );
 
        ParseEntities();
        p = ValueForKey( &entities[0], "_q3map2_cmdline" );
@@ -688,7 +686,7 @@ void OnlyEnts( void ){
        numBSPEntities = numEntities;
        UnparseEntities();
 
-       WriteBSPFile( out );
+       WriteBSPFile( BSPFilePath );
 }
 
 
@@ -702,6 +700,14 @@ int BSPMain( int argc, char **argv ){
        int i;
        char path[ 1024 ], tempSource[ 1024 ];
        qboolean onlyents = qfalse;
+       char BSPFilePath [ 1024 ];
+       char lineFilePath [ 1024 ];
+       char portalFilePath [ 1024 ];
+       char surfaceFilePath [ 1024 ];
+       BSPFilePath[0] = 0;
+       lineFilePath[0] = 0;
+       portalFilePath[0] = 0;
+       surfaceFilePath[0] = 0;
 
 
        /* note it */
@@ -966,11 +972,13 @@ int BSPMain( int argc, char **argv ){
                        colorsRGB = qfalse;
                        Sys_Printf( "Colors are linear\n" );
                }
-               else if ( !strcmp( argv[ i ], "-altsplit" ) ) {
+               else if ( !strcmp( argv[ i ], "-altsplit" ) )
+               {
                        Sys_Printf( "Alternate BSP splitting (by 27) enabled\n" );
                        bspAlternateSplitWeights = qtrue;
                }
-               else if ( !strcmp( argv[ i ], "-deep" ) ) {
+               else if ( !strcmp( argv[ i ], "-deep" ) )
+               {
                        Sys_Printf( "Deep BSP tree generation enabled\n" );
                        deepBSP = qtrue;
                }
@@ -978,12 +986,35 @@ int BSPMain( int argc, char **argv ){
                        Sys_Printf( "Max Area face surface generation enabled\n" );
                        maxAreaFaceSurface = qtrue;
                }
+               else if ( !strcmp( argv[ i ], "-bspfile" ) )
+               {
+                       strcpy( BSPFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+               }
+               else if ( !strcmp( argv[ i ], "-linfile" ) )
+               {
+                       strcpy( lineFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as line file\n", lineFilePath );
+               }
+               else if ( !strcmp( argv[ i ], "-prtfile" ) )
+               {
+                       strcpy( portalFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as portal file\n", portalFilePath );
+               }
+               else if ( !strcmp( argv[ i ], "-srffile" ) )
+               {
+                       strcpy( surfaceFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+               }
                else if ( !strcmp( argv[ i ], "-bsp" ) ) {
                        Sys_Printf( "-bsp argument unnecessary\n" );
                }
-               else
-               {
-                       Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
+               else{
+                       Sys_FPrintf( SYS_WRN, "WARNING: Unknown option \"%s\"\n", argv[ i ] );
                }
        }
 
@@ -999,13 +1030,23 @@ int BSPMain( int argc, char **argv ){
        /* ydnar: set default sample size */
        SetDefaultSampleSize( sampleSize );
 
+       if (!BSPFilePath[0]) {
+               sprintf( BSPFilePath, "%s.bsp", source );
+       }
+       if (!lineFilePath[0]) {
+               sprintf( lineFilePath, "%s.lin", source );
+       }
+       if (!portalFilePath[0]) {
+               sprintf( portalFilePath, "%s.prt", source );
+       }
+       if (!surfaceFilePath[0]) {
+               sprintf( surfaceFilePath, "%s.srf", source );
+       }
+
        /* delete portal, line and surface files */
-       sprintf( path, "%s.prt", source );
-       remove( path );
-       sprintf( path, "%s.lin", source );
-       remove( path );
-       //%     sprintf( path, "%s.srf", source );      /* ydnar */
-       //%     remove( path );
+       remove( portalFilePath );
+       remove( lineFilePath );
+       //%     remove( surfaceFilePath )       /* ydnar */
 
        /* expand mapname */
        strcpy( name, ExpandArg( argv[ i ] ) );
@@ -1018,7 +1059,7 @@ int BSPMain( int argc, char **argv ){
 
        /* if onlyents, just grab the entites and resave */
        if ( onlyents ) {
-               OnlyEnts();
+               OnlyEnts( BSPFilePath );
                return 0;
        }
 
@@ -1043,7 +1084,7 @@ int BSPMain( int argc, char **argv ){
        SetCloneModelNumbers();
 
        /* process world and submodels */
-       ProcessModels();
+       ProcessModels( portalFilePath, lineFilePath );
 
        /* set light styles from targetted light entities */
        SetLightStyles();
@@ -1052,7 +1093,7 @@ int BSPMain( int argc, char **argv ){
        ProcessAdvertisements();
 
        /* finish and write bsp */
-       EndBSPFile( qtrue );
+       EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
 
        /* remove temp map source file if appropriate */
        if ( strlen( tempSource ) > 0 ) {