]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
q3map2: inject the invocation commandline into keys of the worldspawn entity (to...
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sun, 8 Feb 2009 19:35:57 +0000 (19:35 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sun, 8 Feb 2009 19:35:57 +0000 (19:35 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@181 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/bsp.c
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/vis.c

index 2b29ff5ec6a34f5ecebb482faf371fd26b8e2253..9b695d02000e3af3390c1540b86e4d250f2960a1 100644 (file)
@@ -613,7 +613,7 @@ this is probably broken unless teamed with a radiant version that preserves enti
 void OnlyEnts( void )
 {
        char out[ 1024 ];
-
+       // TODO save and restore _q3map2_cmdline when doing this
        
        /* note it */
        Sys_Printf( "--- OnlyEnts ---\n" );
@@ -913,6 +913,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();
        
index 5b515fc8f815d06f00f7d2931cee29f92b253191..e2904186aa75b5d09a5c0959a26361a9e46f0545 100644 (file)
@@ -578,7 +578,44 @@ void ParseEntities( void )
        numBSPEntities = numEntities;
 }
 
+/*
+ * must be called before UnparseEntities
+ */
+void InjectCommandLine(char **argv, int beginArgs, int endArgs)
+{
+       const char *previousCommandLine;
+       char newCommandLine[1024];
+       const char *inpos;
+       char *outpos = newCommandLine;
+       char *sentinel = newCommandLine + sizeof(newCommandLine) - 1;
+       int i;
+
+       previousCommandLine = ValueForKey(&entities[0], "_q3map2_cmdline");
+       if(previousCommandLine && *previousCommandLine)
+       {
+               inpos = previousCommandLine;
+               while(outpos != sentinel && *inpos)
+                       *outpos++ = *inpos++;
+               if(outpos != sentinel)
+                       *outpos++ = ';';
+               if(outpos != sentinel)
+                       *outpos++ = ' ';
+       }
 
+       for(i = beginArgs; i < endArgs; ++i)
+       {
+               if(outpos != sentinel && i != beginArgs)
+                       *outpos++ = ' ';
+               inpos = argv[i];
+               while(outpos != sentinel && *inpos)
+                       if(*inpos != '\\' && *inpos != '"' && *inpos != ';' && (unsigned char) *inpos >= ' ')
+                               *outpos++ = *inpos++;
+       }
+
+       *outpos = 0;
+       SetKeyValue(&entities[0], "_q3map2_cmdline", newCommandLine);
+       SetKeyValue(&entities[0], "_q3map2_version", Q3MAP_VERSION);
+}
 
 /*
 UnparseEntities()
index 8fbfd1e1334ebd5a249786fe0f19544426b384aa..49aaebfe0056ed11bfa2c9e7e86b1f925616bf52 100644 (file)
@@ -1750,6 +1750,7 @@ void LightWorld( void )
        {
                /* store off the bsp between bounces */
                StoreSurfaceLightmaps();
+               UnparseEntities();
                Sys_Printf( "Writing %s\n", source );
                WriteBSPFile( source );
                
@@ -2368,6 +2369,9 @@ int LightMain( int argc, char **argv )
        
        /* parse bsp entities */
        ParseEntities();
+
+       /* inject command line parameters */
+       InjectCommandLine(argv, 0, argc - 1);
        
        /* load map file */
        value = ValueForKey( &entities[ 0 ], "_keepLights" );
index 9e4f36590dcffe9b7469313d1f5ef9c63255de35..44b0c821595a8ce570afb61305948a5e082ad610 100644 (file)
@@ -473,6 +473,9 @@ int ScaleBSPMain( int argc, char **argv )
        VectorScale( vec, scale, vec );
        sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
        SetKeyValue( &entities[ 0 ], "gridsize", str );
+
+       /* inject command line parameters */
+       InjectCommandLine(argv, 0, argc - 1);
        
        /* write the bsp */
        UnparseEntities();
index 2fe5f7b883b95b427237dd1a8563f0e2b7e629bb..8c97255490cad4036fd4fb45000d86d6c18d9455 100644 (file)
@@ -1811,6 +1811,8 @@ vec_t                                             FloatForKey( const entity_t *ent, const char *key );
 void                                           GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
 entity_t                                       *FindTargetEntity( const char *target );
 void                                           GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows );
+void InjectCommandLine(char **argv, int beginArgs, int endArgs);
+               
 
 
 /* bspfile_ibsp.c */
index dc764ba8e0e89188d4aba44670004a208e7bfc6c..566706a9e8c08585956e353478c3dfdfd3f9b7f6 100644 (file)
@@ -1107,6 +1107,10 @@ int VisMain (int argc, char **argv)
        /* ydnar: for getting far plane */
        ParseEntities();
        
+       /* inject command line parameters */
+       InjectCommandLine(argv, 0, argc - 1);
+       UnparseEntities();
+       
        if( mergevis )
        {
                MergeLeaves();