1 /* -------------------------------------------------------------------------------
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
6 This file is part of GtkRadiant.
8 GtkRadiant is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 GtkRadiant is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GtkRadiant; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ----------------------------------------------------------------------------------
24 This code has been altered significantly from its original form, to support
25 several games based on the Quake III Arena engine, in the form of "Q3Map2."
27 ------------------------------------------------------------------------------- */
41 /* -------------------------------------------------------------------------------
45 ------------------------------------------------------------------------------- */
49 ProcessAdvertisements()
50 copies advertisement info into the BSP structures
53 static void ProcessAdvertisements( void ) {
55 const char* className;
59 bspDrawSurface_t* adSurface;
61 Sys_FPrintf( SYS_VRB, "--- ProcessAdvertisements ---\n" );
63 for( i = 0; i < numEntities; i++ ) {
65 /* is an advertisement? */
66 className = ValueForKey( &entities[ i ], "classname" );
68 if( !Q_stricmp( "advertisement", className ) ) {
70 modelKey = ValueForKey( &entities[ i ], "model" );
72 if( strlen( modelKey ) > MAX_QPATH - 1 ) {
73 Error( "Model Key for entity exceeds ad struct string length." );
75 if( numBSPAds < MAX_MAP_ADVERTISEMENTS ) {
76 bspAds[numBSPAds].cellId = IntForKey( &entities[ i ], "cellId" );
77 strncpy( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) );
80 modelNum = atoi( modelKey );
81 adModel = &bspModels[modelNum];
83 if( adModel->numBSPSurfaces != 1 ) {
84 Error( "Ad cell id %d has more than one surface.", bspAds[numBSPAds].cellId );
87 adSurface = &bspDrawSurfaces[adModel->firstBSPSurface];
89 // store the normal for use at run time.. all ad verts are assumed to
90 // have identical normals (because they should be a simple rectangle)
91 // so just use the first vert's normal
92 VectorCopy( bspDrawVerts[adSurface->firstVert].normal, bspAds[numBSPAds].normal );
94 // store the ad quad for quick use at run time
95 if( adSurface->surfaceType == MST_PATCH ) {
96 int v0 = adSurface->firstVert + adSurface->patchHeight - 1;
97 int v1 = adSurface->firstVert + adSurface->numVerts - 1;
98 int v2 = adSurface->firstVert + adSurface->numVerts - adSurface->patchWidth;
99 int v3 = adSurface->firstVert;
100 VectorCopy( bspDrawVerts[v0].xyz, bspAds[numBSPAds].rect[0] );
101 VectorCopy( bspDrawVerts[v1].xyz, bspAds[numBSPAds].rect[1] );
102 VectorCopy( bspDrawVerts[v2].xyz, bspAds[numBSPAds].rect[2] );
103 VectorCopy( bspDrawVerts[v3].xyz, bspAds[numBSPAds].rect[3] );
105 Error( "Ad cell %d has an unsupported Ad Surface type.", bspAds[numBSPAds].cellId );
110 Error( "Maximum number of map advertisements exceeded." );
116 Sys_FPrintf( SYS_VRB, "%9d in-game advertisements\n", numBSPAds );
120 SetCloneModelNumbers() - ydnar
121 sets the model numbers for brush entities
124 static void SetCloneModelNumbers( void )
128 char modelValue[ 10 ];
129 const char *value, *value2, *value3;
132 /* start with 1 (worldspawn is model 0) */
134 for( i = 1; i < numEntities; i++ )
136 /* only entities with brushes or patches get a model number */
137 if( entities[ i ].brushes == NULL && entities[ i ].patches == NULL )
140 /* is this a clone? */
141 value = ValueForKey( &entities[ i ], "_clone" );
142 if( value[ 0 ] != '\0' )
145 /* add the model key */
146 sprintf( modelValue, "*%d", models );
147 SetKeyValue( &entities[ i ], "model", modelValue );
149 /* increment model count */
154 for( i = 1; i < numEntities; i++ )
156 /* only entities with brushes or patches get a model number */
157 if( entities[ i ].brushes == NULL && entities[ i ].patches == NULL )
160 /* is this a clone? */
161 value = ValueForKey( &entities[ i ], "_ins" );
162 if( value[ 0 ] == '\0' )
163 value = ValueForKey( &entities[ i ], "_instance" );
164 if( value[ 0 ] == '\0' )
165 value = ValueForKey( &entities[ i ], "_clone" );
166 if( value[ 0 ] == '\0' )
169 /* find an entity with matching clone name */
170 for( j = 0; j < numEntities; j++ )
172 /* is this a clone parent? */
173 value2 = ValueForKey( &entities[ j ], "_clonename" );
174 if( value2[ 0 ] == '\0' )
178 if( strcmp( value, value2 ) == 0 )
180 /* get the model num */
181 value3 = ValueForKey( &entities[ j ], "model" );
182 if( value3[ 0 ] == '\0' )
184 Sys_Printf( "WARNING: Cloned entity %s referenced entity without model\n", value2 );
187 models = atoi( &value2[ 1 ] );
189 /* add the model key */
190 sprintf( modelValue, "*%d", models );
191 SetKeyValue( &entities[ i ], "model", modelValue );
193 /* nuke the brushes/patches for this entity (fixme: leak!) */
194 entities[ i ].brushes = NULL;
195 entities[ i ].patches = NULL;
204 FixBrushSides() - ydnar
205 matches brushsides back to their appropriate drawsurface and shader
208 static void FixBrushSides( entity_t *e )
211 mapDrawSurface_t *ds;
213 bspBrushSide_t *side;
217 Sys_FPrintf( SYS_VRB, "--- FixBrushSides ---\n" );
219 /* walk list of drawsurfaces */
220 for( i = e->firstDrawSurf; i < numMapDrawSurfs; i++ )
222 /* get surface and try to early out */
223 ds = &mapDrawSurfs[ i ];
224 if( ds->outputNum < 0 )
227 /* walk sideref list */
228 for( sideRef = ds->sideRef; sideRef != NULL; sideRef = sideRef->next )
230 /* get bsp brush side */
231 if( sideRef->side == NULL || sideRef->side->outputNum < 0 )
233 side = &bspBrushSides[ sideRef->side->outputNum ];
235 /* set drawsurface */
236 side->surfaceNum = ds->outputNum;
237 //% Sys_FPrintf( SYS_VRB, "DS: %7d Side: %7d ", ds->outputNum, sideRef->side->outputNum );
240 if( strcmp( bspShaders[ side->shaderNum ].shader, ds->shaderInfo->shader ) )
242 //% Sys_FPrintf( SYS_VRB, "Remapping %s to %s\n", bspShaders[ side->shaderNum ].shader, ds->shaderInfo->shader );
243 side->shaderNum = EmitShader( ds->shaderInfo->shader, &ds->shaderInfo->contentFlags, &ds->shaderInfo->surfaceFlags );
253 creates a full bsp + surfaces for the worldspawn entity
256 void ProcessWorldModel( void )
262 qboolean ignoreLeaks, leaked;
263 xmlNodePtr polyline, leaknode;
264 char level[ 2 ], shader[ 1024 ];
268 /* sets integer blockSize from worldspawn "_blocksize" key if it exists */
269 value = ValueForKey( &entities[ 0 ], "_blocksize" );
270 if( value[ 0 ] == '\0' )
271 value = ValueForKey( &entities[ 0 ], "blocksize" );
272 if( value[ 0 ] == '\0' )
273 value = ValueForKey( &entities[ 0 ], "chopsize" ); /* sof2 */
274 if( value[ 0 ] != '\0' )
277 s = sscanf( value, "%d %d %d", &blockSize[ 0 ], &blockSize[ 1 ], &blockSize[ 2 ] );
279 /* handle legacy case */
282 blockSize[ 1 ] = blockSize[ 0 ];
283 blockSize[ 2 ] = blockSize[ 0 ];
286 Sys_Printf( "block size = { %d %d %d }\n", blockSize[ 0 ], blockSize[ 1 ], blockSize[ 2 ] );
288 /* sof2: ignore leaks? */
289 value = ValueForKey( &entities[ 0 ], "_ignoreleaks" ); /* ydnar */
290 if( value[ 0 ] == '\0' )
291 value = ValueForKey( &entities[ 0 ], "ignoreleaks" );
292 if( value[ 0 ] == '1' )
295 ignoreLeaks = qfalse;
297 /* begin worldspawn model */
300 e->firstDrawSurf = 0;
303 ClearMetaTriangles();
305 /* check for patches with adjacent edges that need to lod together */
306 PatchMapDrawSurfs( e );
308 /* build an initial bsp tree using all of the sides of all of the structural brushes */
309 faces = MakeStructuralBSPFaceList( entities[ 0 ].brushes );
310 tree = FaceBSP( faces );
311 MakeTreePortals( tree );
312 FilterStructuralBrushesIntoTree( e, tree );
314 /* see if the bsp is completely enclosed */
315 if( FloodEntities( tree ) || ignoreLeaks )
317 /* rebuild a better bsp tree using only the sides that are visible from the inside */
318 FillOutside( tree->headnode );
320 /* chop the sides to the convex hull of their visible fragments, giving us the smallest polygons */
321 ClipSidesIntoTree( e, tree );
323 /* build a visible face tree */
324 faces = MakeVisibleBSPFaceList( entities[ 0 ].brushes );
326 tree = FaceBSP( faces );
327 MakeTreePortals( tree );
328 FilterStructuralBrushesIntoTree( e, tree );
331 /* ydnar: flood again for skybox */
333 FloodEntities( tree );
337 Sys_FPrintf( SYS_NOXML, "**********************\n" );
338 Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
339 Sys_FPrintf( SYS_NOXML, "**********************\n" );
340 polyline = LeakFile( tree );
341 leaknode = xmlNewNode( NULL, "message" );
342 xmlNodeSetContent( leaknode, "MAP LEAKED\n" );
343 xmlAddChild( leaknode, polyline );
344 level[0] = (int) '0' + SYS_ERR;
346 xmlSetProp( leaknode, "level", (char*) &level );
347 xml_SendNode( leaknode );
350 Sys_Printf ("--- MAP LEAKED, ABORTING LEAKTEST ---\n");
355 /* chop the sides to the convex hull of their visible fragments, giving us the smallest polygons */
356 ClipSidesIntoTree( e, tree );
359 /* save out information for visibility processing */
360 NumberClusters( tree );
362 WritePortalFile( tree );
364 /* flood from entities */
367 /* create drawsurfs for triangle models */
368 AddTriangleModels( e );
370 /* create drawsurfs for surface models */
371 AddEntitySurfaceModels( e );
373 /* generate bsp brushes from map brushes */
374 EmitBrushes( e->brushes, &e->firstBrush, &e->numBrushes );
376 /* add references to the detail brushes */
377 FilterDetailBrushesIntoTree( e, tree );
379 /* drawsurfs that cross fog boundaries will need to be split along the fog boundary */
381 FogDrawSurfaces( e );
383 /* subdivide each drawsurf as required by shader tesselation */
385 SubdivideFaceSurfaces( e, tree );
387 /* add in any vertexes required to fix t-junctions */
391 /* ydnar: classify the surfaces */
392 ClassifyEntitySurfaces( e );
394 /* ydnar: project decals */
395 MakeEntityDecals( e );
397 /* ydnar: meta surfaces */
398 MakeEntityMetaTriangles( e );
399 SmoothMetaTriangles();
401 MergeMetaTriangles();
403 /* ydnar: debug portals */
405 MakeDebugPortalSurfs( tree );
407 /* ydnar: fog hull */
408 value = ValueForKey( &entities[ 0 ], "_foghull" );
409 if( value[ 0 ] != '\0' )
411 sprintf( shader, "textures/%s", value );
412 MakeFogHullSurfs( e, tree, shader );
415 /* ydnar: bug 645: do flares for lights */
416 for( i = 0; i < numEntities && emitFlares; i++ )
418 entity_t *light, *target;
419 const char *value, *flareShader;
420 vec3_t origin, targetOrigin, normal, color;
425 light = &entities[ i ];
426 value = ValueForKey( light, "classname" );
427 if( !strcmp( value, "light" ) )
429 /* get flare shader */
430 flareShader = ValueForKey( light, "_flareshader" );
431 value = ValueForKey( light, "_flare" );
432 if( flareShader[ 0 ] != '\0' || value[ 0 ] != '\0' )
435 GetVectorForKey( light, "origin", origin );
436 GetVectorForKey( light, "_color", color );
437 lightStyle = IntForKey( light, "_style" );
438 if( lightStyle == 0 )
439 lightStyle = IntForKey( light, "style" );
441 /* handle directional spotlights */
442 value = ValueForKey( light, "target" );
443 if( value[ 0 ] != '\0' )
445 /* get target light */
446 target = FindTargetEntity( value );
449 GetVectorForKey( target, "origin", targetOrigin );
450 VectorSubtract( targetOrigin, origin, normal );
451 VectorNormalize( normal, normal );
455 //% VectorClear( normal );
456 VectorSet( normal, 0, 0, -1 );
458 /* create the flare surface (note shader defaults automatically) */
459 DrawSurfaceForFlare( mapEntityNum, origin, normal, color, (char*) flareShader, lightStyle );
464 /* add references to the final drawsurfs in the apropriate clusters */
465 FilterDrawsurfsIntoTree( e, tree );
467 /* match drawsurfaces back to original brushsides (sof2) */
471 EndModel( e, tree->headnode );
479 creates bsp + surfaces for other brush models
482 void ProcessSubModel( void )
490 /* start a brush model */
492 e = &entities[ mapEntityNum ];
493 e->firstDrawSurf = numMapDrawSurfs;
496 ClearMetaTriangles();
498 /* check for patches with adjacent edges that need to lod together */
499 PatchMapDrawSurfs( e );
501 /* allocate a tree */
503 node->planenum = PLANENUM_LEAF;
505 tree->headnode = node;
507 /* add the sides to the tree */
508 ClipSidesIntoTree( e, tree );
510 /* ydnar: create drawsurfs for triangle models */
511 AddTriangleModels( e );
513 /* create drawsurfs for surface models */
514 AddEntitySurfaceModels( e );
516 /* generate bsp brushes from map brushes */
517 EmitBrushes( e->brushes, &e->firstBrush, &e->numBrushes );
519 /* just put all the brushes in headnode */
520 for( b = e->brushes; b; b = b->next )
523 bc->next = node->brushlist;
524 node->brushlist = bc;
527 /* subdivide each drawsurf as required by shader tesselation */
529 SubdivideFaceSurfaces( e, tree );
531 /* add in any vertexes required to fix t-junctions */
535 /* ydnar: classify the surfaces and project lightmaps */
536 ClassifyEntitySurfaces( e );
538 /* ydnar: project decals */
539 MakeEntityDecals( e );
541 /* ydnar: meta surfaces */
542 MakeEntityMetaTriangles( e );
543 SmoothMetaTriangles();
545 MergeMetaTriangles();
547 /* add references to the final drawsurfs in the apropriate clusters */
548 FilterDrawsurfsIntoTree( e, tree );
550 /* match drawsurfaces back to original brushsides (sof2) */
562 process world + other models into the bsp
565 void ProcessModels( void )
571 /* preserve -v setting */
572 oldVerbose = verbose;
574 /* start a new bsp */
577 /* create map fogs */
580 /* walk entity list */
581 for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
584 entity = &entities[ mapEntityNum ];
585 if( entity->brushes == NULL && entity->patches == NULL )
588 /* process the model */
589 Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
590 if( mapEntityNum == 0 )
595 /* potentially turn off the deluge of text */
596 verbose = verboseEntities;
599 /* restore -v setting */
600 verbose = oldVerbose;
610 this is probably broken unless teamed with a radiant version that preserves entity order
613 void OnlyEnts( void )
617 char save_cmdline[1024], save_version[1024];
621 Sys_Printf( "--- OnlyEnts ---\n" );
623 sprintf( out, "%s.bsp", source );
627 p = ValueForKey(&entities[0], "_q3map2_cmdline");
628 strncpy(save_cmdline, p, sizeof(save_cmdline));
629 save_cmdline[sizeof(save_cmdline)-1] = 0;
630 p = ValueForKey(&entities[0], "_q3map2_version");
631 strncpy(save_version, p, sizeof(save_version));
632 save_version[sizeof(save_version)-1] = 0;
637 LoadMapFile( name, qfalse );
642 SetKeyValue(&entities[0], "_q3map2_cmdline", save_cmdline);
644 SetKeyValue(&entities[0], "_q3map2_version", save_version);
646 numBSPEntities = numEntities;
656 handles creation of a bsp from a map file
659 int BSPMain( int argc, char **argv )
662 char path[ 1024 ], tempSource[ 1024 ];
663 qboolean onlyents = qfalse;
667 Sys_Printf( "--- BSP ---\n" );
669 SetDrawSurfacesBuffer();
670 mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
671 memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
674 tempSource[ 0 ] = '\0';
676 /* set standard game flags */
677 maxSurfaceVerts = game->maxSurfaceVerts;
678 maxSurfaceIndexes = game->maxSurfaceIndexes;
679 emitFlares = game->emitFlares;
681 /* process arguments */
682 for( i = 1; i < (argc - 1); i++ )
684 if( !strcmp( argv[ i ], "-onlyents" ) )
686 Sys_Printf( "Running entity-only compile\n" );
689 else if( !strcmp( argv[ i ], "-tempname" ) )
690 strcpy( tempSource, argv[ ++i ] );
691 else if( !strcmp( argv[ i ], "-tmpout" ) )
692 strcpy( outbase, "/tmp" );
693 else if( !strcmp( argv[ i ], "-nowater" ) )
695 Sys_Printf( "Disabling water\n" );
698 else if( !strcmp( argv[ i ], "-nodetail" ) )
700 Sys_Printf( "Ignoring detail brushes\n") ;
703 else if( !strcmp( argv[ i ], "-fulldetail" ) )
705 Sys_Printf( "Turning detail brushes into structural brushes\n" );
708 else if( !strcmp( argv[ i ], "-nofog" ) )
710 Sys_Printf( "Fog volumes disabled\n" );
713 else if( !strcmp( argv[ i ], "-nosubdivide" ) )
715 Sys_Printf( "Disabling brush face subdivision\n" );
718 else if( !strcmp( argv[ i ], "-leaktest" ) )
720 Sys_Printf( "Leaktest enabled\n" );
723 else if( !strcmp( argv[ i ], "-verboseentities" ) )
725 Sys_Printf( "Verbose entities enabled\n" );
726 verboseEntities = qtrue;
728 else if( !strcmp( argv[ i ], "-nocurves" ) )
730 Sys_Printf( "Ignoring curved surfaces (patches)\n" );
731 noCurveBrushes = qtrue;
733 else if( !strcmp( argv[ i ], "-notjunc" ) )
735 Sys_Printf( "T-junction fixing disabled\n" );
738 else if( !strcmp( argv[ i ], "-fakemap" ) )
740 Sys_Printf( "Generating fakemap.map\n" );
743 else if( !strcmp( argv[ i ], "-samplesize" ) )
745 sampleSize = atoi( argv[ i + 1 ] );
749 Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
751 else if( !strcmp( argv[ i ], "-minsamplesize" ) )
753 minSampleSize = atoi( argv[ i + 1 ] );
754 if( minSampleSize < 1 )
757 Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize );
759 else if( !strcmp( argv[ i ], "-custinfoparms") )
761 Sys_Printf( "Custom info parms enabled\n" );
762 useCustomInfoParms = qtrue;
766 else if( !strcmp( argv[ i ], "-rename" ) )
768 Sys_Printf( "Appending _bsp suffix to misc_model shaders (SOF2)\n" );
769 renameModelShaders = qtrue;
773 else if( !strcmp( argv[ i ], "-ne" ) )
775 normalEpsilon = atof( argv[ i + 1 ] );
777 Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
779 else if( !strcmp( argv[ i ], "-de" ) )
781 distanceEpsilon = atof( argv[ i + 1 ] );
783 Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
785 else if( !strcmp( argv[ i ], "-mv" ) )
787 maxLMSurfaceVerts = atoi( argv[ i + 1 ] );
788 if( maxLMSurfaceVerts < 3 )
789 maxLMSurfaceVerts = 3;
790 if( maxLMSurfaceVerts > maxSurfaceVerts )
791 maxSurfaceVerts = maxLMSurfaceVerts;
793 Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts );
795 else if( !strcmp( argv[ i ], "-mi" ) )
797 maxSurfaceIndexes = atoi( argv[ i + 1 ] );
798 if( maxSurfaceIndexes < 3 )
799 maxSurfaceIndexes = 3;
801 Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
803 else if( !strcmp( argv[ i ], "-np" ) )
805 npDegrees = atof( argv[ i + 1 ] );
806 if( npDegrees < 0.0f )
807 shadeAngleDegrees = 0.0f;
808 else if( npDegrees > 0.0f )
809 Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees );
812 else if( !strcmp( argv[ i ], "-snap" ) )
814 bevelSnap = atoi( argv[ i + 1 ]);
819 Sys_Printf( "Snapping brush bevel planes to %d units\n", bevelSnap );
821 else if( !strcmp( argv[ i ], "-texrange" ) )
823 texRange = atoi( argv[ i + 1 ]);
827 Sys_Printf( "Limiting per-surface texture range to %d texels\n", texRange );
829 else if( !strcmp( argv[ i ], "-nohint" ) )
831 Sys_Printf( "Hint brushes disabled\n" );
834 else if( !strcmp( argv[ i ], "-flat" ) )
836 Sys_Printf( "Flatshading enabled\n" );
839 else if( !strcmp( argv[ i ], "-meta" ) )
841 Sys_Printf( "Creating meta surfaces from brush faces\n" );
844 else if( !strcmp( argv[ i ], "-patchmeta" ) )
846 Sys_Printf( "Creating meta surfaces from patches\n" );
849 else if( !strcmp( argv[ i ], "-flares" ) )
851 Sys_Printf( "Flare surfaces enabled\n" );
854 else if( !strcmp( argv[ i ], "-noflares" ) )
856 Sys_Printf( "Flare surfaces disabled\n" );
859 else if( !strcmp( argv[ i ], "-skyfix" ) )
861 Sys_Printf( "GL_CLAMP sky fix/hack/workaround enabled\n" );
864 else if( !strcmp( argv[ i ], "-debugsurfaces" ) )
866 Sys_Printf( "emitting debug surfaces\n" );
867 debugSurfaces = qtrue;
869 else if( !strcmp( argv[ i ], "-debuginset" ) )
871 Sys_Printf( "Debug surface triangle insetting enabled\n" );
874 else if( !strcmp( argv[ i ], "-debugportals" ) )
876 Sys_Printf( "Debug portal surfaces enabled\n" );
877 debugPortals = qtrue;
879 else if( !strcmp( argv[ i ], "-bsp" ) )
880 Sys_Printf( "-bsp argument unnecessary\n" );
883 Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
887 /* fixme: print more useful usage here */
888 if( i != (argc - 1) )
889 Error( "usage: q3map [options] mapfile" );
891 /* copy source name */
892 strcpy( source, ExpandArg( argv[ i ] ) );
893 StripExtension( source );
895 /* ydnar: set default sample size */
896 SetDefaultSampleSize( sampleSize );
898 /* delete portal, line and surface files */
899 sprintf( path, "%s.prt", source );
901 sprintf( path, "%s.lin", source );
903 //% sprintf( path, "%s.srf", source ); /* ydnar */
907 strcpy( name, ExpandArg( argv[ i ] ) );
908 if( strcmp( name + strlen( name ) - 4, ".reg" ) )
910 /* if we are doing a full map, delete the last saved region map */
911 sprintf( path, "%s.reg", source );
913 DefaultExtension( name, ".map" ); /* might be .reg */
916 /* if onlyents, just grab the entites and resave */
926 /* load original file from temp spot in case it was renamed by the editor on the way in */
927 if( strlen( tempSource ) > 0 )
928 LoadMapFile( tempSource, qfalse );
930 LoadMapFile( name, qfalse );
932 /* div0: inject command line parameters */
933 InjectCommandLine(argv, 1, argc - 1);
935 /* ydnar: decal setup */
938 /* ydnar: cloned brush model entities */
939 SetCloneModelNumbers();
941 /* process world and submodels */
944 /* set light styles from targetted light entities */
947 /* process in game advertisements */
948 ProcessAdvertisements();
950 /* finish and write bsp */
953 /* remove temp map source file if appropriate */
954 if( strlen( tempSource ) > 0)
955 remove( tempSource );
957 /* return to sender */