Example #1
0
static char *Cvar_BitInfo( int bit )
{
	static char info[MAX_INFO_STRING];
	struct trie_dump_s *dump;
	unsigned int i;

	info[0] = 0;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_HasFlags, &bit, &dump );

	// make sure versioncvar comes first
	for( i = dump->size; i > 0; --i )
	{
		cvar_t *const var = dump->key_value_vector[i-1].value;
		if( var == versioncvar )
		{
			Info_SetValueForKey( info, var->name, var->string );
			break;
		}
	}

	// dump other cvars
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = dump->key_value_vector[i].value;
		if( var != versioncvar )
			Info_SetValueForKey( info, var->name, var->string );
	}

	Trie_FreeDump( dump );

	return info;
}
Example #2
0
/*
* Cvar_WriteVariables
* 
* Appends lines containing "set variable value" for all variables
* with the archive flag set to true.
*/
void Cvar_WriteVariables( int file )
{
	char buffer[MAX_PRINTMSG];
	struct trie_dump_s *dump;
	unsigned int i;
	cvar_flag_t cvar_archive = CVAR_ARCHIVE;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_HasFlags, &cvar_archive, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = dump->key_value_vector[i].value;
		const char *cmd;

		if( Cvar_FlagIsSet( var->flags, CVAR_USERINFO ) )
			cmd = "setau";
		else if( Cvar_FlagIsSet( var->flags, CVAR_SERVERINFO ) )
			cmd = "setas";
		else
			cmd = "seta";

		if( Cvar_FlagIsSet( var->flags, CVAR_LATCH ) || Cvar_FlagIsSet( var->flags, CVAR_LATCH_VIDEO ) ||
			Cvar_FlagIsSet( var->flags, CVAR_LATCH_SOUND ) )
		{
			if( var->latched_string )
				Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->latched_string );
			else
				Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->string );
		}
		else
			Q_snprintfz( buffer, sizeof( buffer ), "%s %s \"%s\"\r\n", cmd, var->name, var->string );
		FS_Printf( file, "%s", buffer );
	}
	Trie_FreeDump( dump );
}
Example #3
0
/*
* Cvar_GetLatchedVars
* 
* Any variables with CVAR_LATCHED will now be updated
*/
void Cvar_GetLatchedVars( cvar_flag_t flags )
{
	unsigned int i;
	struct trie_dump_s *dump;
	cvar_flag_t latchFlags;

	Cvar_FlagsClear( &latchFlags );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH_VIDEO );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH_SOUND );
	Cvar_FlagUnset( &flags, ~latchFlags );
	if( !flags )
		return;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_IsLatched, &flags, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = (cvar_t *) dump->key_value_vector[i].value;
		if( !strcmp( var->name, "fs_game" ) )
		{
			FS_SetGameDirectory( var->latched_string, qfalse );
			return;
		}
		Mem_ZoneFree( var->string );
		var->string = var->latched_string;
		var->latched_string = NULL;
		var->value = atof( var->string );
		var->integer = Q_rint( var->value );
	}
	Trie_FreeDump( dump );
}
Example #4
0
void Dynvar_List_f( void )
{
	struct trie_dump_s *dump;
	unsigned int i, size;
	char *pattern;

	Trie_GetSize( dynvar_trie, &size );
	if( !size )
	{
		Com_Printf( "No dynvars\n" );
		return;
	}

	if( Cmd_Argc() == 1 )
		pattern = NULL; // no wildcard
	else
		pattern = Cmd_Args();

	Com_Printf( "\nDynvars:\n" );
	assert( dynvar_trie );
	Trie_DumpIf( dynvar_trie, "", TRIE_DUMP_VALUES, Dynvar_Console, pattern, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		dynvar_t *const dynvar = (dynvar_t *) dump->key_value_vector[i].value;
		Com_Printf( "%s\n", Dynvar_GetName( dynvar ) );
	}
	Trie_FreeDump( dump );
	Com_Printf( "%i dynvars\n", i );
}
Example #5
0
/*
* Cvar_List_f
*/
static void Cvar_List_f( void )
{
	struct trie_dump_s *dump;
	unsigned int i;
	char *pattern;

	if( Cmd_Argc() == 1 )
		pattern = NULL;
	else
		pattern = Cmd_Args();

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_PatternMatches, pattern, &dump );

	Com_Printf( "\nConsole variables:\n" );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = dump->key_value_vector[i].value;
