Restore level music to where it left off

Toggleable via the resume cvar.
This commit is contained in:
James R 2019-11-29 01:56:44 -08:00
parent 8524c3749d
commit 911dd57334
6 changed files with 19 additions and 1 deletions

View file

@ -988,6 +988,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_invincmusicfade);
CV_RegisterVar(&cv_growmusicfade);
CV_RegisterVar(&cv_resume);
// ingame object placing
COM_AddCommand("objectplace", Command_ObjectPlace_f);
COM_AddCommand("writethings", Command_Writethings_f);

View file

@ -34,6 +34,7 @@ extern INT16 gamemap;
extern char mapmusname[7];
extern UINT16 mapmusflags;
extern UINT32 mapmusposition;
extern UINT32 mapmusresume;
#define MUSIC_TRACKMASK 0x0FFF // ----************
#define MUSIC_RELOADRESET 0x8000 // *---------------
#define MUSIC_FORCERESET 0x4000 // -*--------------

View file

@ -80,6 +80,7 @@ static void G_DoStartVote(void);
char mapmusname[7]; // Music name
UINT16 mapmusflags; // Track and reset bit
UINT32 mapmusposition; // Position to jump to
UINT32 mapmusresume;
INT16 gamemap = 1;
INT16 maptol;
@ -532,6 +533,7 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con
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};
consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
#if MAXPLAYERS > 16
#error "please update player_name table using the new value for MAXPLAYERS"

View file

@ -121,6 +121,8 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu
extern consvar_t cv_invincmusicfade;
extern consvar_t cv_growmusicfade;
extern consvar_t cv_resume;
typedef enum
{
AXISNONE = 0,

View file

@ -1188,6 +1188,8 @@ boolean P_EndingMusic(player_t *player)
//
void P_RestoreMusic(player_t *player)
{
UINT32 position;
if (!P_IsLocalPlayer(player)) // Only applies to a local player
return;
@ -1262,8 +1264,14 @@ void P_RestoreMusic(player_t *player)
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value))
S_SpeedMusic(1.2f);
#endif
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0,
if (mapmusresume && cv_resume.value)
position = mapmusresume;
else
position = mapmusposition;
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0,
S_GetRestoreMusicFadeIn());
mapmusresume = 0;
}
}
}

View file

@ -2073,6 +2073,9 @@ void S_StopMusic(void)
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
return;
if (strcasecmp(music_name, mapmusname) == 0)
mapmusresume = I_GetSongPosition();
if (I_SongPaused())
I_ResumeSong();