diff --git a/src/g_game.c b/src/g_game.c index 4e2735ba1..5e9bc1077 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2304,18 +2304,7 @@ void G_PlayerReborn(INT32 player) { if (mapmusflags & MUSIC_RELOADRESET) { - if (keepmusic) - { - S_CopyKeepMusicStuff(); // this is horrible, why do we COMPLETELY need to reset the music on respawn?? oh well - } - else - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - } - mapmusresume = 0; + S_HandleReloadResetMusic(); songcredit = true; } } diff --git a/src/s_sound.c b/src/s_sound.c index 0ad207cb0..569ba5af9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2041,6 +2041,27 @@ void S_KeepMusic(void) oldmap = gamemap; } +void S_HandleReloadResetMusic(void) +{ + if (!(mapmusflags & MUSIC_RELOADRESET)) + return; + + if (keepmusic) + { + // this is horrible, this copies over everything about the mapmusic into temporary variables to reuse + S_CopyKeepMusicStuff(); + } + else + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } + + mapmusresume = 0; +} + // // Per level startup code. // Kills playing sounds at start of level, @@ -2048,21 +2069,7 @@ void S_KeepMusic(void) // void S_InitMapMusic(void) { - if (mapmusflags & MUSIC_RELOADRESET) - { - if (keepmusic) - { - S_CopyKeepMusicStuff(); - } - else - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - } - mapmusresume = 0; - } + S_HandleReloadResetMusic(); if (keepmusic) { diff --git a/src/s_sound.h b/src/s_sound.h index cce96add9..089008174 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -113,6 +113,7 @@ void S_ResetKeepAndSpecialMus(void); void S_InitMapMusic(void); void S_StartMapMusic(void); +void S_HandleReloadResetMusic(void); void S_KeepMusic(void); void S_CopyKeepMusicStuff(void);