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 )
619 Sys_Printf( "--- OnlyEnts ---\n" );
621 sprintf( out, "%s.bsp", source );
626 LoadMapFile( name, qfalse );
630 numBSPEntities = numEntities;
640 handles creation of a bsp from a map file
643 int BSPMain( int argc, char **argv )
646 char path[ 1024 ], tempSource[ 1024 ];
647 qboolean onlyents = qfalse;
651 Sys_Printf( "--- BSP ---\n" );
653 SetDrawSurfacesBuffer();
654 mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
655 memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
658 tempSource[ 0 ] = '\0';
660 /* set standard game flags */
661 maxSurfaceVerts = game->maxSurfaceVerts;
662 maxSurfaceIndexes = game->maxSurfaceIndexes;
663 emitFlares = game->emitFlares;
665 /* process arguments */
666 for( i = 1; i < (argc - 1); i++ )
668 if( !strcmp( argv[ i ], "-onlyents" ) )
670 Sys_Printf( "Running entity-only compile\n" );
673 else if( !strcmp( argv[ i ], "-tempname" ) )
674 strcpy( tempSource, argv[ ++i ] );
675 else if( !strcmp( argv[ i ], "-tmpout" ) )
676 strcpy( outbase, "/tmp" );
677 else if( !strcmp( argv[ i ], "-nowater" ) )
679 Sys_Printf( "Disabling water\n" );
682 else if( !strcmp( argv[ i ], "-nodetail" ) )
684 Sys_Printf( "Ignoring detail brushes\n") ;
687 else if( !strcmp( argv[ i ], "-fulldetail" ) )
689 Sys_Printf( "Turning detail brushes into structural brushes\n" );
692 else if( !strcmp( argv[ i ], "-nofog" ) )
694 Sys_Printf( "Fog volumes disabled\n" );
697 else if( !strcmp( argv[ i ], "-nosubdivide" ) )
699 Sys_Printf( "Disabling brush face subdivision\n" );
702 else if( !strcmp( argv[ i ], "-leaktest" ) )
704 Sys_Printf( "Leaktest enabled\n" );
707 else if( !strcmp( argv[ i ], "-verboseentities" ) )
709 Sys_Printf( "Verbose entities enabled\n" );
710 verboseEntities = qtrue;
712 else if( !strcmp( argv[ i ], "-nocurves" ) )
714 Sys_Printf( "Ignoring curved surfaces (patches)\n" );
715 noCurveBrushes = qtrue;
717 else if( !strcmp( argv[ i ], "-notjunc" ) )
719 Sys_Printf( "T-junction fixing disabled\n" );
722 else if( !strcmp( argv[ i ], "-fakemap" ) )
724 Sys_Printf( "Generating fakemap.map\n" );
727 else if( !strcmp( argv[ i ], "-samplesize" ) )
729 sampleSize = atoi( argv[ i + 1 ] );
733 Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
735 else if( !strcmp( argv[ i ], "-minsamplesize" ) )
737 minSampleSize = atoi( argv[ i + 1 ] );
738 if( minSampleSize < 1 )
741 Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize );
743 else if( !strcmp( argv[ i ], "-custinfoparms") )
745 Sys_Printf( "Custom info parms enabled\n" );
746 useCustomInfoParms = qtrue;
750 else if( !strcmp( argv[ i ], "-rename" ) )
752 Sys_Printf( "Appending _bsp suffix to misc_model shaders (SOF2)\n" );
753 renameModelShaders = qtrue;
757 else if( !strcmp( argv[ i ], "-ne" ) )
759 normalEpsilon = atof( argv[ i + 1 ] );
761 Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
763 else if( !strcmp( argv[ i ], "-de" ) )
765 distanceEpsilon = atof( argv[ i + 1 ] );
767 Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
769 else if( !strcmp( argv[ i ], "-mv" ) )
771 maxLMSurfaceVerts = atoi( argv[ i + 1 ] );
772 if( maxLMSurfaceVerts < 3 )
773 maxLMSurfaceVerts = 3;
774 if( maxLMSurfaceVerts > maxSurfaceVerts )
775 maxSurfaceVerts = maxLMSurfaceVerts;
777 Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts );
779 else if( !strcmp( argv[ i ], "-mi" ) )
781 maxSurfaceIndexes = atoi( argv[ i + 1 ] );
782 if( maxSurfaceIndexes < 3 )
783 maxSurfaceIndexes = 3;
785 Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
787 else if( !strcmp( argv[ i ], "-np" ) )
789 npDegrees = atof( argv[ i + 1 ] );
790 if( npDegrees < 0.0f )
791 shadeAngleDegrees = 0.0f;
792 else if( npDegrees > 0.0f )
793 Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees );
796 else if( !strcmp( argv[ i ], "-snap" ) )
798 bevelSnap = atoi( argv[ i + 1 ]);
803 Sys_Printf( "Snapping brush bevel planes to %d units\n", bevelSnap );
805 else if( !strcmp( argv[ i ], "-texrange" ) )
807 texRange = atoi( argv[ i + 1 ]);
811 Sys_Printf( "Limiting per-surface texture range to %d texels\n", texRange );
813 else if( !strcmp( argv[ i ], "-nohint" ) )
815 Sys_Printf( "Hint brushes disabled\n" );
818 else if( !strcmp( argv[ i ], "-flat" ) )
820 Sys_Printf( "Flatshading enabled\n" );
823 else if( !strcmp( argv[ i ], "-meta" ) )
825 Sys_Printf( "Creating meta surfaces from brush faces\n" );
828 else if( !strcmp( argv[ i ], "-patchmeta" ) )
830 Sys_Printf( "Creating meta surfaces from patches\n" );
833 else if( !strcmp( argv[ i ], "-flares" ) )
835 Sys_Printf( "Flare surfaces enabled\n" );
838 else if( !strcmp( argv[ i ], "-noflares" ) )
840 Sys_Printf( "Flare surfaces disabled\n" );
843 else if( !strcmp( argv[ i ], "-skyfix" ) )
845 Sys_Printf( "GL_CLAMP sky fix/hack/workaround enabled\n" );
848 else if( !strcmp( argv[ i ], "-debugsurfaces" ) )
850 Sys_Printf( "emitting debug surfaces\n" );
851 debugSurfaces = qtrue;
853 else if( !strcmp( argv[ i ], "-debuginset" ) )
855 Sys_Printf( "Debug surface triangle insetting enabled\n" );
858 else if( !strcmp( argv[ i ], "-debugportals" ) )
860 Sys_Printf( "Debug portal surfaces enabled\n" );
861 debugPortals = qtrue;
863 else if( !strcmp( argv[ i ], "-bsp" ) )
864 Sys_Printf( "-bsp argument unnecessary\n" );
867 Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
871 /* fixme: print more useful usage here */
872 if( i != (argc - 1) )
873 Error( "usage: q3map [options] mapfile" );
875 /* copy source name */
876 strcpy( source, ExpandArg( argv[ i ] ) );
877 StripExtension( source );
879 /* ydnar: set default sample size */
880 SetDefaultSampleSize( sampleSize );
882 /* delete portal, line and surface files */
883 sprintf( path, "%s.prt", source );
885 sprintf( path, "%s.lin", source );
887 //% sprintf( path, "%s.srf", source ); /* ydnar */
891 strcpy( name, ExpandArg( argv[ i ] ) );
892 if( strcmp( name + strlen( name ) - 4, ".reg" ) )
894 /* if we are doing a full map, delete the last saved region map */
895 sprintf( path, "%s.reg", source );
897 DefaultExtension( name, ".map" ); /* might be .reg */
900 /* if onlyents, just grab the entites and resave */
910 /* load original file from temp spot in case it was renamed by the editor on the way in */
911 if( strlen( tempSource ) > 0 )
912 LoadMapFile( tempSource, qfalse );
914 LoadMapFile( name, qfalse );
916 /* ydnar: decal setup */
919 /* ydnar: cloned brush model entities */
920 SetCloneModelNumbers();
922 /* process world and submodels */
925 /* set light styles from targetted light entities */
928 /* process in game advertisements */
929 ProcessAdvertisements();
931 /* finish and write bsp */
934 /* remove temp map source file if appropriate */
935 if( strlen( tempSource ) > 0)
936 remove( tempSource );
938 /* return to sender */