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 ------------------------------------------------------------------------------- */
43 returns a pseudorandom number between 0 and 1
48 return (vec_t) rand() / RAND_MAX;
58 static void ExitQ3Map( void )
61 if( mapDrawSurfs != NULL )
69 typedef struct minimap_s
75 float *sample_offsets;
76 float sharpen_boxmult;
77 float sharpen_centermult;
84 static minimap_t minimap;
86 qboolean BrushIntersectionWithLine(bspBrush_t *brush, vec3_t start, vec3_t dir, float *t_in, float *t_out)
89 qboolean in = qfalse, out = qfalse;
90 bspBrushSide_t *sides = &bspBrushSides[brush->firstSide];
92 for(i = 0; i < brush->numSides; ++i)
94 bspPlane_t *p = &bspPlanes[sides[i].planeNum];
95 float sn = DotProduct(start, p->normal);
96 float dn = DotProduct(dir, p->normal);
100 return qfalse; // outside!
104 float t = (p->dist - sn) / dn;
111 // as t_in can only increase, and t_out can only decrease, early out
112 if(out && *t_in >= *t_out)
118 if(!out || t < *t_out)
122 // as t_in can only increase, and t_out can only decrease, early out
123 if(in && *t_in >= *t_out)
132 static float MiniMapSample(float x, float y)
151 for(i = 0; i < minimap.model->numBSPBrushes; ++i)
153 bi = minimap.model->firstBSPBrush + i;
154 if(opaqueBrushes[bi >> 3] & (1 << (bi & 7)))
158 // sort out mins/maxs of the brush
159 s = &bspBrushSides[b->firstSide];
160 if(x < -bspPlanes[s[0].planeNum].dist)
162 if(x > +bspPlanes[s[1].planeNum].dist)
164 if(y < -bspPlanes[s[2].planeNum].dist)
166 if(y > +bspPlanes[s[3].planeNum].dist)
169 if(BrushIntersectionWithLine(b, org, dir, &t0, &t1))
180 void RandomVector2f(float v[2])
184 v[0] = 2 * Random() - 1;
185 v[1] = 2 * Random() - 1;
187 while(v[0] * v[0] + v[1] * v[1] > 1);
190 static void MiniMapRandomlySupersampled(int y)
193 float *p = &minimap.data1f[y * minimap.width];
194 float ymin = minimap.mins[1] + minimap.size[1] * (y / (float) minimap.height);
195 float dx = minimap.size[0] / (float) minimap.width;
196 float dy = minimap.size[1] / (float) minimap.height;
200 for(x = 0; x < minimap.width; ++x)
202 float xmin = minimap.mins[0] + minimap.size[0] * (x / (float) minimap.width);
205 for(i = 0; i < minimap.samples; ++i)
208 thisval = MiniMapSample(
209 xmin + (uv[0] + 0.5) * dx, /* exaggerated random pattern for better results */
210 ymin + (uv[1] + 0.5) * dy /* exaggerated random pattern for better results */
214 val /= minimap.samples * minimap.size[2];
219 static void MiniMapSupersampled(int y)
222 float *p = &minimap.data1f[y * minimap.width];
223 float ymin = minimap.mins[1] + minimap.size[1] * (y / (float) minimap.height);
224 float dx = minimap.size[0] / (float) minimap.width;
225 float dy = minimap.size[1] / (float) minimap.height;
227 for(x = 0; x < minimap.width; ++x)
229 float xmin = minimap.mins[0] + minimap.size[0] * (x / (float) minimap.width);
232 for(i = 0; i < minimap.samples; ++i)
234 float thisval = MiniMapSample(
235 xmin + minimap.sample_offsets[2*i+0] * dx,
236 ymin + minimap.sample_offsets[2*i+1] * dy
240 val /= minimap.samples * minimap.size[2];
245 static void MiniMapNoSupersampling(int y)
248 float *p = &minimap.data1f[y * minimap.width];
249 float ymin = minimap.mins[1] + minimap.size[1] * ((y + 0.5) / (float) minimap.height);
251 for(x = 0; x < minimap.width; ++x)
253 float xmin = minimap.mins[0] + minimap.size[0] * ((x + 0.5) / (float) minimap.width);
254 *p++ = MiniMapSample(xmin, ymin) / minimap.size[2];
258 static void MiniMapSharpen(int y)
261 qboolean up = (y > 0);
262 qboolean down = (y < minimap.height - 1);
263 float *p = &minimap.data1f[y * minimap.width];
264 float *q = &minimap.sharpendata1f[y * minimap.width];
266 for(x = 0; x < minimap.width; ++x)
268 qboolean left = (x > 0);
269 qboolean right = (x < minimap.width - 1);
270 float val = p[0] * minimap.sharpen_centermult;
273 val += p[-1 -minimap.width] * minimap.sharpen_boxmult;
275 val += p[-1 +minimap.width] * minimap.sharpen_boxmult;
277 val += p[+1 -minimap.width] * minimap.sharpen_boxmult;
279 val += p[+1 +minimap.width] * minimap.sharpen_boxmult;
282 val += p[-1] * minimap.sharpen_boxmult;
284 val += p[+1] * minimap.sharpen_boxmult;
286 val += p[-minimap.width] * minimap.sharpen_boxmult;
288 val += p[+minimap.width] * minimap.sharpen_boxmult;
295 static void MiniMapContrastBoost(int y)
298 float *q = &minimap.data1f[y * minimap.width];
299 for(x = 0; x < minimap.width; ++x)
301 *q = *q * minimap.boost / ((minimap.boost - 1) * *q + 1);
306 void MiniMapMakeMinsMaxs(vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect)
308 vec3_t mins, maxs, extend;
309 VectorCopy(mins_in, mins);
310 VectorCopy(maxs_in, maxs);
312 // line compatible to nexuiz mapinfo
313 Sys_Printf("size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]);
317 VectorSubtract(maxs, mins, extend);
318 if(extend[1] > extend[0])
320 mins[0] -= (extend[1] - extend[0]) * 0.5;
321 maxs[0] += (extend[1] - extend[0]) * 0.5;
325 mins[1] -= (extend[0] - extend[1]) * 0.5;
326 maxs[1] += (extend[0] - extend[1]) * 0.5;
330 /* border: amount of black area around the image */
331 /* input: border, 1-2*border, border but we need border/(1-2*border) */
333 VectorSubtract(maxs, mins, extend);
334 VectorScale(extend, border / (1 - 2 * border), extend);
336 VectorSubtract(mins, extend, mins);
337 VectorAdd(maxs, extend, maxs);
339 VectorCopy(mins, minimap.mins);
340 VectorSubtract(maxs, mins, minimap.size);
342 // line compatible to nexuiz mapinfo
343 Sys_Printf("size_texcoords %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]);
347 MiniMapSetupBrushes()
348 determines solid non-sky brushes in the world
351 void MiniMapSetupBrushes( void )
353 int i, b, compileFlags;
360 Sys_FPrintf( SYS_VRB, "--- MiniMapSetupBrushes ---\n" );
363 if( opaqueBrushes == NULL )
364 opaqueBrushes = safe_malloc( numBSPBrushes / 8 + 1 );
367 memset( opaqueBrushes, 0, numBSPBrushes / 8 + 1 );
368 numOpaqueBrushes = 0;
370 /* walk the list of worldspawn brushes */
371 for( i = 0; i < minimap.model->numBSPBrushes; i++ )
374 b = minimap.model->firstBSPBrush + i;
375 brush = &bspBrushes[ b ];
378 /* check all sides */
380 for( j = 0; j < brush->numSides; j++ )
382 /* do bsp shader calculations */
383 side = &bspBrushSides[ brush->firstSide + j ];
384 shader = &bspShaders[ side->shaderNum ];
386 /* get shader info */
387 si = ShaderInfoForShader( shader->shader );
391 /* or together compile flags */
392 compileFlags |= si->compileFlags;
395 shader = &bspShaders[ brush->shaderNum ];
396 si = ShaderInfoForShader( shader->shader );
400 compileFlags = si->compileFlags;
403 /* determine if this brush is solid */
404 if( (compileFlags & (C_SOLID | C_SKY)) == C_SOLID )
406 opaqueBrushes[ b >> 3 ] |= (1 << (b & 7));
412 /* emit some statistics */
413 Sys_FPrintf( SYS_VRB, "%9d solid brushes\n", numOpaqueBrushes );
416 qboolean MiniMapEvaluateSampleOffsets(int *bestj, int *bestk, float *bestval)
421 *bestj = *bestk = -1;
422 *bestval = 3; /* max possible val is 2 */
424 for(j = 0; j < minimap.samples; ++j)
425 for(k = j + 1; k < minimap.samples; ++k)
427 dx = minimap.sample_offsets[2*j+0] - minimap.sample_offsets[2*k+0];
428 dy = minimap.sample_offsets[2*j+1] - minimap.sample_offsets[2*k+1];
429 if(dx > +0.5) dx -= 1;
430 if(dx < -0.5) dx += 1;
431 if(dy > +0.5) dy -= 1;
432 if(dy < -0.5) dy += 1;
433 val = dx * dx + dy * dy;
445 void MiniMapMakeSampleOffsets()
448 float val, valj, valk, sx, sy, rx, ry;
450 Sys_Printf( "Generating good sample offsets (this may take a while)...\n" );
452 /* start with entirely random samples */
453 for(i = 0; i < minimap.samples; ++i)
455 minimap.sample_offsets[2*i+0] = Random();
456 minimap.sample_offsets[2*i+1] = Random();
459 for(i = 0; i < 1000; ++i)
461 if(MiniMapEvaluateSampleOffsets(&j, &k, &val))
463 sx = minimap.sample_offsets[2*j+0];
464 sy = minimap.sample_offsets[2*j+1];
465 minimap.sample_offsets[2*j+0] = rx = Random();
466 minimap.sample_offsets[2*j+1] = ry = Random();
467 if(!MiniMapEvaluateSampleOffsets(&jj, &kk, &valj))
469 minimap.sample_offsets[2*j+0] = sx;
470 minimap.sample_offsets[2*j+1] = sy;
472 sx = minimap.sample_offsets[2*k+0];
473 sy = minimap.sample_offsets[2*k+1];
474 minimap.sample_offsets[2*k+0] = rx;
475 minimap.sample_offsets[2*k+1] = ry;
476 if(!MiniMapEvaluateSampleOffsets(&jj, &kk, &valk))
478 minimap.sample_offsets[2*k+0] = sx;
479 minimap.sample_offsets[2*k+1] = sy;
485 /* valj is the greatest */
486 minimap.sample_offsets[2*j+0] = rx;
487 minimap.sample_offsets[2*j+1] = ry;
492 /* valj is the greater and it is useless - forget it */
499 /* valk is the greatest */
500 minimap.sample_offsets[2*k+0] = rx;
501 minimap.sample_offsets[2*k+1] = ry;
506 /* valk is the greater and it is useless - forget it */
515 void MergeRelativePath(char *out, const char *absolute, const char *relative)
517 const char *endpos = absolute + strlen(absolute);
518 while(endpos != absolute && (endpos[-1] == '/' || endpos[-1] == '\\'))
520 while(relative[0] == '.' && relative[1] == '.' && (relative[2] == '/' || relative[2] == '\\'))
523 while(endpos != absolute)
526 if(*endpos == '/' || *endpos == '\\')
529 while(endpos != absolute && (endpos[-1] == '/' || endpos[-1] == '\\'))
532 memcpy(out, absolute, endpos - absolute);
533 out[endpos - absolute] = '/';
534 strcpy(out + (endpos - absolute + 1), relative);
537 int MiniMapBSPMain( int argc, char **argv )
539 char minimapFilename[1024];
542 char relativeMinimapFilename[1024];
543 float minimapSharpen;
556 Sys_Printf( "Usage: q3map [-v] -minimap [-size n] [-sharpen f] [-samples n | -random n] [-o filename.tga] [-minmax Xmin Ymin Zmin Xmax Ymax Zmax] <mapname>\n" );
560 /* load the BSP first */
561 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
562 StripExtension( source );
563 DefaultExtension( source, ".bsp" );
564 Sys_Printf( "Loading %s\n", source );
565 BeginMapShaderFile( source );
567 LoadBSPFile( source );
569 minimap.model = &bspModels[0];
570 VectorCopy(minimap.model->mins, mins);
571 VectorCopy(minimap.model->maxs, maxs);
573 *minimapFilename = 0;
574 minimapSharpen = game->miniMapSharpen;
575 minimap.width = minimap.height = game->miniMapSize;
576 border = game->miniMapBorder;
577 keepaspect = game->miniMapKeepAspect;
578 mode = game->miniMapMode;
581 minimap.sample_offsets = NULL;
584 /* process arguments */
585 for( i = 1; i < (argc - 1); i++ )
587 if( !strcmp( argv[ i ], "-size" ) )
589 minimap.width = minimap.height = atoi(argv[i + 1]);
591 Sys_Printf( "Image size set to %i\n", minimap.width );
593 else if( !strcmp( argv[ i ], "-sharpen" ) )
595 minimapSharpen = atof(argv[i + 1]);
597 Sys_Printf( "Sharpening coefficient set to %f\n", minimapSharpen );
599 else if( !strcmp( argv[ i ], "-samples" ) )
601 minimap.samples = atoi(argv[i + 1]);
603 Sys_Printf( "Samples set to %i\n", minimap.samples );
604 if(minimap.sample_offsets)
605 free(minimap.sample_offsets);
606 minimap.sample_offsets = malloc(2 * sizeof(*minimap.sample_offsets) * minimap.samples);
607 MiniMapMakeSampleOffsets();
609 else if( !strcmp( argv[ i ], "-random" ) )
611 minimap.samples = atoi(argv[i + 1]);
613 Sys_Printf( "Random samples set to %i\n", minimap.samples );
614 if(minimap.sample_offsets)
615 free(minimap.sample_offsets);
616 minimap.sample_offsets = NULL;
618 else if( !strcmp( argv[ i ], "-border" ) )
620 border = atof(argv[i + 1]);
622 Sys_Printf( "Border set to %f\n", border );
624 else if( !strcmp( argv[ i ], "-keepaspect" ) )
627 Sys_Printf( "Keeping aspect ratio by letterboxing\n", border );
629 else if( !strcmp( argv[ i ], "-nokeepaspect" ) )
632 Sys_Printf( "Not keeping aspect ratio\n", border );
634 else if( !strcmp( argv[ i ], "-o" ) )
636 strcpy(minimapFilename, argv[i + 1]);
638 Sys_Printf( "Output file name set to %s\n", minimapFilename );
640 else if( !strcmp( argv[ i ], "-minmax" ) && i < (argc - 7) )
642 mins[0] = atof(argv[i + 1]);
643 mins[1] = atof(argv[i + 2]);
644 mins[2] = atof(argv[i + 3]);
645 maxs[0] = atof(argv[i + 4]);
646 maxs[1] = atof(argv[i + 5]);
647 maxs[2] = atof(argv[i + 6]);
649 Sys_Printf( "Map mins/maxs overridden\n" );
651 else if( !strcmp( argv[ i ], "-gray" ) )
653 mode = MINIMAP_MODE_GRAY;
654 Sys_Printf( "Writing as white-on-black image\n" );
656 else if( !strcmp( argv[ i ], "-black" ) )
658 mode = MINIMAP_MODE_BLACK;
659 Sys_Printf( "Writing as black alpha image\n" );
661 else if( !strcmp( argv[ i ], "-white" ) )
663 mode = MINIMAP_MODE_WHITE;
664 Sys_Printf( "Writing as white alpha image\n" );
666 else if( !strcmp( argv[ i ], "-boost" ) )
668 minimap.boost = atof(argv[i + 1]);
670 Sys_Printf( "Contrast boost set to %f\n", minimap.boost );
674 MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect);
676 if(!*minimapFilename)
678 ExtractFileBase(source, basename);
679 ExtractFilePath(source, path);
680 sprintf(relativeMinimapFilename, game->miniMapNameFormat, basename);
681 MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
682 Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
684 ExtractFilePath(minimapFilename, path);
687 if(minimapSharpen >= 0)
689 minimap.sharpen_centermult = 8 * minimapSharpen + 1;
690 minimap.sharpen_boxmult = -minimapSharpen;
693 minimap.data1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
694 data4b = safe_malloc(minimap.width * minimap.height * 4);
695 if(minimapSharpen >= 0)
696 minimap.sharpendata1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
698 MiniMapSetupBrushes();
700 if(minimap.samples <= 1)
702 Sys_Printf( "\n--- MiniMapNoSupersampling (%d) ---\n", minimap.height );
703 RunThreadsOnIndividual(minimap.height, qtrue, MiniMapNoSupersampling);
707 if(minimap.sample_offsets)
709 Sys_Printf( "\n--- MiniMapSupersampled (%d) ---\n", minimap.height );
710 RunThreadsOnIndividual(minimap.height, qtrue, MiniMapSupersampled);
714 Sys_Printf( "\n--- MiniMapRandomlySupersampled (%d) ---\n", minimap.height );
715 RunThreadsOnIndividual(minimap.height, qtrue, MiniMapRandomlySupersampled);
719 if(minimap.boost != 1.0)
721 Sys_Printf( "\n--- MiniMapContrastBoost (%d) ---\n", minimap.height );
722 RunThreadsOnIndividual(minimap.height, qtrue, MiniMapContrastBoost);
725 if(minimap.sharpendata1f)
727 Sys_Printf( "\n--- MiniMapSharpen (%d) ---\n", minimap.height );
728 RunThreadsOnIndividual(minimap.height, qtrue, MiniMapSharpen);
729 q = minimap.sharpendata1f;
736 Sys_Printf( "\nConverting...");
740 case MINIMAP_MODE_GRAY:
742 for(y = 0; y < minimap.height; ++y)
743 for(x = 0; x < minimap.width; ++x)
748 if(v > 255.0/256.0) v = 255.0/256.0;
752 Sys_Printf( " writing to %s...", minimapFilename );
753 WriteTGAGray(minimapFilename, data4b, minimap.width, minimap.height);
755 case MINIMAP_MODE_BLACK:
757 for(y = 0; y < minimap.height; ++y)
758 for(x = 0; x < minimap.width; ++x)
763 if(v > 255.0/256.0) v = 255.0/256.0;
770 Sys_Printf( " writing to %s...", minimapFilename );
771 WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
773 case MINIMAP_MODE_WHITE:
775 for(y = 0; y < minimap.height; ++y)
776 for(x = 0; x < minimap.width; ++x)
781 if(v > 255.0/256.0) v = 255.0/256.0;
788 Sys_Printf( " writing to %s...", minimapFilename );
789 WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
793 Sys_Printf( " done.\n" );
795 /* return to sender */
805 calculates an md4 checksum for a block of data
808 static int MD4BlockChecksum( void *buffer, int length )
810 return Com_BlockChecksum(buffer, length);
815 resets an aas checksum to match the given BSP
818 int FixAAS( int argc, char **argv )
820 int length, checksum;
823 char aas[ 1024 ], **ext;
836 Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
840 /* do some path mangling */
841 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
842 StripExtension( source );
843 DefaultExtension( source, ".bsp" );
846 Sys_Printf( "--- FixAAS ---\n" );
849 Sys_Printf( "Loading %s\n", source );
850 length = LoadFile( source, &buffer );
852 /* create bsp checksum */
853 Sys_Printf( "Creating checksum...\n" );
854 checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
856 /* write checksum to aas */
861 strcpy( aas, source );
862 StripExtension( aas );
864 Sys_Printf( "Trying %s\n", aas );
868 file = fopen( aas, "r+b" );
871 if( fwrite( &checksum, 4, 1, file ) != 1 )
872 Error( "Error writing checksum to %s", aas );
876 /* return to sender */
884 analyzes a Quake engine BSP file
887 typedef struct abspHeader_s
892 bspLump_t lumps[ 1 ]; /* unknown size */
896 typedef struct abspLumpTest_s
903 int AnalyzeBSP( int argc, char **argv )
905 abspHeader_t *header;
906 int size, i, version, offset, length, lumpInt, count;
910 char lumpString[ 1024 ], source[ 1024 ];
911 qboolean lumpSwap = qfalse;
912 abspLumpTest_t *lumpTest;
913 static abspLumpTest_t lumpTests[] =
915 { sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" },
916 { sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" },
917 { 8, 6, "IBSP LUMP_BRUSHSIDES" },
918 { sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" },
919 { sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" },
920 { sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" },
921 { sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" },
922 { 104, 3, "IBSP LUMP_DRAWSURFS" },
923 { 44, 3, "IBSP LUMP_DRAWVERTS" },
924 { 4, 6, "IBSP LUMP_DRAWINDEXES" },
925 { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" },
926 { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" },
927 { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" },
935 Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
939 /* process arguments */
940 for( i = 1; i < (argc - 1); i++ )
942 /* -format map|ase|... */
943 if( !strcmp( argv[ i ], "-lumpswap" ) )
945 Sys_Printf( "Swapped lump structs enabled\n" );
950 /* clean up map name */
951 strcpy( source, ExpandArg( argv[ i ] ) );
952 Sys_Printf( "Loading %s\n", source );
955 size = LoadFile( source, (void**) &header );
956 if( size == 0 || header == NULL )
958 Sys_Printf( "Unable to load %s.\n", source );
962 /* analyze ident/version */
963 memcpy( ident, header->ident, 4 );
965 version = LittleLong( header->version );
967 Sys_Printf( "Identity: %s\n", ident );
968 Sys_Printf( "Version: %d\n", version );
969 Sys_Printf( "---------------------------------------\n" );
971 /* analyze each lump */
972 for( i = 0; i < 100; i++ )
974 /* call of duty swapped lump pairs */
977 offset = LittleLong( header->lumps[ i ].length );
978 length = LittleLong( header->lumps[ i ].offset );
981 /* standard lump pairs */
984 offset = LittleLong( header->lumps[ i ].offset );
985 length = LittleLong( header->lumps[ i ].length );
989 lump = (byte*) header + offset;
990 lumpInt = LittleLong( (int) *((int*) lump) );
991 lumpFloat = LittleFloat( (float) *((float*) lump) );
992 memcpy( lumpString, (char*) lump, (length < sizeof(lumpString) ? length : sizeof(lumpString)-1) );
993 lumpString[ sizeof(lumpString)-1 ] = '\0';
995 /* print basic lump info */
996 Sys_Printf( "Lump: %d\n", i );
997 Sys_Printf( "Offset: %d bytes\n", offset );
998 Sys_Printf( "Length: %d bytes\n", length );
1000 /* only operate on valid lumps */
1003 /* print data in 4 formats */
1004 Sys_Printf( "As hex: %08X\n", lumpInt );
1005 Sys_Printf( "As int: %d\n", lumpInt );
1006 Sys_Printf( "As float: %f\n", lumpFloat );
1007 Sys_Printf( "As string: %s\n", lumpString );
1009 /* guess lump type */
1010 if( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' )
1011 Sys_Printf( "Type guess: IBSP LUMP_ENTITIES\n" );
1012 else if( strstr( lumpString, "textures/" ) )
1013 Sys_Printf( "Type guess: IBSP LUMP_SHADERS\n" );
1016 /* guess based on size/count */
1017 for( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ )
1019 if( (length % lumpTest->radix) != 0 )
1021 count = length / lumpTest->radix;
1022 if( count < lumpTest->minCount )
1024 Sys_Printf( "Type guess: %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix );
1029 Sys_Printf( "---------------------------------------\n" );
1032 if( offset + length >= size )
1037 Sys_Printf( "Lump count: %d\n", i + 1 );
1038 Sys_Printf( "File size: %d bytes\n", size );
1040 /* return to caller */
1048 emits statistics about the bsp file
1051 int BSPInfo( int count, char **fileNames )
1054 char source[ 1024 ], ext[ 64 ];
1062 Sys_Printf( "No files to dump info for.\n");
1066 /* enable info mode */
1069 /* walk file list */
1070 for( i = 0; i < count; i++ )
1072 Sys_Printf( "---------------------------------\n" );
1074 /* mangle filename and get size */
1075 strcpy( source, fileNames[ i ] );
1076 ExtractFileExtension( source, ext );
1077 if( !Q_stricmp( ext, "map" ) )
1078 StripExtension( source );
1079 DefaultExtension( source, ".bsp" );
1080 f = fopen( source, "rb" );
1083 size = Q_filelength (f);
1089 /* load the bsp file and print lump sizes */
1090 Sys_Printf( "%s\n", source );
1091 LoadBSPFile( source );
1092 PrintBSPFileSizes();
1096 Sys_Printf( " total %9d\n", size );
1097 Sys_Printf( " %9d KB\n", size / 1024 );
1098 Sys_Printf( " %9d MB\n", size / (1024 * 1024) );
1100 Sys_Printf( "---------------------------------\n" );
1108 static void ExtrapolateTexcoords(const float *axyz, const float *ast, const float *bxyz, const float *bst, const float *cxyz, const float *cst, const float *axyz_new, float *ast_out, const float *bxyz_new, float *bst_out, const float *cxyz_new, float *cst_out)
1110 vec4_t scoeffs, tcoeffs;
1116 VectorSubtract(bxyz, axyz, dab);
1117 VectorSubtract(cxyz, axyz, dac);
1118 CrossProduct(dab, dac, norm);
1122 // s(v + norm) = s(v) when n ortho xyz
1124 // s(v) = DotProduct(v, scoeffs) + scoeffs[3]
1127 // scoeffs * (axyz, 1) == ast[0]
1128 // scoeffs * (bxyz, 1) == bst[0]
1129 // scoeffs * (cxyz, 1) == cst[0]
1130 // scoeffs * (norm, 0) == 0
1131 // scoeffs * [axyz, 1 | bxyz, 1 | cxyz, 1 | norm, 0] = [ast[0], bst[0], cst[0], 0]
1132 solvematrix[0] = axyz[0];
1133 solvematrix[4] = axyz[1];
1134 solvematrix[8] = axyz[2];
1135 solvematrix[12] = 1;
1136 solvematrix[1] = bxyz[0];
1137 solvematrix[5] = bxyz[1];
1138 solvematrix[9] = bxyz[2];
1139 solvematrix[13] = 1;
1140 solvematrix[2] = cxyz[0];
1141 solvematrix[6] = cxyz[1];
1142 solvematrix[10] = cxyz[2];
1143 solvematrix[14] = 1;
1144 solvematrix[3] = norm[0];
1145 solvematrix[7] = norm[1];
1146 solvematrix[11] = norm[2];
1147 solvematrix[15] = 0;
1149 md = m4_det(solvematrix);
1152 Sys_Printf("Cannot invert some matrix, some texcoords aren't extrapolated!");
1156 m4x4_invert(solvematrix);
1158 scoeffs[0] = ast[0];
1159 scoeffs[1] = bst[0];
1160 scoeffs[2] = cst[0];
1162 m4x4_transform_vec4(solvematrix, scoeffs);
1163 tcoeffs[0] = ast[1];
1164 tcoeffs[1] = bst[1];
1165 tcoeffs[2] = cst[1];
1167 m4x4_transform_vec4(solvematrix, tcoeffs);
1169 ast_out[0] = scoeffs[0] * axyz_new[0] + scoeffs[1] * axyz_new[1] + scoeffs[2] * axyz_new[2] + scoeffs[3];
1170 ast_out[1] = tcoeffs[0] * axyz_new[0] + tcoeffs[1] * axyz_new[1] + tcoeffs[2] * axyz_new[2] + tcoeffs[3];
1171 bst_out[0] = scoeffs[0] * bxyz_new[0] + scoeffs[1] * bxyz_new[1] + scoeffs[2] * bxyz_new[2] + scoeffs[3];
1172 bst_out[1] = tcoeffs[0] * bxyz_new[0] + tcoeffs[1] * bxyz_new[1] + tcoeffs[2] * bxyz_new[2] + tcoeffs[3];
1173 cst_out[0] = scoeffs[0] * cxyz_new[0] + scoeffs[1] * cxyz_new[1] + scoeffs[2] * cxyz_new[2] + scoeffs[3];
1174 cst_out[1] = tcoeffs[0] * cxyz_new[0] + tcoeffs[1] * cxyz_new[1] + tcoeffs[2] * cxyz_new[2] + tcoeffs[3];
1179 amaze and confuse your enemies with wierd scaled maps!
1182 int ScaleBSPMain( int argc, char **argv )
1191 float *old_xyzst = NULL;
1192 float spawn_ref = 0;
1198 Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
1203 for(i = 1; i < argc-2; ++i)
1205 if(!strcmp(argv[i], "-tex"))
1209 else if(!strcmp(argv[i], "-spawn_ref"))
1211 spawn_ref = atof(argv[i+1]);
1219 // if(argc-2 >= i) // always true
1220 scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
1222 scale[1] = scale[0] = atof( argv[ argc - 3 ] );
1224 scale[0] = atof( argv[ argc - 4 ] );
1226 uniform = ((scale[0] == scale[1]) && (scale[1] == scale[2]));
1228 if( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f )
1230 Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
1231 Sys_Printf( "Non-zero scale value required.\n" );
1235 /* do some path mangling */
1236 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
1237 StripExtension( source );
1238 DefaultExtension( source, ".bsp" );
1241 Sys_Printf( "Loading %s\n", source );
1242 LoadBSPFile( source );
1246 Sys_Printf( "--- ScaleBSP ---\n" );
1247 Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
1249 /* scale entity keys */
1250 for( i = 0; i < numBSPEntities && i < numEntities; i++ )
1253 GetVectorForKey( &entities[ i ], "origin", vec );
1254 if( (vec[ 0 ] || vec[ 1 ] || vec[ 2 ]) )
1256 if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
1257 vec[2] += spawn_ref;
1261 if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
1262 vec[2] -= spawn_ref;
1263 sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
1264 SetKeyValue( &entities[ i ], "origin", str );
1267 a = FloatForKey( &entities[ i ], "angle" );
1268 if(a == -1 || a == -2) // z scale
1270 else if(fabs(sin(DEG2RAD(a))) < 0.707)
1275 /* scale door lip */
1276 f = FloatForKey( &entities[ i ], "lip" );
1280 sprintf( str, "%f", f );
1281 SetKeyValue( &entities[ i ], "lip", str );
1284 /* scale plat height */
1285 f = FloatForKey( &entities[ i ], "height" );
1289 sprintf( str, "%f", f );
1290 SetKeyValue( &entities[ i ], "height", str );
1293 // TODO maybe allow a definition file for entities to specify which values are scaled how?
1297 for( i = 0; i < numBSPModels; i++ )
1299 bspModels[ i ].mins[0] *= scale[0];
1300 bspModels[ i ].mins[1] *= scale[1];
1301 bspModels[ i ].mins[2] *= scale[2];
1302 bspModels[ i ].maxs[0] *= scale[0];
1303 bspModels[ i ].maxs[1] *= scale[1];
1304 bspModels[ i ].maxs[2] *= scale[2];
1308 for( i = 0; i < numBSPNodes; i++ )
1310 bspNodes[ i ].mins[0] *= scale[0];
1311 bspNodes[ i ].mins[1] *= scale[1];
1312 bspNodes[ i ].mins[2] *= scale[2];
1313 bspNodes[ i ].maxs[0] *= scale[0];
1314 bspNodes[ i ].maxs[1] *= scale[1];
1315 bspNodes[ i ].maxs[2] *= scale[2];
1319 for( i = 0; i < numBSPLeafs; i++ )
1321 bspLeafs[ i ].mins[0] *= scale[0];
1322 bspLeafs[ i ].mins[1] *= scale[1];
1323 bspLeafs[ i ].mins[2] *= scale[2];
1324 bspLeafs[ i ].maxs[0] *= scale[0];
1325 bspLeafs[ i ].maxs[1] *= scale[1];
1326 bspLeafs[ i ].maxs[2] *= scale[2];
1331 Sys_Printf("Using texture unlocking (and probably breaking texture alignment a lot)\n");
1332 old_xyzst = safe_malloc(sizeof(*old_xyzst) * numBSPDrawVerts * 5);
1333 for(i = 0; i < numBSPDrawVerts; i++)
1335 old_xyzst[5*i+0] = bspDrawVerts[i].xyz[0];
1336 old_xyzst[5*i+1] = bspDrawVerts[i].xyz[1];
1337 old_xyzst[5*i+2] = bspDrawVerts[i].xyz[2];
1338 old_xyzst[5*i+3] = bspDrawVerts[i].st[0];
1339 old_xyzst[5*i+4] = bspDrawVerts[i].st[1];
1343 /* scale drawverts */
1344 for( i = 0; i < numBSPDrawVerts; i++ )
1346 bspDrawVerts[i].xyz[0] *= scale[0];
1347 bspDrawVerts[i].xyz[1] *= scale[1];
1348 bspDrawVerts[i].xyz[2] *= scale[2];
1349 bspDrawVerts[i].normal[0] /= scale[0];
1350 bspDrawVerts[i].normal[1] /= scale[1];
1351 bspDrawVerts[i].normal[2] /= scale[2];
1352 VectorNormalize(bspDrawVerts[i].normal, bspDrawVerts[i].normal);
1357 for(i = 0; i < numBSPDrawSurfaces; i++)
1359 switch(bspDrawSurfaces[i].surfaceType)
1363 if(bspDrawSurfaces[i].numIndexes % 3)
1364 Error("Not a triangulation!");
1365 for(j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3)
1367 int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j+1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j+2] + bspDrawSurfaces[i].firstVert;
1368 bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
1369 float *oa = &old_xyzst[ia*5], *ob = &old_xyzst[ib*5], *oc = &old_xyzst[ic*5];
1374 ExtrapolateTexcoords(
1390 for( i = 0; i < numBSPPlanes; i++ )
1392 bspPlanes[ i ].dist *= scale[0];
1397 for( i = 0; i < numBSPPlanes; i++ )
1399 bspPlanes[ i ].normal[0] /= scale[0];
1400 bspPlanes[ i ].normal[1] /= scale[1];
1401 bspPlanes[ i ].normal[2] /= scale[2];
1402 f = 1/VectorLength(bspPlanes[i].normal);
1403 VectorScale(bspPlanes[i].normal, f, bspPlanes[i].normal);
1404 bspPlanes[ i ].dist *= f;
1408 /* scale gridsize */
1409 GetVectorForKey( &entities[ 0 ], "gridsize", vec );
1410 if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) == 0.0f )
1411 VectorCopy( gridSize, vec );
1415 sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
1416 SetKeyValue( &entities[ 0 ], "gridsize", str );
1418 /* inject command line parameters */
1419 InjectCommandLine(argv, 0, argc - 1);
1423 StripExtension( source );
1424 DefaultExtension( source, "_s.bsp" );
1425 Sys_Printf( "Writing %s\n", source );
1426 WriteBSPFile( source );
1428 /* return to sender */
1435 a stripped down ProcessModels
1437 void PseudoCompileBSP(qboolean need_tree)
1440 char modelValue[10];
1449 SetDrawSurfacesBuffer();
1450 mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
1451 memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
1452 numMapDrawSurfs = 0;
1456 for( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
1459 entity = &entities[ mapEntityNum ];
1460 if( entity->brushes == NULL && entity->patches == NULL )
1463 if(mapEntityNum != 0)
1465 sprintf( modelValue, "*%d", models++);
1466 SetKeyValue(entity, "model", modelValue);
1469 /* process the model */
1470 Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
1473 entity->firstDrawSurf = numMapDrawSurfs;
1475 ClearMetaTriangles();
1476 PatchMapDrawSurfs(entity);
1478 if(mapEntityNum == 0 && need_tree)
1480 faces = MakeStructuralBSPFaceList(entities[0].brushes);
1481 tree = FaceBSP(faces);
1482 node = tree->headnode;
1487 node->planenum = PLANENUM_LEAF;
1489 tree->headnode = node;
1492 /* a minimized ClipSidesIntoTree */
1493 for( brush = entity->brushes; brush; brush = brush->next )
1495 /* walk the brush sides */
1496 for( i = 0; i < brush->numsides; i++ )
1499 side = &brush->sides[ i ];
1500 if( side->winding == NULL )
1503 if( side->shaderInfo == NULL )
1505 /* save this winding as a visible surface */
1506 DrawSurfaceForSide(entity, brush, side, side->winding);
1512 ClassifyEntitySurfaces(entity);
1513 MakeEntityDecals(entity);
1514 MakeEntityMetaTriangles(entity);
1515 SmoothMetaTriangles();
1516 MergeMetaTriangles();
1518 FilterDrawsurfsIntoTree(entity, tree);
1520 FilterStructuralBrushesIntoTree(entity, tree);
1521 FilterDetailBrushesIntoTree(entity, tree);
1523 EmitBrushes(entity->brushes, &entity->firstBrush, &entity->numBrushes );
1524 EndModel(entity, node);
1531 main argument processing function for bsp conversion
1534 int ConvertBSPMain( int argc, char **argv )
1537 int (*convertFunc)( char * );
1538 game_t *convertGame;
1540 qboolean map_allowed, force_bsp, force_map;
1544 convertFunc = ConvertBSPToASE;
1546 map_allowed = qfalse;
1553 Sys_Printf( "Usage: q3map -convert -format <ase|obj|map_bp|map> [-shadesasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] <mapname>\n" );
1557 /* process arguments */
1558 for( i = 1; i < (argc - 1); i++ )
1560 /* -format map|ase|... */
1561 if( !strcmp( argv[ i ], "-format" ) )
1564 if( !Q_stricmp( argv[ i ], "ase" ) )
1566 convertFunc = ConvertBSPToASE;
1567 map_allowed = qfalse;
1569 else if( !Q_stricmp( argv[ i ], "obj" ) )
1571 convertFunc = ConvertBSPToOBJ;
1572 map_allowed = qfalse;
1574 else if( !Q_stricmp( argv[ i ], "map_bp" ) )
1576 convertFunc = ConvertBSPToMap_BP;
1577 map_allowed = qtrue;
1579 else if( !Q_stricmp( argv[ i ], "map" ) )
1581 convertFunc = ConvertBSPToMap;
1582 map_allowed = qtrue;
1586 convertGame = GetGame( argv[ i ] );
1587 map_allowed = qfalse;
1588 if( convertGame == NULL )
1589 Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
1592 else if( !strcmp( argv[ i ], "-ne" ) )
1594 normalEpsilon = atof( argv[ i + 1 ] );
1596 Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
1598 else if( !strcmp( argv[ i ], "-de" ) )
1600 distanceEpsilon = atof( argv[ i + 1 ] );
1602 Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
1604 else if( !strcmp( argv[ i ], "-shadersasbitmap" ) )
1605 shadersAsBitmap = qtrue;
1606 else if( !strcmp( argv[ i ], "-lightmapsastexcoord" ) )
1607 lightmapsAsTexcoord = qtrue;
1608 else if( !strcmp( argv[ i ], "-deluxemapsastexcoord" ) )
1610 lightmapsAsTexcoord = qtrue;
1613 else if( !strcmp( argv[ i ], "-readbsp" ) )
1615 else if( !strcmp( argv[ i ], "-readmap" ) )
1617 else if( !strcmp( argv[ i ], "-meta" ) )
1619 else if( !strcmp( argv[ i ], "-patchmeta" ) )
1628 /* clean up map name */
1629 strcpy(source, ExpandArg(argv[i]));
1630 ExtractFileExtension(source, ext);
1632 if(!map_allowed && !force_map)
1635 if(force_map || (!force_bsp && !Q_stricmp(ext, "map") && map_allowed))
1638 Sys_Printf("WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n");
1639 StripExtension(source);
1640 DefaultExtension(source, ".map");
1641 Sys_Printf("Loading %s\n", source);
1642 LoadMapFile(source, qfalse, convertGame == NULL);
1643 PseudoCompileBSP(convertGame != NULL);
1647 StripExtension(source);
1648 DefaultExtension(source, ".bsp");
1649 Sys_Printf("Loading %s\n", source);
1650 LoadBSPFile(source);
1654 /* bsp format convert? */
1655 if( convertGame != NULL )
1657 /* set global game */
1661 StripExtension( source );
1662 DefaultExtension( source, "_c.bsp" );
1663 Sys_Printf( "Writing %s\n", source );
1664 WriteBSPFile( source );
1666 /* return to sender */
1670 /* normal convert */
1671 return convertFunc( source );
1681 int main( int argc, char **argv )
1687 /* we want consistent 'randomness' */
1691 start = I_FloatTime();
1693 /* this was changed to emit version number over the network */
1694 printf( Q3MAP_VERSION "\n" );
1697 atexit( ExitQ3Map );
1699 /* read general options first */
1700 for( i = 1; i < argc; i++ )
1703 if( !strcmp( argv[ i ], "-connect" ) )
1707 Broadcast_Setup( argv[ i ] );
1712 else if( !strcmp( argv[ i ], "-v" ) )
1722 else if( !strcmp( argv[ i ], "-force" ) )
1728 /* patch subdivisions */
1729 else if( !strcmp( argv[ i ], "-subdivisions" ) )
1733 patchSubdivisions = atoi( argv[ i ] );
1735 if( patchSubdivisions <= 0 )
1736 patchSubdivisions = 1;
1740 else if( !strcmp( argv[ i ], "-threads" ) )
1744 numthreads = atoi( argv[ i ] );
1749 /* init model library */
1751 PicoSetMallocFunc( safe_malloc );
1752 PicoSetFreeFunc( free );
1753 PicoSetPrintFunc( PicoPrintFunc );
1754 PicoSetLoadFileFunc( PicoLoadFileFunc );
1755 PicoSetFreeFileFunc( free );
1757 /* set number of threads */
1760 /* generate sinusoid jitter table */
1761 for( i = 0; i < MAX_JITTERS; i++ )
1763 jitters[ i ] = sin( i * 139.54152147 );
1764 //% Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
1767 /* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
1768 and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
1770 Sys_Printf( "Q3Map - v1.0r (c) 1999 Id Software Inc.\n" );
1771 Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
1772 Sys_Printf( "NetRadiant - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
1773 Sys_Printf( "%s\n", Q3MAP_MOTD );
1775 /* ydnar: new path initialization */
1776 InitPaths( &argc, argv );
1778 /* set game options */
1779 if (!patchSubdivisions)
1780 patchSubdivisions = game->patchSubdivisions;
1782 /* check if we have enough options left to attempt something */
1784 Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] );
1787 if( !strcmp( argv[ 1 ], "-fixaas" ) )
1788 r = FixAAS( argc - 1, argv + 1 );
1791 else if( !strcmp( argv[ 1 ], "-analyze" ) )
1792 r = AnalyzeBSP( argc - 1, argv + 1 );
1795 else if( !strcmp( argv[ 1 ], "-info" ) )
1796 r = BSPInfo( argc - 2, argv + 2 );
1799 else if( !strcmp( argv[ 1 ], "-vis" ) )
1800 r = VisMain( argc - 1, argv + 1 );
1803 else if( !strcmp( argv[ 1 ], "-light" ) )
1804 r = LightMain( argc - 1, argv + 1 );
1807 else if( !strcmp( argv[ 1 ], "-vlight" ) )
1809 Sys_Printf( "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
1810 argv[ 1 ] = "-fast"; /* eek a hack */
1811 r = LightMain( argc, argv );
1814 /* ydnar: lightmap export */
1815 else if( !strcmp( argv[ 1 ], "-export" ) )
1816 r = ExportLightmapsMain( argc - 1, argv + 1 );
1818 /* ydnar: lightmap import */
1819 else if( !strcmp( argv[ 1 ], "-import" ) )
1820 r = ImportLightmapsMain( argc - 1, argv + 1 );
1822 /* ydnar: bsp scaling */
1823 else if( !strcmp( argv[ 1 ], "-scale" ) )
1824 r = ScaleBSPMain( argc - 1, argv + 1 );
1826 /* ydnar: bsp conversion */
1827 else if( !strcmp( argv[ 1 ], "-convert" ) )
1828 r = ConvertBSPMain( argc - 1, argv + 1 );
1831 else if( !strcmp( argv[ 1 ], "-minimap" ) )
1832 r = MiniMapBSPMain(argc - 1, argv + 1);
1834 /* ydnar: otherwise create a bsp */
1836 r = BSPMain( argc, argv );
1839 end = I_FloatTime();
1840 Sys_Printf( "%9.0f seconds elapsed\n", end - start );
1842 /* shut down connection */
1843 Broadcast_Shutdown();
1845 /* return any error code */