Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-wildcard for cvarlist #448

Open
Gelmo opened this issue Jan 10, 2025 · 0 comments
Open

Auto-wildcard for cvarlist #448

Gelmo opened this issue Jan 10, 2025 · 0 comments

Comments

@Gelmo
Copy link
Member

Gelmo commented Jan 10, 2025

Adjust the cvarlist command so it wraps the provided arg in wildcards. For example, it would be nice to do cvarlist color instead of cvarlist *color*

source/qcommon/cvar.c:

/*
* Cvar_List_f
*/
static void Cvar_List_f( void )
{
        struct trie_dump_s *dump = NULL;
        unsigned int i;
        char *pattern;

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

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

        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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant