Check divisor in musicclass::play()

Previously, it was assuming that the number of PPPPPP/MMMMMM tracks
would always be 16, since if that wasn't the case... then the game would
rudely and abruptly segfault when attempting to load the file. Huh.

But now that the game properly deals with invalid headers, it's possible
for the number of tracks to be 0. So I'll need to remove this
assumption.
This commit is contained in:
Misa authored and Ethan Lee committed 2020-08-14 09:51:19 -04:00
1 parent 4bfd9de371
commit 6bed5fc88c
1 file changed
+6 -3
+6 -3
View File
@@ -151,12 +151,15 @@ void songend()
void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fadein_ms /*= 3000*/)
{
// No need to check if num_tracks is greater than 0, we wouldn't be here if it wasn't
if (mmmmmm && usingmmmmmm)
{
t %= num_mmmmmm_tracks;
// Don't conjoin this if-statement with the above one...
if (num_mmmmmm_tracks > 0)
{
t %= num_mmmmmm_tracks;
}
}
else
else if (num_pppppp_tracks > 0)
{
t %= num_pppppp_tracks;
}