From 9fdd1d9e170a42a93dac379e5b85181adea4588c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 Feb 2020 00:43:13 +0100 Subject: [PATCH] - continued work on Blood save state * save and restore the ambient sound state * removed a few unused global variables * removed unused code from choke.cpp --- source/blood/src/asound.cpp | 33 ++++++++++++++++++++++++++++++ source/blood/src/blood.cpp | 7 ------- source/blood/src/blood.h | 5 ----- source/blood/src/choke.cpp | 38 ----------------------------------- source/blood/src/choke.h | 2 -- source/blood/src/loadsave.cpp | 3 ++- 6 files changed, 35 insertions(+), 53 deletions(-) diff --git a/source/blood/src/asound.cpp b/source/blood/src/asound.cpp index 1604319ff..fd8899c30 100644 --- a/source/blood/src/asound.cpp +++ b/source/blood/src/asound.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "resource.h" #include "sound.h" +#include "loadsave.h" #include "sound/s_soundinternal.h" BEGIN_BLD_NS @@ -151,4 +152,36 @@ void ambInit(void) } } +class ASoundLoadSave : public LoadSave +{ + virtual void Load(void); + virtual void Save(void); +}; + +void ASoundLoadSave::Load(void) +{ + for (auto &amb : ambChannels) + { + Read(&amb.check, sizeof(amb.check)); + amb.soundID = FSoundID(amb.check); + amb.distance = 0; + } +} + +void ASoundLoadSave::Save(void) +{ + for (auto &amb : ambChannels) + { + Write(&amb.check, sizeof(amb.check)); + } +} + +static ASoundLoadSave *myLoadSave; + +void ASoundLoadSaveConstruct(void) +{ + myLoadSave = new ASoundLoadSave(); +} + + END_BLD_NS diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index ee003c60d..c46ff6734 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -77,8 +77,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -int32_t gNoSetup = 0, gCommandSetup = 0; - INPUT_MODE gInputMode; #ifdef USE_QHEAP @@ -103,12 +101,9 @@ int gChokeCounter = 0; double g_gameUpdateTime, g_gameUpdateAndDrawTime; double g_gameUpdateAvgTime = 0.001; -int gSaveGameNum; bool gQuitGame; int gQuitRequest; bool gPaused; -bool gSaveGameActive; -int gCacheMiss; enum gametokens { @@ -669,7 +664,6 @@ void StartLevel(GAMEOPTIONS *gameOptions) sfxSetReverb(0); ambInit(); sub_79760(); - gCacheMiss = 0; gFrame = 0; gChokeCounter = 0; if (!gDemo.at1) @@ -719,7 +713,6 @@ void StartNetworkLevel(void) StartLevel(&gGameOptions); } -int gDoQuickSave = 0; void LocalKeys(void) { diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 01e93b5bb..1a1837fdf 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -51,7 +51,6 @@ enum INPUT_MODE { }; extern INPUT_MODE gInputMode; -extern int32_t gNoSetup; extern short BloodVersion; extern int gNetPlayers; extern bool gRestartGame; @@ -60,14 +59,10 @@ extern double g_gameUpdateTime, g_gameUpdateAndDrawTime; extern double g_gameUpdateAvgTime; extern int blood_globalflags; -extern int gSaveGameNum; extern bool gPaused; -extern bool gSaveGameActive; extern bool gSavingGame; extern bool gQuitGame; extern int gQuitRequest; -extern int gCacheMiss; -extern int gDoQuickSave; void QuitGame(void); void PreloadCache(void); diff --git a/source/blood/src/choke.cpp b/source/blood/src/choke.cpp index 1d3c7011b..7af6bb86f 100644 --- a/source/blood/src/choke.cpp +++ b/source/blood/src/choke.cpp @@ -36,26 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -void CChoke::sub_83F54(char *a1, int _x, int _y, void (*a2)(PLAYER*)) -{ - at14 = _x; - at18 = _y; - at0 = a1; - at1c = a2; - if (!at4 && at0) - { - at4 = gSysRes.Lookup(at0, "QAV"); - if (!at4) - ThrowError("Could not load QAV %s\n", at0); - at8 = (QAV*)gSysRes.Lock(at4); - at8->nSprite = -1; - at8->x = at14; - at8->y = at18; - at8->Preload(); - sub_84218(); - } -} - void CChoke::sub_83ff0(int a1, void(*a2)(PLAYER*)) { at0 = NULL; @@ -74,24 +54,6 @@ void CChoke::sub_83ff0(int a1, void(*a2)(PLAYER*)) } } -void CChoke::sub_84080(char *a1, void(*a2)(PLAYER*)) -{ - at0 = a1; - at1c = a2; - if (!at4 && at0) - { - at4 = gSysRes.Lookup(at0, "QAV"); - if (!at4) - ThrowError("Could not load QAV %s\n", at0); - at8 = (QAV*)gSysRes.Lock(at4); - at8->nSprite = -1; - at8->x = at14; - at8->y = at18; - at8->Preload(); - sub_84218(); - } -} - void CChoke::sub_84110(int x, int y) { if (!at4) diff --git a/source/blood/src/choke.h b/source/blood/src/choke.h index d8e1c183c..5cd5d0b4a 100644 --- a/source/blood/src/choke.h +++ b/source/blood/src/choke.h @@ -43,9 +43,7 @@ public: at14 = 0; at18 = 0; }; - void sub_83F54(char *a1, int _x, int _y, void(*a2)(PLAYER*)); void sub_83ff0(int a1, void(*a2)(PLAYER*)); - void sub_84080(char *a1, void(*a2)(PLAYER*)); void sub_84110(int x, int y); void sub_84218(); char *at0; diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 0fdc4852a..5b3956321 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -565,7 +565,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node) } gFrameTicks = 0; gFrame = 0; - gCacheMiss = 0; gFrameRate = 0; totalclock = 0; gPaused = 0; @@ -835,6 +834,7 @@ void ViewLoadSaveConstruct(void); void WarpLoadSaveConstruct(void); void WeaponLoadSaveConstruct(void); void NNLoadSaveConstruct(void); +void ASoundLoadSaveConstruct(void); void LoadSaveSetup(void) { @@ -854,6 +854,7 @@ void LoadSaveSetup(void) WarpLoadSaveConstruct(); WeaponLoadSaveConstruct(); NNLoadSaveConstruct(); + ASoundLoadSaveConstruct(); } END_BLD_NS