From 478a8325153d418ec85f973e8ded9d869e0c84e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 28 Oct 2023 09:20:56 +0200 Subject: [PATCH] fixed handling of DSDHacked sound replacement in the index range between the regular sounds and the MBF21 extensions. --- src/gamedata/d_dehacked.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index b0231627c9..78efd6c839 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -152,9 +152,12 @@ static PClassActor* FindInfoName(int index, bool mustexist = false) static FSoundID DehFindSound(int index,bool mustexist = false) { if (index < 0) return NO_SOUND; - if (index < (int) SoundMap.Size()) return SoundMap[index]; - FStringf name("~dsdhacked/#%d", index); - if (dsdhacked && !mustexist) return soundEngine->FindSoundTentative(name.GetChars()); + if (index < (int) SoundMap.Size() && SoundMap[index].isvalid()) return SoundMap[index]; + if (dsdhacked && !mustexist) + { + FStringf name("~dsdhacked/#%d", index); + return soundEngine->FindSoundTentative(name.GetChars()); + } return NO_SOUND; } @@ -1476,7 +1479,7 @@ static int PatchThing (int thingy) } else if (stricmp (Line1 + linelen - 6, " sound") == 0) { - FSoundID snd = DehFindSound(val - 1); + FSoundID snd = DehFindSound(val - 1, false); if (snd == NO_SOUND) // This won't trigger for dsdhacked patches! {