Fix MIDI crash bug when changing music between levels

This happened when the old music was ERZ2 native midi, then warping to any other level.
This commit is contained in:
mazmazz 2019-03-15 10:02:50 -04:00
parent 7346684bd8
commit ad50fa4d9e
1 changed files with 12 additions and 11 deletions

View File

@ -2725,19 +2725,20 @@ boolean P_SetupLevel(boolean skipprecip)
S_StopSounds();
S_ClearSfx();
// Fade out music here. Deduct 2 tics so the fade volume actually reaches 0.
// But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug.
if (cv_resetmusic.value ||
strnicmp(S_MusicName(),
(mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7))
S_FadeMusic(0, FixedMul(
FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE));
if (!titlemapinaction)
{
// Let's fade to black here
// But only if we didn't do the special stage wipe
if (rendermode != render_none && !ranspecialwipe)
{
// Fade out music here. Deduct 2 tics so the fade volume actually reaches 0
if (cv_resetmusic.value ||
strnicmp(S_MusicName(),
(mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7))
S_FadeOutStopMusic(FixedMul(
FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE));
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
@ -2745,10 +2746,6 @@ boolean P_SetupLevel(boolean skipprecip)
F_RunWipe(wipedefs[wipe_level_toblack], false);
}
// As oddly named as this is, this handles music only.
// We should be fine starting it here.
S_Start();
if (ranspecialwipe == 2)
{
pausedelay = -3; // preticker plus one
@ -2770,6 +2767,10 @@ boolean P_SetupLevel(boolean skipprecip)
}
}
// As oddly named as this is, this handles music only.
// We should be fine starting it here.
S_Start();
levelfadecol = (ranspecialwipe) ? 0 : 31;
// Close text prompt before freeing the old level