#ifdef PUBLIC_BUILD
		if( Cvar_FlagIsSet( var->flags, CVAR_DEVELOPER ) )
			continue;
#endif
		if( Cvar_FlagIsSet( var->flags, CVAR_ARCHIVE ) )
			Com_Printf( "*" );
		else
			Com_Printf( " " );
		if( Cvar_FlagIsSet( var->flags, CVAR_USERINFO ) )
			Com_Printf( "U" );
		else
			Com_Printf( " " );
		if( Cvar_FlagIsSet( var->flags, CVAR_SERVERINFO ) )
			Com_Printf( "S" );
		else
			Com_Printf( " " );
		if( Cvar_FlagIsSet( var->flags, CVAR_NOSET ) || Cvar_FlagIsSet( var->flags, CVAR_READONLY ) )
			Com_Printf( "-" );
		else if( Cvar_FlagIsSet( var->flags, CVAR_LATCH ) || Cvar_FlagIsSet( var->flags, CVAR_LATCH_VIDEO ) ||
			Cvar_FlagIsSet( var->flags, CVAR_LATCH_SOUND ) )
			Com_Printf( "L" );
		else
			Com_Printf( " " );
		if( Cvar_FlagIsSet( var->flags, CVAR_CHEAT ) )
			Com_Printf( "C" );
		else
			Com_Printf( " " );
		Com_Printf( " %s \"%s%s\", default: \"%s%s\"\n", var->name, 
			var->string, Q_ColorStringTerminator( var->string, ColorIndex(COLOR_WHITE) ),
			var->dvalue, Q_ColorStringTerminator( var->dvalue, ColorIndex(COLOR_WHITE) ) );
	}
	Com_Printf( "%i variables\n", i );

	Trie_FreeDump( dump );
}
Example #6
0
/*
* ML_MapListCmd
* Handler for console command "maplist"
*/
static void ML_MapListCmd( void )
{
	char *pattern;
	mapinfo_t *map;
	int argc = Cmd_Argc();
	unsigned int i;
	struct trie_dump_s *dump = NULL;

	if( argc > 2 )
	{
		Com_Printf( "Usage: %s [rebuild]\n", Cmd_Argv(0) );
		return;
	}

	pattern = (argc == 2 ? Cmd_Argv( 1 ) : NULL);
	if( pattern && !*pattern )
		pattern = NULL;

	if( pattern )
	{
		if( !strcmp( pattern, "rebuild" ) )
		{
			Com_Printf( "Rebuilding map list...\n" );
			ML_Restart( true );
			return;
		}

		if( !strcmp( pattern, "update" ) )
		{
			Com_Printf( "Updating map list...\n" );
			ML_Update();
			return;
		}
	}

	Trie_DumpIf( mlist_filenames_trie, "", TRIE_DUMP_VALUES, ML_PatternMatchesMap, pattern, &dump );
	for( i = 0; i < dump->size; i++ )
	{
		map = ( mapinfo_t * )( dump->key_value_vector[i].value );
		Com_Printf( "%s: %s\n", map->filename, map->fullname );
	}
	Trie_FreeDump( dump );

	Com_Printf( "%d map(s) %s\n", i, pattern ? "matching" : "total" );
}
Example #7
0
/*
* Cvar_FixCheatVars
* 
* All cheat variables with be reset to default unless cheats are allowed
*/
void Cvar_FixCheatVars( void )
{
	struct trie_dump_s *dump;
	unsigned int i;
	cvar_flag_t flags = CVAR_CHEAT;

	if( Cvar_CheatsAllowed() )
		return;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_HasFlags, &flags, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = (cvar_t *) dump->key_value_vector[i].value;
		Mem_ZoneFree( var->string );
		var->string = ZoneCopyString( var->dvalue );
		var->value = atof( var->string );
		var->integer = Q_rint( var->value );
	}
	Trie_FreeDump( dump );
}