]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
enable q3map2 out of tree compilation 20/head
authorThomas Debesse <dev@illwieckz.net>
Mon, 20 Jul 2015 10:39:42 +0000 (12:39 +0200)
committerThomas Debesse <dev@illwieckz.net>
Thu, 14 Apr 2016 01:44:05 +0000 (03:44 +0200)
tools/quake3/q3map2/bsp.c
tools/quake3/q3map2/convert_bsp.c
tools/quake3/q3map2/help.c
tools/quake3/q3map2/leakfile.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/prtfile.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/surface_extra.c
tools/quake3/q3map2/vis.c
tools/quake3/q3map2/writebsp.c

index da7374605d32fa698044fbeae938d254628d045e..4ac39f36ded15067c8476df765a8c61965a46ab7 100644 (file)
@@ -265,7 +265,7 @@ static void FixBrushSides( entity_t *e ){
    creates a full bsp + surfaces for the worldspawn entity
  */
 
    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;
        int i, s;
        entity_t    *e;
        tree_t      *tree;
@@ -343,7 +343,7 @@ void ProcessWorldModel( void ){
                Sys_FPrintf( SYS_NOXML, "**********************\n" );
                Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
                Sys_FPrintf( SYS_NOXML, "**********************\n" );
                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 );
                leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
                xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
                xmlAddChild( leaknode, polyline );
@@ -380,7 +380,7 @@ void ProcessWorldModel( void ){
        /* save out information for visibility processing */
        NumberClusters( tree );
        if ( !leaked ) {
        /* save out information for visibility processing */
        NumberClusters( tree );
        if ( !leaked ) {
-               WritePortalFile( tree );
+               WritePortalFile( tree, portalFilePath );
        }
 
        /* flood from entities */
        }
 
        /* flood from entities */
@@ -592,7 +592,7 @@ void ProcessSubModel( void ){
    process world + other models into the bsp
  */
 
    process world + other models into the bsp
  */
 
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
        qboolean oldVerbose;
        entity_t    *entity;
 
        qboolean oldVerbose;
        entity_t    *entity;
 
@@ -618,7 +618,7 @@ void ProcessModels( void ){
                /* process the model */
                Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
                if ( mapEntityNum == 0 ) {
                /* process the model */
                Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
                if ( mapEntityNum == 0 ) {
-                       ProcessWorldModel();
+                       ProcessWorldModel(portalFilePath, lineFilePath);
                }
                else{
                        ProcessSubModel();
                }
                else{
                        ProcessSubModel();
@@ -645,17 +645,14 @@ void ProcessModels( void ){
    this is probably broken unless teamed with a radiant version that preserves entity order
  */
 
    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" );
 
        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" );
 
        ParseEntities();
        p = ValueForKey( &entities[0], "_q3map2_cmdline" );
@@ -688,7 +685,7 @@ void OnlyEnts( void ){
        numBSPEntities = numEntities;
        UnparseEntities();
 
        numBSPEntities = numEntities;
        UnparseEntities();
 
-       WriteBSPFile( out );
+       WriteBSPFile( BSPFilePath );
 }
 
 
 }
 
 
@@ -702,6 +699,14 @@ int BSPMain( int argc, char **argv ){
        int i;
        char path[ 1024 ], tempSource[ 1024 ];
        qboolean onlyents = qfalse;
        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 */
 
 
        /* note it */
@@ -978,6 +983,30 @@ int BSPMain( int argc, char **argv ){
                        Sys_Printf( "Max Area face surface generation enabled\n" );
                        maxAreaFaceSurface = qtrue;
                }
                        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 if ( !strcmp( argv[ i ], "-bsp" ) ) {
                        Sys_Printf( "-bsp argument unnecessary\n" );
                }
@@ -999,13 +1028,23 @@ int BSPMain( int argc, char **argv ){
        /* ydnar: set default sample size */
        SetDefaultSampleSize( sampleSize );
 
        /* 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 */
        /* 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 ] ) );
 
        /* expand mapname */
        strcpy( name, ExpandArg( argv[ i ] ) );
@@ -1018,7 +1057,7 @@ int BSPMain( int argc, char **argv ){
 
        /* if onlyents, just grab the entites and resave */
        if ( onlyents ) {
 
        /* if onlyents, just grab the entites and resave */
        if ( onlyents ) {
-               OnlyEnts();
+               OnlyEnts( BSPFilePath );
                return 0;
        }
 
                return 0;
        }
 
@@ -1043,7 +1082,7 @@ int BSPMain( int argc, char **argv ){
        SetCloneModelNumbers();
 
        /* process world and submodels */
        SetCloneModelNumbers();
 
        /* process world and submodels */
-       ProcessModels();
+       ProcessModels( portalFilePath, lineFilePath );
 
        /* set light styles from targetted light entities */
        SetLightStyles();
 
        /* set light styles from targetted light entities */
        SetLightStyles();
@@ -1052,7 +1091,7 @@ int BSPMain( int argc, char **argv ){
        ProcessAdvertisements();
 
        /* finish and write bsp */
        ProcessAdvertisements();
 
        /* finish and write bsp */
-       EndBSPFile( qtrue );
+       EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
 
        /* remove temp map source file if appropriate */
        if ( strlen( tempSource ) > 0 ) {
 
        /* remove temp map source file if appropriate */
        if ( strlen( tempSource ) > 0 ) {
index 5a03df9c067b83eb42023dc0cb48d5d38224d2aa..ac6270319527735677aed7ed0cb1fa6b1b6a0dc5 100644 (file)
@@ -37,7 +37,7 @@
    PseudoCompileBSP()
    a stripped down ProcessModels
  */
    PseudoCompileBSP()
    a stripped down ProcessModels
  */
-void PseudoCompileBSP( qboolean need_tree ){
+void PseudoCompileBSP( qboolean need_tree, const char *BSPFilePath, const char *surfaceFilePath ){
        int models;
        char modelValue[10];
        entity_t *entity;
        int models;
        char modelValue[10];
        entity_t *entity;
@@ -125,7 +125,7 @@ void PseudoCompileBSP( qboolean need_tree ){
                EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
                EndModel( entity, node );
        }
                EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
                EndModel( entity, node );
        }
-       EndBSPFile( qfalse );
+       EndBSPFile( qfalse, BSPFilePath, surfaceFilePath );
 }
 
 /*
 }
 
 /*
@@ -138,6 +138,8 @@ int ConvertBSPMain( int argc, char **argv ){
        int ( *convertFunc )( char * );
        game_t  *convertGame;
        char ext[1024];
        int ( *convertFunc )( char * );
        game_t  *convertGame;
        char ext[1024];
+       char BSPFilePath [ 1024 ];
+       char surfaceFilePath [ 1024 ];
        qboolean map_allowed, force_bsp, force_map;
 
 
        qboolean map_allowed, force_bsp, force_map;
 
 
@@ -238,7 +240,9 @@ int ConvertBSPMain( int argc, char **argv ){
                DefaultExtension( source, ".map" );
                Sys_Printf( "Loading %s\n", source );
                LoadMapFile( source, qfalse, convertGame == NULL );
                DefaultExtension( source, ".map" );
                Sys_Printf( "Loading %s\n", source );
                LoadMapFile( source, qfalse, convertGame == NULL );
-               PseudoCompileBSP( convertGame != NULL );
+               sprintf( BSPFilePath, "%s.bsp", source );
+               sprintf( surfaceFilePath, "%s.srf", source );
+               PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath );
        }
        else
        {
        }
        else
        {
index 0dc528ad4221fbfcd2e2482516c17aa8601b94fd..f76a88dbf46906bc2eeb21d50927e3f82f5ca624 100644 (file)
@@ -88,6 +88,7 @@ void HelpBsp()
        struct HelpOption bsp[] = {
                {"-bsp <filename.map>", "Switch that enters this stage"},
                {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
        struct HelpOption bsp[] = {
                {"-bsp <filename.map>", "Switch that enters this stage"},
                {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
+               {"-bspfile <filename.bsp>", "BSP file to write"},
                {"-celshader <shadername>", "Sets a global cel shader name"},
                {"-custinfoparms", "Read scripts/custinfoparms.txt"},
                {"-debuginset", "Push all triangle vertexes towards the triangle center"},
                {"-celshader <shadername>", "Sets a global cel shader name"},
                {"-custinfoparms", "Read scripts/custinfoparms.txt"},
                {"-debuginset", "Push all triangle vertexes towards the triangle center"},
@@ -100,6 +101,7 @@ void HelpBsp()
                {"-flat", "Enable flat shading (good for combining with -celshader)"},
                {"-fulldetail", "Treat detail brushes as structural ones"},
                {"-leaktest", "Abort if a leak was found"},
                {"-flat", "Enable flat shading (good for combining with -celshader)"},
                {"-fulldetail", "Treat detail brushes as structural ones"},
                {"-leaktest", "Abort if a leak was found"},
+               {"-linefile <filename.lin>", "Line file to write"},
                {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
                {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
                {"-mi <N>", "Sets the maximum number of indexes per surface"},
                {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
                {"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
                {"-mi <N>", "Sets the maximum number of indexes per surface"},
@@ -116,10 +118,12 @@ void HelpBsp()
                {"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
                {"-onlyents", "Only update entities in the BSP"},
                {"-patchmeta", "Turn patches into triangle meshes for display"},
                {"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
                {"-onlyents", "Only update entities in the BSP"},
                {"-patchmeta", "Turn patches into triangle meshes for display"},
-               {"-rename", "Append Ã¢â‚¬Å“bspâ€\9d suffix to miscmodel shaders (needed for SoF2)"},
+               {"-prtfile <filename.prt>", "Portal file to write"},
+               {"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"},
                {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
                {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
                {"-snap <N>", "Snap brush bevel planes to the given number of units"},
                {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
                {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
                {"-snap <N>", "Snap brush bevel planes to the given number of units"},
+               {"-srffile <filename.srf>", "Surface file to write"},
                {"-tempname <filename.map>", "Read the MAP file from the given file name"},
                {"-texrange <N>", "Limit per-surface texture range to the given number of units, and subdivide surfaces like with `q3map_tessSize` if this is not met"},
                {"-tmpout", "Write the BSP file to /tmp"},
                {"-tempname <filename.map>", "Read the MAP file from the given file name"},
                {"-texrange <N>", "Limit per-surface texture range to the given number of units, and subdivide surfaces like with `q3map_tessSize` if this is not met"},
                {"-tmpout", "Write the BSP file to /tmp"},
@@ -138,7 +142,8 @@ void HelpVis()
                {"-nopassage", "Just use PortalFlow vis (usually less fps)"},
                {"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
                {"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
                {"-nopassage", "Just use PortalFlow vis (usually less fps)"},
                {"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
                {"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
-               {"-saveprt", "Keep the PRT file after running vis (so you can run vis again)"},
+               {"-prtfile <filename.prt>", "Portal file to read"},
+               {"-saveprt", "Keep the Portal file after running vis (so you can run vis again)"},
                {"-tmpin", "Use /tmp folder for input"},
                {"-tmpout", "Use /tmp folder for output"},
        };
                {"-tmpin", "Use /tmp folder for input"},
                {"-tmpout", "Use /tmp folder for output"},
        };
@@ -157,6 +162,7 @@ void HelpLight()
                {"-bounceonly", "Only compute radiosity"},
                {"-bouncescale <F>", "Scaling factor for radiosity"},
                {"-bounce <N>", "Number of bounces for radiosity"},
                {"-bounceonly", "Only compute radiosity"},
                {"-bouncescale <F>", "Scaling factor for radiosity"},
                {"-bounce <N>", "Number of bounces for radiosity"},
+               {"-bspfile <filename.bsp>", "BSP file to write"},
                {"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
                {"-cheap", "Abort vertex light calculations when white is reached"},
                {"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
                {"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
                {"-cheap", "Abort vertex light calculations when white is reached"},
                {"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
@@ -223,6 +229,7 @@ void HelpLight()
                {"-shade", "Enable phong shading at default shade angle"},
                {"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
                {"-smooth", "Deprecated alias for `-samples 2`"},
                {"-shade", "Enable phong shading at default shade angle"},
                {"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
                {"-smooth", "Deprecated alias for `-samples 2`"},
+               {"-srffile <filename.srf>", "Surface file to read"},
                {"-style, -styles", "Enable support for light styles"},
                {"-sunonly", "Only compute sun light"},
                {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
                {"-style, -styles", "Enable support for light styles"},
                {"-sunonly", "Only compute sun light"},
                {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
index 5d448ba54045ac7241688550b328ae8500c3e758..243af8a3c45ea0e3dc10775ed00da2be74c711f6 100644 (file)
@@ -43,7 +43,7 @@
 
    LEAK FILE GENERATION
 
 
    LEAK FILE GENERATION
 
-   Save out name.line for qe3 to read
+   Save out name.lin for qe3 to read
    ==============================================================================
  */
 
    ==============================================================================
  */
 
    TTimo: builds a polyline xml node
    =============
  */
    TTimo: builds a polyline xml node
    =============
  */
-xmlNodePtr LeakFile( tree_t *tree ){
+xmlNodePtr LeakFile( tree_t *tree, const char *filename ){
        vec3_t mid;
        FILE    *linefile;
        vec3_t mid;
        FILE    *linefile;
-       char filename[1024];
        node_t  *node;
        int count;
        xmlNodePtr xml_node, point;
        node_t  *node;
        int count;
        xmlNodePtr xml_node, point;
@@ -76,7 +75,6 @@ xmlNodePtr LeakFile( tree_t *tree ){
        //
        // write the points to the file
        //
        //
        // write the points to the file
        //
-       sprintf( filename, "%s.lin", source );
        linefile = fopen( filename, "w" );
        if ( !linefile ) {
                Error( "Couldn't open %s\n", filename );
        linefile = fopen( filename, "w" );
        if ( !linefile ) {
                Error( "Couldn't open %s\n", filename );
index a09659795a527a326e7628697a36d20c8881d1fc..0e8d160200f7c5be45a006adce671afd34e9f3b5 100644 (file)
@@ -1890,7 +1890,7 @@ void SetupGrid( void ){
    does what it says...
  */
 
    does what it says...
  */
 
-void LightWorld( void ){
+void LightWorld( const char *BSPFilePath ){
        vec3_t color;
        float f;
        int b, bt;
        vec3_t color;
        float f;
        int b, bt;
@@ -2035,8 +2035,8 @@ void LightWorld( void ){
                /* store off the bsp between bounces */
                StoreSurfaceLightmaps();
                UnparseEntities();
                /* store off the bsp between bounces */
                StoreSurfaceLightmaps();
                UnparseEntities();
-               Sys_Printf( "Writing %s\n", source );
-               WriteBSPFile( source );
+               Sys_Printf( "Writing %s\n", BSPFilePath );
+               WriteBSPFile( BSPFilePath );
 
                /* note it */
                Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
 
                /* note it */
                Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
@@ -2109,7 +2109,10 @@ void LightWorld( void ){
 int LightMain( int argc, char **argv ){
        int i;
        float f;
 int LightMain( int argc, char **argv ){
        int i;
        float f;
-       char mapSource[ 1024 ];
+       char BSPFilePath[ 1024 ];
+       char surfaceFilePath[ 1024 ];
+       BSPFilePath[0] = 0;
+       surfaceFilePath[0] = 0;
        const char  *value;
        int lightmapMergeSize = 0;
        qboolean lightSamplesInsist = qfalse;
        const char  *value;
        int lightmapMergeSize = 0;
        qboolean lightSamplesInsist = qfalse;
@@ -2859,6 +2862,18 @@ int LightMain( int argc, char **argv ){
                        lightmapFill = qtrue;
                        Sys_Printf( "Filling lightmap colors from surrounding pixels to improve JPEG compression\n" );
                }
                        lightmapFill = qtrue;
                        Sys_Printf( "Filling lightmap colors from surrounding pixels to improve JPEG compression\n" );
                }
+               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 ], "-srffile" ) )
+               {
+                       strcpy( surfaceFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+               }
                /* unhandled args */
                else
                {
                /* unhandled args */
                else
                {
@@ -2912,29 +2927,37 @@ int LightMain( int argc, char **argv ){
                Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
        }
 
                Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
        }
 
-       /* clean up map name */
        strcpy( source, ExpandArg( argv[ i ] ) );
        StripExtension( source );
        strcpy( source, ExpandArg( argv[ i ] ) );
        StripExtension( source );
-       DefaultExtension( source, ".bsp" );
-       strcpy( mapSource, ExpandArg( argv[ i ] ) );
-       StripExtension( mapSource );
-       DefaultExtension( mapSource, ".map" );
+       DefaultExtension( source, ".map" );
+
+       if (!BSPFilePath[0]) {
+               strcpy( BSPFilePath, ExpandArg( argv[ i ] ) );
+               StripExtension( BSPFilePath );
+               DefaultExtension( BSPFilePath, ".bsp" );
+       }
+
+       if (!surfaceFilePath[0]) {
+               strcpy( surfaceFilePath, ExpandArg( argv[ i ] ) );
+               StripExtension( surfaceFilePath );
+               DefaultExtension( surfaceFilePath, ".srf" );
+       }
 
        /* ydnar: set default sample size */
        SetDefaultSampleSize( sampleSize );
 
        /* ydnar: handle shaders */
 
        /* ydnar: set default sample size */
        SetDefaultSampleSize( sampleSize );
 
        /* ydnar: handle shaders */
-       BeginMapShaderFile( source );
+       BeginMapShaderFile( BSPFilePath );
        LoadShaderInfo();
 
        /* note loading */
        Sys_Printf( "Loading %s\n", source );
 
        /* ydnar: load surface file */
        LoadShaderInfo();
 
        /* note loading */
        Sys_Printf( "Loading %s\n", source );
 
        /* ydnar: load surface file */
-       LoadSurfaceExtraFile( source );
+       LoadSurfaceExtraFile( surfaceFilePath );
 
        /* load bsp file */
 
        /* load bsp file */
-       LoadBSPFile( source );
+       LoadBSPFile( BSPFilePath );
 
        /* parse bsp entities */
        ParseEntities();
 
        /* parse bsp entities */
        ParseEntities();
@@ -2945,7 +2968,7 @@ int LightMain( int argc, char **argv ){
        /* load map file */
        value = ValueForKey( &entities[ 0 ], "_keepLights" );
        if ( value[ 0 ] != '1' ) {
        /* load map file */
        value = ValueForKey( &entities[ 0 ], "_keepLights" );
        if ( value[ 0 ] != '1' ) {
-               LoadMapFile( mapSource, qtrue, qfalse );
+               LoadMapFile( source, qtrue, qfalse );
        }
 
        /* set the entity/model origins and init yDrawVerts */
        }
 
        /* set the entity/model origins and init yDrawVerts */
@@ -2961,15 +2984,15 @@ int LightMain( int argc, char **argv ){
        SetupTraceNodes();
 
        /* light the world */
        SetupTraceNodes();
 
        /* light the world */
-       LightWorld();
+       LightWorld( BSPFilePath );
 
        /* ydnar: store off lightmaps */
        StoreSurfaceLightmaps();
 
        /* write out the bsp */
        UnparseEntities();
 
        /* ydnar: store off lightmaps */
        StoreSurfaceLightmaps();
 
        /* write out the bsp */
        UnparseEntities();
-       Sys_Printf( "Writing %s\n", source );
-       WriteBSPFile( source );
+       Sys_Printf( "Writing %s\n", BSPFilePath );
+       WriteBSPFile( BSPFilePath );
 
        /* ydnar: export lightmaps */
        if ( exportLightmaps && !externalLightmaps ) {
 
        /* ydnar: export lightmaps */
        if ( exportLightmaps && !externalLightmaps ) {
index 514d255f7b556ba2ce35597a04a1feb874f35f38..2cd7015c35acb47090c90e996b8121cfcfdb9a25 100644 (file)
@@ -371,17 +371,15 @@ void NumberClusters( tree_t *tree ) {
    WritePortalFile
    ================
  */
    WritePortalFile
    ================
  */
-void WritePortalFile( tree_t *tree ){
-       char filename[1024];
+void WritePortalFile( tree_t *tree, const char *portalFilePath ){
 
        Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
 
        // write the file
 
        Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
 
        // write the file
-       sprintf( filename, "%s.prt", source );
-       Sys_Printf( "writing %s\n", filename );
-       pf = fopen( filename, "w" );
+       Sys_Printf( "writing %s\n", portalFilePath );
+       pf = fopen( portalFilePath, "w" );
        if ( !pf ) {
        if ( !pf ) {
-               Error( "Error opening %s", filename );
+               Error( "Error opening %s", portalFilePath );
        }
 
        fprintf( pf, "%s\n", PORTALFILE );
        }
 
        fprintf( pf, "%s\n", PORTALFILE );
index 53bb60dac2502eae5ed8da79c8b0b1398dc44547..0100048ddf9e99846339d9027f6d11b71a85b690 100644 (file)
@@ -1626,12 +1626,12 @@ void                        MakeTreePortals( tree_t *tree );
 
 
 /* leakfile.c */
 
 
 /* leakfile.c */
-xmlNodePtr                  LeakFile( tree_t *tree );
+xmlNodePtr                  LeakFile( tree_t *tree, const char *lineFilePath );
 
 
 /* prtfile.c */
 void                        NumberClusters( tree_t *tree );
 
 
 /* prtfile.c */
 void                        NumberClusters( tree_t *tree );
-void                        WritePortalFile( tree_t *tree );
+void                        WritePortalFile( tree_t *tree, const char *portalFilePath );
 
 
 /* writebsp.c */
 
 
 /* writebsp.c */
@@ -1641,7 +1641,7 @@ void                        SetLightStyles( void );
 int                         EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
 
 void                        BeginBSPFile( void );
 int                         EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
 
 void                        BeginBSPFile( void );
-void                        EndBSPFile( qboolean do_write );
+void                        EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath );
 void                        EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
 void                        EmitFogs( void );
 
 void                        EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
 void                        EmitFogs( void );
 
@@ -1753,8 +1753,8 @@ int                         GetSurfaceExtraMinSampleSize( int num );
 float                       GetSurfaceExtraLongestCurve( int num );
 void                        GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
 
 float                       GetSurfaceExtraLongestCurve( int num );
 void                        GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
 
-void                        WriteSurfaceExtraFile( const char *path );
-void                        LoadSurfaceExtraFile( const char *path );
+void                        WriteSurfaceExtraFile( const char *surfaceFilePath );
+void                        LoadSurfaceExtraFile( const char *surfaceFilePath );
 
 
 /* decals.c */
 
 
 /* decals.c */
index 291cce263075356d3732b737ce39f5d782363d3d..676896e4ceb3b36d13099966c00619aa37f56c55 100644 (file)
@@ -211,15 +211,14 @@ void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis ){
    writes out a surface info file (<map>.srf)
  */
 
    writes out a surface info file (<map>.srf)
  */
 
-void WriteSurfaceExtraFile( const char *path ){
-       char srfPath[ 1024 ];
+void WriteSurfaceExtraFile( const char *surfaceFilePath ){
        FILE            *sf;
        surfaceExtra_t  *se;
        int i;
 
 
        /* dummy check */
        FILE            *sf;
        surfaceExtra_t  *se;
        int i;
 
 
        /* dummy check */
-       if ( path == NULL || path[ 0 ] == '\0' ) {
+       if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
                return;
        }
 
                return;
        }
 
@@ -227,13 +226,10 @@ void WriteSurfaceExtraFile( const char *path ){
        Sys_Printf( "--- WriteSurfaceExtraFile ---\n" );
 
        /* open the file */
        Sys_Printf( "--- WriteSurfaceExtraFile ---\n" );
 
        /* open the file */
-       strcpy( srfPath, path );
-       StripExtension( srfPath );
-       strcat( srfPath, ".srf" );
-       Sys_Printf( "Writing %s\n", srfPath );
-       sf = fopen( srfPath, "w" );
+       Sys_Printf( "Writing %s\n", surfaceFilePath );
+       sf = fopen( surfaceFilePath, "w" );
        if ( sf == NULL ) {
        if ( sf == NULL ) {
-               Error( "Error opening %s for writing", srfPath );
+               Error( "Error opening %s for writing", surfaceFilePath );
        }
 
        /* lap through the extras list */
        }
 
        /* lap through the extras list */
@@ -321,26 +317,22 @@ void WriteSurfaceExtraFile( const char *path ){
    reads a surface info file (<map>.srf)
  */
 
    reads a surface info file (<map>.srf)
  */
 
-void LoadSurfaceExtraFile( const char *path ){
-       char srfPath[ 1024 ];
+void LoadSurfaceExtraFile( const char *surfaceFilePath ){
        surfaceExtra_t  *se;
        int surfaceNum, size;
        byte            *buffer;
 
 
        /* dummy check */
        surfaceExtra_t  *se;
        int surfaceNum, size;
        byte            *buffer;
 
 
        /* dummy check */
-       if ( path == NULL || path[ 0 ] == '\0' ) {
+       if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
                return;
        }
 
        /* load the file */
                return;
        }
 
        /* load the file */
-       strcpy( srfPath, path );
-       StripExtension( srfPath );
-       strcat( srfPath, ".srf" );
-       Sys_Printf( "Loading %s\n", srfPath );
-       size = LoadFile( srfPath, (void**) &buffer );
+       Sys_Printf( "Loading %s\n", surfaceFilePath );
+       size = LoadFile( surfaceFilePath, (void**) &buffer );
        if ( size <= 0 ) {
        if ( size <= 0 ) {
-               Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", srfPath );
+               Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", surfaceFilePath );
                return;
        }
 
                return;
        }
 
@@ -365,7 +357,7 @@ void LoadSurfaceExtraFile( const char *path ){
                {
                        surfaceNum = atoi( token );
                        if ( surfaceNum < 0 || surfaceNum > MAX_MAP_DRAW_SURFS ) {
                {
                        surfaceNum = atoi( token );
                        if ( surfaceNum < 0 || surfaceNum > MAX_MAP_DRAW_SURFS ) {
-                               Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", srfPath, scriptline, surfaceNum );
+                               Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", surfaceFilePath, scriptline, surfaceNum );
                        }
                        while ( surfaceNum >= numSurfaceExtras )
                                se = AllocSurfaceExtra();
                        }
                        while ( surfaceNum >= numSurfaceExtras )
                                se = AllocSurfaceExtra();
@@ -374,7 +366,7 @@ void LoadSurfaceExtraFile( const char *path ){
 
                /* handle { } section */
                if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
 
                /* handle { } section */
                if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
-                       Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", srfPath, scriptline );
+                       Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", surfaceFilePath, scriptline );
                }
                while ( 1 )
                {
                }
                while ( 1 )
                {
index b166c91fc4f576f46a1f964dad2c98b31d83e820..702b7bfe1cd144597298eff3b7005f9576d3558c 100644 (file)
@@ -812,16 +812,16 @@ int CountActivePortals( void ){
  */
 void WriteFloat( FILE *f, vec_t v );
 
  */
 void WriteFloat( FILE *f, vec_t v );
 
-void WritePortals( char *filename ){
+void WritePortals( char *portalpathfile ){
        int i, j, num;
        FILE *pf;
        vportal_t *p;
        fixedWinding_t *w;
 
        // write the file
        int i, j, num;
        FILE *pf;
        vportal_t *p;
        fixedWinding_t *w;
 
        // write the file
-       pf = fopen( filename, "w" );
+       pf = fopen( portalpathfile, "w" );
        if ( !pf ) {
        if ( !pf ) {
-               Error( "Error opening %s", filename );
+               Error( "Error opening %s", portalpathfile );
        }
 
        num = 0;
        }
 
        num = 0;
@@ -1099,8 +1099,9 @@ void LoadPortals( char *name ){
    ===========
  */
 int VisMain( int argc, char **argv ){
    ===========
  */
 int VisMain( int argc, char **argv ){
-       char portalfile[1024];
        int i;
        int i;
+       char portalFilePath[ 1024 ];
+       portalFilePath[0] = 0;
 
 
        /* note it */
 
 
        /* note it */
@@ -1148,13 +1149,18 @@ int VisMain( int argc, char **argv ){
                        strcpy( outbase, "/tmp" );
                }
 
                        strcpy( outbase, "/tmp" );
                }
 
-
                /* ydnar: -hint to merge all but hint portals */
                else if ( !strcmp( argv[ i ], "-hint" ) ) {
                        Sys_Printf( "hint = true\n" );
                        hint = qtrue;
                        mergevis = qtrue;
                }
                /* ydnar: -hint to merge all but hint portals */
                else if ( !strcmp( argv[ i ], "-hint" ) ) {
                        Sys_Printf( "hint = true\n" );
                        hint = qtrue;
                        mergevis = qtrue;
                }
+               else if ( !strcmp( argv[ i ], "-prtfile" ) )
+               {
+                       strcpy( portalFilePath, argv[i + 1] );
+                       i++;
+                       Sys_Printf( "Use %s as portal file\n", portalFilePath );
+               }
 
                else
                {
 
                else
                {
@@ -1163,7 +1169,7 @@ int VisMain( int argc, char **argv ){
        }
 
        if ( i != argc - 1 ) {
        }
 
        if ( i != argc - 1 ) {
-               Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile" );
+               Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] BSPFilePath" );
        }
 
 
        }
 
 
@@ -1175,11 +1181,13 @@ int VisMain( int argc, char **argv ){
        LoadBSPFile( source );
 
        /* load the portal file */
        LoadBSPFile( source );
 
        /* load the portal file */
-       sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) );
-       StripExtension( portalfile );
-       strcat( portalfile, ".prt" );
-       Sys_Printf( "Loading %s\n", portalfile );
-       LoadPortals( portalfile );
+       if (!portalFilePath[0]) {
+               sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
+               StripExtension( portalFilePath );
+               strcat( portalFilePath, ".prt" );
+               Sys_Printf( "Loading %s\n", portalFilePath );
+               LoadPortals( portalFilePath );
+       }
 
        /* ydnar: exit if no portals, hence no vis */
        if ( numportals == 0 ) {
 
        /* ydnar: exit if no portals, hence no vis */
        if ( numportals == 0 ) {
@@ -1211,7 +1219,7 @@ int VisMain( int argc, char **argv ){
 
        /* delete the prt file */
        if ( !saveprt ) {
 
        /* delete the prt file */
        if ( !saveprt ) {
-               remove( portalfile );
+               remove( portalFilePath );
        }
 
        /* write the bsp file */
        }
 
        /* write the bsp file */
index 24692449f10318718589dddf213555c5cddc4b37..186bbd2fb8110214c44a23fd69b518e587cbd16f 100644 (file)
@@ -402,9 +402,7 @@ void BeginBSPFile( void ){
    finishes a new bsp and writes to disk
  */
 
    finishes a new bsp and writes to disk
  */
 
-void EndBSPFile( qboolean do_write ){
-       char path[ 1024 ];
-
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath ){
 
        Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
 
 
        Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
 
@@ -415,12 +413,11 @@ void EndBSPFile( qboolean do_write ){
 
        if ( do_write ) {
                /* write the surface extra file */
 
        if ( do_write ) {
                /* write the surface extra file */
-               WriteSurfaceExtraFile( source );
+               WriteSurfaceExtraFile( surfaceFilePath );
 
                /* write the bsp */
 
                /* write the bsp */
-               sprintf( path, "%s.bsp", source );
-               Sys_Printf( "Writing %s\n", path );
-               WriteBSPFile( path );
+               Sys_Printf( "Writing %s\n", BSPFilePath );
+               WriteBSPFile( BSPFilePath );
        }
 }
 
        }
 }