diff --git a/src/m_menu.c b/src/m_menu.c index 68f527473..a3e986fdf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1307,9 +1307,10 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_HEADER, NULL, "Accessibility", NULL, 103}, // 50 {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 115}, // 56 + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 125}, // 62 #if defined(HAVE_OPENMPT) || defined(HAVE_MIXERX) - {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 133}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 143}, #endif }; diff --git a/src/p_setup.c b/src/p_setup.c index c2872a836..a089e0a8f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2686,6 +2686,12 @@ boolean P_SetupLevel(boolean skipprecip) S_StartSound(NULL, sfx_s3kaf); + // Fade music! Time it to S3KAF: 0.25 seconds is snappy. + if (cv_resetmusic.value || + strnicmp(S_MusicName(), + (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7)) + S_FadeOutStopMusic(MUSICRATE/4); //FixedMul(FixedDiv(F_GetWipeLength(wipedefs[wipe_speclevel_towhite])*NEWTICRATERATIO, NEWTICRATE), MUSICRATE) + F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); @@ -2693,6 +2699,7 @@ boolean P_SetupLevel(boolean skipprecip) F_RunWipe(wipedefs[wipe_speclevel_towhite], false); nowtime = lastwipetic; + // Hold on white for extra effect. while (nowtime < endtime) { @@ -2711,12 +2718,13 @@ boolean P_SetupLevel(boolean skipprecip) S_StopSounds(); S_ClearSfx(); - if (!titlemapinaction) - { - // As oddly named as this is, this handles music only. - // We should be fine starting it here. - S_Start(); - } + // 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 (!titlemapinaction && (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)); // Let's fade to black here // But only if we didn't do the special stage wipe @@ -2756,6 +2764,11 @@ boolean P_SetupLevel(boolean skipprecip) V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); I_UpdateNoVsync(); } + + // As oddly named as this is, this handles music only. + // We should be fine starting it here. + // Don't do this during titlemap, because the menu code handles music by itself. + S_Start(); } levelfadecol = (ranspecialwipe) ? 0 : 31; diff --git a/src/s_sound.c b/src/s_sound.c index 280a9989e..2c6faf041 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -108,7 +108,7 @@ consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_ consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetmusic = {"resetmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // Sound system toggles, saved into the config consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1911,7 +1911,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } - if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same + if (prefadems) // queue music change for after fade // allow even if the music is the same + // && S_MusicPlaying() // Let the delay happen even if we're not playing music { CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); S_QueueMusic(newmusic, mflags, looping, position, fadeinms);