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 ------------------------------------------------------------------------------- */
42 returns a pseudorandom number between 0 and 1
46 return (vec_t) rand() / RAND_MAX;
50 char *Q_strncpyz( char *dst, const char *src, size_t len ) {
55 strncpy( dst, src, len );
56 dst[ len - 1 ] = '\0';
61 char *Q_strcat( char *dst, size_t dlen, const char *src ) {
62 size_t n = strlen( dst );
65 abort(); /* buffer overflow */
68 return Q_strncpyz( dst + n, src, dlen - n );
72 char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
73 size_t n = strlen( dst );
76 abort(); /* buffer overflow */
79 return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
88 static void ExitQ3Map( void ){
90 if ( mapDrawSurfs != NULL ) {
98 shifts a map: for testing physics with huge coordinates
101 int ShiftBSPMain( int argc, char **argv ){
111 Sys_Printf( "Usage: q3map [-v] -shift [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
115 for ( i = 1; i < argc - 2; ++i )
117 if ( !strcmp( argv[i], "-tex" ) ) {
119 else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
120 spawn_ref = atof( argv[i + 1] );
129 // if(argc-2 >= i) // always true
130 scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
131 if ( argc - 3 >= i ) {
132 scale[1] = scale[0] = atof( argv[ argc - 3 ] );
134 if ( argc - 4 >= i ) {
135 scale[0] = atof( argv[ argc - 4 ] );
139 /* do some path mangling */
140 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
141 StripExtension( source );
142 DefaultExtension( source, ".bsp" );
145 Sys_Printf( "Loading %s\n", source );
146 LoadBSPFile( source );
150 Sys_Printf( "--- ShiftBSP ---\n" );
151 Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
153 /* shift entity keys */
154 for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
157 GetVectorForKey( &entities[ i ], "origin", vec );
158 if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
159 if ( !!strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
165 if ( !!strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
168 sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
169 SetKeyValue( &entities[ i ], "origin", str );
175 for ( i = 0; i < numBSPModels; i++ )
177 bspModels[ i ].mins[0] += scale[0];
178 bspModels[ i ].mins[1] += scale[1];
179 bspModels[ i ].mins[2] += scale[2];
180 bspModels[ i ].maxs[0] += scale[0];
181 bspModels[ i ].maxs[1] += scale[1];
182 bspModels[ i ].maxs[2] += scale[2];
186 for ( i = 0; i < numBSPNodes; i++ )
188 bspNodes[ i ].mins[0] += scale[0];
189 bspNodes[ i ].mins[1] += scale[1];
190 bspNodes[ i ].mins[2] += scale[2];
191 bspNodes[ i ].maxs[0] += scale[0];
192 bspNodes[ i ].maxs[1] += scale[1];
193 bspNodes[ i ].maxs[2] += scale[2];
197 for ( i = 0; i < numBSPLeafs; i++ )
199 bspLeafs[ i ].mins[0] += scale[0];
200 bspLeafs[ i ].mins[1] += scale[1];
201 bspLeafs[ i ].mins[2] += scale[2];
202 bspLeafs[ i ].maxs[0] += scale[0];
203 bspLeafs[ i ].maxs[1] += scale[1];
204 bspLeafs[ i ].maxs[2] += scale[2];
207 /* shift drawverts */
208 for ( i = 0; i < numBSPDrawVerts; i++ )
210 bspDrawVerts[i].xyz[0] += scale[0];
211 bspDrawVerts[i].xyz[1] += scale[1];
212 bspDrawVerts[i].xyz[2] += scale[2];
219 for ( i = 0; i < numBSPPlanes; i++ )
221 //find point on plane
222 for ( j=0; j<3; j++ ){
223 if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){
224 point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j];
225 point[(j+1)%3] = point[(j+2)%3] = 0;
230 for ( j=0; j<3; j++ ){
231 point[j] += scale[j];
233 //calc new plane dist
234 bspPlanes[ i ].dist = DotProduct( point, bspPlanes[ i ].normal );
239 GetVectorForKey( &entities[ 0 ], "gridsize", vec );
240 if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
241 VectorCopy( gridSize, vec );
246 sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
247 SetKeyValue( &entities[ 0 ], "gridsize", str );
249 /* inject command line parameters */
250 InjectCommandLine( argv, 0, argc - 1 );
254 StripExtension( source );
255 DefaultExtension( source, "_sh.bsp" );
256 Sys_Printf( "Writing %s\n", source );
257 WriteBSPFile( source );
259 /* return to sender */
264 void FixDOSName( char *src ){
271 if ( *src == '\\' ) {
279 Check if newcoming texture is unique and not excluded
281 void tex2list( char* texlist, int *texnum, char* EXtex, int *EXtexnum ){
283 if ( token[0] == '\0') return;
284 StripExtension( token );
286 for ( i = 0; i < *texnum; i++ ){
287 if ( !Q_stricmp( texlist[i], token ) ) return;
289 for ( i = 0; i < *EXtexnum; i++ ){
290 if ( !Q_stricmp( EXtex[i], token ) ) return;
292 strcpy ( texlist + (*texnum)*65, token );
298 void tex2list2( char* texlist, int *texnum, char* EXtex, int *EXtexnum, char* rEXtex, int *rEXtexnum ){
300 if ( token[0] == '\0') return;
301 //StripExtension( token );
302 char* dot = strrchr( token, '.' );
304 if ( Q_stricmp( dot, ".tga" ) && Q_stricmp( dot, ".jpg" ) && Q_stricmp( dot, ".png" ) ){
305 Sys_Printf( "WARNING4: %s : weird or missing extension in shader\n", token );
312 strcpy ( texlist + (*texnum)*65, token );
313 strcat( token, ".tga" );
316 for ( i = 0; i < *texnum; i++ ){
317 if ( !Q_stricmp( texlist + i*65, texlist + (*texnum)*65 ) ) return;
319 for ( i = 0; i < *EXtexnum; i++ ){
320 if ( !Q_stricmp( EXtex + i*65, texlist + (*texnum)*65 ) ) return;
322 for ( i = 0; i < *rEXtexnum; i++ ){
323 if ( !Q_stricmp( rEXtex + i*65, texlist + (*texnum)*65 ) ) return;
331 Check if newcoming res is unique
333 void res2list( char* data, int *num ){
335 if ( strlen( data + (*num)*65 ) > 64 ){
336 Sys_Printf( "WARNING6: %s : path too long.\n", data + (*num)*65 );
338 while ( *( data + (*num)*65 ) == '\\' || *( data + (*num)*65 ) == '/' ){
339 char* cut = data + (*num)*65 + 1;
340 strcpy( data + (*num)*65, cut );
342 if ( *( data + (*num)*65 ) == '\0') return;
343 for ( i = 0; i < *num; i++ ){
344 if ( !Q_stricmp( data[i], data[*num] ) ) return;
350 void parseEXblock ( char* data, int *num, const char *exName ){
351 if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
352 Error( "ReadExclusionsFile: %s, line %d: { not found", exName, scriptline );
356 if ( !GetToken( qtrue ) ) {
359 if ( !strcmp( token, "}" ) ) {
362 if ( token[0] == '{' ) {
363 Error( "ReadExclusionsFile: %s, line %d: brace, opening twice in a row.", exName, scriptline );
367 strcpy( data + (*num)*65, token );
373 char q3map2path[1024];
376 map autopackager, works for Q3 type of shaders and ents
379 int pk3BSPMain( int argc, char **argv ){
381 qboolean dbg = qfalse, png = qfalse, packFAIL = qfalse;
383 /* process arguments */
384 for ( i = 1; i < ( argc - 1 ); i++ ){
385 if ( !strcmp( argv[ i ], "-dbg" ) ) {
388 else if ( !strcmp( argv[ i ], "-png" ) ) {
393 /* do some path mangling */
394 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
395 StripExtension( source );
396 DefaultExtension( source, ".bsp" );
399 Sys_Printf( "Loading %s\n", source );
400 LoadBSPFile( source );
404 char packname[ 1024 ], packFailName[ 1024 ], base[ 1024 ], nameOFmap[ 1024 ], temp[ 1024 ];
407 strcpy( base, source );
408 StripExtension( base );
410 /* extract map name */
411 len = strlen( base ) - 1;
412 while ( len > 0 && base[ len ] != '/' && base[ len ] != '\\' )
414 strcpy( nameOFmap, &base[ len + 1 ] );
417 qboolean drawsurfSHs[1024] = { qfalse };
419 for ( i = 0; i < numBSPDrawSurfaces; i++ ){
420 /* can't exclude nodraw patches here (they want shaders :0!) */
421 //if ( !( bspDrawSurfaces[i].surfaceType == 2 && bspDrawSurfaces[i].numIndexes == 0 ) ) drawsurfSHs[bspDrawSurfaces[i].shaderNum] = qtrue;
422 drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = qtrue;
423 //Sys_Printf( "%s\n", bspShaders[bspDrawSurfaces[i].shaderNum].shader );
427 char* pk3Shaders = (char *)calloc( 1024*65, sizeof( char ) );
429 char* pk3Sounds = (char *)calloc( 1024*65, sizeof( char ) );
430 int pk3ShaderfilesN = 0;
431 char* pk3Shaderfiles = (char *)calloc( 1024*65, sizeof( char ) );
432 int pk3TexturesN = 0;
433 char* pk3Textures = (char *)calloc( 1024*65, sizeof( char ) );
435 char* pk3Videos = (char *)calloc( 1024*65, sizeof( char ) );
439 for ( i = 0; i < numBSPShaders; i++ ){
440 if ( drawsurfSHs[i] ){
441 strcpy( pk3Shaders + pk3ShadersN*65, bspShaders[i].shader );
442 res2list( pk3Shaders, &pk3ShadersN );
444 //Sys_Printf( "%s\n", bspShaders[i].shader );
450 for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
452 if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
453 sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
454 res2list( pk3Shaders, &pk3ShadersN );
457 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[0], "music" ) );
458 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' ){
459 FixDOSName( pk3Sounds + pk3SoundsN*65 );
460 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
461 res2list( pk3Sounds, &pk3SoundsN );
464 for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
466 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[i], "noise" ) );
467 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' && *( pk3Sounds + pk3SoundsN*65 ) != '*' ){
468 FixDOSName( pk3Sounds + pk3SoundsN*65 );
469 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
470 res2list( pk3Sounds, &pk3SoundsN );
473 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
474 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
475 res2list( pk3Sounds, &pk3SoundsN );
476 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
477 res2list( pk3Sounds, &pk3SoundsN );
479 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
480 if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
481 strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
482 res2list( pk3Sounds, &pk3SoundsN );
485 strcpy( pk3Shaders + pk3ShadersN*65, ValueForKey( &entities[i], "targetShaderNewName" ) );
486 res2list( pk3Shaders, &pk3ShadersN );
490 sprintf( pk3Shaders + pk3ShadersN*65, "levelshots/%s", nameOFmap );
491 res2list( pk3Shaders, &pk3ShadersN );
495 Sys_Printf( "\n\tDrawsurface+ent calls....%i\n", pk3ShadersN );
496 for ( i = 0; i < pk3ShadersN; i++ ){
497 Sys_Printf( "%s\n", pk3Shaders + i*65 );
499 Sys_Printf( "\n\tSounds....%i\n", pk3SoundsN );
500 for ( i = 0; i < pk3SoundsN; i++ ){
501 Sys_Printf( "%s\n", pk3Sounds + i*65 );
505 vfsListShaderFiles( pk3Shaderfiles, &pk3ShaderfilesN );
508 Sys_Printf( "\n\tSchroider fileses.....%i\n", pk3ShaderfilesN );
509 for ( i = 0; i < pk3ShaderfilesN; i++ ){
510 Sys_Printf( "%s\n", pk3Shaderfiles + i*65 );
515 /* load exclusions file */
517 char* ExTextures = (char *)calloc( 4096*65, sizeof( char ) );
519 char* ExShaders = (char *)calloc( 4096*65, sizeof( char ) );
521 char* ExSounds = (char *)calloc( 4096*65, sizeof( char ) );
522 int ExShaderfilesN = 0;
523 char* ExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
525 char* ExVideos = (char *)calloc( 4096*65, sizeof( char ) );
526 int ExPureTexturesN = 0;
527 char* ExPureTextures = (char *)calloc( 4096*65, sizeof( char ) );
529 char* ExReasonShader[4096] = { NULL };
530 char* ExReasonShaderFile[4096] = { NULL };
536 strcpy( exName, q3map2path );
537 char *cut = strrchr( exName, '\\' );
538 char *cut2 = strrchr( exName, '/' );
539 if ( cut == NULL && cut2 == NULL ){
540 Sys_Printf( "WARNING: Unable to load exclusions file.\n" );
543 if ( cut2 > cut ) cut = cut2;
545 strcat( exName, game->arg );
546 strcat( exName, ".exclude" );
548 Sys_Printf( "Loading %s\n", exName );
549 size = TryLoadFile( exName, (void**) &buffer );
551 Sys_Printf( "WARNING: Unable to find exclusions file %s.\n", exName );
556 ParseFromMemory( (char *) buffer, size );
561 /* test for end of file */
562 if ( !GetToken( qtrue ) ) {
567 if ( !Q_stricmp( token, "textures" ) ){
568 parseEXblock ( ExTextures, &ExTexturesN, exName );
570 else if ( !Q_stricmp( token, "shaders" ) ){
571 parseEXblock ( ExShaders, &ExShadersN, exName );
573 else if ( !Q_stricmp( token, "shaderfiles" ) ){
574 parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
576 else if ( !Q_stricmp( token, "sounds" ) ){
577 parseEXblock ( ExSounds, &ExSoundsN, exName );
579 else if ( !Q_stricmp( token, "videos" ) ){
580 parseEXblock ( ExVideos, &ExVideosN, exName );
583 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
587 /* free the buffer */
590 for ( i = 0; i < ExTexturesN; i++ ){
591 for ( j = 0; j < ExShadersN; j++ ){
592 if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
596 if ( j == ExShadersN ){
597 strcpy ( ExPureTextures + ExPureTexturesN*65, ExTextures + i*65 );
605 Sys_Printf( "\n\tExTextures....%i\n", ExTexturesN );
606 for ( i = 0; i < ExTexturesN; i++ ) Sys_Printf( "%s\n", ExTextures + i*65 );
607 Sys_Printf( "\n\tExPureTextures....%i\n", ExPureTexturesN );
608 for ( i = 0; i < ExPureTexturesN; i++ ) Sys_Printf( "%s\n", ExPureTextures + i*65 );
609 Sys_Printf( "\n\tExShaders....%i\n", ExShadersN );
610 for ( i = 0; i < ExShadersN; i++ ) Sys_Printf( "%s\n", ExShaders + i*65 );
611 Sys_Printf( "\n\tExShaderfiles....%i\n", ExShaderfilesN );
612 for ( i = 0; i < ExShaderfilesN; i++ ) Sys_Printf( "%s\n", ExShaderfiles + i*65 );
613 Sys_Printf( "\n\tExSounds....%i\n", ExSoundsN );
614 for ( i = 0; i < ExSoundsN; i++ ) Sys_Printf( "%s\n", ExSounds + i*65 );
615 Sys_Printf( "\n\tExVideos....%i\n", ExVideosN );
616 for ( i = 0; i < ExVideosN; i++ ) Sys_Printf( "%s\n", ExVideos + i*65 );
619 /* can exclude pure textures right now, shouldn't create shaders for them anyway */
620 for ( i = 0; i < pk3ShadersN ; i++ ){
621 for ( j = 0; j < ExPureTexturesN ; j++ ){
622 if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
623 *( pk3Shaders + i*65 ) = '\0';
633 for ( i = 0; i < pk3ShaderfilesN; i++ ){
634 qboolean wantShader = qfalse, wantShaderFile = qfalse, ShaderFileExcluded = qfalse;
636 char* reasonShader = NULL;
637 char* reasonShaderFile = NULL;
639 /* load the shader */
640 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
641 SilentLoadScriptFile( temp, 0 );
642 if( dbg ) Sys_Printf( "\n\tentering %s\n", pk3Shaderfiles + i*65 );
644 /* do wanna le shader file? */
645 for ( j = 0; j < ExShaderfilesN; j++ ){
646 if ( !Q_stricmp( ExShaderfiles + j*65, pk3Shaderfiles + i*65 ) ){
647 ShaderFileExcluded = qtrue;
648 reasonShaderFile = ExShaderfiles + j*65;
653 /* check if shader file has to be excluded */
654 while ( !ShaderFileExcluded )
656 /* test for end of file */
657 if ( !GetToken( qtrue ) ) {
661 /* does it contain restricted shaders/textures? */
662 for ( j = 0; j < ExShadersN; j++ ){
663 if ( !Q_stricmp( ExShaders + j*65, token ) ){
664 ShaderFileExcluded = qtrue;
665 reasonShader = ExShaders + j*65;
669 if ( ShaderFileExcluded )
671 for ( j = 0; j < ExPureTexturesN; j++ ){
672 if ( !Q_stricmp( ExPureTextures + j*65, token ) ){
673 ShaderFileExcluded = qtrue;
674 reasonShader = ExPureTextures + j*65;
678 if ( ShaderFileExcluded )
681 /* handle { } section */
682 if ( !GetToken( qtrue ) ) {
685 if ( strcmp( token, "{" ) ) {
686 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s",
687 temp, scriptline, token );
692 /* get the next token */
693 if ( !GetToken( qtrue ) ) {
696 if ( !strcmp( token, "}" ) ) {
699 /* parse stage directives */
700 if ( !strcmp( token, "{" ) ) {
703 if ( !GetToken( qtrue ) ) {
706 if ( !strcmp( token, "}" ) ) {
714 /* tokenize it again */
715 SilentLoadScriptFile( temp, 0 );
718 /* test for end of file */
719 if ( !GetToken( qtrue ) ) {
723 if( dbg ) Sys_Printf( "%s\n", token );
725 /* do wanna le shader? */
727 for ( j = 0; j < pk3ShadersN; j++ ){
728 if ( !Q_stricmp( pk3Shaders + j*65, token) ){
735 /* handle { } section */
736 if ( !GetToken( qtrue ) ) {
739 if ( strcmp( token, "{" ) ) {
740 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s",
741 temp, scriptline, token );
744 qboolean hasmap = qfalse;
747 /* get the next token */
748 if ( !GetToken( qtrue ) ) {
751 if ( !strcmp( token, "}" ) ) {
756 /* -----------------------------------------------------------------
757 shader stages (passes)
758 ----------------------------------------------------------------- */
760 /* parse stage directives */
761 if ( !strcmp( token, "{" ) ) {
764 if ( !GetToken( qtrue ) ) {
767 if ( !strcmp( token, "}" ) ) {
770 if ( !strcmp( token, "{" ) ) {
771 Sys_Printf( "WARNING9: %s : line %d : opening brace inside shader stage\n", temp, scriptline );
773 if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
774 Sys_Printf( "WARNING7: %s : line %d : unsupported '%s' map directive\n", temp, scriptline, token );
776 /* skip the shader */
777 if ( !wantShader ) continue;
779 /* digest any images */
780 if ( !Q_stricmp( token, "map" ) ||
781 !Q_stricmp( token, "clampMap" ) ) {
785 if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
786 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
789 else if ( !Q_stricmp( token, "animMap" ) ||
790 !Q_stricmp( token, "clampAnimMap" ) ) {
792 GetToken( qfalse );// skip num
793 while ( TokenAvailable() ){
795 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
798 else if ( !Q_stricmp( token, "videoMap" ) ){
802 if ( strchr( token, '/' ) == NULL && strchr( token, '\\' ) == NULL ){
803 sprintf( temp, "video/%s", token );
804 strcpy( token, temp );
807 for ( j = 0; j < pk3VideosN; j++ ){
808 if ( !Q_stricmp( pk3Videos + j*65, token ) ){
812 for ( j = 0; j < ExVideosN; j++ ){
813 if ( !Q_stricmp( ExVideos + j*65, token ) ){
817 strcpy ( pk3Videos + pk3VideosN*65, token );
824 else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
825 Sys_Printf( "WARNING5: %s : line %d : unsupported %s shader\n", temp, scriptline, token );
827 /* skip the shader */
828 else if ( !wantShader ) continue;
830 /* -----------------------------------------------------------------
831 surfaceparm * directives
832 ----------------------------------------------------------------- */
834 /* match surfaceparm */
835 else if ( !Q_stricmp( token, "surfaceparm" ) ) {
837 if ( !Q_stricmp( token, "nodraw" ) ) {
839 *( pk3Shaders + shader*65 ) = '\0';
843 /* skyparms <outer image> <cloud height> <inner image> */
844 else if ( !Q_stricmp( token, "skyParms" ) ) {
849 /* ignore bogus paths */
850 if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
851 strcpy ( temp, token );
852 sprintf( token, "%s_up", temp );
853 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
854 sprintf( token, "%s_dn", temp );
855 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
856 sprintf( token, "%s_lf", temp );
857 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
858 sprintf( token, "%s_rt", temp );
859 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
860 sprintf( token, "%s_bk", temp );
861 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
862 sprintf( token, "%s_ft", temp );
863 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
865 /* skip rest of line */
869 else if ( !Q_stricmp( token, "fogparms" ) ){
876 for ( j = 0; j < ExShadersN; j++ ){
877 if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
879 *( pk3Shaders + shader*65 ) = '\0';
887 if ( ShaderFileExcluded ){
888 if ( reasonShaderFile != NULL ){
889 ExReasonShaderFile[ shader ] = reasonShaderFile;
892 ExReasonShaderFile[ shader ] = ( char* ) calloc( 65, sizeof( char ) );
893 strcpy( ExReasonShaderFile[ shader ], pk3Shaderfiles + i*65 );
895 ExReasonShader[ shader ] = reasonShader;
898 wantShaderFile = qtrue;
899 *( pk3Shaders + shader*65 ) = '\0';
904 if ( !wantShaderFile ){
905 *( pk3Shaderfiles + i*65 ) = '\0';
912 //wanted shaders from excluded .shaders
914 for ( i = 0; i < pk3ShadersN; i++ ){
915 if ( *( pk3Shaders + i*65 ) != '\0' && ( ExReasonShader[i] != NULL || ExReasonShaderFile[i] != NULL ) ){
916 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
918 if ( ExReasonShader[i] != NULL ){
919 Sys_Printf( " reason: is located in %s,\n containing restricted shader %s\n", ExReasonShaderFile[i], ExReasonShader[i] );
922 Sys_Printf( " reason: is located in restricted %s\n", ExReasonShaderFile[i] );
924 *( pk3Shaders + i*65 ) = '\0';
927 //pure textures (shader ones are done)
928 for ( i = 0; i < pk3ShadersN; i++ ){
929 if ( *( pk3Shaders + i*65 ) != '\0' ){
930 FixDOSName( pk3Shaders + i*65 );
931 for ( j = 0; j < pk3TexturesN; j++ ){
932 if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
933 *( pk3Shaders + i*65 ) = '\0';
937 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
938 for ( j = 0; j < ExTexturesN; j++ ){
939 if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
940 *( pk3Shaders + i*65 ) = '\0';
948 for ( i = 0; i < pk3SoundsN; i++ ){
949 for ( j = 0; j < ExSoundsN; j++ ){
950 if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
951 *( pk3Sounds + i*65 ) = '\0';
958 sprintf( packname, "%s/%s_autopacked.pk3", EnginePath, nameOFmap );
960 sprintf( packFailName, "%s/%s_FAILEDpack.pk3", EnginePath, nameOFmap );
961 remove( packFailName );
963 Sys_Printf( "\n--- ZipZip ---\n" );
965 Sys_Printf( "\n\tShader referenced textures....\n" );
967 for ( i = 0; i < pk3TexturesN; i++ ){
969 sprintf( temp, "%s.png", pk3Textures + i*65 );
970 if ( vfsPackFile( temp, packname, 10 ) ){
971 Sys_Printf( "++%s\n", temp );
975 sprintf( temp, "%s.tga", pk3Textures + i*65 );
976 if ( vfsPackFile( temp, packname, 10 ) ){
977 Sys_Printf( "++%s\n", temp );
980 sprintf( temp, "%s.jpg", pk3Textures + i*65 );
981 if ( vfsPackFile( temp, packname, 10 ) ){
982 Sys_Printf( "++%s\n", temp );
985 Sys_Printf( " !FAIL! %s\n", pk3Textures + i*65 );
989 Sys_Printf( "\n\tPure textures....\n" );
991 for ( i = 0; i < pk3ShadersN; i++ ){
992 if ( *( pk3Shaders + i*65 ) != '\0' ){
994 sprintf( temp, "%s.png", pk3Shaders + i*65 );
995 if ( vfsPackFile( temp, packname, 10 ) ){
996 Sys_Printf( "++%s\n", temp );
1000 sprintf( temp, "%s.tga", pk3Shaders + i*65 );
1001 if ( vfsPackFile( temp, packname, 10 ) ){
1002 Sys_Printf( "++%s\n", temp );
1005 sprintf( temp, "%s.jpg", pk3Shaders + i*65 );
1006 if ( vfsPackFile( temp, packname, 10 ) ){
1007 Sys_Printf( "++%s\n", temp );
1010 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
1011 if ( i != pk3ShadersN - 1 ) packFAIL = qtrue; //levelshot typically
1015 Sys_Printf( "\n\tShaizers....\n" );
1017 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1018 if ( *( pk3Shaderfiles + i*65 ) != '\0' ){
1019 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
1020 if ( vfsPackFile( temp, packname, 10 ) ){
1021 Sys_Printf( "++%s\n", temp );
1024 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
1029 Sys_Printf( "\n\tSounds....\n" );
1031 for ( i = 0; i < pk3SoundsN; i++ ){
1032 if ( *( pk3Sounds + i*65 ) != '\0' ){
1033 if ( vfsPackFile( pk3Sounds + i*65, packname, 10 ) ){
1034 Sys_Printf( "++%s\n", pk3Sounds + i*65 );
1037 Sys_Printf( " !FAIL! %s\n", pk3Sounds + i*65 );
1042 Sys_Printf( "\n\tVideos....\n" );
1044 for ( i = 0; i < pk3VideosN; i++ ){
1045 if ( vfsPackFile( pk3Videos + i*65, packname, 10 ) ){
1046 Sys_Printf( "++%s\n", pk3Videos + i*65 );
1049 Sys_Printf( " !FAIL! %s\n", pk3Videos + i*65 );
1053 Sys_Printf( "\n\t.bsp and stuff\n" );
1055 sprintf( temp, "maps/%s.bsp", nameOFmap );
1056 if ( vfsPackFile( temp, packname, 10 ) ){
1057 Sys_Printf( "++%s\n", temp );
1060 Sys_Printf( " !FAIL! %s\n", temp );
1064 sprintf( temp, "maps/%s.aas", nameOFmap );
1065 if ( vfsPackFile( temp, packname, 10 ) ){
1066 Sys_Printf( "++%s\n", temp );
1069 Sys_Printf( " !FAIL! %s\n", temp );
1072 sprintf( temp, "scripts/%s.arena", nameOFmap );
1073 if ( vfsPackFile( temp, packname, 10 ) ){
1074 Sys_Printf( "++%s\n", temp );
1077 Sys_Printf( " !FAIL! %s\n", temp );
1080 sprintf( temp, "scripts/%s.defi", nameOFmap );
1081 if ( vfsPackFile( temp, packname, 10 ) ){
1082 Sys_Printf( "++%s\n", temp );
1085 Sys_Printf( " !FAIL! %s\n", temp );
1089 Sys_Printf( "\nSaved to %s\n", packname );
1092 rename( packname, packFailName );
1093 Sys_Printf( "\nSaved to %s\n", packFailName );
1095 /* return to sender */
1102 repack multiple maps, strip out only required shaders
1103 works for Q3 type of shaders and ents
1106 int repackBSPMain( int argc, char **argv ){
1107 int i, j, len, compLevel = 0;
1108 qboolean dbg = qfalse, png = qfalse;
1110 /* process arguments */
1111 for ( i = 1; i < ( argc - 1 ); i++ ){
1112 if ( !strcmp( argv[ i ], "-dbg" ) ) {
1115 else if ( !strcmp( argv[ i ], "-png" ) ) {
1118 else if ( !strcmp( argv[ i ], "-complevel" ) ) {
1119 compLevel = atoi( argv[ i + 1 ] );
1121 if ( compLevel < -1 ) compLevel = -1;
1122 if ( compLevel > 10 ) compLevel = 10;
1123 Sys_Printf( "Compression level set to %i\n", compLevel );
1127 /* load exclusions file */
1128 int ExTexturesN = 0;
1129 char* ExTextures = (char *)calloc( 4096*65, sizeof( char ) );
1131 char* ExShaders = (char *)calloc( 4096*65, sizeof( char ) );
1133 char* ExSounds = (char *)calloc( 4096*65, sizeof( char ) );
1134 int ExShaderfilesN = 0;
1135 char* ExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1137 char* ExVideos = (char *)calloc( 4096*65, sizeof( char ) );
1138 int ExPureTexturesN = 0;
1139 char* ExPureTextures = (char *)calloc( 4096*65, sizeof( char ) );
1142 char exName[ 1024 ];
1146 strcpy( exName, q3map2path );
1147 char *cut = strrchr( exName, '\\' );
1148 char *cut2 = strrchr( exName, '/' );
1149 if ( cut == NULL && cut2 == NULL ){
1150 Sys_Printf( "WARNING: Unable to load exclusions file.\n" );
1153 if ( cut2 > cut ) cut = cut2;
1155 strcat( exName, game->arg );
1156 strcat( exName, ".exclude" );
1158 Sys_Printf( "Loading %s\n", exName );
1159 size = TryLoadFile( exName, (void**) &buffer );
1161 Sys_Printf( "WARNING: Unable to find exclusions file %s.\n", exName );
1165 /* parse the file */
1166 ParseFromMemory( (char *) buffer, size );
1171 /* test for end of file */
1172 if ( !GetToken( qtrue ) ) {
1177 if ( !Q_stricmp( token, "textures" ) ){
1178 parseEXblock ( ExTextures, &ExTexturesN, exName );
1180 else if ( !Q_stricmp( token, "shaders" ) ){
1181 parseEXblock ( ExShaders, &ExShadersN, exName );
1183 else if ( !Q_stricmp( token, "shaderfiles" ) ){
1184 parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
1186 else if ( !Q_stricmp( token, "sounds" ) ){
1187 parseEXblock ( ExSounds, &ExSoundsN, exName );
1189 else if ( !Q_stricmp( token, "videos" ) ){
1190 parseEXblock ( ExVideos, &ExVideosN, exName );
1193 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
1197 /* free the buffer */
1200 for ( i = 0; i < ExTexturesN; i++ ){
1201 for ( j = 0; j < ExShadersN; j++ ){
1202 if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
1206 if ( j == ExShadersN ){
1207 strcpy ( ExPureTextures + ExPureTexturesN*65, ExTextures + i*65 );
1215 Sys_Printf( "\n\tExTextures....%i\n", ExTexturesN );
1216 for ( i = 0; i < ExTexturesN; i++ ) Sys_Printf( "%s\n", ExTextures + i*65 );
1217 Sys_Printf( "\n\tExPureTextures....%i\n", ExPureTexturesN );
1218 for ( i = 0; i < ExPureTexturesN; i++ ) Sys_Printf( "%s\n", ExPureTextures + i*65 );
1219 Sys_Printf( "\n\tExShaders....%i\n", ExShadersN );
1220 for ( i = 0; i < ExShadersN; i++ ) Sys_Printf( "%s\n", ExShaders + i*65 );
1221 Sys_Printf( "\n\tExShaderfiles....%i\n", ExShaderfilesN );
1222 for ( i = 0; i < ExShaderfilesN; i++ ) Sys_Printf( "%s\n", ExShaderfiles + i*65 );
1223 Sys_Printf( "\n\tExSounds....%i\n", ExSoundsN );
1224 for ( i = 0; i < ExSoundsN; i++ ) Sys_Printf( "%s\n", ExSounds + i*65 );
1225 Sys_Printf( "\n\tExVideos....%i\n", ExVideosN );
1226 for ( i = 0; i < ExVideosN; i++ ) Sys_Printf( "%s\n", ExVideos + i*65 );
1232 /* load repack.exclude */
1233 int rExTexturesN = 0;
1234 char* rExTextures = (char *)calloc( 65536*65, sizeof( char ) );
1235 int rExShadersN = 0;
1236 char* rExShaders = (char *)calloc( 32768*65, sizeof( char ) );
1238 char* rExSounds = (char *)calloc( 8192*65, sizeof( char ) );
1239 int rExShaderfilesN = 0;
1240 char* rExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1242 char* rExVideos = (char *)calloc( 4096*65, sizeof( char ) );
1244 strcpy( exName, q3map2path );
1245 cut = strrchr( exName, '\\' );
1246 cut2 = strrchr( exName, '/' );
1247 if ( cut == NULL && cut2 == NULL ){
1248 Sys_Printf( "WARNING: Unable to load repack exclusions file.\n" );
1251 if ( cut2 > cut ) cut = cut2;
1253 strcat( exName, "repack.exclude" );
1255 Sys_Printf( "Loading %s\n", exName );
1256 size = TryLoadFile( exName, (void**) &buffer );
1258 Sys_Printf( "WARNING: Unable to find repack exclusions file %s.\n", exName );
1262 /* parse the file */
1263 ParseFromMemory( (char *) buffer, size );
1268 /* test for end of file */
1269 if ( !GetToken( qtrue ) ) {
1274 if ( !Q_stricmp( token, "textures" ) ){
1275 parseEXblock ( rExTextures, &rExTexturesN, exName );
1277 else if ( !Q_stricmp( token, "shaders" ) ){
1278 parseEXblock ( rExShaders, &rExShadersN, exName );
1280 else if ( !Q_stricmp( token, "shaderfiles" ) ){
1281 parseEXblock ( rExShaderfiles, &rExShaderfilesN, exName );
1283 else if ( !Q_stricmp( token, "sounds" ) ){
1284 parseEXblock ( rExSounds, &rExSoundsN, exName );
1286 else if ( !Q_stricmp( token, "videos" ) ){
1287 parseEXblock ( rExVideos, &rExVideosN, exName );
1290 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
1294 /* free the buffer */
1300 Sys_Printf( "\n\trExTextures....%i\n", rExTexturesN );
1301 for ( i = 0; i < rExTexturesN; i++ ) Sys_Printf( "%s\n", rExTextures + i*65 );
1302 Sys_Printf( "\n\trExShaders....%i\n", rExShadersN );
1303 for ( i = 0; i < rExShadersN; i++ ) Sys_Printf( "%s\n", rExShaders + i*65 );
1304 Sys_Printf( "\n\trExShaderfiles....%i\n", rExShaderfilesN );
1305 for ( i = 0; i < rExShaderfilesN; i++ ) Sys_Printf( "%s\n", rExShaderfiles + i*65 );
1306 Sys_Printf( "\n\trExSounds....%i\n", rExSoundsN );
1307 for ( i = 0; i < rExSoundsN; i++ ) Sys_Printf( "%s\n", rExSounds + i*65 );
1308 Sys_Printf( "\n\trExVideos....%i\n", rExVideosN );
1309 for ( i = 0; i < rExVideosN; i++ ) Sys_Printf( "%s\n", rExVideos + i*65 );
1316 char* bspList = (char *)calloc( 8192*1024, sizeof( char ) );
1318 /* do some path mangling */
1319 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
1320 if ( !Q_stricmp( strrchr( source, '.' ), ".bsp" ) ){
1321 strcpy( bspList, source );
1325 /* load bsps paths list */
1326 Sys_Printf( "Loading %s\n", source );
1327 size = TryLoadFile( source, (void**) &buffer );
1329 Sys_Printf( "WARNING: Unable to open bsps paths list file %s.\n", source );
1332 /* parse the file */
1333 ParseFromMemory( (char *) buffer, size );
1338 /* test for end of file */
1339 if ( !GetToken( qtrue ) ) {
1342 strcpy( bspList + bspListN * 1024 , token );
1346 /* free the buffer */
1350 char packname[ 1024 ], nameOFrepack[ 1024 ], nameOFmap[ 1024 ], temp[ 1024 ];
1352 /* copy input file name */
1353 strcpy( temp, source );
1354 StripExtension( temp );
1356 /* extract input file name */
1357 len = strlen( temp ) - 1;
1358 while ( len > 0 && temp[ len ] != '/' && temp[ len ] != '\\' )
1360 strcpy( nameOFrepack, &temp[ len + 1 ] );
1364 int pk3ShadersN = 0;
1365 char* pk3Shaders = (char *)calloc( 65536*65, sizeof( char ) );
1367 char* pk3Sounds = (char *)calloc( 4096*65, sizeof( char ) );
1368 int pk3ShaderfilesN = 0;
1369 char* pk3Shaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1370 int pk3TexturesN = 0;
1371 char* pk3Textures = (char *)calloc( 65536*65, sizeof( char ) );
1373 char* pk3Videos = (char *)calloc( 1024*65, sizeof( char ) );
1375 for( j = 0; j < bspListN; j++ ){
1377 int pk3SoundsNold = pk3SoundsN;
1378 int pk3ShadersNold = pk3ShadersN;
1380 strcpy( source, bspList + j*1024 );
1381 StripExtension( source );
1382 DefaultExtension( source, ".bsp" );
1385 Sys_Printf( "\nLoading %s\n", source );
1386 PartialLoadBSPFile( source );
1390 strcpy( temp, source );
1391 StripExtension( temp );
1393 /* extract map name */
1394 len = strlen( temp ) - 1;
1395 while ( len > 0 && temp[ len ] != '/' && temp[ len ] != '\\' )
1397 strcpy( nameOFmap, &temp[ len + 1 ] );
1400 qboolean drawsurfSHs[1024] = { qfalse };
1402 for ( i = 0; i < numBSPDrawSurfaces; i++ ){
1403 drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = qtrue;
1406 for ( i = 0; i < numBSPShaders; i++ ){
1407 if ( drawsurfSHs[i] ){
1408 strcpy( pk3Shaders + pk3ShadersN*65, bspShaders[i].shader );
1409 res2list( pk3Shaders, &pk3ShadersN );
1415 for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
1417 if ( !!Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
1418 sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
1419 res2list( pk3Shaders, &pk3ShadersN );
1422 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[0], "music" ) );
1423 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' ){
1424 FixDOSName( pk3Sounds + pk3SoundsN*65 );
1425 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
1426 res2list( pk3Sounds, &pk3SoundsN );
1429 for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
1431 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[i], "noise" ) );
1432 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' && *( pk3Sounds + pk3SoundsN*65 ) != '*' ){
1433 FixDOSName( pk3Sounds + pk3SoundsN*65 );
1434 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
1435 res2list( pk3Sounds, &pk3SoundsN );
1438 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
1439 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
1440 res2list( pk3Sounds, &pk3SoundsN );
1441 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
1442 res2list( pk3Sounds, &pk3SoundsN );
1444 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
1445 if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
1446 strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
1447 res2list( pk3Sounds, &pk3SoundsN );
1450 strcpy( pk3Shaders + pk3ShadersN*65, ValueForKey( &entities[i], "targetShaderNewName" ) );
1451 res2list( pk3Shaders, &pk3ShadersN );
1455 sprintf( pk3Shaders + pk3ShadersN*65, "levelshots/%s", nameOFmap );
1456 res2list( pk3Shaders, &pk3ShadersN );
1460 Sys_Printf( "\n\t+Drawsurface+ent calls....%i\n", pk3ShadersN - pk3ShadersNold );
1461 for ( i = pk3ShadersNold; i < pk3ShadersN; i++ ){
1462 Sys_Printf( "%s\n", pk3Shaders + i*65 );
1464 Sys_Printf( "\n\t+Sounds....%i\n", pk3SoundsN - pk3SoundsNold );
1465 for ( i = pk3SoundsNold; i < pk3SoundsN; i++ ){
1466 Sys_Printf( "%s\n", pk3Sounds + i*65 );
1470 if ( bspDrawVerts != 0 ) {
1471 free( bspDrawVerts );
1472 bspDrawVerts = NULL;
1473 //numBSPDrawVerts = 0;
1474 Sys_Printf( "freed BSPDrawVerts\n" );
1476 */ if ( bspDrawSurfaces != 0 ) {
1477 free( bspDrawSurfaces );
1478 bspDrawSurfaces = NULL;
1479 //numBSPDrawSurfaces = 0;
1480 //Sys_Printf( "freed bspDrawSurfaces\n" );
1482 /* if ( bspLightBytes != 0 ) {
1483 free( bspLightBytes );
1484 bspLightBytes = NULL;
1485 //numBSPLightBytes = 0;
1486 Sys_Printf( "freed BSPLightBytes\n" );
1488 if ( bspGridPoints != 0 ) {
1489 free( bspGridPoints );
1490 bspGridPoints = NULL;
1491 //numBSPGridPoints = 0;
1492 Sys_Printf( "freed BSPGridPoints\n" );
1494 if ( bspPlanes != 0 ) {
1497 Sys_Printf( "freed bspPlanes\n" );
1499 //allocatedBSPPlanes = 0;
1501 if ( bspBrushes != 0 ) {
1504 Sys_Printf( "freed bspBrushes\n" );
1505 //numBSPBrushes = 0;
1506 //allocatedBSPBrushes = 0;
1508 */ if ( entities != 0 ) {
1510 for ( i = 0; i < numBSPEntities && i < numEntities; i++ ){
1511 ep = entities[i].epairs;
1520 //Sys_Printf( "freed entities\n" );
1523 allocatedEntities = 0;
1525 /* if ( bspModels != 0 ) {
1528 Sys_Printf( "freed bspModels\n" );
1530 //allocatedBSPModels = 0;
1532 */ if ( bspShaders != 0 ) {
1535 //Sys_Printf( "freed bspShaders\n" );
1536 //numBSPShaders = 0;
1537 //allocatedBSPShaders = 0;
1539 if ( bspEntData != 0 ) {
1542 //Sys_Printf( "freed bspEntData\n" );
1543 //bspEntDataSize = 0;
1544 //allocatedBSPEntData = 0;
1546 /* if ( bspNodes != 0 ) {
1549 Sys_Printf( "freed bspNodes\n" );
1551 //allocatedBSPNodes = 0;
1553 if ( bspDrawIndexes != 0 ) {
1554 free( bspDrawIndexes );
1555 bspDrawIndexes = NULL;
1556 Sys_Printf( "freed bspDrawIndexes\n" );
1557 //numBSPDrawIndexes = 0;
1558 //allocatedBSPDrawIndexes = 0;
1560 if ( bspLeafSurfaces != 0 ) {
1561 free( bspLeafSurfaces );
1562 bspLeafSurfaces = NULL;
1563 Sys_Printf( "freed bspLeafSurfaces\n" );
1564 //numBSPLeafSurfaces = 0;
1565 //allocatedBSPLeafSurfaces = 0;
1567 if ( bspLeafBrushes != 0 ) {
1568 free( bspLeafBrushes );
1569 bspLeafBrushes = NULL;
1570 Sys_Printf( "freed bspLeafBrushes\n" );
1571 //numBSPLeafBrushes = 0;
1572 //allocatedBSPLeafBrushes = 0;
1574 if ( bspBrushSides != 0 ) {
1575 free( bspBrushSides );
1576 bspBrushSides = NULL;
1577 Sys_Printf( "freed bspBrushSides\n" );
1578 numBSPBrushSides = 0;
1579 allocatedBSPBrushSides = 0;
1581 if ( numBSPFogs != 0 ) {
1582 Sys_Printf( "freed numBSPFogs\n" );
1585 if ( numBSPAds != 0 ) {
1586 Sys_Printf( "freed numBSPAds\n" );
1589 if ( numBSPLeafs != 0 ) {
1590 Sys_Printf( "freed numBSPLeafs\n" );
1593 if ( numBSPVisBytes != 0 ) {
1594 Sys_Printf( "freed numBSPVisBytes\n" );
1601 vfsListShaderFiles( pk3Shaderfiles, &pk3ShaderfilesN );
1604 Sys_Printf( "\n\tSchroider fileses.....%i\n", pk3ShaderfilesN );
1605 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1606 Sys_Printf( "%s\n", pk3Shaderfiles + i*65 );
1612 /* can exclude pure *base* textures right now, shouldn't create shaders for them anyway */
1613 for ( i = 0; i < pk3ShadersN ; i++ ){
1614 for ( j = 0; j < ExPureTexturesN ; j++ ){
1615 if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
1616 *( pk3Shaders + i*65 ) = '\0';
1621 /* can exclude repack.exclude shaders, assuming they got all their images */
1622 for ( i = 0; i < pk3ShadersN ; i++ ){
1623 for ( j = 0; j < rExShadersN ; j++ ){
1624 if ( !Q_stricmp( pk3Shaders + i*65, rExShaders + j*65 ) ){
1625 *( pk3Shaders + i*65 ) = '\0';
1631 //Parse Shader Files
1632 Sys_Printf( "\t\nParsing shaders....\n\n" );
1633 char shaderText[ 8192 ];
1634 char* allShaders = (char *)calloc( 16777216, sizeof( char ) );
1636 endofscript = qtrue;
1638 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1639 qboolean wantShader = qfalse;
1642 /* load the shader */
1643 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
1644 if ( dbg ) Sys_Printf( "\n\tentering %s\n", pk3Shaderfiles + i*65 );
1645 SilentLoadScriptFile( temp, 0 );
1650 int line = scriptline;
1651 /* test for end of file */
1652 if ( !GetToken( qtrue ) ) {
1656 if( dbg ) Sys_Printf( "%s\n", token );
1658 strcpy( shaderText, token );
1660 if ( strchr( token, '\\') != NULL ){
1661 Sys_Printf( "WARNING1: %s : %s : shader name with backslash\n", pk3Shaderfiles + i*65, token );
1664 /* do wanna le shader? */
1665 wantShader = qfalse;
1666 for ( j = 0; j < pk3ShadersN; j++ ){
1667 if ( !Q_stricmp( pk3Shaders + j*65, token) ){
1674 for ( j = 0; j < rExTexturesN ; j++ ){
1675 if ( !Q_stricmp( pk3Shaders + shader*65, rExTextures + j*65 ) ){
1676 Sys_Printf( "WARNING3: %s : about to include shader for excluded texture\n", pk3Shaders + shader*65 );
1682 /* handle { } section */
1683 if ( !GetToken( qtrue ) ) {
1686 if ( strcmp( token, "{" ) ) {
1687 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s",
1688 temp, scriptline, token );
1690 strcat( shaderText, "\n{" );
1691 qboolean hasmap = qfalse;
1696 /* get the next token */
1697 if ( !GetToken( qtrue ) ) {
1700 if ( !strcmp( token, "}" ) ) {
1701 strcat( shaderText, "\n}\n\n" );
1704 /* parse stage directives */
1705 if ( !strcmp( token, "{" ) ) {
1706 qboolean tokenready = qfalse;
1707 strcat( shaderText, "\n\t{" );
1710 /* detour of TokenAvailable() '~' */
1711 if ( tokenready ) tokenready = qfalse;
1712 else line = scriptline;
1713 if ( !GetToken( qtrue ) ) {
1716 if ( !strcmp( token, "}" ) ) {
1717 strcat( shaderText, "\n\t}" );
1720 if ( !strcmp( token, "{" ) ) {
1721 strcat( shaderText, "\n\t{" );
1722 Sys_Printf( "WARNING9: %s : line %d : opening brace inside shader stage\n", temp, scriptline );
1724 /* skip the shader */
1725 if ( !wantShader ) continue;
1727 /* digest any images */
1728 if ( !Q_stricmp( token, "map" ) ||
1729 !Q_stricmp( token, "clampMap" ) ) {
1730 strcat( shaderText, "\n\t\t" );
1731 strcat( shaderText, token );
1736 if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
1737 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1739 strcat( shaderText, " " );
1740 strcat( shaderText, token );
1742 else if ( !Q_stricmp( token, "animMap" ) ||
1743 !Q_stricmp( token, "clampAnimMap" ) ) {
1744 strcat( shaderText, "\n\t\t" );
1745 strcat( shaderText, token );
1748 GetToken( qfalse );// skip num
1749 strcat( shaderText, " " );
1750 strcat( shaderText, token );
1751 while ( TokenAvailable() ){
1753 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1754 strcat( shaderText, " " );
1755 strcat( shaderText, token );
1759 else if ( !Q_stricmp( token, "videoMap" ) ){
1760 strcat( shaderText, "\n\t\t" );
1761 strcat( shaderText, token );
1764 strcat( shaderText, " " );
1765 strcat( shaderText, token );
1766 FixDOSName( token );
1767 if ( strchr( token, '/' ) == NULL && strchr( token, '\\' ) == NULL ){
1768 sprintf( temp, "video/%s", token );
1769 strcpy( token, temp );
1771 FixDOSName( token );
1772 for ( j = 0; j < pk3VideosN; j++ ){
1773 if ( !Q_stricmp( pk3Videos + j*65, token ) ){
1777 for ( j = 0; j < ExVideosN; j++ ){
1778 if ( !Q_stricmp( ExVideos + j*65, token ) ){
1782 for ( j = 0; j < rExVideosN; j++ ){
1783 if ( !Q_stricmp( rExVideos + j*65, token ) ){
1787 strcpy ( pk3Videos + pk3VideosN*65, token );
1792 else if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
1793 Sys_Printf( "WARNING7: %s : %s shader\n", pk3Shaders + shader*65, token );
1795 if ( line == scriptline ){
1796 strcat( shaderText, " " );
1797 strcat( shaderText, token );
1800 strcat( shaderText, "\n\t\t" );
1801 strcat( shaderText, token );
1804 else if ( line == scriptline ){
1805 strcat( shaderText, " " );
1806 strcat( shaderText, token );
1809 strcat( shaderText, "\n\t\t" );
1810 strcat( shaderText, token );
1814 /* skip the shader */
1815 else if ( !wantShader ) continue;
1817 /* -----------------------------------------------------------------
1818 surfaceparm * directives
1819 ----------------------------------------------------------------- */
1821 /* match surfaceparm */
1822 else if ( !Q_stricmp( token, "surfaceparm" ) ) {
1823 strcat( shaderText, "\n\tsurfaceparm " );
1825 strcat( shaderText, token );
1826 if ( !Q_stricmp( token, "nodraw" ) ) {
1827 wantShader = qfalse;
1828 *( pk3Shaders + shader*65 ) = '\0';
1832 /* skyparms <outer image> <cloud height> <inner image> */
1833 else if ( !Q_stricmp( token, "skyParms" ) ) {
1834 strcat( shaderText, "\n\tskyParms " );
1836 /* get image base */
1838 strcat( shaderText, token );
1840 /* ignore bogus paths */
1841 if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
1842 strcpy ( temp, token );
1843 sprintf( token, "%s_up", temp );
1844 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1845 sprintf( token, "%s_dn", temp );
1846 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1847 sprintf( token, "%s_lf", temp );
1848 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1849 sprintf( token, "%s_rt", temp );
1850 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1851 sprintf( token, "%s_bk", temp );
1852 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1853 sprintf( token, "%s_ft", temp );
1854 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1856 /* skip rest of line */
1858 strcat( shaderText, " " );
1859 strcat( shaderText, token );
1861 strcat( shaderText, " " );
1862 strcat( shaderText, token );
1864 else if ( !!Q_strncasecmp( token, "implicit", 8 ) ){
1865 Sys_Printf( "WARNING5: %s : %s shader\n", pk3Shaders + shader*65, token );
1867 if ( line == scriptline ){
1868 strcat( shaderText, " " );
1869 strcat( shaderText, token );
1872 strcat( shaderText, "\n\t" );
1873 strcat( shaderText, token );
1876 else if ( !Q_stricmp( token, "fogparms" ) ){
1878 if ( line == scriptline ){
1879 strcat( shaderText, " " );
1880 strcat( shaderText, token );
1883 strcat( shaderText, "\n\t" );
1884 strcat( shaderText, token );
1887 else if ( line == scriptline ){
1888 strcat( shaderText, " " );
1889 strcat( shaderText, token );
1892 strcat( shaderText, "\n\t" );
1893 strcat( shaderText, token );
1899 for ( j = 0; j < ExShadersN; j++ ){
1900 if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
1901 wantShader = qfalse;
1902 *( pk3Shaders + shader*65 ) = '\0';
1906 if ( wantShader && !hasmap ){
1907 Sys_Printf( "WARNING8: %s : shader has no known maps\n", pk3Shaders + shader*65 );
1908 wantShader = qfalse;
1909 *( pk3Shaders + shader*65 ) = '\0';
1912 strcat( allShaders, shaderText );
1913 *( pk3Shaders + shader*65 ) = '\0';
1918 /* TODO: RTCW's mapComp, mapNoComp, animmapcomp, animmapnocomp; nocompress?; ET's implicitmap, implicitblend, implicitmask */
1923 //pure textures (shader ones are done)
1924 for ( i = 0; i < pk3ShadersN; i++ ){
1925 if ( *( pk3Shaders + i*65 ) != '\0' ){
1926 if ( strchr( pk3Shaders + i*65, '\\') != NULL ){
1927 Sys_Printf( "WARNING2: %s : bsp shader path with backslash\n", pk3Shaders + i*65 );
1928 FixDOSName( pk3Shaders + i*65 );
1929 //what if theres properly slashed one in the list?
1930 for ( j = 0; j < pk3ShadersN; j++ ){
1931 if ( !Q_stricmp( pk3Shaders + i*65, pk3Shaders + j*65 ) && (i != j) ){
1932 *( pk3Shaders + i*65 ) = '\0';
1937 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1938 for ( j = 0; j < pk3TexturesN; j++ ){
1939 if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
1940 *( pk3Shaders + i*65 ) = '\0';
1944 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1945 for ( j = 0; j < ExTexturesN; j++ ){
1946 if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
1947 *( pk3Shaders + i*65 ) = '\0';
1951 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1952 for ( j = 0; j < rExTexturesN; j++ ){
1953 if ( !Q_stricmp( pk3Shaders + i*65, rExTextures + j*65 ) ){
1954 *( pk3Shaders + i*65 ) = '\0';
1962 for ( i = 0; i < pk3SoundsN; i++ ){
1963 for ( j = 0; j < ExSoundsN; j++ ){
1964 if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
1965 *( pk3Sounds + i*65 ) = '\0';
1969 if ( *( pk3Sounds + i*65 ) == '\0' ) continue;
1970 for ( j = 0; j < rExSoundsN; j++ ){
1971 if ( !Q_stricmp( pk3Sounds + i*65, rExSounds + j*65 ) ){
1972 *( pk3Sounds + i*65 ) = '\0';
1979 sprintf( temp, "%s/%s_strippedBYrepacker.shader", EnginePath, nameOFrepack );
1981 f = fopen( temp, "wb" );
1982 fwrite( allShaders, sizeof( char ), strlen( allShaders ), f );
1984 Sys_Printf( "Shaders saved to %s\n", temp );
1987 sprintf( packname, "%s/%s_repacked.pk3", EnginePath, nameOFrepack );
1990 Sys_Printf( "\n--- ZipZip ---\n" );
1992 Sys_Printf( "\n\tShader referenced textures....\n" );
1994 for ( i = 0; i < pk3TexturesN; i++ ){
1996 sprintf( temp, "%s.png", pk3Textures + i*65 );
1997 if ( vfsPackFile( temp, packname, compLevel ) ){
1998 Sys_Printf( "++%s\n", temp );
2002 sprintf( temp, "%s.tga", pk3Textures + i*65 );
2003 if ( vfsPackFile( temp, packname, compLevel ) ){
2004 Sys_Printf( "++%s\n", temp );
2007 sprintf( temp, "%s.jpg", pk3Textures + i*65 );
2008 if ( vfsPackFile( temp, packname, compLevel ) ){
2009 Sys_Printf( "++%s\n", temp );
2012 Sys_Printf( " !FAIL! %s\n", pk3Textures + i*65 );
2015 Sys_Printf( "\n\tPure textures....\n" );
2017 for ( i = 0; i < pk3ShadersN; i++ ){
2018 if ( *( pk3Shaders + i*65 ) != '\0' ){
2020 sprintf( temp, "%s.png", pk3Shaders + i*65 );
2021 if ( vfsPackFile( temp, packname, compLevel ) ){
2022 Sys_Printf( "++%s\n", temp );
2026 sprintf( temp, "%s.tga", pk3Shaders + i*65 );
2027 if ( vfsPackFile( temp, packname, compLevel ) ){
2028 Sys_Printf( "++%s\n", temp );
2031 sprintf( temp, "%s.jpg", pk3Shaders + i*65 );
2032 if ( vfsPackFile( temp, packname, compLevel ) ){
2033 Sys_Printf( "++%s\n", temp );
2036 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
2040 Sys_Printf( "\n\tSounds....\n" );
2042 for ( i = 0; i < pk3SoundsN; i++ ){
2043 if ( *( pk3Sounds + i*65 ) != '\0' ){
2044 if ( vfsPackFile( pk3Sounds + i*65, packname, compLevel ) ){
2045 Sys_Printf( "++%s\n", pk3Sounds + i*65 );
2048 Sys_Printf( " !FAIL! %s\n", pk3Sounds + i*65 );
2052 Sys_Printf( "\n\tVideos....\n" );
2054 for ( i = 0; i < pk3VideosN; i++ ){
2055 if ( vfsPackFile( pk3Videos + i*65, packname, compLevel ) ){
2056 Sys_Printf( "++%s\n", pk3Videos + i*65 );
2059 Sys_Printf( " !FAIL! %s\n", pk3Videos + i*65 );
2062 Sys_Printf( "\nSaved to %s\n", packname );
2064 /* return to sender */
2075 int main( int argc, char **argv ){
2078 extern qboolean werror;
2081 /* we want consistent 'randomness' */
2085 start = I_FloatTime();
2087 /* this was changed to emit version number over the network */
2088 printf( Q3MAP_VERSION "\n" );
2091 atexit( ExitQ3Map );
2093 /* read general options first */
2094 for ( i = 1; i < argc; i++ )
2097 if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
2098 || !strcmp( argv[ i ], "-help" ) ) {
2099 HelpMain( ( i + 1 < argc ) ? argv[ i + 1 ] : NULL );
2104 if ( !strcmp( argv[ i ], "-connect" ) ) {
2105 if ( ++i >= argc || !argv[ i ] ) {
2106 Error( "Out of arguments: No address specified after %s", argv[ i - 1 ] );
2108 argv[ i - 1 ] = NULL;
2109 Broadcast_Setup( argv[ i ] );
2114 else if ( !strcmp( argv[ i ], "-v" ) ) {
2122 else if ( !strcmp( argv[ i ], "-force" ) ) {
2127 /* make all warnings into errors */
2128 else if ( !strcmp( argv[ i ], "-werror" ) ) {
2133 /* patch subdivisions */
2134 else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
2135 if ( ++i >= argc || !argv[ i ] ) {
2136 Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
2138 argv[ i - 1 ] = NULL;
2139 patchSubdivisions = atoi( argv[ i ] );
2141 if ( patchSubdivisions <= 0 ) {
2142 patchSubdivisions = 1;
2147 else if ( !strcmp( argv[ i ], "-threads" ) ) {
2148 if ( ++i >= argc || !argv[ i ] ) {
2149 Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
2151 argv[ i - 1 ] = NULL;
2152 numthreads = atoi( argv[ i ] );
2156 else if( !strcmp( argv[ i ], "-nocmdline" ) )
2158 Sys_Printf( "noCmdLine\n" );
2165 /* init model library */
2167 PicoSetMallocFunc( safe_malloc );
2168 PicoSetFreeFunc( free );
2169 PicoSetPrintFunc( PicoPrintFunc );
2170 PicoSetLoadFileFunc( PicoLoadFileFunc );
2171 PicoSetFreeFileFunc( free );
2173 /* set number of threads */
2176 /* generate sinusoid jitter table */
2177 for ( i = 0; i < MAX_JITTERS; i++ )
2179 jitters[ i ] = sin( i * 139.54152147 );
2180 //% Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
2183 /* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
2184 and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
2186 Sys_Printf( "Q3Map - v1.0r (c) 1999 Id Software Inc.\n" );
2187 Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
2188 Sys_Printf( RADIANT_NAME " - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
2189 Sys_Printf( "%s\n", Q3MAP_MOTD );
2190 Sys_Printf( "%s\n", argv[0] );
2192 strcpy( q3map2path, argv[0] );//fuer autoPack func
2194 /* ydnar: new path initialization */
2195 InitPaths( &argc, argv );
2197 /* set game options */
2198 if ( !patchSubdivisions ) {
2199 patchSubdivisions = game->patchSubdivisions;
2202 /* check if we have enough options left to attempt something */
2204 Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] );
2208 if ( !strcmp( argv[ 1 ], "-fixaas" ) ) {
2209 r = FixAASMain( argc - 1, argv + 1 );
2213 else if ( !strcmp( argv[ 1 ], "-analyze" ) ) {
2214 r = AnalyzeBSPMain( argc - 1, argv + 1 );
2218 else if ( !strcmp( argv[ 1 ], "-info" ) ) {
2219 r = BSPInfoMain( argc - 2, argv + 2 );
2223 else if ( !strcmp( argv[ 1 ], "-vis" ) ) {
2224 r = VisMain( argc - 1, argv + 1 );
2228 else if ( !strcmp( argv[ 1 ], "-light" ) ) {
2229 r = LightMain( argc - 1, argv + 1 );
2233 else if ( !strcmp( argv[ 1 ], "-vlight" ) ) {
2234 Sys_FPrintf( SYS_WRN, "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
2235 argv[ 1 ] = "-fast"; /* eek a hack */
2236 r = LightMain( argc, argv );
2239 /* QBall: export entities */
2240 else if ( !strcmp( argv[ 1 ], "-exportents" ) ) {
2241 r = ExportEntitiesMain( argc - 1, argv + 1 );
2244 /* ydnar: lightmap export */
2245 else if ( !strcmp( argv[ 1 ], "-export" ) ) {
2246 r = ExportLightmapsMain( argc - 1, argv + 1 );
2249 /* ydnar: lightmap import */
2250 else if ( !strcmp( argv[ 1 ], "-import" ) ) {
2251 r = ImportLightmapsMain( argc - 1, argv + 1 );
2254 /* ydnar: bsp scaling */
2255 else if ( !strcmp( argv[ 1 ], "-scale" ) ) {
2256 r = ScaleBSPMain( argc - 1, argv + 1 );
2260 else if ( !strcmp( argv[ 1 ], "-shift" ) ) {
2261 r = ShiftBSPMain( argc - 1, argv + 1 );
2265 else if ( !strcmp( argv[ 1 ], "-pk3" ) ) {
2266 r = pk3BSPMain( argc - 1, argv + 1 );
2270 else if ( !strcmp( argv[ 1 ], "-repack" ) ) {
2271 r = repackBSPMain( argc - 1, argv + 1 );
2274 /* ydnar: bsp conversion */
2275 else if ( !strcmp( argv[ 1 ], "-convert" ) ) {
2276 r = ConvertBSPMain( argc - 1, argv + 1 );
2280 else if ( !strcmp( argv[ 1 ], "-minimap" ) ) {
2281 r = MiniMapBSPMain( argc - 1, argv + 1 );
2284 /* ydnar: otherwise create a bsp */
2286 /* used to write Smokin'Guns like tex file */
2287 compile_map = qtrue;
2289 r = BSPMain( argc, argv );
2293 end = I_FloatTime();
2294 Sys_Printf( "%9.0f seconds elapsed\n", end - start );
2296 /* shut down connection */
2297 Broadcast_Shutdown();
2299 /* return any error code */