From 77a2bcb958dd67703373d6a5ab16424e4ab0b5c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers <coelckers@users.noreply.github.com> Date: Fri, 18 Sep 2020 00:33:18 +0200 Subject: [PATCH] - SW: make ambients start properly. This fell victim to some fudging code that was needed to avoid crashes with the original game loop. All that fudging could easily be removed now because nothing of it is needed anymore. --- source/sw/src/game.cpp | 9 --------- source/sw/src/save.cpp | 6 +++--- source/sw/src/sounds.cpp | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 5165c72ce..7771cb757 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -620,15 +620,6 @@ void GameInterface::NewGame(MapRecord *map, int skill) void GameInterface::Ticker(void) { - if (SavegameLoaded) - { - InitLevelGlobals(); - SavegameLoaded = false; - // contains what is needed from calls below - if (snd_ambience) - StartAmbientSound(); - } - int i; TRAVERSE_CONNECT(i) { diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 966e88595..b7e15ada6 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -66,6 +66,8 @@ TO DO ////////////////////////////////////////////////////////////////////////////// */ +void InitLevelGlobals(void); + extern int lastUpdate; extern char SaveGameDescr[10][80]; extern int PlayClock; @@ -641,8 +643,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) } -extern bool SavegameLoaded; - bool GameInterface::LoadGame(FSaveGameNode* sv) { MFILE_READ fil; @@ -1075,7 +1075,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) DoPlayerDivePalette(Player+myconnectindex); DoPlayerNightVisionPalette(Player+myconnectindex); - SavegameLoaded = true; + InitLevelGlobals(); return true; } diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 3837d6957..934bdbf41 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -280,9 +280,9 @@ void InitAmbient(int num, SPRITEp sp) void StartAmbientSound(void) { - short i, nexti; + int i, nexti; - if (gamestate != GS_LEVEL || !SoundEnabled()) return; // Don't restart ambience if no level is active! Will crash game. + if (!SoundEnabled()) return; TRAVERSE_SPRITE_STAT(headspritestat[STAT_AMBIENT], i, nexti) {