]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/main.c
qtrue too
[xonotic/netradiant.git] / tools / quake3 / q3map2 / main.c
index d7d77538ac23329bf24478b658ad4a2479a57188..b55cc654e6de470616a3ff549bcfbf1fdb12675e 100644 (file)
@@ -1,4 +1,4 @@
-/* -------------------------------------------------------------------------------
+/* -------------------------------------------------------------------------------;
 
 Copyright (C) 1999-2007 id Software, Inc. and contributors.
 For a list of contributors, see the accompanying CONTRIBUTORS file.
@@ -1189,29 +1189,45 @@ int ScaleBSPMain( int argc, char **argv )
        int uniform, axis;
        qboolean texscale;
        float *old_xyzst = NULL;
+       float spawn_ref = 0;
        
        
        /* arg checking */
        if( argc < 3 )
        {
-               Sys_Printf( "Usage: q3map [-v] -scale [-tex] <value> <mapname>\n" );
+               Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
                return 0;
        }
        
+       texscale = qfalse;
+       for(i = 1; i < argc-2; ++i)
+       {
+               if(!strcmp(argv[i], "-tex"))
+               {
+                       texscale = qtrue;
+               }
+               else if(!strcmp(argv[i], "-spawn_ref"))
+               {
+                       spawn_ref = atof(argv[i+1]);
+                       ++i;
+               }
+               else
+                       break;
+       }
+       
        /* get scale */
-       scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
-       if(argc >= 4)
+       // if(argc-2 >= i) // always true
+               scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
+       if(argc-3 >= i)
                scale[1] = scale[0] = atof( argv[ argc - 3 ] );
-       if(argc >= 5)
+       if(argc-4 >= i)
                scale[0] = atof( argv[ argc - 4 ] );
 
-       texscale = !strcmp(argv[1], "-tex");
-       
        uniform = ((scale[0] == scale[1]) && (scale[1] == scale[2]));
 
        if( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f )
        {
-               Sys_Printf( "Usage: q3map [-v] -scale [-tex] <value> <mapname>\n" );
+               Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
                Sys_Printf( "Non-zero scale value required.\n" );
                return 0;
        }
@@ -1237,9 +1253,13 @@ int ScaleBSPMain( int argc, char **argv )
                GetVectorForKey( &entities[ i ], "origin", vec );
                if( (vec[ 0 ] || vec[ 1 ] || vec[ 2 ]) )
                {
+                       if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
+                               vec[2] += spawn_ref;
                        vec[0] *= scale[0];
                        vec[1] *= scale[1];
                        vec[2] *= scale[2];
+                       if(!strncmp(ValueForKey(&entities[i], "classname"), "info_player_", 12))
+                               vec[2] -= spawn_ref;
                        sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
                        SetKeyValue( &entities[ i ], "origin", str );
                }
@@ -1579,7 +1599,7 @@ int main( int argc, char **argv )
                        argv[ i ] = NULL;
                }
        }
-       
+
        /* init model library */
        PicoInit();
        PicoSetMallocFunc( safe_malloc );