diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index 9f7bd6acd..b5b4fbb74 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -88,7 +88,7 @@ class DoomSoundEngine : public SoundEngine bool ValidatePosVel(int sourcetype, const void* source, const FVector3& pos, const FVector3& vel); TArray ReadSound(int lumpnum); int PickReplacement(int refid); - int ResolveSound(const void *ent, int type, sfxinfo_t *sfx, float &attenuation); + FSoundID ResolveSound(const void *ent, int type, FSoundID soundid, float &attenuation) override; public: DoomSoundEngine() = default; @@ -305,16 +305,16 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound) // //========================================================================== -int DoomSoundEngine::ResolveSound(const void * ent, int type, sfxinfo_t *sfx, float &attenuation) +FSoundID DoomSoundEngine::ResolveSound(const void * ent, int type, FSoundID soundid, float &attenuation) { - if (isPlayerReserve(sfx->index)) + if (isPlayerReserve(soundid)) { AActor *src; if (type != SOURCE_Actor) src = nullptr; else src = (AActor*)ent; - return S_FindSkinnedSound(src, sfx->index); + return S_FindSkinnedSound(src, soundid); } - return SoundEngine::ResolveSound(ent, type, sfx, attenuation); + return SoundEngine::ResolveSound(ent, type, soundid, attenuation); } //========================================================================== diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 414120222..1f90c3707 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -350,17 +350,19 @@ bool SoundEngine::ValidatePosVel(const FSoundChan* const chan, const FVector3& p // //========================================================================== -int SoundEngine::ResolveSound(const void *, int, sfxinfo_t *sfx, float &attenuation) +FSoundID SoundEngine::ResolveSound(const void *, int, FSoundID soundid, float &attenuation) { - if (sfx->bRandomHeader) + const sfxinfo_t &sfx = S_sfx[soundid]; + + if (sfx.bRandomHeader) { // Random sounds attenuate based on the original (random) sound as well as the chosen one. - attenuation *= sfx->Attenuation; - return PickReplacement (sfx->index); + attenuation *= sfx.Attenuation; + return PickReplacement (soundid); } else { - return sfx->link; + return sfx.link; } } @@ -422,9 +424,9 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, // Resolve player sounds, random sounds, and aliases while (sfx->link != sfxinfo_t::NO_LINK) { - auto newid = ResolveSound(source, type, sfx, attenuation); - if (newid < 0) return nullptr; - auto newsfx = &S_sfx[newid]; + sound_id = ResolveSound(source, type, sound_id, attenuation); + if (sound_id < 0) return nullptr; + auto newsfx = &S_sfx[sound_id]; if (newsfx != sfx) { if (near_limit < 0) diff --git a/src/sound/s_soundinternal.h b/src/sound/s_soundinternal.h index 13150e630..38502d192 100644 --- a/src/sound/s_soundinternal.h +++ b/src/sound/s_soundinternal.h @@ -264,7 +264,7 @@ private: bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel); virtual TArray ReadSound(int lumpnum) = 0; protected: - virtual int ResolveSound(const void *ent, int srctype, sfxinfo_t *sfx, float &attenuation); + virtual FSoundID ResolveSound(const void *ent, int srctype, FSoundID soundid, float &attenuation); public: virtual ~SoundEngine() = default;