- simplify the music starting code in Blood.

This commit is contained in:
Christoph Oelckers 2020-08-16 12:35:46 +02:00
parent 0ac8568be0
commit 598ea99441
4 changed files with 11 additions and 17 deletions

View file

@ -893,7 +893,7 @@ static void commonTicker(bool &playvideo)
auto completion = [](bool = false) auto completion = [](bool = false)
{ {
StartLevel(&gGameOptions); StartLevel(&gGameOptions);
levelTryPlayMusicOrNothing(gGameOptions.nEpisode, gGameOptions.nLevel); levelTryPlayMusic();
gNetFifoClock = gFrameClock = totalclock; gNetFifoClock = gFrameClock = totalclock;
gamestate = GS_LEVEL; gamestate = GS_LEVEL;
}; };

View file

@ -286,27 +286,22 @@ void levelRestart(void)
gStartNewGame = true; gStartNewGame = true;
} }
bool levelTryPlayMusic(int nEpisode, int nLevel, bool bSetLevelSong) bool levelTryPlayMusic()
{ {
auto level = FindMapByLevelNum(levelnum(nEpisode, nLevel));
if (!level) return false;
FString buffer; FString buffer;
if (mus_redbook && level->cdSongId > 0) if (mus_redbook && currentLevel->cdSongId > 0)
buffer.Format("blood%02i.ogg", level->cdSongId); buffer.Format("blood%02i.ogg", currentLevel->cdSongId);
else else
{ {
buffer = level->music; buffer = currentLevel->music;
if (Mus_Play(level->labelName, buffer, true)) return true; if (Mus_Play(currentLevel->labelName, buffer, true)) return true;
DefaultExtension(buffer, ".mid"); DefaultExtension(buffer, ".mid");
} }
return !!Mus_Play(level->labelName, buffer, true); if (!Mus_Play(currentLevel->labelName, buffer, true))
}
void levelTryPlayMusicOrNothing(int nEpisode, int nLevel)
{ {
if (!levelTryPlayMusic(nEpisode, nLevel, true))
Mus_Play("", "", true); Mus_Play("", "", true);
} }
}
class LevelsLoadSave : public LoadSave class LevelsLoadSave : public LoadSave
{ {

View file

@ -106,7 +106,6 @@ void levelGetNextLevels(int nEpisode, int nLevel, int *pnEndingA, int *pnEndingB
// arg: 0 is normal exit, 1 is secret level // arg: 0 is normal exit, 1 is secret level
void levelEndLevel(int arg); void levelEndLevel(int arg);
void levelRestart(void); void levelRestart(void);
bool levelTryPlayMusic(int nEpisode, int nlevel, bool bSetLevelSong = false); bool levelTryPlayMusic();
void levelTryPlayMusicOrNothing(int nEpisode, int nLevel);
END_BLD_NS END_BLD_NS

View file

@ -274,7 +274,7 @@ void LevelWarp(int nEpisode, int nLevel)
{ {
levelSetupOptions(nEpisode, nLevel); levelSetupOptions(nEpisode, nLevel);
StartLevel(&gGameOptions); StartLevel(&gGameOptions);
levelTryPlayMusicOrNothing(nEpisode, nLevel); levelTryPlayMusic();
} }
bool bPlayerCheated = false; bool bPlayerCheated = false;