void OnlyEnts( void )
{
char out[ 1024 ];
-
+ // TODO save and restore _q3map2_cmdline when doing this
/* note it */
Sys_Printf( "--- OnlyEnts ---\n" );
else
LoadMapFile( name, qfalse );
+ /* div0: inject command line parameters */
+ InjectCommandLine(argv, 1, argc - 1);
+
/* ydnar: decal setup */
ProcessDecals();
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()
{
/* store off the bsp between bounces */
StoreSurfaceLightmaps();
+ UnparseEntities();
Sys_Printf( "Writing %s\n", source );
WriteBSPFile( source );
/* parse bsp entities */
ParseEntities();
+
+ /* inject command line parameters */
+ InjectCommandLine(argv, 0, argc - 1);
/* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" );
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();
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 */
/* ydnar: for getting far plane */
ParseEntities();
+ /* inject command line parameters */
+ InjectCommandLine(argv, 0, argc - 1);
+ UnparseEntities();
+
if( mergevis )
{
MergeLeaves();