From 7346684bd873d29db2732ee171e1a3d4e2935341 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 15 Mar 2019 04:21:17 -0400 Subject: [PATCH 1/5] Fade out music upon dying or level change: 2.1 frontport --- src/f_finale.h | 1 + src/f_wipe.c | 27 +++++++++++++++++++++++++++ src/m_menu.c | 1 + src/p_setup.c | 22 ++++++++++++++++++---- src/s_sound.c | 5 +++-- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/f_finale.h b/src/f_finale.h index ce3c65c29..40a3d004a 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 3d561075e..4267621a4 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 1c3873613..970c030e5 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 3dd673906..3d375e215 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 93588f081..7d3196bcd 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); From ad50fa4d9e9278aaa45df8515d50e02f014d73eb Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 15 Mar 2019 10:02:50 -0400 Subject: [PATCH 2/5] 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. --- src/p_setup.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3d375e215..dc93fd2fe 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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 From efc8e42083617f83e8e093e80650359c0b43b5ab Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Aug 2019 22:48:40 -0400 Subject: [PATCH 3/5] Fix titlemap music bug --- src/p_setup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index f966acc19..fb0e6ff47 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2728,9 +2728,9 @@ boolean P_SetupLevel(boolean skipprecip) // 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 || + if (!titlemapinaction && (cv_resetmusic.value || strnicmp(S_MusicName(), - (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7)) + (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7))) S_FadeMusic(0, FixedMul( FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)); @@ -2781,11 +2781,12 @@ 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. - S_Start(); + // 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; From a9b66109fc349d021d35a0e66934eb7748ba922a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Aug 2019 22:49:12 -0400 Subject: [PATCH 4/5] Fix titlemap music bug --- src/p_setup.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index fb0e6ff47..82713c3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2734,15 +2734,6 @@ boolean P_SetupLevel(boolean skipprecip) S_FadeMusic(0, FixedMul( FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)); - // todo old titlemap music fix, 255d5c6c9422d5934d9acfd2bc2767112ded8a9b - // may not be necessary for this branch - // 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) From 07d1363da909429db9bd21d70f20e81644ddf942 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 3 Aug 2019 23:00:21 -0400 Subject: [PATCH 5/5] gcc7 compile fixes (Fall through; spr2 var comparison) --- src/hardware/hw_draw.c | 2 +- src/hardware/hw_main.h | 2 +- src/lua_infolib.c | 2 +- src/p_mobj.c | 2 ++ src/r_things.c | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 1ba357105..f1e53bb28 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1080,7 +1080,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) // -------------------+ // HWR_DrawConsoleFill : draw flat coloured transparent rectangle because that's cool, and hw sucks less than sw for that. // -------------------+ -void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options) +void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color) { FOutVector v[4]; FSurfaceInfo Surf; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index fab18e08a..d706aae86 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -50,7 +50,7 @@ void HWR_CreateStaticLightmaps(INT32 bspnum); void HWR_PrepLevelCache(size_t pnumtextures); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 actualcolor, UINT8 strength); -void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. +void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color); // Lat: separate flags from color since color needs to be an uint to work right. void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum); UINT8 *HWR_GetScreenshot(void); diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 8bd4ce9ff..77f37f8ec 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -207,7 +207,7 @@ static int lib_setSpr2default(lua_State *L) else return luaL_error(L, "spr2defaults[] invalid set"); - if (j < 0 || j >= free_spr2) + if (j >= free_spr2) return luaL_error(L, "spr2defaults[] set %d out of range (%d - %d)", j, 0, free_spr2-1); spr2defaults[i] = j; diff --git a/src/p_mobj.c b/src/p_mobj.c index 8c74fd76e..7ff8aa9f2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9717,6 +9717,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) case MT_EGGROBO1: mobj->movecount = P_RandomKey(13); mobj->color = SKINCOLOR_RUBY + P_RandomKey(MAXSKINCOLORS - SKINCOLOR_RUBY); + // fall through case MT_HIVEELEMENTAL: mobj->extravalue1 = 5; break; @@ -11116,6 +11117,7 @@ You should think about modifying the deathmatch starts to take full advantage of mobj->color = SKINCOLOR_GOLD; mobj->colorized = true; } + // fall through case MT_EGGMOBILE3: mobj->cusval = mthing->extrainfo; break; diff --git a/src/r_things.c b/src/r_things.c index 71e4c0214..fdf0e230d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2540,6 +2540,7 @@ UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player) ? player->charability : skin->ability) == CA_SWIM) ? SPR2_SWIM : SPR2_FLY; + // fall through // Use the handy list, that's what it's there for! default: