diff --git a/src/f_finale.h b/src/f_finale.h index ce3c65c291b3c06fb29e9b4668561b3e849080dc..40a3d004aaa84d6610cd0c40c54facb47e04ac90 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -89,6 +89,7 @@ extern INT32 lastwipetic; void F_WipeStartScreen(void); void F_WipeEndScreen(void); void F_RunWipe(UINT8 wipetype, boolean drawMenu); +tic_t F_GetWipeLength(UINT8 wipetype); enum { diff --git a/src/f_wipe.c b/src/f_wipe.c index 3d561075e56f3ba1bee915787ca3f666feb67a19..4267621a4523a00b65fb6299efcdb7d598bc30b4 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -378,3 +378,30 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) WipeInAction = false; #endif } + +/** Returns tic length of wipe + * One lump equals one tic + */ +tic_t F_GetWipeLength(UINT8 wipetype) +{ +#ifdef NOWIPE + return 0; +#else + static char lumpname[10] = "FADEmmss"; + lumpnum_t lumpnum; + UINT8 wipeframe; + + if (wipetype > 99) + return 0; + + for (wipeframe = 0; wipeframe < 100; wipeframe++) + { + sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe); + + lumpnum = W_CheckNumForName(lumpname); + if (lumpnum == LUMPERROR) + return --wipeframe; + } + return --wipeframe; +#endif +} diff --git a/src/m_menu.c b/src/m_menu.c index 1c38736136a9674135eb34181f849795e71fe6a4..970c030e55a5bfedb8bb4356777c20b5d3d94ea3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1305,6 +1305,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_HEADER, NULL, "Advanced", 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, 127}, // 62 }; static menuitem_t OP_DataOptionsMenu[] = diff --git a/src/p_setup.c b/src/p_setup.c index 3dd6739069e62997c6e9d66a19be8043b0fe2742..3d375e215c0fb81624a82e14e2127527da025aa4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2693,6 +2693,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); @@ -2700,6 +2706,7 @@ boolean P_SetupLevel(boolean skipprecip) F_RunWipe(wipedefs[wipe_speclevel_towhite], false); nowtime = lastwipetic; + // Hold on white for extra effect. while (nowtime < endtime) { @@ -2720,14 +2727,17 @@ boolean P_SetupLevel(boolean skipprecip) if (!titlemapinaction) { - // As oddly named as this is, this handles music only. - // We should be fine starting it here. - S_Start(); - // 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); @@ -2735,6 +2745,10 @@ 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 diff --git a/src/s_sound.c b/src/s_sound.c index 93588f081854547961103526599cdbda2c132a75..7d3196bcd5fe19d3df2738d9400cdbb97550bc98 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -104,7 +104,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}; @@ -1613,7 +1613,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);