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 // This line being commented out is an unexplained change by Garux
224 // see dd7f4f1689e8ede7580bdfa8e08d0b78d08f5253
225 //point[j] = bspPlanes[ i ].dist * bspPlanes[ i ].normal[j];
226 if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){
227 point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j];
228 point[(j+1)%3] = point[(j+2)%3] = 0;
233 for ( j=0; j<3; j++ ){
234 point[j] += scale[j];
236 //calc new plane dist
237 bspPlanes[ i ].dist = DotProduct( point, bspPlanes[ i ].normal );
242 GetVectorForKey( &entities[ 0 ], "gridsize", vec );
243 if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
244 VectorCopy( gridSize, vec );
249 sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
250 SetKeyValue( &entities[ 0 ], "gridsize", str );
252 /* inject command line parameters */
253 InjectCommandLine( argv, 0, argc - 1 );
257 StripExtension( source );
258 DefaultExtension( source, "_sh.bsp" );
259 Sys_Printf( "Writing %s\n", source );
260 WriteBSPFile( source );
262 /* return to sender */
267 void FixDOSName( char *src ){
274 if ( *src == '\\' ) {
282 Check if newcoming texture is unique and not excluded
284 void tex2list( char* texlist, int *texnum, char* EXtex, int *EXtexnum ){
286 if ( token[0] == '\0') return;
287 StripExtension( token );
289 for ( i = 0; i < *texnum; i++ ){
290 if ( !Q_stricmp( texlist + i*65, token ) ) return;
292 for ( i = 0; i < *EXtexnum; i++ ){
293 if ( !Q_stricmp( EXtex + i*65, token ) ) return;
295 strcpy ( texlist + (*texnum)*65, token );
301 void tex2list2( char* texlist, int *texnum, char* EXtex, int *EXtexnum, char* rEXtex, int *rEXtexnum ){
303 if ( token[0] == '\0') return;
304 //StripExtension( token );
305 char* dot = strrchr( token, '.' );
307 if ( Q_stricmp( dot, ".tga" ) && Q_stricmp( dot, ".jpg" ) && Q_stricmp( dot, ".png" ) ){
308 Sys_Printf( "WARNING4: %s : weird or missing extension in shader\n", token );
315 strcpy ( texlist + (*texnum)*65, token );
316 strcat( token, ".tga" );
319 for ( i = 0; i < *texnum; i++ ){
320 if ( !Q_stricmp( texlist + i*65, texlist + (*texnum)*65 ) ) return;
322 for ( i = 0; i < *EXtexnum; i++ ){
323 if ( !Q_stricmp( EXtex + i*65, texlist + (*texnum)*65 ) ) return;
325 for ( i = 0; i < *rEXtexnum; i++ ){
326 if ( !Q_stricmp( rEXtex + i*65, texlist + (*texnum)*65 ) ) return;
334 Check if newcoming res is unique
336 void res2list( char* data, int *num ){
338 if ( strlen( data + (*num)*65 ) > 64 ){
339 Sys_Printf( "WARNING6: %s : path too long.\n", data + (*num)*65 );
341 while ( *( data + (*num)*65 ) == '\\' || *( data + (*num)*65 ) == '/' ){
342 char* cut = data + (*num)*65 + 1;
343 strcpy( data + (*num)*65, cut );
345 if ( *( data + (*num)*65 ) == '\0') return;
346 for ( i = 0; i < *num; i++ ){
347 if ( !Q_stricmp( data + i*65, data + (*num)*65 ) ) return;
353 void parseEXblock ( char* data, int *num, const char *exName ){
354 if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
355 Error( "ReadExclusionsFile: %s, line %d: { not found", exName, scriptline );
359 if ( !GetToken( qtrue ) ) {
362 if ( !strcmp( token, "}" ) ) {
365 if ( token[0] == '{' ) {
366 Error( "ReadExclusionsFile: %s, line %d: brace, opening twice in a row.", exName, scriptline );
370 strcpy( data + (*num)*65, token );
376 char q3map2path[1024];
379 map autopackager, works for Q3 type of shaders and ents
382 int pk3BSPMain( int argc, char **argv ){
384 qboolean dbg = qfalse, png = qfalse, packFAIL = qfalse;
386 /* process arguments */
387 for ( i = 1; i < ( argc - 1 ); i++ ){
388 if ( !strcmp( argv[ i ], "-dbg" ) ) {
391 else if ( !strcmp( argv[ i ], "-png" ) ) {
396 /* do some path mangling */
397 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
398 StripExtension( source );
399 DefaultExtension( source, ".bsp" );
402 Sys_Printf( "Loading %s\n", source );
403 LoadBSPFile( source );
407 char packname[ 1024 ], packFailName[ 1024 ], base[ 1024 ], nameOFmap[ 1024 ], temp[ 1024 ];
410 strcpy( base, source );
411 StripExtension( base );
413 /* extract map name */
414 len = strlen( base ) - 1;
415 while ( len > 0 && base[ len ] != '/' && base[ len ] != '\\' )
417 strcpy( nameOFmap, &base[ len + 1 ] );
420 qboolean drawsurfSHs[1024] = { qfalse };
422 for ( i = 0; i < numBSPDrawSurfaces; i++ ){
423 /* can't exclude nodraw patches here (they want shaders :0!) */
424 //if ( !( bspDrawSurfaces[i].surfaceType == 2 && bspDrawSurfaces[i].numIndexes == 0 ) ) drawsurfSHs[bspDrawSurfaces[i].shaderNum] = qtrue;
425 drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = qtrue;
426 //Sys_Printf( "%s\n", bspShaders[bspDrawSurfaces[i].shaderNum].shader );
430 char* pk3Shaders = (char *)calloc( 1024*65, sizeof( char ) );
432 char* pk3Sounds = (char *)calloc( 1024*65, sizeof( char ) );
433 int pk3ShaderfilesN = 0;
434 char* pk3Shaderfiles = (char *)calloc( 1024*65, sizeof( char ) );
435 int pk3TexturesN = 0;
436 char* pk3Textures = (char *)calloc( 1024*65, sizeof( char ) );
438 char* pk3Videos = (char *)calloc( 1024*65, sizeof( char ) );
442 for ( i = 0; i < numBSPShaders; i++ ){
443 if ( drawsurfSHs[i] ){
444 strcpy( pk3Shaders + pk3ShadersN*65, bspShaders[i].shader );
445 res2list( pk3Shaders, &pk3ShadersN );
447 //Sys_Printf( "%s\n", bspShaders[i].shader );
453 for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
455 if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
456 sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
457 res2list( pk3Shaders, &pk3ShadersN );
460 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[0], "music" ) );
461 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' ){
462 FixDOSName( pk3Sounds + pk3SoundsN*65 );
463 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
464 res2list( pk3Sounds, &pk3SoundsN );
467 for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
469 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[i], "noise" ) );
470 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' && *( pk3Sounds + pk3SoundsN*65 ) != '*' ){
471 FixDOSName( pk3Sounds + pk3SoundsN*65 );
472 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
473 res2list( pk3Sounds, &pk3SoundsN );
476 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
477 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
478 res2list( pk3Sounds, &pk3SoundsN );
479 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
480 res2list( pk3Sounds, &pk3SoundsN );
482 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
483 if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
484 strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
485 res2list( pk3Sounds, &pk3SoundsN );
488 strcpy( pk3Shaders + pk3ShadersN*65, ValueForKey( &entities[i], "targetShaderNewName" ) );
489 res2list( pk3Shaders, &pk3ShadersN );
493 sprintf( pk3Shaders + pk3ShadersN*65, "levelshots/%s", nameOFmap );
494 res2list( pk3Shaders, &pk3ShadersN );
498 Sys_Printf( "\n\tDrawsurface+ent calls....%i\n", pk3ShadersN );
499 for ( i = 0; i < pk3ShadersN; i++ ){
500 Sys_Printf( "%s\n", pk3Shaders + i*65 );
502 Sys_Printf( "\n\tSounds....%i\n", pk3SoundsN );
503 for ( i = 0; i < pk3SoundsN; i++ ){
504 Sys_Printf( "%s\n", pk3Sounds + i*65 );
508 vfsListShaderFiles( pk3Shaderfiles, &pk3ShaderfilesN );
511 Sys_Printf( "\n\tSchroider fileses.....%i\n", pk3ShaderfilesN );
512 for ( i = 0; i < pk3ShaderfilesN; i++ ){
513 Sys_Printf( "%s\n", pk3Shaderfiles + i*65 );
518 /* load exclusions file */
520 char* ExTextures = (char *)calloc( 4096*65, sizeof( char ) );
522 char* ExShaders = (char *)calloc( 4096*65, sizeof( char ) );
524 char* ExSounds = (char *)calloc( 4096*65, sizeof( char ) );
525 int ExShaderfilesN = 0;
526 char* ExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
528 char* ExVideos = (char *)calloc( 4096*65, sizeof( char ) );
529 int ExPureTexturesN = 0;
530 char* ExPureTextures = (char *)calloc( 4096*65, sizeof( char ) );
532 char* ExReasonShader[4096] = { NULL };
533 char* ExReasonShaderFile[4096] = { NULL };
539 strcpy( exName, q3map2path );
540 char *cut = strrchr( exName, '\\' );
541 char *cut2 = strrchr( exName, '/' );
542 if ( cut == NULL && cut2 == NULL ){
543 Sys_Printf( "WARNING: Unable to load exclusions file.\n" );
546 if ( cut2 > cut ) cut = cut2;
548 strcat( exName, game->arg );
549 strcat( exName, ".exclude" );
551 Sys_Printf( "Loading %s\n", exName );
552 size = TryLoadFile( exName, (void**) &buffer );
554 Sys_Printf( "WARNING: Unable to find exclusions file %s.\n", exName );
559 ParseFromMemory( (char *) buffer, size );
564 /* test for end of file */
565 if ( !GetToken( qtrue ) ) {
570 if ( !Q_stricmp( token, "textures" ) ){
571 parseEXblock ( ExTextures, &ExTexturesN, exName );
573 else if ( !Q_stricmp( token, "shaders" ) ){
574 parseEXblock ( ExShaders, &ExShadersN, exName );
576 else if ( !Q_stricmp( token, "shaderfiles" ) ){
577 parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
579 else if ( !Q_stricmp( token, "sounds" ) ){
580 parseEXblock ( ExSounds, &ExSoundsN, exName );
582 else if ( !Q_stricmp( token, "videos" ) ){
583 parseEXblock ( ExVideos, &ExVideosN, exName );
586 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
590 /* free the buffer */
593 for ( i = 0; i < ExTexturesN; i++ ){
594 for ( j = 0; j < ExShadersN; j++ ){
595 if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
599 if ( j == ExShadersN ){
600 strcpy ( ExPureTextures + ExPureTexturesN*65, ExTextures + i*65 );
608 Sys_Printf( "\n\tExTextures....%i\n", ExTexturesN );
609 for ( i = 0; i < ExTexturesN; i++ ) Sys_Printf( "%s\n", ExTextures + i*65 );
610 Sys_Printf( "\n\tExPureTextures....%i\n", ExPureTexturesN );
611 for ( i = 0; i < ExPureTexturesN; i++ ) Sys_Printf( "%s\n", ExPureTextures + i*65 );
612 Sys_Printf( "\n\tExShaders....%i\n", ExShadersN );
613 for ( i = 0; i < ExShadersN; i++ ) Sys_Printf( "%s\n", ExShaders + i*65 );
614 Sys_Printf( "\n\tExShaderfiles....%i\n", ExShaderfilesN );
615 for ( i = 0; i < ExShaderfilesN; i++ ) Sys_Printf( "%s\n", ExShaderfiles + i*65 );
616 Sys_Printf( "\n\tExSounds....%i\n", ExSoundsN );
617 for ( i = 0; i < ExSoundsN; i++ ) Sys_Printf( "%s\n", ExSounds + i*65 );
618 Sys_Printf( "\n\tExVideos....%i\n", ExVideosN );
619 for ( i = 0; i < ExVideosN; i++ ) Sys_Printf( "%s\n", ExVideos + i*65 );
622 /* can exclude pure textures right now, shouldn't create shaders for them anyway */
623 for ( i = 0; i < pk3ShadersN ; i++ ){
624 for ( j = 0; j < ExPureTexturesN ; j++ ){
625 if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
626 *( pk3Shaders + i*65 ) = '\0';
636 for ( i = 0; i < pk3ShaderfilesN; i++ ){
637 qboolean wantShader = qfalse, wantShaderFile = qfalse, ShaderFileExcluded = qfalse;
639 char* reasonShader = NULL;
640 char* reasonShaderFile = NULL;
642 /* load the shader */
643 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
644 SilentLoadScriptFile( temp, 0 );
645 if( dbg ) Sys_Printf( "\n\tentering %s\n", pk3Shaderfiles + i*65 );
647 /* do wanna le shader file? */
648 for ( j = 0; j < ExShaderfilesN; j++ ){
649 if ( !Q_stricmp( ExShaderfiles + j*65, pk3Shaderfiles + i*65 ) ){
650 ShaderFileExcluded = qtrue;
651 reasonShaderFile = ExShaderfiles + j*65;
656 /* check if shader file has to be excluded */
657 while ( !ShaderFileExcluded )
659 /* test for end of file */
660 if ( !GetToken( qtrue ) ) {
664 /* does it contain restricted shaders/textures? */
665 for ( j = 0; j < ExShadersN; j++ ){
666 if ( !Q_stricmp( ExShaders + j*65, token ) ){
667 ShaderFileExcluded = qtrue;
668 reasonShader = ExShaders + j*65;
672 if ( ShaderFileExcluded )
674 for ( j = 0; j < ExPureTexturesN; j++ ){
675 if ( !Q_stricmp( ExPureTextures + j*65, token ) ){
676 ShaderFileExcluded = qtrue;
677 reasonShader = ExPureTextures + j*65;
681 if ( ShaderFileExcluded )
684 /* handle { } section */
685 if ( !GetToken( qtrue ) ) {
688 if ( strcmp( token, "{" ) ) {
689 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
690 temp, scriptline, token, g_strLoadedFileLocation );
695 /* get the next token */
696 if ( !GetToken( qtrue ) ) {
699 if ( !strcmp( token, "}" ) ) {
702 /* parse stage directives */
703 if ( !strcmp( token, "{" ) ) {
706 if ( !GetToken( qtrue ) ) {
709 if ( !strcmp( token, "}" ) ) {
717 /* tokenize it again */
718 SilentLoadScriptFile( temp, 0 );
721 /* test for end of file */
722 if ( !GetToken( qtrue ) ) {
726 if( dbg ) Sys_Printf( "%s\n", token );
728 /* do wanna le shader? */
730 for ( j = 0; j < pk3ShadersN; j++ ){
731 if ( !Q_stricmp( pk3Shaders + j*65, token) ){
738 /* handle { } section */
739 if ( !GetToken( qtrue ) ) {
742 if ( strcmp( token, "{" ) ) {
743 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
744 temp, scriptline, token, g_strLoadedFileLocation );
747 qboolean hasmap = qfalse;
750 /* get the next token */
751 if ( !GetToken( qtrue ) ) {
754 if ( !strcmp( token, "}" ) ) {
759 /* -----------------------------------------------------------------
760 shader stages (passes)
761 ----------------------------------------------------------------- */
763 /* parse stage directives */
764 if ( !strcmp( token, "{" ) ) {
767 if ( !GetToken( qtrue ) ) {
770 if ( !strcmp( token, "}" ) ) {
773 if ( !strcmp( token, "{" ) ) {
774 Sys_Printf( "WARNING9: %s : line %d : opening brace inside shader stage\n", temp, scriptline );
776 if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
777 Sys_Printf( "WARNING7: %s : line %d : unsupported '%s' map directive\n", temp, scriptline, token );
779 /* skip the shader */
780 if ( !wantShader ) continue;
782 /* digest any images */
783 if ( !Q_stricmp( token, "map" ) ||
784 !Q_stricmp( token, "clampMap" ) ) {
788 if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
789 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
792 else if ( !Q_stricmp( token, "animMap" ) ||
793 !Q_stricmp( token, "clampAnimMap" ) ) {
795 GetToken( qfalse );// skip num
796 while ( TokenAvailable() ){
798 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
801 else if ( !Q_stricmp( token, "videoMap" ) ){
805 if ( strchr( token, '/' ) == NULL && strchr( token, '\\' ) == NULL ){
806 sprintf( temp, "video/%s", token );
807 strcpy( token, temp );
810 for ( j = 0; j < pk3VideosN; j++ ){
811 if ( !Q_stricmp( pk3Videos + j*65, token ) ){
815 for ( j = 0; j < ExVideosN; j++ ){
816 if ( !Q_stricmp( ExVideos + j*65, token ) ){
820 strcpy ( pk3Videos + pk3VideosN*65, token );
827 else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
828 Sys_Printf( "WARNING5: %s : line %d : unsupported %s shader\n", temp, scriptline, token );
830 /* skip the shader */
831 else if ( !wantShader ) continue;
833 /* -----------------------------------------------------------------
834 surfaceparm * directives
835 ----------------------------------------------------------------- */
837 /* match surfaceparm */
838 else if ( !Q_stricmp( token, "surfaceparm" ) ) {
840 if ( !Q_stricmp( token, "nodraw" ) ) {
842 *( pk3Shaders + shader*65 ) = '\0';
846 /* skyparms <outer image> <cloud height> <inner image> */
847 else if ( !Q_stricmp( token, "skyParms" ) ) {
852 /* ignore bogus paths */
853 if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
854 strcpy ( temp, token );
855 sprintf( token, "%s_up", temp );
856 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
857 sprintf( token, "%s_dn", temp );
858 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
859 sprintf( token, "%s_lf", temp );
860 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
861 sprintf( token, "%s_rt", temp );
862 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
863 sprintf( token, "%s_bk", temp );
864 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
865 sprintf( token, "%s_ft", temp );
866 tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
868 /* skip rest of line */
872 else if ( !Q_stricmp( token, "fogparms" ) ){
879 for ( j = 0; j < ExShadersN; j++ ){
880 if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
882 *( pk3Shaders + shader*65 ) = '\0';
890 if ( ShaderFileExcluded ){
891 if ( reasonShaderFile != NULL ){
892 ExReasonShaderFile[ shader ] = reasonShaderFile;
895 ExReasonShaderFile[ shader ] = ( char* ) calloc( 65, sizeof( char ) );
896 strcpy( ExReasonShaderFile[ shader ], pk3Shaderfiles + i*65 );
898 ExReasonShader[ shader ] = reasonShader;
901 wantShaderFile = qtrue;
902 *( pk3Shaders + shader*65 ) = '\0';
907 if ( !wantShaderFile ){
908 *( pk3Shaderfiles + i*65 ) = '\0';
915 //wanted shaders from excluded .shaders
917 for ( i = 0; i < pk3ShadersN; i++ ){
918 if ( *( pk3Shaders + i*65 ) != '\0' && ( ExReasonShader[i] != NULL || ExReasonShaderFile[i] != NULL ) ){
919 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
921 if ( ExReasonShader[i] != NULL ){
922 Sys_Printf( " reason: is located in %s,\n containing restricted shader %s\n", ExReasonShaderFile[i], ExReasonShader[i] );
925 Sys_Printf( " reason: is located in restricted %s\n", ExReasonShaderFile[i] );
927 *( pk3Shaders + i*65 ) = '\0';
930 //pure textures (shader ones are done)
931 for ( i = 0; i < pk3ShadersN; i++ ){
932 if ( *( pk3Shaders + i*65 ) != '\0' ){
933 FixDOSName( pk3Shaders + i*65 );
934 for ( j = 0; j < pk3TexturesN; j++ ){
935 if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
936 *( pk3Shaders + i*65 ) = '\0';
940 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
941 for ( j = 0; j < ExTexturesN; j++ ){
942 if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
943 *( pk3Shaders + i*65 ) = '\0';
951 for ( i = 0; i < pk3SoundsN; i++ ){
952 for ( j = 0; j < ExSoundsN; j++ ){
953 if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
954 *( pk3Sounds + i*65 ) = '\0';
961 sprintf( packname, "%s/%s_autopacked.pk3", EnginePath, nameOFmap );
963 sprintf( packFailName, "%s/%s_FAILEDpack.pk3", EnginePath, nameOFmap );
964 remove( packFailName );
966 Sys_Printf( "\n--- ZipZip ---\n" );
968 Sys_Printf( "\n\tShader referenced textures....\n" );
970 for ( i = 0; i < pk3TexturesN; i++ ){
972 sprintf( temp, "%s.png", pk3Textures + i*65 );
973 if ( vfsPackFile( temp, packname, 10 ) ){
974 Sys_Printf( "++%s\n", temp );
978 sprintf( temp, "%s.tga", pk3Textures + i*65 );
979 if ( vfsPackFile( temp, packname, 10 ) ){
980 Sys_Printf( "++%s\n", temp );
983 sprintf( temp, "%s.jpg", pk3Textures + i*65 );
984 if ( vfsPackFile( temp, packname, 10 ) ){
985 Sys_Printf( "++%s\n", temp );
988 Sys_Printf( " !FAIL! %s\n", pk3Textures + i*65 );
992 Sys_Printf( "\n\tPure textures....\n" );
994 for ( i = 0; i < pk3ShadersN; i++ ){
995 if ( *( pk3Shaders + i*65 ) != '\0' ){
997 sprintf( temp, "%s.png", pk3Shaders + i*65 );
998 if ( vfsPackFile( temp, packname, 10 ) ){
999 Sys_Printf( "++%s\n", temp );
1003 sprintf( temp, "%s.tga", pk3Shaders + i*65 );
1004 if ( vfsPackFile( temp, packname, 10 ) ){
1005 Sys_Printf( "++%s\n", temp );
1008 sprintf( temp, "%s.jpg", pk3Shaders + i*65 );
1009 if ( vfsPackFile( temp, packname, 10 ) ){
1010 Sys_Printf( "++%s\n", temp );
1014 if ( i == pk3ShadersN - 1 ){ //levelshot typically
1015 Sys_Printf( " ~fail %s\n", pk3Shaders + i*65 );
1018 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
1024 Sys_Printf( "\n\tShaizers....\n" );
1026 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1027 if ( *( pk3Shaderfiles + i*65 ) != '\0' ){
1028 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
1029 if ( vfsPackFile( temp, packname, 10 ) ){
1030 Sys_Printf( "++%s\n", temp );
1033 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
1038 Sys_Printf( "\n\tSounds....\n" );
1040 for ( i = 0; i < pk3SoundsN; i++ ){
1041 if ( *( pk3Sounds + i*65 ) != '\0' ){
1042 if ( vfsPackFile( pk3Sounds + i*65, packname, 10 ) ){
1043 Sys_Printf( "++%s\n", pk3Sounds + i*65 );
1046 Sys_Printf( " !FAIL! %s\n", pk3Sounds + i*65 );
1051 Sys_Printf( "\n\tVideos....\n" );
1053 for ( i = 0; i < pk3VideosN; i++ ){
1054 if ( vfsPackFile( pk3Videos + i*65, packname, 10 ) ){
1055 Sys_Printf( "++%s\n", pk3Videos + i*65 );
1058 Sys_Printf( " !FAIL! %s\n", pk3Videos + i*65 );
1062 Sys_Printf( "\n\t.bsp and stuff\n" );
1064 sprintf( temp, "maps/%s.bsp", nameOFmap );
1065 //if ( vfsPackFile( temp, packname, 10 ) ){
1066 if ( vfsPackFile_Absolute_Path( source, temp, packname, 10 ) ){
1067 Sys_Printf( "++%s\n", temp );
1070 Sys_Printf( " !FAIL! %s\n", temp );
1074 sprintf( temp, "maps/%s.aas", nameOFmap );
1075 if ( vfsPackFile( temp, packname, 10 ) ){
1076 Sys_Printf( "++%s\n", temp );
1079 Sys_Printf( " ~fail %s\n", temp );
1082 sprintf( temp, "scripts/%s.arena", nameOFmap );
1083 if ( vfsPackFile( temp, packname, 10 ) ){
1084 Sys_Printf( "++%s\n", temp );
1087 Sys_Printf( " ~fail %s\n", temp );
1090 sprintf( temp, "scripts/%s.defi", nameOFmap );
1091 if ( vfsPackFile( temp, packname, 10 ) ){
1092 Sys_Printf( "++%s\n", temp );
1095 Sys_Printf( " ~fail %s\n", temp );
1099 Sys_Printf( "\nSaved to %s\n", packname );
1102 rename( packname, packFailName );
1103 Sys_Printf( "\nSaved to %s\n", packFailName );
1105 /* return to sender */
1112 repack multiple maps, strip out only required shaders
1113 works for Q3 type of shaders and ents
1116 int repackBSPMain( int argc, char **argv ){
1117 int i, j, len, compLevel = 0;
1118 qboolean dbg = qfalse, png = qfalse;
1120 /* process arguments */
1121 for ( i = 1; i < ( argc - 1 ); i++ ){
1122 if ( !strcmp( argv[ i ], "-dbg" ) ) {
1125 else if ( !strcmp( argv[ i ], "-png" ) ) {
1128 else if ( !strcmp( argv[ i ], "-complevel" ) ) {
1129 compLevel = atoi( argv[ i + 1 ] );
1131 if ( compLevel < -1 ) compLevel = -1;
1132 if ( compLevel > 10 ) compLevel = 10;
1133 Sys_Printf( "Compression level set to %i\n", compLevel );
1137 /* load exclusions file */
1138 int ExTexturesN = 0;
1139 char* ExTextures = (char *)calloc( 4096*65, sizeof( char ) );
1141 char* ExShaders = (char *)calloc( 4096*65, sizeof( char ) );
1143 char* ExSounds = (char *)calloc( 4096*65, sizeof( char ) );
1144 int ExShaderfilesN = 0;
1145 char* ExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1147 char* ExVideos = (char *)calloc( 4096*65, sizeof( char ) );
1148 int ExPureTexturesN = 0;
1149 char* ExPureTextures = (char *)calloc( 4096*65, sizeof( char ) );
1152 char exName[ 1024 ];
1156 strcpy( exName, q3map2path );
1157 char *cut = strrchr( exName, '\\' );
1158 char *cut2 = strrchr( exName, '/' );
1159 if ( cut == NULL && cut2 == NULL ){
1160 Sys_Printf( "WARNING: Unable to load exclusions file.\n" );
1163 if ( cut2 > cut ) cut = cut2;
1165 strcat( exName, game->arg );
1166 strcat( exName, ".exclude" );
1168 Sys_Printf( "Loading %s\n", exName );
1169 size = TryLoadFile( exName, (void**) &buffer );
1171 Sys_Printf( "WARNING: Unable to find exclusions file %s.\n", exName );
1175 /* parse the file */
1176 ParseFromMemory( (char *) buffer, size );
1181 /* test for end of file */
1182 if ( !GetToken( qtrue ) ) {
1187 if ( !Q_stricmp( token, "textures" ) ){
1188 parseEXblock ( ExTextures, &ExTexturesN, exName );
1190 else if ( !Q_stricmp( token, "shaders" ) ){
1191 parseEXblock ( ExShaders, &ExShadersN, exName );
1193 else if ( !Q_stricmp( token, "shaderfiles" ) ){
1194 parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
1196 else if ( !Q_stricmp( token, "sounds" ) ){
1197 parseEXblock ( ExSounds, &ExSoundsN, exName );
1199 else if ( !Q_stricmp( token, "videos" ) ){
1200 parseEXblock ( ExVideos, &ExVideosN, exName );
1203 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
1207 /* free the buffer */
1210 for ( i = 0; i < ExTexturesN; i++ ){
1211 for ( j = 0; j < ExShadersN; j++ ){
1212 if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
1216 if ( j == ExShadersN ){
1217 strcpy ( ExPureTextures + ExPureTexturesN*65, ExTextures + i*65 );
1225 Sys_Printf( "\n\tExTextures....%i\n", ExTexturesN );
1226 for ( i = 0; i < ExTexturesN; i++ ) Sys_Printf( "%s\n", ExTextures + i*65 );
1227 Sys_Printf( "\n\tExPureTextures....%i\n", ExPureTexturesN );
1228 for ( i = 0; i < ExPureTexturesN; i++ ) Sys_Printf( "%s\n", ExPureTextures + i*65 );
1229 Sys_Printf( "\n\tExShaders....%i\n", ExShadersN );
1230 for ( i = 0; i < ExShadersN; i++ ) Sys_Printf( "%s\n", ExShaders + i*65 );
1231 Sys_Printf( "\n\tExShaderfiles....%i\n", ExShaderfilesN );
1232 for ( i = 0; i < ExShaderfilesN; i++ ) Sys_Printf( "%s\n", ExShaderfiles + i*65 );
1233 Sys_Printf( "\n\tExSounds....%i\n", ExSoundsN );
1234 for ( i = 0; i < ExSoundsN; i++ ) Sys_Printf( "%s\n", ExSounds + i*65 );
1235 Sys_Printf( "\n\tExVideos....%i\n", ExVideosN );
1236 for ( i = 0; i < ExVideosN; i++ ) Sys_Printf( "%s\n", ExVideos + i*65 );
1242 /* load repack.exclude */
1243 int rExTexturesN = 0;
1244 char* rExTextures = (char *)calloc( 65536*65, sizeof( char ) );
1245 int rExShadersN = 0;
1246 char* rExShaders = (char *)calloc( 32768*65, sizeof( char ) );
1248 char* rExSounds = (char *)calloc( 8192*65, sizeof( char ) );
1249 int rExShaderfilesN = 0;
1250 char* rExShaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1252 char* rExVideos = (char *)calloc( 4096*65, sizeof( char ) );
1254 strcpy( exName, q3map2path );
1255 cut = strrchr( exName, '\\' );
1256 cut2 = strrchr( exName, '/' );
1257 if ( cut == NULL && cut2 == NULL ){
1258 Sys_Printf( "WARNING: Unable to load repack exclusions file.\n" );
1261 if ( cut2 > cut ) cut = cut2;
1263 strcat( exName, "repack.exclude" );
1265 Sys_Printf( "Loading %s\n", exName );
1266 size = TryLoadFile( exName, (void**) &buffer );
1268 Sys_Printf( "WARNING: Unable to find repack exclusions file %s.\n", exName );
1272 /* parse the file */
1273 ParseFromMemory( (char *) buffer, size );
1278 /* test for end of file */
1279 if ( !GetToken( qtrue ) ) {
1284 if ( !Q_stricmp( token, "textures" ) ){
1285 parseEXblock ( rExTextures, &rExTexturesN, exName );
1287 else if ( !Q_stricmp( token, "shaders" ) ){
1288 parseEXblock ( rExShaders, &rExShadersN, exName );
1290 else if ( !Q_stricmp( token, "shaderfiles" ) ){
1291 parseEXblock ( rExShaderfiles, &rExShaderfilesN, exName );
1293 else if ( !Q_stricmp( token, "sounds" ) ){
1294 parseEXblock ( rExSounds, &rExSoundsN, exName );
1296 else if ( !Q_stricmp( token, "videos" ) ){
1297 parseEXblock ( rExVideos, &rExVideosN, exName );
1300 Error( "ReadExclusionsFile: %s, line %d: unknown block name!\nValid ones are: textures, shaders, shaderfiles, sounds, videos.", exName, scriptline );
1304 /* free the buffer */
1310 Sys_Printf( "\n\trExTextures....%i\n", rExTexturesN );
1311 for ( i = 0; i < rExTexturesN; i++ ) Sys_Printf( "%s\n", rExTextures + i*65 );
1312 Sys_Printf( "\n\trExShaders....%i\n", rExShadersN );
1313 for ( i = 0; i < rExShadersN; i++ ) Sys_Printf( "%s\n", rExShaders + i*65 );
1314 Sys_Printf( "\n\trExShaderfiles....%i\n", rExShaderfilesN );
1315 for ( i = 0; i < rExShaderfilesN; i++ ) Sys_Printf( "%s\n", rExShaderfiles + i*65 );
1316 Sys_Printf( "\n\trExSounds....%i\n", rExSoundsN );
1317 for ( i = 0; i < rExSoundsN; i++ ) Sys_Printf( "%s\n", rExSounds + i*65 );
1318 Sys_Printf( "\n\trExVideos....%i\n", rExVideosN );
1319 for ( i = 0; i < rExVideosN; i++ ) Sys_Printf( "%s\n", rExVideos + i*65 );
1326 char* bspList = (char *)calloc( 8192*1024, sizeof( char ) );
1328 /* do some path mangling */
1329 strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
1330 if ( !Q_stricmp( strrchr( source, '.' ), ".bsp" ) ){
1331 strcpy( bspList, source );
1335 /* load bsps paths list */
1336 Sys_Printf( "Loading %s\n", source );
1337 size = TryLoadFile( source, (void**) &buffer );
1339 Sys_Printf( "WARNING: Unable to open bsps paths list file %s.\n", source );
1342 /* parse the file */
1343 ParseFromMemory( (char *) buffer, size );
1348 /* test for end of file */
1349 if ( !GetToken( qtrue ) ) {
1352 strcpy( bspList + bspListN * 1024 , token );
1356 /* free the buffer */
1360 char packname[ 1024 ], nameOFrepack[ 1024 ], nameOFmap[ 1024 ], temp[ 1024 ];
1362 /* copy input file name */
1363 strcpy( temp, source );
1364 StripExtension( temp );
1366 /* extract input file name */
1367 len = strlen( temp ) - 1;
1368 while ( len > 0 && temp[ len ] != '/' && temp[ len ] != '\\' )
1370 strcpy( nameOFrepack, &temp[ len + 1 ] );
1374 int pk3ShadersN = 0;
1375 char* pk3Shaders = (char *)calloc( 65536*65, sizeof( char ) );
1377 char* pk3Sounds = (char *)calloc( 4096*65, sizeof( char ) );
1378 int pk3ShaderfilesN = 0;
1379 char* pk3Shaderfiles = (char *)calloc( 4096*65, sizeof( char ) );
1380 int pk3TexturesN = 0;
1381 char* pk3Textures = (char *)calloc( 65536*65, sizeof( char ) );
1383 char* pk3Videos = (char *)calloc( 1024*65, sizeof( char ) );
1385 for( j = 0; j < bspListN; j++ ){
1387 int pk3SoundsNold = pk3SoundsN;
1388 int pk3ShadersNold = pk3ShadersN;
1390 strcpy( source, bspList + j*1024 );
1391 StripExtension( source );
1392 DefaultExtension( source, ".bsp" );
1395 Sys_Printf( "\nLoading %s\n", source );
1396 PartialLoadBSPFile( source );
1400 strcpy( temp, source );
1401 StripExtension( temp );
1403 /* extract map name */
1404 len = strlen( temp ) - 1;
1405 while ( len > 0 && temp[ len ] != '/' && temp[ len ] != '\\' )
1407 strcpy( nameOFmap, &temp[ len + 1 ] );
1410 qboolean drawsurfSHs[1024] = { qfalse };
1412 for ( i = 0; i < numBSPDrawSurfaces; i++ ){
1413 drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = qtrue;
1416 for ( i = 0; i < numBSPShaders; i++ ){
1417 if ( drawsurfSHs[i] ){
1418 strcpy( pk3Shaders + pk3ShadersN*65, bspShaders[i].shader );
1419 res2list( pk3Shaders, &pk3ShadersN );
1425 for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
1427 if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
1428 sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
1429 res2list( pk3Shaders, &pk3ShadersN );
1432 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[0], "music" ) );
1433 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' ){
1434 FixDOSName( pk3Sounds + pk3SoundsN*65 );
1435 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
1436 res2list( pk3Sounds, &pk3SoundsN );
1439 for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
1441 strcpy( pk3Sounds + pk3SoundsN*65, ValueForKey( &entities[i], "noise" ) );
1442 if ( *( pk3Sounds + pk3SoundsN*65 ) != '\0' && *( pk3Sounds + pk3SoundsN*65 ) != '*' ){
1443 FixDOSName( pk3Sounds + pk3SoundsN*65 );
1444 DefaultExtension( pk3Sounds + pk3SoundsN*65, ".wav" );
1445 res2list( pk3Sounds, &pk3SoundsN );
1448 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
1449 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
1450 res2list( pk3Sounds, &pk3SoundsN );
1451 strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
1452 res2list( pk3Sounds, &pk3SoundsN );
1454 if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
1455 if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
1456 strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
1457 res2list( pk3Sounds, &pk3SoundsN );
1460 strcpy( pk3Shaders + pk3ShadersN*65, ValueForKey( &entities[i], "targetShaderNewName" ) );
1461 res2list( pk3Shaders, &pk3ShadersN );
1465 sprintf( pk3Shaders + pk3ShadersN*65, "levelshots/%s", nameOFmap );
1466 res2list( pk3Shaders, &pk3ShadersN );
1470 Sys_Printf( "\n\t+Drawsurface+ent calls....%i\n", pk3ShadersN - pk3ShadersNold );
1471 for ( i = pk3ShadersNold; i < pk3ShadersN; i++ ){
1472 Sys_Printf( "%s\n", pk3Shaders + i*65 );
1474 Sys_Printf( "\n\t+Sounds....%i\n", pk3SoundsN - pk3SoundsNold );
1475 for ( i = pk3SoundsNold; i < pk3SoundsN; i++ ){
1476 Sys_Printf( "%s\n", pk3Sounds + i*65 );
1480 if ( bspDrawVerts != 0 ) {
1481 free( bspDrawVerts );
1482 bspDrawVerts = NULL;
1483 //numBSPDrawVerts = 0;
1484 Sys_Printf( "freed BSPDrawVerts\n" );
1486 */ if ( bspDrawSurfaces != 0 ) {
1487 free( bspDrawSurfaces );
1488 bspDrawSurfaces = NULL;
1489 //numBSPDrawSurfaces = 0;
1490 //Sys_Printf( "freed bspDrawSurfaces\n" );
1492 /* if ( bspLightBytes != 0 ) {
1493 free( bspLightBytes );
1494 bspLightBytes = NULL;
1495 //numBSPLightBytes = 0;
1496 Sys_Printf( "freed BSPLightBytes\n" );
1498 if ( bspGridPoints != 0 ) {
1499 free( bspGridPoints );
1500 bspGridPoints = NULL;
1501 //numBSPGridPoints = 0;
1502 Sys_Printf( "freed BSPGridPoints\n" );
1504 if ( bspPlanes != 0 ) {
1507 Sys_Printf( "freed bspPlanes\n" );
1509 //allocatedBSPPlanes = 0;
1511 if ( bspBrushes != 0 ) {
1514 Sys_Printf( "freed bspBrushes\n" );
1515 //numBSPBrushes = 0;
1516 //allocatedBSPBrushes = 0;
1518 */ if ( entities != 0 ) {
1520 for ( i = 0; i < numBSPEntities && i < numEntities; i++ ){
1521 ep = entities[i].epairs;
1530 //Sys_Printf( "freed entities\n" );
1533 allocatedEntities = 0;
1535 /* if ( bspModels != 0 ) {
1538 Sys_Printf( "freed bspModels\n" );
1540 //allocatedBSPModels = 0;
1542 */ if ( bspShaders != 0 ) {
1545 //Sys_Printf( "freed bspShaders\n" );
1546 //numBSPShaders = 0;
1547 //allocatedBSPShaders = 0;
1549 if ( bspEntData != 0 ) {
1552 //Sys_Printf( "freed bspEntData\n" );
1553 //bspEntDataSize = 0;
1554 //allocatedBSPEntData = 0;
1556 /* if ( bspNodes != 0 ) {
1559 Sys_Printf( "freed bspNodes\n" );
1561 //allocatedBSPNodes = 0;
1563 if ( bspDrawIndexes != 0 ) {
1564 free( bspDrawIndexes );
1565 bspDrawIndexes = NULL;
1566 Sys_Printf( "freed bspDrawIndexes\n" );
1567 //numBSPDrawIndexes = 0;
1568 //allocatedBSPDrawIndexes = 0;
1570 if ( bspLeafSurfaces != 0 ) {
1571 free( bspLeafSurfaces );
1572 bspLeafSurfaces = NULL;
1573 Sys_Printf( "freed bspLeafSurfaces\n" );
1574 //numBSPLeafSurfaces = 0;
1575 //allocatedBSPLeafSurfaces = 0;
1577 if ( bspLeafBrushes != 0 ) {
1578 free( bspLeafBrushes );
1579 bspLeafBrushes = NULL;
1580 Sys_Printf( "freed bspLeafBrushes\n" );
1581 //numBSPLeafBrushes = 0;
1582 //allocatedBSPLeafBrushes = 0;
1584 if ( bspBrushSides != 0 ) {
1585 free( bspBrushSides );
1586 bspBrushSides = NULL;
1587 Sys_Printf( "freed bspBrushSides\n" );
1588 numBSPBrushSides = 0;
1589 allocatedBSPBrushSides = 0;
1591 if ( numBSPFogs != 0 ) {
1592 Sys_Printf( "freed numBSPFogs\n" );
1595 if ( numBSPAds != 0 ) {
1596 Sys_Printf( "freed numBSPAds\n" );
1599 if ( numBSPLeafs != 0 ) {
1600 Sys_Printf( "freed numBSPLeafs\n" );
1603 if ( numBSPVisBytes != 0 ) {
1604 Sys_Printf( "freed numBSPVisBytes\n" );
1611 vfsListShaderFiles( pk3Shaderfiles, &pk3ShaderfilesN );
1614 Sys_Printf( "\n\tSchroider fileses.....%i\n", pk3ShaderfilesN );
1615 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1616 Sys_Printf( "%s\n", pk3Shaderfiles + i*65 );
1622 /* can exclude pure *base* textures right now, shouldn't create shaders for them anyway */
1623 for ( i = 0; i < pk3ShadersN ; i++ ){
1624 for ( j = 0; j < ExPureTexturesN ; j++ ){
1625 if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
1626 *( pk3Shaders + i*65 ) = '\0';
1631 /* can exclude repack.exclude shaders, assuming they got all their images */
1632 for ( i = 0; i < pk3ShadersN ; i++ ){
1633 for ( j = 0; j < rExShadersN ; j++ ){
1634 if ( !Q_stricmp( pk3Shaders + i*65, rExShaders + j*65 ) ){
1635 *( pk3Shaders + i*65 ) = '\0';
1641 //Parse Shader Files
1642 Sys_Printf( "\t\nParsing shaders....\n\n" );
1643 char shaderText[ 8192 ];
1644 char* allShaders = (char *)calloc( 16777216, sizeof( char ) );
1646 endofscript = qtrue;
1648 for ( i = 0; i < pk3ShaderfilesN; i++ ){
1649 qboolean wantShader = qfalse;
1652 /* load the shader */
1653 sprintf( temp, "%s/%s", game->shaderPath, pk3Shaderfiles + i*65 );
1654 if ( dbg ) Sys_Printf( "\n\tentering %s\n", pk3Shaderfiles + i*65 );
1655 SilentLoadScriptFile( temp, 0 );
1660 int line = scriptline;
1661 /* test for end of file */
1662 if ( !GetToken( qtrue ) ) {
1666 if( dbg ) Sys_Printf( "%s\n", token );
1668 strcpy( shaderText, token );
1670 if ( strchr( token, '\\') != NULL ){
1671 Sys_Printf( "WARNING1: %s : %s : shader name with backslash\n", pk3Shaderfiles + i*65, token );
1674 /* do wanna le shader? */
1675 wantShader = qfalse;
1676 for ( j = 0; j < pk3ShadersN; j++ ){
1677 if ( !Q_stricmp( pk3Shaders + j*65, token) ){
1684 for ( j = 0; j < rExTexturesN ; j++ ){
1685 if ( !Q_stricmp( pk3Shaders + shader*65, rExTextures + j*65 ) ){
1686 Sys_Printf( "WARNING3: %s : about to include shader for excluded texture\n", pk3Shaders + shader*65 );
1692 /* handle { } section */
1693 if ( !GetToken( qtrue ) ) {
1696 if ( strcmp( token, "{" ) ) {
1697 Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
1698 temp, scriptline, token, g_strLoadedFileLocation );
1700 strcat( shaderText, "\n{" );
1701 qboolean hasmap = qfalse;
1706 /* get the next token */
1707 if ( !GetToken( qtrue ) ) {
1710 if ( !strcmp( token, "}" ) ) {
1711 strcat( shaderText, "\n}\n\n" );
1714 /* parse stage directives */
1715 if ( !strcmp( token, "{" ) ) {
1716 qboolean tokenready = qfalse;
1717 strcat( shaderText, "\n\t{" );
1720 /* detour of TokenAvailable() '~' */
1721 if ( tokenready ) tokenready = qfalse;
1722 else line = scriptline;
1723 if ( !GetToken( qtrue ) ) {
1726 if ( !strcmp( token, "}" ) ) {
1727 strcat( shaderText, "\n\t}" );
1730 if ( !strcmp( token, "{" ) ) {
1731 strcat( shaderText, "\n\t{" );
1732 Sys_Printf( "WARNING9: %s : line %d : opening brace inside shader stage\n", temp, scriptline );
1734 /* skip the shader */
1735 if ( !wantShader ) continue;
1737 /* digest any images */
1738 if ( !Q_stricmp( token, "map" ) ||
1739 !Q_stricmp( token, "clampMap" ) ) {
1740 strcat( shaderText, "\n\t\t" );
1741 strcat( shaderText, token );
1746 if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
1747 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1749 strcat( shaderText, " " );
1750 strcat( shaderText, token );
1752 else if ( !Q_stricmp( token, "animMap" ) ||
1753 !Q_stricmp( token, "clampAnimMap" ) ) {
1754 strcat( shaderText, "\n\t\t" );
1755 strcat( shaderText, token );
1758 GetToken( qfalse );// skip num
1759 strcat( shaderText, " " );
1760 strcat( shaderText, token );
1761 while ( TokenAvailable() ){
1763 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1764 strcat( shaderText, " " );
1765 strcat( shaderText, token );
1769 else if ( !Q_stricmp( token, "videoMap" ) ){
1770 strcat( shaderText, "\n\t\t" );
1771 strcat( shaderText, token );
1774 strcat( shaderText, " " );
1775 strcat( shaderText, token );
1776 FixDOSName( token );
1777 if ( strchr( token, '/' ) == NULL && strchr( token, '\\' ) == NULL ){
1778 sprintf( temp, "video/%s", token );
1779 strcpy( token, temp );
1781 FixDOSName( token );
1782 for ( j = 0; j < pk3VideosN; j++ ){
1783 if ( !Q_stricmp( pk3Videos + j*65, token ) ){
1787 for ( j = 0; j < ExVideosN; j++ ){
1788 if ( !Q_stricmp( ExVideos + j*65, token ) ){
1792 for ( j = 0; j < rExVideosN; j++ ){
1793 if ( !Q_stricmp( rExVideos + j*65, token ) ){
1797 strcpy ( pk3Videos + pk3VideosN*65, token );
1802 else if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
1803 Sys_Printf( "WARNING7: %s : %s shader\n", pk3Shaders + shader*65, token );
1805 if ( line == scriptline ){
1806 strcat( shaderText, " " );
1807 strcat( shaderText, token );
1810 strcat( shaderText, "\n\t\t" );
1811 strcat( shaderText, token );
1814 else if ( line == scriptline ){
1815 strcat( shaderText, " " );
1816 strcat( shaderText, token );
1819 strcat( shaderText, "\n\t\t" );
1820 strcat( shaderText, token );
1824 /* skip the shader */
1825 else if ( !wantShader ) continue;
1827 /* -----------------------------------------------------------------
1828 surfaceparm * directives
1829 ----------------------------------------------------------------- */
1831 /* match surfaceparm */
1832 else if ( !Q_stricmp( token, "surfaceparm" ) ) {
1833 strcat( shaderText, "\n\tsurfaceparm " );
1835 strcat( shaderText, token );
1836 if ( !Q_stricmp( token, "nodraw" ) ) {
1837 wantShader = qfalse;
1838 *( pk3Shaders + shader*65 ) = '\0';
1842 /* skyparms <outer image> <cloud height> <inner image> */
1843 else if ( !Q_stricmp( token, "skyParms" ) ) {
1844 strcat( shaderText, "\n\tskyParms " );
1846 /* get image base */
1848 strcat( shaderText, token );
1850 /* ignore bogus paths */
1851 if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
1852 strcpy ( temp, token );
1853 sprintf( token, "%s_up", temp );
1854 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1855 sprintf( token, "%s_dn", temp );
1856 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1857 sprintf( token, "%s_lf", temp );
1858 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1859 sprintf( token, "%s_rt", temp );
1860 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1861 sprintf( token, "%s_bk", temp );
1862 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1863 sprintf( token, "%s_ft", temp );
1864 tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
1866 /* skip rest of line */
1868 strcat( shaderText, " " );
1869 strcat( shaderText, token );
1871 strcat( shaderText, " " );
1872 strcat( shaderText, token );
1874 else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
1875 Sys_Printf( "WARNING5: %s : %s shader\n", pk3Shaders + shader*65, token );
1877 if ( line == scriptline ){
1878 strcat( shaderText, " " );
1879 strcat( shaderText, token );
1882 strcat( shaderText, "\n\t" );
1883 strcat( shaderText, token );
1886 else if ( !Q_stricmp( token, "fogparms" ) ){
1888 if ( line == scriptline ){
1889 strcat( shaderText, " " );
1890 strcat( shaderText, token );
1893 strcat( shaderText, "\n\t" );
1894 strcat( shaderText, token );
1897 else if ( line == scriptline ){
1898 strcat( shaderText, " " );
1899 strcat( shaderText, token );
1902 strcat( shaderText, "\n\t" );
1903 strcat( shaderText, token );
1909 for ( j = 0; j < ExShadersN; j++ ){
1910 if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
1911 wantShader = qfalse;
1912 *( pk3Shaders + shader*65 ) = '\0';
1916 if ( wantShader && !hasmap ){
1917 Sys_Printf( "WARNING8: %s : shader has no known maps\n", pk3Shaders + shader*65 );
1918 wantShader = qfalse;
1919 *( pk3Shaders + shader*65 ) = '\0';
1922 strcat( allShaders, shaderText );
1923 *( pk3Shaders + shader*65 ) = '\0';
1928 /* TODO: RTCW's mapComp, mapNoComp, animmapcomp, animmapnocomp; nocompress?; ET's implicitmap, implicitblend, implicitmask */
1933 //pure textures (shader ones are done)
1934 for ( i = 0; i < pk3ShadersN; i++ ){
1935 if ( *( pk3Shaders + i*65 ) != '\0' ){
1936 if ( strchr( pk3Shaders + i*65, '\\') != NULL ){
1937 Sys_Printf( "WARNING2: %s : bsp shader path with backslash\n", pk3Shaders + i*65 );
1938 FixDOSName( pk3Shaders + i*65 );
1939 //what if theres properly slashed one in the list?
1940 for ( j = 0; j < pk3ShadersN; j++ ){
1941 if ( !Q_stricmp( pk3Shaders + i*65, pk3Shaders + j*65 ) && (i != j) ){
1942 *( pk3Shaders + i*65 ) = '\0';
1947 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1948 for ( j = 0; j < pk3TexturesN; j++ ){
1949 if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
1950 *( pk3Shaders + i*65 ) = '\0';
1954 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1955 for ( j = 0; j < ExTexturesN; j++ ){
1956 if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
1957 *( pk3Shaders + i*65 ) = '\0';
1961 if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
1962 for ( j = 0; j < rExTexturesN; j++ ){
1963 if ( !Q_stricmp( pk3Shaders + i*65, rExTextures + j*65 ) ){
1964 *( pk3Shaders + i*65 ) = '\0';
1972 for ( i = 0; i < pk3SoundsN; i++ ){
1973 for ( j = 0; j < ExSoundsN; j++ ){
1974 if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
1975 *( pk3Sounds + i*65 ) = '\0';
1979 if ( *( pk3Sounds + i*65 ) == '\0' ) continue;
1980 for ( j = 0; j < rExSoundsN; j++ ){
1981 if ( !Q_stricmp( pk3Sounds + i*65, rExSounds + j*65 ) ){
1982 *( pk3Sounds + i*65 ) = '\0';
1989 sprintf( temp, "%s/%s_strippedBYrepacker.shader", EnginePath, nameOFrepack );
1991 f = fopen( temp, "wb" );
1992 fwrite( allShaders, sizeof( char ), strlen( allShaders ), f );
1994 Sys_Printf( "Shaders saved to %s\n", temp );
1997 sprintf( packname, "%s/%s_repacked.pk3", EnginePath, nameOFrepack );
2000 Sys_Printf( "\n--- ZipZip ---\n" );
2002 Sys_Printf( "\n\tShader referenced textures....\n" );
2004 for ( i = 0; i < pk3TexturesN; i++ ){
2006 sprintf( temp, "%s.png", pk3Textures + i*65 );
2007 if ( vfsPackFile( temp, packname, compLevel ) ){
2008 Sys_Printf( "++%s\n", temp );
2012 sprintf( temp, "%s.tga", pk3Textures + i*65 );
2013 if ( vfsPackFile( temp, packname, compLevel ) ){
2014 Sys_Printf( "++%s\n", temp );
2017 sprintf( temp, "%s.jpg", pk3Textures + i*65 );
2018 if ( vfsPackFile( temp, packname, compLevel ) ){
2019 Sys_Printf( "++%s\n", temp );
2022 Sys_Printf( " !FAIL! %s\n", pk3Textures + i*65 );
2025 Sys_Printf( "\n\tPure textures....\n" );
2027 for ( i = 0; i < pk3ShadersN; i++ ){
2028 if ( *( pk3Shaders + i*65 ) != '\0' ){
2030 sprintf( temp, "%s.png", pk3Shaders + i*65 );
2031 if ( vfsPackFile( temp, packname, compLevel ) ){
2032 Sys_Printf( "++%s\n", temp );
2036 sprintf( temp, "%s.tga", pk3Shaders + i*65 );
2037 if ( vfsPackFile( temp, packname, compLevel ) ){
2038 Sys_Printf( "++%s\n", temp );
2041 sprintf( temp, "%s.jpg", pk3Shaders + i*65 );
2042 if ( vfsPackFile( temp, packname, compLevel ) ){
2043 Sys_Printf( "++%s\n", temp );
2046 Sys_Printf( " !FAIL! %s\n", pk3Shaders + i*65 );
2050 Sys_Printf( "\n\tSounds....\n" );
2052 for ( i = 0; i < pk3SoundsN; i++ ){
2053 if ( *( pk3Sounds + i*65 ) != '\0' ){
2054 if ( vfsPackFile( pk3Sounds + i*65, packname, compLevel ) ){
2055 Sys_Printf( "++%s\n", pk3Sounds + i*65 );
2058 Sys_Printf( " !FAIL! %s\n", pk3Sounds + i*65 );
2062 Sys_Printf( "\n\tVideos....\n" );
2064 for ( i = 0; i < pk3VideosN; i++ ){
2065 if ( vfsPackFile( pk3Videos + i*65, packname, compLevel ) ){
2066 Sys_Printf( "++%s\n", pk3Videos + i*65 );
2069 Sys_Printf( " !FAIL! %s\n", pk3Videos + i*65 );
2072 Sys_Printf( "\nSaved to %s\n", packname );
2074 /* return to sender */
2085 int main( int argc, char **argv ){
2088 extern qboolean werror;
2094 /* we want consistent 'randomness' */
2098 start = I_FloatTime();
2100 /* this was changed to emit version number over the network */
2101 printf( Q3MAP_VERSION "\n" );
2104 atexit( ExitQ3Map );
2106 /* read general options first */
2107 for ( i = 1; i < argc; i++ )
2110 if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
2111 || !strcmp( argv[ i ], "-help" ) ) {
2112 HelpMain( ( i + 1 < argc ) ? argv[ i + 1 ] : NULL );
2117 if ( !strcmp( argv[ i ], "-connect" ) ) {
2118 if ( ++i >= argc || !argv[ i ] ) {
2119 Error( "Out of arguments: No address specified after %s", argv[ i - 1 ] );
2121 argv[ i - 1 ] = NULL;
2122 Broadcast_Setup( argv[ i ] );
2127 else if ( !strcmp( argv[ i ], "-v" ) ) {
2135 else if ( !strcmp( argv[ i ], "-force" ) ) {
2140 /* make all warnings into errors */
2141 else if ( !strcmp( argv[ i ], "-werror" ) ) {
2146 /* patch subdivisions */
2147 else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
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 patchSubdivisions = atoi( argv[ i ] );
2154 if ( patchSubdivisions <= 0 ) {
2155 patchSubdivisions = 1;
2160 else if ( !strcmp( argv[ i ], "-threads" ) ) {
2161 if ( ++i >= argc || !argv[ i ] ) {
2162 Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
2164 argv[ i - 1 ] = NULL;
2165 numthreads = atoi( argv[ i ] );
2169 else if( !strcmp( argv[ i ], "-nocmdline" ) )
2171 Sys_Printf( "noCmdLine\n" );
2178 /* init model library */
2180 PicoSetMallocFunc( safe_malloc );
2181 PicoSetFreeFunc( free );
2182 PicoSetPrintFunc( PicoPrintFunc );
2183 PicoSetLoadFileFunc( PicoLoadFileFunc );
2184 PicoSetFreeFileFunc( free );
2186 /* set number of threads */
2189 /* generate sinusoid jitter table */
2190 for ( i = 0; i < MAX_JITTERS; i++ )
2192 jitters[ i ] = sin( i * 139.54152147 );
2193 //% Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
2196 /* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
2197 and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
2199 Sys_Printf( "Q3Map - v1.0r (c) 1999 Id Software Inc.\n" );
2200 Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
2201 Sys_Printf( RADIANT_NAME " - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
2202 Sys_Printf( "%s\n", Q3MAP_MOTD );
2203 Sys_Printf( "%s\n", argv[0] );
2205 strcpy( q3map2path, argv[0] );//fuer autoPack func
2207 /* ydnar: new path initialization */
2208 InitPaths( &argc, argv );
2210 /* set game options */
2211 if ( !patchSubdivisions ) {
2212 patchSubdivisions = game->patchSubdivisions;
2215 /* check if we have enough options left to attempt something */
2217 Error( "Usage: %s [general options] [options] mapfile\n%s -help for help", argv[ 0 ] , argv[ 0 ] );
2221 if ( !strcmp( argv[ 1 ], "-fixaas" ) ) {
2222 r = FixAASMain( argc - 1, argv + 1 );
2226 else if ( !strcmp( argv[ 1 ], "-analyze" ) ) {
2227 r = AnalyzeBSPMain( argc - 1, argv + 1 );
2231 else if ( !strcmp( argv[ 1 ], "-info" ) ) {
2232 r = BSPInfoMain( argc - 2, argv + 2 );
2236 else if ( !strcmp( argv[ 1 ], "-vis" ) ) {
2237 r = VisMain( argc - 1, argv + 1 );
2241 else if ( !strcmp( argv[ 1 ], "-light" ) ) {
2242 r = LightMain( argc - 1, argv + 1 );
2246 else if ( !strcmp( argv[ 1 ], "-vlight" ) ) {
2247 Sys_FPrintf( SYS_WRN, "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
2248 argv[ 1 ] = "-fast"; /* eek a hack */
2249 r = LightMain( argc, argv );
2252 /* QBall: export entities */
2253 else if ( !strcmp( argv[ 1 ], "-exportents" ) ) {
2254 r = ExportEntitiesMain( argc - 1, argv + 1 );
2257 /* ydnar: lightmap export */
2258 else if ( !strcmp( argv[ 1 ], "-export" ) ) {
2259 r = ExportLightmapsMain( argc - 1, argv + 1 );
2262 /* ydnar: lightmap import */
2263 else if ( !strcmp( argv[ 1 ], "-import" ) ) {
2264 r = ImportLightmapsMain( argc - 1, argv + 1 );
2267 /* ydnar: bsp scaling */
2268 else if ( !strcmp( argv[ 1 ], "-scale" ) ) {
2269 r = ScaleBSPMain( argc - 1, argv + 1 );
2273 else if ( !strcmp( argv[ 1 ], "-shift" ) ) {
2274 r = ShiftBSPMain( argc - 1, argv + 1 );
2278 else if ( !strcmp( argv[ 1 ], "-pk3" ) ) {
2279 r = pk3BSPMain( argc - 1, argv + 1 );
2283 else if ( !strcmp( argv[ 1 ], "-repack" ) ) {
2284 r = repackBSPMain( argc - 1, argv + 1 );
2287 /* ydnar: bsp conversion */
2288 else if ( !strcmp( argv[ 1 ], "-convert" ) ) {
2289 r = ConvertBSPMain( argc - 1, argv + 1 );
2293 else if ( !strcmp( argv[ 1 ], "-minimap" ) ) {
2294 r = MiniMapBSPMain( argc - 1, argv + 1 );
2297 /* ydnar: otherwise create a bsp */
2299 /* used to write Smokin'Guns like tex file */
2300 compile_map = qtrue;
2302 r = BSPMain( argc, argv );
2306 end = I_FloatTime();
2307 Sys_Printf( "%9.0f seconds elapsed\n", end - start );
2309 /* shut down connection */
2310 Broadcast_Shutdown();
2312 /* return any error code */