Skip to content

Commit 48d9211

Browse files
committed
cvarlist_rd concommand
works on server, preferably need someone to test on client (client compilation doesnt work for me since a year ago, lazy to solve)
1 parent 4bb0be7 commit 48d9211

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

src/game/client/swarm/rd_convar_hacks.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,89 @@ static class CRD_Convar_Hacks final : public CAutoGameSystem
190190
pConVar->SetValue( szNewDefault );
191191
}
192192
} s_RD_Convar_Hacks;
193+
194+
195+
196+
static bool ConCommandBaseSortFunc( const ConCommandBase* const &hLeftCMD, const ConCommandBase* const &hRightCMD )
197+
{
198+
const char* szLeftCMDName = hLeftCMD->GetName();
199+
const char* szRightCMDName = hRightCMD->GetName();
200+
201+
if ( *szLeftCMDName == '-' || *szLeftCMDName == '+' )
202+
szLeftCMDName++;
203+
if ( *szRightCMDName == '-' || *szRightCMDName == '+' )
204+
szRightCMDName++;
205+
206+
return ( Q_stricmp( szLeftCMDName, szRightCMDName ) < 0 );
207+
}
208+
209+
CON_COMMAND( cvarlist_rd, "Prints a list of all cvars, with correct values (unlike normal cvarlist)." )
210+
{
211+
ConMsg( "cvar list\n--------------\n" );
212+
213+
const ConCommandBase* pCMD;
214+
ICvar::Iterator cvariterator( g_pCVar );
215+
CUtlRBTree< const ConCommandBase* > cvarsorted( 0, 0, ConCommandBaseSortFunc );
216+
217+
for ( cvariterator.SetFirst(); cvariterator.IsValid(); cvariterator.Next() )
218+
{
219+
pCMD = cvariterator.Get();
220+
221+
if ( pCMD->IsFlagSet( FCVAR_HIDDEN ) || pCMD->IsFlagSet( FCVAR_DEVELOPMENTONLY ) )
222+
continue;
223+
224+
cvarsorted.Insert( pCMD );
225+
}
226+
227+
for ( int i = cvarsorted.FirstInorder(); i != cvarsorted.InvalidIndex(); i = cvarsorted.NextInorder( i ) )
228+
{
229+
pCMD = cvarsorted[ i ];
230+
if ( pCMD->IsCommand() )
231+
{
232+
char tempbuff[512]{};
233+
ConMsg( "%-40s : %-8s : %-16s : %s\n", pCMD->GetName(), "cmd", "", pCMD->GetHelpText() );
234+
}
235+
else
236+
{
237+
char szFullFlags[128]{};
238+
239+
constexpr static const char* s_szFlagDesc[] =
240+
{
241+
"",
242+
"",
243+
"sv",
244+
"cl",
245+
"",
246+
"prot",
247+
"sp",
248+
"a",
249+
"nf",
250+
"user",
251+
"print",
252+
"log",
253+
"numeric",
254+
"rep",
255+
"cheat",
256+
"",
257+
"demo",
258+
"norecord",
259+
};
260+
261+
for ( int c = 2; c < ARRAYSIZE( s_szFlagDesc ); ++c )
262+
{
263+
char szFlag[32]{};
264+
265+
if ( pCMD->IsFlagSet( 1<<c ) && sizeof( s_szFlagDesc[c] ) != sizeof( "" ) )
266+
{
267+
Q_snprintf( szFlag, sizeof( szFlag ), ", %s", s_szFlagDesc[c] );
268+
Q_strncat( szFullFlags, szFlag, sizeof( szFullFlags ), COPY_ALL_CHARACTERS );
269+
}
270+
}
271+
272+
char tempbuff[512]{};
273+
ConMsg( "%-40s : %-8s : %-16s : %s\n", pCMD->GetName(), dynamic_cast< const ConVar* >( pCMD )->GetString(), szFullFlags, pCMD->GetHelpText() );
274+
}
275+
}
276+
277+
ConMsg("--------------\n%3i total convars/concommands\n", cvarsorted.Count() );
278+
}

0 commit comments

Comments
 (0)