mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- Use a TArray for backing up cvars overwritten by a demo.
SVN r4184 (trunk)
This commit is contained in:
parent
b096c7a82f
commit
573b6992ce
2 changed files with 16 additions and 36 deletions
|
@ -1390,58 +1390,42 @@ void C_ReadCVars (BYTE **demo_p)
|
||||||
*demo_p += strlen (*((char **)demo_p)) + 1;
|
*demo_p += strlen (*((char **)demo_p)) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct backup_s
|
struct FCVarBackup
|
||||||
{
|
{
|
||||||
char *name, *string;
|
FString Name, String;
|
||||||
} CVarBackups[MAX_DEMOCVARS];
|
};
|
||||||
|
static TArray<FCVarBackup> CVarBackups;
|
||||||
static int numbackedup = 0;
|
|
||||||
|
|
||||||
void C_BackupCVars (void)
|
void C_BackupCVars (void)
|
||||||
{
|
{
|
||||||
struct backup_s *backup = CVarBackups;
|
assert(CVarBackups.Size() == 0);
|
||||||
FBaseCVar *cvar = CVars;
|
CVarBackups.Clear();
|
||||||
|
|
||||||
while (cvar)
|
FCVarBackup backup;
|
||||||
|
|
||||||
|
for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||||
{
|
{
|
||||||
if ((cvar->Flags & (CVAR_SERVERINFO|CVAR_DEMOSAVE))
|
if ((cvar->Flags & (CVAR_SERVERINFO|CVAR_DEMOSAVE)) && !(cvar->Flags & CVAR_LATCH))
|
||||||
&& !(cvar->Flags & CVAR_LATCH))
|
|
||||||
{
|
{
|
||||||
if (backup == &CVarBackups[MAX_DEMOCVARS])
|
backup.Name = cvar->GetName();
|
||||||
I_Error ("C_BackupDemoCVars: Too many cvars to save (%d)", MAX_DEMOCVARS);
|
backup.String = cvar->GetGenericRep(CVAR_String).String;
|
||||||
backup->name = copystring (cvar->GetName());
|
CVarBackups.Push(backup);
|
||||||
backup->string = copystring (cvar->GetGenericRep (CVAR_String).String);
|
|
||||||
backup++;
|
|
||||||
}
|
}
|
||||||
cvar = cvar->m_Next;
|
|
||||||
}
|
}
|
||||||
numbackedup = int(backup - CVarBackups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_RestoreCVars (void)
|
void C_RestoreCVars (void)
|
||||||
{
|
{
|
||||||
struct backup_s *backup = CVarBackups;
|
for (unsigned int i = 0; i < CVarBackups.Size(); ++i)
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = numbackedup; i; i--, backup++)
|
|
||||||
{
|
{
|
||||||
cvar_set (backup->name, backup->string);
|
cvar_set(CVarBackups[i].Name, CVarBackups[i].String);
|
||||||
}
|
}
|
||||||
C_ForgetCVars();
|
C_ForgetCVars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_ForgetCVars (void)
|
void C_ForgetCVars (void)
|
||||||
{
|
{
|
||||||
struct backup_s *backup = CVarBackups;
|
CVarBackups.Clear();
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = numbackedup; i; i--, backup++)
|
|
||||||
{
|
|
||||||
delete[] backup->name;
|
|
||||||
delete[] backup->string;
|
|
||||||
backup->name = backup->string = NULL;
|
|
||||||
}
|
|
||||||
numbackedup = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev)
|
FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev)
|
||||||
|
|
|
@ -404,10 +404,6 @@ inline FBaseCVar *cvar_forceset (const char *var_name, const BYTE *value) { retu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Maximum number of cvars that can be saved across a demo. If you need
|
|
||||||
// to save more, bump this up.
|
|
||||||
#define MAX_DEMOCVARS 32
|
|
||||||
|
|
||||||
// Restore demo cvars. Called after demo playback to restore all cvars
|
// Restore demo cvars. Called after demo playback to restore all cvars
|
||||||
// that might possibly have been changed during the course of demo playback.
|
// that might possibly have been changed during the course of demo playback.
|
||||||
void C_RestoreCVars (void);
|
void C_RestoreCVars (void);
|
||||||
|
|
Loading…
Reference in a new issue