Skip to content

Commit

Permalink
Voice Line Randomizer: Fix softlock on rural_bank_heist
Browse files Browse the repository at this point in the history
  • Loading branch information
Parik27 committed Aug 1, 2021
1 parent 5e74764 commit b50ea72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build-count.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
473
475
11 changes: 7 additions & 4 deletions src/sounds/voicelines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <audEngine.hh>
#include <thread>
#include <common/config.hh>
#include <CTheScripts.hh>

class audScriptAudioEntity;
class audSpeechSound;
Expand Down Expand Up @@ -54,7 +55,11 @@ class VoiceLineRandomizer
static bool
ShouldRandomizeVoiceLine (uint32_t hash)
{
return true;
return std::find_if (std::begin (mSounds), std::end (mSounds),
[hash] (const SoundPair &sound) {
return sound.soundHash == hash;
})
!= std::end (mSounds);
}

/*******************************************************/
Expand All @@ -65,11 +70,9 @@ class VoiceLineRandomizer
uint32_t, uint8_t, uint8_t, uint8_t)
{
if (mSounds.size () > 0
&& ShouldRandomizeVoiceLine (rage::atStringHash (subtitle)))
&& ShouldRandomizeVoiceLine (rage::atPartialStringHash (sound)))
{
auto &newSound = GetRandomElement (mSounds);
if (strstr (sound, "SFX_") == sound)
return true;

subtitle = newSound.subtitle.c_str ();
mAudioPairs[rage::atPartialStringHash (sound)] = &newSound;
Expand Down

0 comments on commit b50ea72

Please sign in to comment.