mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- fixed linked sound resolving
Hash indices and sound ids were used interchangeably but they are different entities https://forum.zdoom.org/viewtopic.php?t=66618
This commit is contained in:
parent
1a19dbb52f
commit
c3ede69d16
3 changed files with 16 additions and 14 deletions
|
@ -88,7 +88,7 @@ class DoomSoundEngine : public SoundEngine
|
||||||
bool ValidatePosVel(int sourcetype, const void* source, const FVector3& pos, const FVector3& vel);
|
bool ValidatePosVel(int sourcetype, const void* source, const FVector3& pos, const FVector3& vel);
|
||||||
TArray<uint8_t> ReadSound(int lumpnum);
|
TArray<uint8_t> ReadSound(int lumpnum);
|
||||||
int PickReplacement(int refid);
|
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:
|
public:
|
||||||
DoomSoundEngine() = default;
|
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;
|
AActor *src;
|
||||||
if (type != SOURCE_Actor) src = nullptr;
|
if (type != SOURCE_Actor) src = nullptr;
|
||||||
else src = (AActor*)ent;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -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.
|
// Random sounds attenuate based on the original (random) sound as well as the chosen one.
|
||||||
attenuation *= sfx->Attenuation;
|
attenuation *= sfx.Attenuation;
|
||||||
return PickReplacement (sfx->index);
|
return PickReplacement (soundid);
|
||||||
}
|
}
|
||||||
else
|
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
|
// Resolve player sounds, random sounds, and aliases
|
||||||
while (sfx->link != sfxinfo_t::NO_LINK)
|
while (sfx->link != sfxinfo_t::NO_LINK)
|
||||||
{
|
{
|
||||||
auto newid = ResolveSound(source, type, sfx, attenuation);
|
sound_id = ResolveSound(source, type, sound_id, attenuation);
|
||||||
if (newid < 0) return nullptr;
|
if (sound_id < 0) return nullptr;
|
||||||
auto newsfx = &S_sfx[newid];
|
auto newsfx = &S_sfx[sound_id];
|
||||||
if (newsfx != sfx)
|
if (newsfx != sfx)
|
||||||
{
|
{
|
||||||
if (near_limit < 0)
|
if (near_limit < 0)
|
||||||
|
|
|
@ -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);
|
bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel);
|
||||||
virtual TArray<uint8_t> ReadSound(int lumpnum) = 0;
|
virtual TArray<uint8_t> ReadSound(int lumpnum) = 0;
|
||||||
protected:
|
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:
|
public:
|
||||||
virtual ~SoundEngine() = default;
|
virtual ~SoundEngine() = default;
|
||||||
|
|
Loading…
Reference in a new issue