- 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)
{
StartLevel(&gGameOptions);
levelTryPlayMusicOrNothing(gGameOptions.nEpisode, gGameOptions.nLevel);
levelTryPlayMusic();
gNetFifoClock = gFrameClock = totalclock;
gamestate = GS_LEVEL;
};

View file

@ -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

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
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

View file

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