q3map2: inject the invocation commandline into keys of the worldspawn entity (to allow easier recompiling of the map)

git-svn-id: svn://svn.icculus.org/netradiant/trunk@181 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
divverent 2009-02-08 19:35:57 +00:00
parent af88b4208b
commit 3aca84b7e5
6 changed files with 54 additions and 1 deletions

View File

@ -613,7 +613,7 @@ this is probably broken unless teamed with a radiant version that preserves enti
void OnlyEnts( void ) void OnlyEnts( void )
{ {
char out[ 1024 ]; char out[ 1024 ];
// TODO save and restore _q3map2_cmdline when doing this
/* note it */ /* note it */
Sys_Printf( "--- OnlyEnts ---\n" ); Sys_Printf( "--- OnlyEnts ---\n" );
@ -913,6 +913,9 @@ int BSPMain( int argc, char **argv )
else else
LoadMapFile( name, qfalse ); LoadMapFile( name, qfalse );
/* div0: inject command line parameters */
InjectCommandLine(argv, 1, argc - 1);
/* ydnar: decal setup */ /* ydnar: decal setup */
ProcessDecals(); ProcessDecals();

View File

@ -578,7 +578,44 @@ void ParseEntities( void )
numBSPEntities = numEntities; 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() UnparseEntities()

View File

@ -1750,6 +1750,7 @@ void LightWorld( void )
{ {
/* store off the bsp between bounces */ /* store off the bsp between bounces */
StoreSurfaceLightmaps(); StoreSurfaceLightmaps();
UnparseEntities();
Sys_Printf( "Writing %s\n", source ); Sys_Printf( "Writing %s\n", source );
WriteBSPFile( source ); WriteBSPFile( source );
@ -2368,6 +2369,9 @@ int LightMain( int argc, char **argv )
/* parse bsp entities */ /* parse bsp entities */
ParseEntities(); ParseEntities();
/* inject command line parameters */
InjectCommandLine(argv, 0, argc - 1);
/* load map file */ /* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" ); value = ValueForKey( &entities[ 0 ], "_keepLights" );

View File

@ -473,6 +473,9 @@ int ScaleBSPMain( int argc, char **argv )
VectorScale( vec, scale, vec ); VectorScale( vec, scale, vec );
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] ); sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
SetKeyValue( &entities[ 0 ], "gridsize", str ); SetKeyValue( &entities[ 0 ], "gridsize", str );
/* inject command line parameters */
InjectCommandLine(argv, 0, argc - 1);
/* write the bsp */ /* write the bsp */
UnparseEntities(); UnparseEntities();

View 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 ); void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
entity_t *FindTargetEntity( const char *target ); entity_t *FindTargetEntity( const char *target );
void GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows ); 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 */ /* bspfile_ibsp.c */

View File

@ -1107,6 +1107,10 @@ int VisMain (int argc, char **argv)
/* ydnar: for getting far plane */ /* ydnar: for getting far plane */
ParseEntities(); ParseEntities();
/* inject command line parameters */
InjectCommandLine(argv, 0, argc - 1);
UnparseEntities();
if( mergevis ) if( mergevis )
{ {
MergeLeaves(); MergeLeaves();