From 823ff04e2add46d87b77424244a61717cdd14f99 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 28 Nov 2019 22:05:49 -0800 Subject: [PATCH] Fade level music back in after Invincibility and Grow Cvars are invincibilitymusicfade and growmusicfade. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 3 +++ src/g_game.h | 3 +++ src/p_user.c | 9 ++++++++- src/s_sound.c | 18 ++++++++++++++++++ src/s_sound.h | 3 +++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4a90de333..fe18ba733 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -972,6 +972,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); + CV_RegisterVar(&cv_invincmusicfade); + CV_RegisterVar(&cv_growmusicfade); + // 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 d9d7b7f12..ddbe65987 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -519,6 +519,9 @@ consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NU consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index 493be5d49..dcbe84db0 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,9 @@ 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_deadzone4; 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; + typedef enum { AXISNONE = 0, diff --git a/src/p_user.c b/src/p_user.c index cb6b7bd62..83a296a39 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1275,10 +1275,16 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) + { S_ChangeMusicInternal("kgrow", true); + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + } // Item - Invincibility else if (wantedmus == 1) + { S_ChangeMusicInternal("kinvnc", true); + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + } else { #if 0 @@ -1287,7 +1293,8 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, + S_GetRestoreMusicFadeIn()); } } } diff --git a/src/s_sound.c b/src/s_sound.c index e6c76909c..84d9d241d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1565,6 +1565,7 @@ static char music_name[7]; // up to 6-character name static void *music_data; static UINT16 music_flags; static boolean music_looping; +static consvar_t *music_refade_cv; static char queue_name[7]; static UINT16 queue_flags; @@ -1948,6 +1949,8 @@ static void S_UnloadMusic(void) music_name[0] = 0; music_flags = 0; music_looping = false; + + music_refade_cv = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -2169,6 +2172,21 @@ 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) + return music_refade_cv->value; + else + return 0; +} + /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 530049328..b1f558df8 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -186,6 +186,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) +void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +int S_GetRestoreMusicFadeIn (void); + // Stops the music. void S_StopMusic(void);