- fixed CVAR saving.

- do not use snd_enabled for temporarily hacking the sound state. userConfig.noSound is better suited for such antics.
This commit is contained in:
Christoph Oelckers 2019-11-02 21:21:48 +01:00
parent e35a5bac79
commit cfbcf33c8c
8 changed files with 32 additions and 30 deletions

View file

@ -39,6 +39,7 @@
#include "configfile.h" #include "configfile.h"
#include "c_console.h" #include "c_console.h"
#include "gamecvars.h"
//#include "cmdlib.h" //#include "cmdlib.h"
//#include "c_dispatch.h" //#include "c_dispatch.h"
@ -1410,9 +1411,10 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
qsort(cvarlist.Data(), cvarlist.Size(), sizeof(FBaseCVar*), cvarcmp); qsort(cvarlist.Data(), cvarlist.Size(), sizeof(FBaseCVar*), cvarcmp);
for (auto cvar : cvarlist) for (auto cvar : cvarlist)
{ {
const char* const value = (cvar->Flags & CVAR_ISDEFAULT) // This does not work with the menus at use here.
? cvar->GetGenericRep(CVAR_String).String const char* const value = //(cvar->Flags & CVAR_ISDEFAULT)
: cvar->SafeValue.GetChars(); /*?*/ cvar->GetGenericRep(CVAR_String).String
/*: cvar->SafeValue.GetChars()*/;
f->SetValueForKey(cvar->GetName(), value); f->SetValueForKey(cvar->GetName(), value);
} }
} }

View file

@ -1457,10 +1457,10 @@ ACTOR_STATIC void G_MoveFX(void)
int32_t const spriteHitag = (uint16_t)pSprite->hitag; int32_t const spriteHitag = (uint16_t)pSprite->hitag;
auto const pPlayer = g_player[screenpeek].ps; auto const pPlayer = g_player[screenpeek].ps;
if (T2(spriteNum) != snd_enabled) if (T2(spriteNum) != (int)SoundEnabled())
{ {
// If sound playback was toggled, restart. // If sound playback was toggled, restart.
T2(spriteNum) = snd_enabled; T2(spriteNum) = SoundEnabled();
T1(spriteNum) = 0; T1(spriteNum) = 0;
} }

View file

@ -69,8 +69,8 @@ void Demo_PrepareWarp(void)
{ {
if (!g_demo_paused) if (!g_demo_paused)
{ {
g_demo_soundToggle = snd_enabled; g_demo_soundToggle = userConfig.nosound;
snd_enabled = 0; userConfig.nosound = true;
} }
FX_StopAllSounds(); FX_StopAllSounds();
@ -403,8 +403,8 @@ static void Demo_SetupProfile(void)
{ {
g_demo_profile *= -1; // now >0: profile for real g_demo_profile *= -1; // now >0: profile for real
g_demo_soundToggle = snd_enabled; g_demo_soundToggle = userConfig.nosound;
snd_enabled = 0; // restored by Demo_FinishProfile() userConfig.nosound = true; // restored by Demo_FinishProfile()
Bmemset(&g_prof, 0, sizeof(g_prof)); Bmemset(&g_prof, 0, sizeof(g_prof));
@ -420,7 +420,7 @@ static void Demo_FinishProfile(void)
double gms=g_prof.totalgamems; double gms=g_prof.totalgamems;
double dms1=g_prof.totalroomsdrawms, dms2=g_prof.totalrestdrawms; double dms1=g_prof.totalroomsdrawms, dms2=g_prof.totalrestdrawms;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
if (nt > 0) if (nt > 0)
{ {
@ -689,7 +689,7 @@ nextdemo_nomenu:
if (g_demo_goalCnt>0) if (g_demo_goalCnt>0)
{ {
g_demo_goalCnt=0; g_demo_goalCnt=0;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
} }
if (Demo_IsProfiling()) // don't reset g_demo_profile if it's < 0 if (Demo_IsProfiling()) // don't reset g_demo_profile if it's < 0
@ -731,10 +731,10 @@ nextdemo_nomenu:
} }
else else
{ {
int32_t k = snd_enabled; int32_t k = userConfig.nosound;
snd_enabled = 0; userConfig.nosound = true;
G_DoMoveThings(); G_DoMoveThings();
snd_enabled = k; userConfig.nosound = k;
} }
ototalclock += TICSPERFRAME; ototalclock += TICSPERFRAME;
@ -749,7 +749,7 @@ nextdemo_nomenu:
if (g_demo_cnt>=g_demo_goalCnt) if (g_demo_cnt>=g_demo_goalCnt)
{ {
g_demo_goalCnt = 0; g_demo_goalCnt = 0;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
} }
} }
} }

View file

