From 200aaabf488e3b3364fc195c697f6abe14355e92 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 28 Sep 2020 14:34:17 -0700 Subject: [PATCH] cv_fading to disable music fading entirely --- src/d_netcmd.c | 11 +++++++++++ src/g_game.c | 35 +++++++++++++++++++++++++++++++++++ src/g_game.h | 11 +++++++++++ src/p_inter.c | 17 +++++++++++++++++ src/s_sound.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b36ab33a3..769b35b7b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -998,6 +998,17 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); + CV_RegisterVar(&cv_invincmusicfade); + CV_RegisterVar(&cv_growmusicfade); + + CV_RegisterVar(&cv_respawnfademusicout); + CV_RegisterVar(&cv_respawnfademusicback); + + CV_RegisterVar(&cv_resetspecialmusic); + + CV_RegisterVar(&cv_resume); + CV_RegisterVar(&cv_fading); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/g_game.c b/src/g_game.c index c6b633cee..61cc965a6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -531,6 +531,14 @@ consvar_t cv_xdeadzone4 = {"joy4_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_c consvar_t cv_ydeadzone4 = {"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_resetspecialmusic = {"resetspecialmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fading = {"fading", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" #endif @@ -2689,6 +2697,9 @@ void G_PlayerReborn(INT32 player) tic_t grieftime; UINT8 griefstrikes; + boolean fade; + boolean playing; + score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2864,7 +2875,31 @@ void G_PlayerReborn(INT32 player) } } + /* I'm putting this here because lol */ + + fade = ( cv_fading.value && P_IsLocalPlayer(p) ); + + if (fade) + { + playing = S_MusicPlaying(); + + /* + Fade it in with the same call to avoid + max volume for a few milliseconds (?). + */ + if (! playing) + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + } + P_RestoreMusic(p); + + if (fade) + { + /* mid-way fading out, fade back up */ + if (playing) + S_FadeMusic(100, cv_respawnfademusicback.value); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/g_game.h b/src/g_game.h index b258ffd7e..05e8aeebd 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,17 @@ extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_lookbackaxis4,cv_xdeadzone4,cv_ydeadzone4; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; +extern consvar_t cv_invincmusicfade; +extern consvar_t cv_growmusicfade; + +extern consvar_t cv_respawnfademusicout; +extern consvar_t cv_respawnfademusicback; + +extern consvar_t cv_resetspecialmusic; + +extern consvar_t cv_resume; +extern consvar_t cv_fading; + typedef enum { AXISNONE = 0, diff --git a/src/p_inter.c b/src/p_inter.c index db321541e..27bbfdd47 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2347,6 +2347,23 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; + if (cv_fading.value && P_IsLocalPlayer(target->player)) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; + + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } + if (target->player == &players[consoleplayer]) { // don't die in auto map, diff --git a/src/s_sound.c b/src/s_sound.c index ea0a1bbe7..25d4aa4cf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2156,6 +2156,34 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } +void +S_SetRestoreMusicFadeInCvar (consvar_t *cv) +{ + music_refade_cv = cv; +} + +int +S_GetRestoreMusicFadeIn (void) +{ + if (music_refade_cv && cv_fading.value) + return music_refade_cv->value; + else + return 0; +} + +void +S_SetMusicUsage (int type) +{ + music_usage = type; + I_UpdateSongLagConditions(); +} + +int +S_MusicUsage (void) +{ + return music_usage; +} + /// ------------------------ /// Music Fading /// ------------------------