Skip to content
Permalink
Browse files

- sort CVAR output in config alphabetically instead of randomly dumpi…

…ng them in their internal order.
  • Loading branch information...
coelckers committed Oct 27, 2019
1 parent 8f7e902 commit d54a7de284e315101eb064d198170c88e29b66b7
Showing with 17 additions and 4 deletions.
  1. +17 −4 src/console/c_cvars.cpp
@@ -1534,23 +1534,36 @@ void C_SetCVarsToDefaults (void)
}
}

static int cvarcmp(const void* a, const void* b)
{
FBaseCVar** A = (FBaseCVar**)a;
FBaseCVar** B = (FBaseCVar**)b;
return strcmp((*A)->GetName(), (*B)->GetName());
}

void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
{
FBaseCVar *cvar = CVars;
TArray<FBaseCVar*> cvarlist;

while (cvar)
{
if ((cvar->Flags &
(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE))
== filter)
{
const char *const value = (cvar->Flags & CVAR_ISDEFAULT)
? cvar->GetGenericRep(CVAR_String).String
: cvar->SafeValue.GetChars();
f->SetValueForKey(cvar->GetName(), value);
cvarlist.Push(cvar);
}
cvar = cvar->m_Next;
}
qsort(cvarlist.Data(), cvarlist.Size(), sizeof(FBaseCVar*), cvarcmp);
for (auto cvar : cvarlist)
{
const char* const value = (cvar->Flags & CVAR_ISDEFAULT)
? cvar->GetGenericRep(CVAR_String).String
: cvar->SafeValue.GetChars();
f->SetValueForKey(cvar->GetName(), value);
}
}

EXTERN_CVAR(Bool, sv_cheats);

0 comments on commit d54a7de

Please sign in to comment.
You can’t perform that action at this time.