diff --git a/src/g_game.c b/src/g_game.c index ef72e9eb3..bd729e6a9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3065,7 +3065,7 @@ static gametype_t defaultgametypes[] = { "Special", "GT_SPECIAL", - GTR_CATCHER|GTR_SPECIALSTART|GTR_ROLLINGSTART|GTR_CIRCUIT, + GTR_CATCHER|GTR_SPECIALSTART|GTR_ROLLINGSTART|GTR_CIRCUIT|GTR_NOPOSITION, TOL_SPECIAL, int_time, 0, diff --git a/src/music.cpp b/src/music.cpp index b95d74b4a..00b200a21 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -35,6 +35,12 @@ void Music_Init(void) tune.nightcoreable = true; } + { + Tune& tune = g_tunes.insert("level_nosync", g_tunes.find("level")); + + tune.sync = false; + } + { Tune& tune = g_tunes.insert("position"); @@ -133,9 +139,9 @@ void Music_Init(void) } { - Tune& tune = g_tunes.insert("menu_nocred"); + Tune& tune = g_tunes.insert("menu_nocred", g_tunes.find("menu")); - tune.priority = 100; + tune.credit = false; } { @@ -165,14 +171,10 @@ void Music_Init(void) } { - Tune& tune = g_tunes.insert("stereo_fade"); + Tune& tune = g_tunes.insert("stereo_fade", g_tunes.find("stereo")); - tune.priority = 1000; tune.fade_out = 5000; tune.fade_out_inclusive = false; - tune.resist = true; - tune.keep_open = true; - tune.credit = true; } } @@ -350,3 +352,13 @@ const char* Music_CurrentId(void) { return g_tunes.current_id(); } + +void Music_BatchExempt(const char* id) +{ + Tune* tune = g_tunes.find(id); + + if (tune) + { + tune->resist_once = true; + } +} diff --git a/src/music.h b/src/music.h index c7712a472..a85b1913f 100644 --- a/src/music.h +++ b/src/music.h @@ -92,6 +92,10 @@ void Music_Remap(const char *id, const char *song); // Set whether a tune should loop. void Music_Loop(const char *id, boolean loop); +// Temporarily exemplify a tune from batch operations, such +// as Music_StopAll. +void Music_BatchExempt(const char *id); + // // Query properties. diff --git a/src/music_manager.hpp b/src/music_manager.hpp index 5ac215878..38110d46c 100644 --- a/src/music_manager.hpp +++ b/src/music_manager.hpp @@ -44,9 +44,9 @@ public: return it != map_.end() ? const_cast(&it->second) : nullptr; } - Tune& insert(const char* id) + Tune& insert(const char* id, const Tune* original = nullptr) { - auto res = map_.emplace(id, Tune{}); + auto res = map_.emplace(id, original ? *original : Tune{}); SRB2_ASSERT(res.second); @@ -73,6 +73,12 @@ public: { for (auto& [_, tune] : map_) { + if (tune.resist_once) + { + tune.resist_once = false; + continue; + } + if (!tune.resist) { f(tune); diff --git a/src/music_tune.hpp b/src/music_tune.hpp index b22efb23d..ec9aac6dd 100644 --- a/src/music_tune.hpp +++ b/src/music_tune.hpp @@ -57,6 +57,7 @@ public: // from TuneManager::stop_all etc. It must be // stopped/paused individually. bool resist = false; + bool resist_once = false; // set at runtime // This tune shows a credit when first played (not // resumed). diff --git a/src/p_setup.c b/src/p_setup.c index 4b458037c..e1a2cc1d5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8110,11 +8110,26 @@ void P_ResetLevelMusic(void) void P_LoadLevelMusic(void) { - tic_t level_music_start = starttime + (TICRATE/2); + const char *music = mapheaderinfo[gamemap-1]->musname[mapmusrng]; - Music_StopAll(); - Music_Remap("level", mapheaderinfo[gamemap-1]->musname[mapmusrng]); - Music_Seek("level", max(leveltime, level_music_start) - level_music_start); + if (gametyperules & GTR_NOPOSITION) + { + if (!stricmp(Music_Song("level_nosync"), music)) + { + // Do not reset music if it is the same + Music_BatchExempt("level_nosync"); + } + Music_StopAll(); + Music_Remap("level_nosync", music); + } + else + { + Music_StopAll(); + Music_Remap("level", music); + + tic_t level_music_start = starttime + (TICRATE/2); + Music_Seek("level", max(leveltime, level_music_start) - level_music_start); + } } /** Loads a level from a lump or external wad. diff --git a/src/p_tick.c b/src/p_tick.c index 48738ac16..b12f2f361 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -975,7 +975,11 @@ void P_Ticker(boolean run) if (leveltime == (starttime + (TICRATE/2))) { // Plays the music after the starting countdown. - Music_Play("level"); + if (!Music_Playing("level_nosync")) + { + // Do not stop level_nosync + Music_Play(Music_Song("level_nosync")[0] ? "level_nosync" : "level"); + } } else if (starttime != introtime) {