- sort CVAR output in config alphabetically instead of randomly dumping them in their internal order.

This commit is contained in:
Christoph Oelckers 2019-10-27 08:17:29 +01:00 committed by drfrag
parent 2351ae8317
commit 2ec4331afe

View file

@ -1740,9 +1740,17 @@ 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) void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
{ {
FBaseCVar *cvar = CVars; FBaseCVar *cvar = CVars;
TArray<FBaseCVar*> cvarlist;
while (cvar) while (cvar)
{ {
@ -1750,13 +1758,18 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE)) (CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE))
== filter) == filter)
{ {
const char *const value = (cvar->Flags & CVAR_ISDEFAULT) cvarlist.Push(cvar);
? cvar->GetGenericRep(CVAR_String).String
: cvar->SafeValue.GetChars();
f->SetValueForKey(cvar->GetName(), value);
} }
cvar = cvar->m_Next; 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); EXTERN_CVAR(Bool, sv_cheats);