- fixed SoundEngine::isValidSoundId.

This never accounted for linked and random sounds. It never got noticed because it never was used to validate anything essential before.
This commit is contained in:
Christoph Oelckers 2022-11-25 10:27:54 +01:00
parent 8206c29edf
commit 473221bb33
2 changed files with 8 additions and 1 deletions

View file

@ -357,7 +357,7 @@ public:
bool isValidSoundId(FSoundID sid)
{
int id = sid.index();
return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && S_sfx[id].lumpnum != sfx_empty;
return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && (S_sfx[id].lumpnum != sfx_empty || S_sfx[id].bRandomHeader || S_sfx[id].link != sfxinfo_t::NO_LINK);
}
template<class func> bool EnumerateChannels(func callback)

View file

@ -316,9 +316,16 @@ public:
// Returns a reference to the last element
T &Last() const
{
assert(Count > 0);
return Array[Count-1];
}
T SafeGet (size_t index, const T& defaultval) const
{
if (index <= Count) return Array[index];
else return defaultval;
}
// returns address of first element
T *Data() const
{