From: Thomas Debesse Date: Mon, 20 Jul 2015 10:39:42 +0000 (+0200) Subject: enable q3map2 out of tree compilation X-Git-Tag: xonotic-v0.8.2~14^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b13a86abcfa99aa0898d11e90a9c4e811b55d432;p=xonotic%2Fnetradiant.git enable q3map2 out of tree compilation --- diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index da737460..4ac39f36 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -265,7 +265,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 +343,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 +380,7 @@ void ProcessWorldModel( void ){ /* save out information for visibility processing */ NumberClusters( tree ); if ( !leaked ) { - WritePortalFile( tree ); + WritePortalFile( tree, portalFilePath ); } /* flood from entities */ @@ -592,7 +592,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 +618,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 +645,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 +685,7 @@ void OnlyEnts( void ){ 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; + 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 */ @@ -978,6 +983,30 @@ 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" ); } @@ -999,13 +1028,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 +1057,7 @@ int BSPMain( int argc, char **argv ){ /* if onlyents, just grab the entites and resave */ if ( onlyents ) { - OnlyEnts(); + OnlyEnts( BSPFilePath ); return 0; } @@ -1043,7 +1082,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 +1091,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 ) { diff --git a/tools/quake3/q3map2/convert_bsp.c b/tools/quake3/q3map2/convert_bsp.c index 5a03df9c..ac627031 100644 --- a/tools/quake3/q3map2/convert_bsp.c +++ b/tools/quake3/q3map2/convert_bsp.c @@ -37,7 +37,7 @@ 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; @@ -125,7 +125,7 @@ void PseudoCompileBSP( qboolean need_tree ){ 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]; + char BSPFilePath [ 1024 ]; + char surfaceFilePath [ 1024 ]; 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 ); - PseudoCompileBSP( convertGame != NULL ); + sprintf( BSPFilePath, "%s.bsp", source ); + sprintf( surfaceFilePath, "%s.srf", source ); + PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath ); } else { diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index 0dc528ad..f76a88db 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -88,6 +88,7 @@ void HelpBsp() struct HelpOption bsp[] = { {"-bsp ", "Switch that enters this stage"}, {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"}, + {"-bspfile ", "BSP file to write"}, {"-celshader ", "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"}, + {"-linefile ", "Line file to write"}, {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"}, {"-minsamplesize ", "Sets minimum lightmap resolution in luxels/qu"}, {"-mi ", "Sets the maximum number of indexes per surface"}, @@ -116,10 +118,12 @@ void HelpBsp() {"-np ", "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” suffix to miscmodel shaders (needed for SoF2)"}, + {"-prtfile ", "Portal file to write"}, + {"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"}, {"-samplesize ", "Sets default lightmap resolution in luxels/qu"}, {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"}, {"-snap ", "Snap brush bevel planes to the given number of units"}, + {"-srffile ", "Surface file to write"}, {"-tempname ", "Read the MAP file from the given file name"}, {"-texrange ", "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)"}, - {"-saveprt", "Keep the PRT file after running vis (so you can run vis again)"}, + {"-prtfile ", "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"}, }; @@ -157,6 +162,7 @@ void HelpLight() {"-bounceonly", "Only compute radiosity"}, {"-bouncescale ", "Scaling factor for radiosity"}, {"-bounce ", "Number of bounces for radiosity"}, + {"-bspfile ", "BSP file to write"}, {"-cheapgrid", "Use `-cheap` style lighting for radiosity"}, {"-cheap", "Abort vertex light calculations when white is reached"}, {"-compensate ", "Lightmap compensate (darkening factor applied after everything else)"}, @@ -223,6 +229,7 @@ void HelpLight() {"-shade", "Enable phong shading at default shade angle"}, {"-skyscale ", "Scaling factor for sky and sun light"}, {"-smooth", "Deprecated alias for `-samples 2`"}, + {"-srffile ", "Surface file to read"}, {"-style, -styles", "Enable support for light styles"}, {"-sunonly", "Only compute sun light"}, {"-super ", "Ordered grid supersampling quality"}, diff --git a/tools/quake3/q3map2/leakfile.c b/tools/quake3/q3map2/leakfile.c index 5d448ba5..243af8a3 100644 --- a/tools/quake3/q3map2/leakfile.c +++ b/tools/quake3/q3map2/leakfile.c @@ -43,7 +43,7 @@ LEAK FILE GENERATION - Save out name.line for qe3 to read + Save out name.lin for qe3 to read ============================================================================== */ @@ -59,10 +59,9 @@ TTimo: builds a polyline xml node ============= */ -xmlNodePtr LeakFile( tree_t *tree ){ +xmlNodePtr LeakFile( tree_t *tree, const char *filename ){ vec3_t mid; FILE *linefile; - char filename[1024]; node_t *node; int count; xmlNodePtr xml_node, point; @@ -76,7 +75,6 @@ xmlNodePtr LeakFile( tree_t *tree ){ // // write the points to the file // - sprintf( filename, "%s.lin", source ); linefile = fopen( filename, "w" ); if ( !linefile ) { Error( "Couldn't open %s\n", filename ); diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index a0965979..0e8d1602 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1890,7 +1890,7 @@ void SetupGrid( void ){ does what it says... */ -void LightWorld( void ){ +void LightWorld( const char *BSPFilePath ){ vec3_t color; float f; int b, bt; @@ -2035,8 +2035,8 @@ void LightWorld( void ){ /* 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 ); @@ -2109,7 +2109,10 @@ void LightWorld( void ){ 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; @@ -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" ); } + 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 { @@ -2912,29 +2927,37 @@ int LightMain( int argc, char **argv ){ Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize ); } - /* clean up map name */ 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 */ - BeginMapShaderFile( source ); + BeginMapShaderFile( BSPFilePath ); LoadShaderInfo(); /* note loading */ Sys_Printf( "Loading %s\n", source ); /* ydnar: load surface file */ - LoadSurfaceExtraFile( source ); + LoadSurfaceExtraFile( surfaceFilePath ); /* load bsp file */ - LoadBSPFile( source ); + LoadBSPFile( BSPFilePath ); /* 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' ) { - LoadMapFile( mapSource, qtrue, qfalse ); + LoadMapFile( source, qtrue, qfalse ); } /* set the entity/model origins and init yDrawVerts */ @@ -2961,15 +2984,15 @@ int LightMain( int argc, char **argv ){ SetupTraceNodes(); /* light the world */ - LightWorld(); + LightWorld( BSPFilePath ); /* 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 ) { diff --git a/tools/quake3/q3map2/prtfile.c b/tools/quake3/q3map2/prtfile.c index 514d255f..2cd7015c 100644 --- a/tools/quake3/q3map2/prtfile.c +++ b/tools/quake3/q3map2/prtfile.c @@ -371,17 +371,15 @@ void NumberClusters( tree_t *tree ) { 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 - 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 ) { - Error( "Error opening %s", filename ); + Error( "Error opening %s", portalFilePath ); } fprintf( pf, "%s\n", PORTALFILE ); diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 53bb60da..0100048d 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1626,12 +1626,12 @@ void MakeTreePortals( tree_t *tree ); /* leakfile.c */ -xmlNodePtr LeakFile( tree_t *tree ); +xmlNodePtr LeakFile( tree_t *tree, const char *lineFilePath ); /* prtfile.c */ void NumberClusters( tree_t *tree ); -void WritePortalFile( tree_t *tree ); +void WritePortalFile( tree_t *tree, const char *portalFilePath ); /* writebsp.c */ @@ -1641,7 +1641,7 @@ void SetLightStyles( 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 ); @@ -1753,8 +1753,8 @@ int GetSurfaceExtraMinSampleSize( int num ); 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 */ diff --git a/tools/quake3/q3map2/surface_extra.c b/tools/quake3/q3map2/surface_extra.c index 291cce26..676896e4 100644 --- a/tools/quake3/q3map2/surface_extra.c +++ b/tools/quake3/q3map2/surface_extra.c @@ -211,15 +211,14 @@ void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis ){ writes out a surface info file (.srf) */ -void WriteSurfaceExtraFile( const char *path ){ - char srfPath[ 1024 ]; +void WriteSurfaceExtraFile( const char *surfaceFilePath ){ FILE *sf; surfaceExtra_t *se; int i; /* dummy check */ - if ( path == NULL || path[ 0 ] == '\0' ) { + if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) { return; } @@ -227,13 +226,10 @@ void WriteSurfaceExtraFile( const char *path ){ 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 ) { - Error( "Error opening %s for writing", srfPath ); + Error( "Error opening %s for writing", surfaceFilePath ); } /* lap through the extras list */ @@ -321,26 +317,22 @@ void WriteSurfaceExtraFile( const char *path ){ reads a surface info file (.srf) */ -void LoadSurfaceExtraFile( const char *path ){ - char srfPath[ 1024 ]; +void LoadSurfaceExtraFile( const char *surfaceFilePath ){ 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 */ - 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 ) { - 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; } @@ -365,7 +357,7 @@ void LoadSurfaceExtraFile( const char *path ){ { 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(); @@ -374,7 +366,7 @@ void LoadSurfaceExtraFile( const char *path ){ /* 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 ) { diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index b166c91f..702b7bfe 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -812,16 +812,16 @@ int CountActivePortals( void ){ */ 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 - pf = fopen( filename, "w" ); + pf = fopen( portalpathfile, "w" ); if ( !pf ) { - Error( "Error opening %s", filename ); + Error( "Error opening %s", portalpathfile ); } num = 0; @@ -1099,8 +1099,9 @@ void LoadPortals( char *name ){ =========== */ int VisMain( int argc, char **argv ){ - char portalfile[1024]; int i; + char portalFilePath[ 1024 ]; + portalFilePath[0] = 0; /* note it */ @@ -1148,13 +1149,18 @@ int VisMain( int argc, char **argv ){ 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; } + else if ( !strcmp( argv[ i ], "-prtfile" ) ) + { + strcpy( portalFilePath, argv[i + 1] ); + i++; + Sys_Printf( "Use %s as portal file\n", portalFilePath ); + } else { @@ -1163,7 +1169,7 @@ int VisMain( int argc, char **argv ){ } 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 */ - 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 ) { @@ -1211,7 +1219,7 @@ int VisMain( int argc, char **argv ){ /* delete the prt file */ if ( !saveprt ) { - remove( portalfile ); + remove( portalFilePath ); } /* write the bsp file */ diff --git a/tools/quake3/q3map2/writebsp.c b/tools/quake3/q3map2/writebsp.c index 24692449..186bbd2f 100644 --- a/tools/quake3/q3map2/writebsp.c +++ b/tools/quake3/q3map2/writebsp.c @@ -402,9 +402,7 @@ void BeginBSPFile( void ){ 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" ); @@ -415,12 +413,11 @@ void EndBSPFile( qboolean do_write ){ if ( do_write ) { /* write the surface extra file */ - WriteSurfaceExtraFile( source ); + WriteSurfaceExtraFile( surfaceFilePath ); /* write the bsp */ - sprintf( path, "%s.bsp", source ); - Sys_Printf( "Writing %s\n", path ); - WriteBSPFile( path ); + Sys_Printf( "Writing %s\n", BSPFilePath ); + WriteBSPFile( BSPFilePath ); } }