From 598ea994417c39e56c68295d238cc899e858658d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Aug 2020 12:35:46 +0200 Subject: [PATCH] - simplify the music starting code in Blood. --- source/blood/src/blood.cpp | 2 +- source/blood/src/levels.cpp | 21 ++++++++------------- source/blood/src/levels.h | 3 +-- source/blood/src/messages.cpp | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index b533c2260..0bdcdb37e 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -893,7 +893,7 @@ static void commonTicker(bool &playvideo) auto completion = [](bool = false) { StartLevel(&gGameOptions); - levelTryPlayMusicOrNothing(gGameOptions.nEpisode, gGameOptions.nLevel); + levelTryPlayMusic(); gNetFifoClock = gFrameClock = totalclock; gamestate = GS_LEVEL; }; diff --git a/source/blood/src/levels.cpp b/source/blood/src/levels.cpp index 88e1be06e..7bf973b9e 100644 --- a/source/blood/src/levels.cpp +++ b/source/blood/src/levels.cpp @@ -286,26 +286,21 @@ void levelRestart(void) gStartNewGame = true; } -bool levelTryPlayMusic(int nEpisode, int nLevel, bool bSetLevelSong) +bool levelTryPlayMusic() { - auto level = FindMapByLevelNum(levelnum(nEpisode, nLevel)); - if (!level) return false; FString buffer; - if (mus_redbook && level->cdSongId > 0) - buffer.Format("blood%02i.ogg", level->cdSongId); + if (mus_redbook && currentLevel->cdSongId > 0) + buffer.Format("blood%02i.ogg", currentLevel->cdSongId); else { - buffer = level->music; - if (Mus_Play(level->labelName, buffer, true)) return true; + buffer = currentLevel->music; + if (Mus_Play(currentLevel->labelName, buffer, true)) return true; DefaultExtension(buffer, ".mid"); } - return !!Mus_Play(level->labelName, buffer, true); -} - -void levelTryPlayMusicOrNothing(int nEpisode, int nLevel) -{ - if (!levelTryPlayMusic(nEpisode, nLevel, true)) + if (!Mus_Play(currentLevel->labelName, buffer, true)) + { Mus_Play("", "", true); + } } class LevelsLoadSave : public LoadSave diff --git a/source/blood/src/levels.h b/source/blood/src/levels.h index 5f8b3295f..4cef3226d 100644 --- a/source/blood/src/levels.h +++ b/source/blood/src/levels.h @@ -106,7 +106,6 @@ void levelGetNextLevels(int nEpisode, int nLevel, int *pnEndingA, int *pnEndingB // arg: 0 is normal exit, 1 is secret level void levelEndLevel(int arg); void levelRestart(void); -bool levelTryPlayMusic(int nEpisode, int nlevel, bool bSetLevelSong = false); -void levelTryPlayMusicOrNothing(int nEpisode, int nLevel); +bool levelTryPlayMusic(); END_BLD_NS diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 34cb8238e..0f2eb4006 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -274,7 +274,7 @@ void LevelWarp(int nEpisode, int nLevel) { levelSetupOptions(nEpisode, nLevel); StartLevel(&gGameOptions); - levelTryPlayMusicOrNothing(nEpisode, nLevel); + levelTryPlayMusic(); } bool bPlayerCheated = false;