Skip to content

Commit

Permalink
Refined criteria for choosing custom sound effects
Browse files Browse the repository at this point in the history
Previously, any number would be interpreted as a stock sound effect ID,
causing the side effect of being able to call custom sound effects using
numbers over 27 (which is unreliable).

Now only numbers that correspond to a stock sound effect ID will be
considered (leading zeroes work as well), and everything else will be
interpreted as a custom sound effect file name.
  • Loading branch information
Fussmatte committed Feb 19, 2023
1 parent 98f2e65 commit 4bea3ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions desktop_version/src/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ musicclass::musicclass(void)
quick_fade = true;

usingmmmmmm = false;

stockSoundTracks = 0;
}

void musicclass::init(void)
Expand Down Expand Up @@ -659,6 +661,8 @@ void musicclass::init(void)
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));

stockSoundTracks = soundTracks.size();

//Here's where we find all the custom sounds in a level's assets folder
EnumHandle handle = {};
Expand Down
2 changes: 2 additions & 0 deletions desktop_version/src/Music.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class musicclass
bool mmmmmm;
bool usingmmmmmm;

int stockSoundTracks;

binaryBlob pppppp_blob;
binaryBlob mmmmmm_blob;
int num_pppppp_tracks;
Expand Down
6 changes: 3 additions & 3 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ void scriptclass::run(void)
}
if (words[0] == "playef")
{
if (words[1] != "0" && ss_toi(words[1]) == 0)
if (is_number(words[1].c_str()) && ss_toi(words[1]) >= 0 && ss_toi(words[1]) < music.stockSoundTracks)
{
music.playef_name(raw_words[1]);
music.playef(ss_toi(words[1]));
}
else
{
music.playef(ss_toi(words[1]));
music.playef_name(raw_words[1]);
}
}
if (words[0] == "play")
Expand Down

0 comments on commit 4bea3ee

Please sign in to comment.