Add manual config saving to CVar struct

Allows for calling to save custom cvars manually to ensure they're reliably stored. As is, the only way to ensure that cvars are saved is to safely/manually close out GZDoom, meaning if a crash occurs, that data is lost.

THis is very detrimental to mods/standalone projects that rely on CVars for storing custom data, and or data that transcends save games.
This commit is contained in:
Kaelan 2024-10-15 12:12:33 -06:00 committed by Ricardo Luís Vaz Silva
parent 70eb4b974d
commit 9d725276ac
2 changed files with 7 additions and 0 deletions

View file

@ -41,6 +41,7 @@
#include "c_cvars.h"
#include "c_bind.h"
#include "c_dispatch.h"
#include "m_misc.h"
#include "menu.h"
#include "vm.h"
@ -1032,6 +1033,11 @@ DEFINE_ACTION_FUNCTION(_CVar, FindCVar)
ACTION_RETURN_POINTER(FindCVar(name.GetChars(), nullptr));
}
DEFINE_ACTION_FUNCTION(_CVar, SaveConfig)
{
ACTION_RETURN_BOOL(M_SaveDefaults(nullptr));
}
//=============================================================================
//
//

View file

@ -689,6 +689,7 @@ struct CVar native
};
native static CVar FindCVar(Name name);
native static bool SaveConfig();
bool GetBool() { return GetInt(); }
native int GetInt();
native double GetFloat();