From 5dfb0c902ac90282fef73c1dfd325cb1c593210e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 27 May 2023 09:12:51 +0200 Subject: [PATCH] - consolidation of sound init code. --- source/core/raze_sound.cpp | 17 +++++++++++++++++ source/core/raze_sound.h | 1 + source/games/duke/src/sounds.cpp | 16 ---------------- source/games/duke/src/sounds.h | 1 - source/games/sw/src/game.cpp | 2 +- source/games/sw/src/sounds.cpp | 14 -------------- source/games/sw/src/sounds.h | 1 - 7 files changed, 19 insertions(+), 33 deletions(-) diff --git a/source/core/raze_sound.cpp b/source/core/raze_sound.cpp index 14875222f..19a9343ff 100644 --- a/source/core/raze_sound.cpp +++ b/source/core/raze_sound.cpp @@ -45,6 +45,7 @@ #include "gamecontrol.h" #include "build.h" #include "coreactor.h" +#include "g_input.h" extern ReverbContainer* ForcedEnvironment; static int LastReverb; @@ -273,6 +274,22 @@ void S_SerializeSounds(FSerializer& arc) GSnd->UpdateSounds(); } +//========================================================================== +// +// +// +//========================================================================== + +void S_CacheAllSounds(void) +{ + for (unsigned i = 0; i < soundEngine->GetNumSounds(); i++) + { + soundEngine->CacheSound(FSoundID::fromInt(i)); + if ((i & 31) == 0) + I_GetEvent(); + } +} + //========================================================================== // // CCMD playsound diff --git a/source/core/raze_sound.h b/source/core/raze_sound.h index 3fe2674c2..2b5f24b95 100644 --- a/source/core/raze_sound.h +++ b/source/core/raze_sound.h @@ -34,6 +34,7 @@ int S_LookupSound(const char* fn); class FSerializer; void S_SerializeSounds(FSerializer& arc); int S_ReserveSoundSlot(const char* logicalname, int slotnum, int limit = 6); +void S_CacheAllSounds(void); class RazeSoundEngine : public SoundEngine { diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 362d77d7a..2a87fe696 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -157,22 +157,6 @@ TArray DukeSoundEngine::ReadSound(int lumpnum) // //========================================================================== -void S_CacheAllSounds(void) -{ - for(unsigned i = 0; i < soundEngine->GetNumSounds(); i++) - { - soundEngine->CacheSound(FSoundID::fromInt(i)); - if ((i & 31) == 0) - I_GetEvent(); - } -} - -//========================================================================== -// -// -// -//========================================================================== - int S_GetUserFlags(FSoundID soundid) { if (!soundEngine->isValidSoundId(soundid)) return 0; diff --git a/source/games/duke/src/sounds.h b/source/games/duke/src/sounds.h index 81af46f46..e8030eefe 100644 --- a/source/games/duke/src/sounds.h +++ b/source/games/duke/src/sounds.h @@ -39,7 +39,6 @@ void S_ChangeSoundPitch(FSoundID soundNum, DDukeActor* spriteNum, int pitchoffse int S_CheckActorSoundPlaying(DDukeActor* spriteNum, FSoundID soundNum, int channel = 0); int S_CheckSoundPlaying(FSoundID soundNum); -void S_CacheAllSounds(void); int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr, int m, int vo, float vol); void S_WorldTourMappingsForOldSounds(); void S_MenuSound(void); diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index c91450871..0ebc2998a 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -305,7 +305,7 @@ void GameInterface::app_init() LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information userConfig.AddDefs.reset(); - InitFX(); + S_CacheAllSounds(); } //--------------------------------------------------------------------------- diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 7f0423610..c5e5a201b 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -428,20 +428,6 @@ void GameInterface::StartSoundEngine() soundEngine = new SWSoundEngine; } -void InitFX(void) -{ - - auto &S_sfx = soundEngine->GetSounds(); - - soundEngine->HashSounds(); - for (auto& sfx : S_sfx) - { - soundEngine->CacheSound(&sfx); - } -} - - - //========================================================================== // // diff --git a/source/games/sw/src/sounds.h b/source/games/sw/src/sounds.h index 9efb1792e..0d9d8a507 100644 --- a/source/games/sw/src/sounds.h +++ b/source/games/sw/src/sounds.h @@ -72,7 +72,6 @@ void DeleteNoFollowSoundOwner(DSWActor*); inline bool CacheSound(int num, int type) { return false; } void COVER_SetReverb(int amt); void UnInitSound(void); -void InitFX(void); void StopFX(void); void StopSound(void); void StartAmbientSound(void);