mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-05-31 00:51:21 +00:00
- store CVARs non-destructively in savegames.
The old method using a single string with a backslash as separator is unable to handle anything with actual backslashes in the data. It now uses a JSON object with each CVAR being a separate key.
This commit is contained in:
parent
3e9a43d7f0
commit
e3eae62af2
4 changed files with 52 additions and 6 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "d_player.h"
|
||||
#include "v_video.h"
|
||||
#include "d_netinf.h"
|
||||
#include "serializer.h"
|
||||
|
||||
#include "menu/menu.h"
|
||||
#include "vm.h"
|
||||
|
@ -1261,6 +1262,47 @@ FString C_GetMassCVarString (uint32_t filter, bool compact)
|
|||
return dump;
|
||||
}
|
||||
|
||||
void C_SerializeCVars(FSerializer &arc, const char *label, uint32_t filter)
|
||||
{
|
||||
FBaseCVar* cvar;
|
||||
FString dump;
|
||||
|
||||
if (arc.BeginObject(label))
|
||||
{
|
||||
if (arc.isWriting())
|
||||
{
|
||||
for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||
{
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_NOSAVEGAME)))
|
||||
{
|
||||
UCVarValue val = cvar->GetGenericRep(CVAR_String);
|
||||
char* c = const_cast<char*>(val.String);
|
||||
arc(cvar->GetName(), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||
{
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_NOSAVEGAME)))
|
||||
{
|
||||
UCVarValue val;
|
||||
char *c = nullptr;
|
||||
arc(cvar->GetName(), c);
|
||||
if (c != nullptr)
|
||||
{
|
||||
val.String = c;
|
||||
cvar->SetGenericRep(val, CVAR_String);
|
||||
delete[] c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
arc.EndObject();
|
||||
}
|
||||
}
|
||||
|
||||
void C_ReadCVars (uint8_t **demo_p)
|
||||
{
|
||||
char *ptr = *((char **)demo_p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue