From 95cdc2c5a672e715a9efddca74ff5506edcacec7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Sep 2024 11:45:33 +0200 Subject: [PATCH] change how keepmusic works compare map and encore instead of the music itself --- src/g_game.c | 1 + src/s_sound.c | 47 ++++++++++++++++++++++++++++++++++++++++------- src/s_sound.h | 2 ++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 502fb4e02..a0795c7ff 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4267,6 +4267,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool else { LUAh_MapChange(gamemap); + S_KeepMusic(); G_DoLoadLevel(resetplayer); } diff --git a/src/s_sound.c b/src/s_sound.c index 4e64587d3..08671cdad 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1946,8 +1946,7 @@ boolean S_FadeOutStopMusic(UINT32 ms) return I_FadeSong(0, ms, &S_StopMusic); } - -static boolean S_KeepMusic(const char *mapmusicname) +/*static boolean S_KeepMusic(void) { //if (!cv_keepmusic.value) //return false; @@ -1955,16 +1954,50 @@ static boolean S_KeepMusic(const char *mapmusicname) // should i compare songs or maps? static char oldmusname[7] = ""; - if (strcmp(music_name, mapmusicname) != 0) + if (strcmp(music_name, mapmusname) != 0) return false; - if (strcmp(oldmusname, mapmusicname) == 0) + if (strcmp(oldmusname, mapmusname) == 0) return true; - strncpy(oldmusname, mapmusicname, 7); + strncpy(oldmusname, mapmusname, 7); oldmusname[6] = '\0'; return false; +}*/ + +static INT16 oldmap = 0; +static INT32 oldencore = 0; +static boolean keepmusic = false; + +void S_KeepMusic(void) +{ + //if (!cv_keepmusic.value) + //return false; + + //this one compares map and encoremode instead of the music itself + //makes tunes work and stuff + + keepmusic = false; + + //dont keep the intro "sound" lmao + if (strcmp(music_name, (encoremode ? "estart" : "kstart")) == 0) + return; + + if (oldencore != cv_kartencore.value) + { + oldencore = cv_kartencore.value; + return; + } + + // we on the same map? keep it + if (oldmap == gamemap) + { + keepmusic = true; + return; + } + + oldmap = gamemap; } /// ------------------------ @@ -1987,7 +2020,7 @@ void S_Start(void) mapmusresume = 0; } - if (S_KeepMusic(mapmusname)) + if (keepmusic) return; /*if (cv_skipintromusic.value) @@ -2022,7 +2055,7 @@ void M_Start(void) return; }*/ - if (S_KeepMusic(mapmusname)) + if (keepmusic) return; // The GO! sound stops the level start ambience diff --git a/src/s_sound.h b/src/s_sound.h index 474b22c3b..e90914162 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -103,6 +103,8 @@ void S_ClearSfx(void); void S_Start(void); void M_Start(void); +void S_KeepMusic(void); + // Stops music and restarts it from same position. Used for instant applying changes to amiga filters. void S_RestartMusic(void);