]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bsp.c
new argument -celshader, for cel shading without changing the .map file
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bsp.c
index 30ea92c0dad3cde2ddbcf7f92220511627fcfdb9..5bf40c33d7277069adea961ebe4798586b9069be 100644 (file)
@@ -614,18 +614,34 @@ void OnlyEnts( void )
 {
        char out[ 1024 ];
 
+       char save_cmdline[1024], save_version[1024];
+       const char *p;
        
        /* note it */
        Sys_Printf( "--- OnlyEnts ---\n" );
        
        sprintf( out, "%s.bsp", source );
        LoadBSPFile( out );
+
+       ParseEntities();
+       p = ValueForKey(&entities[0], "_q3map2_cmdline");
+       strncpy(save_cmdline, p, sizeof(save_cmdline));
+       save_cmdline[sizeof(save_cmdline)-1] = 0;
+       p = ValueForKey(&entities[0], "_q3map2_version");
+       strncpy(save_version, p, sizeof(save_version));
+       save_version[sizeof(save_version)-1] = 0;
+
        numEntities = 0;
 
        LoadShaderInfo();
        LoadMapFile( name, qfalse );
        SetModelNumbers();
        SetLightStyles();
+
+       if(*save_cmdline)
+               SetKeyValue(&entities[0], "_q3map2_cmdline", save_cmdline);
+       if(*save_version)
+               SetKeyValue(&entities[0], "_q3map2_version", save_version);
        
        numBSPEntities = numEntities;
        UnparseEntities();
@@ -656,6 +672,7 @@ int BSPMain( int argc, char **argv )
        numMapDrawSurfs = 0;
        
        tempSource[ 0 ] = '\0';
+       globalCelShader[0] = 0;
        
        /* set standard game flags */
        maxSurfaceVerts = game->maxSurfaceVerts;
@@ -820,6 +837,15 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Flatshading enabled\n" );
                        flat = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-celshader" ) )
+               {
+                       ++i;
+                       if(argv[i][0])
+                               sprintf( globalCelShader, "textures/%s", argv[ i ] );
+                       else
+                               *globalCelShader = 0;
+                       Sys_Printf( "Global cel shader set to \"%s\"\n", globalCelShader );
+               }
                else if( !strcmp( argv[ i ], "-meta" ) )
                {
                        Sys_Printf( "Creating meta surfaces from brush faces\n" );
@@ -864,8 +890,7 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "-bsp argument unnecessary\n" );
                else
                {
-                       Sys_Printf( "WARNING: Unknown option \"%s\"\a\n", argv[ i ] );
-                       sleep(1);
+                       Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
                }
        }
        
@@ -914,6 +939,9 @@ int BSPMain( int argc, char **argv )
        else
                LoadMapFile( name, qfalse );
        
+       /* div0: inject command line parameters */
+       InjectCommandLine(argv, 1, argc - 1);
+       
        /* ydnar: decal setup */
        ProcessDecals();