@ -1486,7 +1486,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2)
case USERDEFS_VM_PLAYER: labelNum = vm.playerNum; break; case USERDEFS_VM_PLAYER: labelNum = vm.playerNum; break;
case USERDEFS_VM_SPRITE: labelNum = vm.spriteNum; break; case USERDEFS_VM_SPRITE: labelNum = vm.spriteNum; break;
case USERDEFS_VM_DISTANCE: labelNum = vm.playerDist; break; case USERDEFS_VM_DISTANCE: labelNum = vm.playerDist; break;
case USERDEFS_SOUNDTOGGLE: labelNum = snd_enabled; break; case USERDEFS_SOUNDTOGGLE: labelNum = SoundEnabled(); break;
case USERDEFS_GAMETEXT_TRACKING: labelNum = MF_Bluefont.between.x; break; case USERDEFS_GAMETEXT_TRACKING: labelNum = MF_Bluefont.between.x; break;
case USERDEFS_MENUTEXT_TRACKING: labelNum = MF_Redfont.between.x; break; case USERDEFS_MENUTEXT_TRACKING: labelNum = MF_Redfont.between.x; break;
case USERDEFS_MAXSPRITESONSCREEN: labelNum = maxspritesonscreen; break; case USERDEFS_MAXSPRITESONSCREEN: labelNum = maxspritesonscreen; break;

View file

@ -2399,7 +2399,7 @@ static void postloadplayer(int32_t savegamep)
for (SPRITES_OF(STAT_FX, i)) for (SPRITES_OF(STAT_FX, i))
if (sprite[i].picnum == MUSICANDSFX) if (sprite[i].picnum == MUSICANDSFX)
{ {
T2(i) = snd_enabled; T2(i) = SoundEnabled();
T1(i) = 0; T1(i) = 0;
} }

View file

@ -1324,10 +1324,10 @@ ACTOR_STATIC void G_MoveFX(void)
int32_t const spriteHitag = (uint16_t)pSprite->hitag; int32_t const spriteHitag = (uint16_t)pSprite->hitag;
DukePlayer_t *const pPlayer = g_player[screenpeek].ps; DukePlayer_t *const pPlayer = g_player[screenpeek].ps;
if (T2(spriteNum) != snd_enabled) if (T2(spriteNum) != (int)SoundEnabled())
{ {
// If sound playback was toggled, restart. // If sound playback was toggled, restart.
T2(spriteNum) = snd_enabled; T2(spriteNum) = SoundEnabled();
T1(spriteNum) = 0; T1(spriteNum) = 0;
} }

View file

@ -72,8 +72,8 @@ void Demo_PrepareWarp(void)
{ {
if (!g_demo_paused) if (!g_demo_paused)
{ {
g_demo_soundToggle = snd_enabled; g_demo_soundToggle = userConfig.nosound;
snd_enabled = 0; userConfig.nosound = true;
} }
FX_StopAllSounds(); FX_StopAllSounds();
@ -406,8 +406,8 @@ static void Demo_SetupProfile(void)
{ {
g_demo_profile *= -1; // now >0: profile for real g_demo_profile *= -1; // now >0: profile for real
g_demo_soundToggle = snd_enabled; g_demo_soundToggle = userConfig.nosound;
snd_enabled = 0; // restored by Demo_FinishProfile() userConfig.nosound = true; // restored by Demo_FinishProfile()
Bmemset(&g_prof, 0, sizeof(g_prof)); Bmemset(&g_prof, 0, sizeof(g_prof));
@ -423,7 +423,7 @@ static void Demo_FinishProfile(void)
double gms=g_prof.totalgamems; double gms=g_prof.totalgamems;
double dms1=g_prof.totalroomsdrawms, dms2=g_prof.totalrestdrawms; double dms1=g_prof.totalroomsdrawms, dms2=g_prof.totalrestdrawms;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
if (nt > 0) if (nt > 0)
{ {
@ -692,7 +692,7 @@ nextdemo_nomenu:
if (g_demo_goalCnt>0) if (g_demo_goalCnt>0)
{ {
g_demo_goalCnt=0; g_demo_goalCnt=0;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
} }
if (Demo_IsProfiling()) // don't reset g_demo_profile if it's < 0 if (Demo_IsProfiling()) // don't reset g_demo_profile if it's < 0
@ -736,10 +736,10 @@ nextdemo_nomenu:
} }
else else
{ {
int32_t k = snd_enabled; int32_t k = userConfig.nosound;
snd_enabled = 0; userConfig.nosound = true;
G_DoMoveThings(); G_DoMoveThings();
snd_enabled = k; userConfig.nosound = k;
} }
ototalclock += TICSPERFRAME; ototalclock += TICSPERFRAME;
@ -754,7 +754,7 @@ nextdemo_nomenu:
if (g_demo_cnt>=g_demo_goalCnt) if (g_demo_cnt>=g_demo_goalCnt)
{ {
g_demo_goalCnt = 0; g_demo_goalCnt = 0;
snd_enabled = g_demo_soundToggle; userConfig.nosound = g_demo_soundToggle;
} }
} }
} }

View file

@ -1892,7 +1892,7 @@ static void postloadplayer(int32_t savegamep)
for (SPRITES_OF(STAT_FX, i)) for (SPRITES_OF(STAT_FX, i))
if (sprite[i].picnum == MUSICANDSFX) if (sprite[i].picnum == MUSICANDSFX)
{ {
T2(i) = snd_enabled; T2(i) = SoundEnabled();
T1(i) = 0; T1(i) = 0;
} }