- added a CVAR to disable WT's ogg music and a fallback for when it cannot be found.

Fixes #354
This commit is contained in:
Christoph Oelckers 2020-09-07 21:26:07 +02:00
parent 775c4a3b51
commit 703b142bad
3 changed files with 36 additions and 4 deletions

View file

@ -319,7 +319,7 @@ bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force)
if (!force && PlayList.GetNumSongs())
{ // Don't change if a playlist is active
return false;
return true; // do not report an error here.
}
// Do game specific lookup.
FString musicname_;

View file

@ -197,7 +197,7 @@ int Mus_Play(const char *mapname, const char *fn, bool loop)
if (!MusicEnabled())
{
return 0;
return 1;
}
// Allow per level music substitution.

View file

@ -587,12 +587,44 @@ void S_MenuSound(void)
//
//==========================================================================
CVAR(Bool, wt_forcemidi, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // quick hack to disable the oggs, which are of lower quality than playing the MIDIs with a good synth and sound font.
static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on.
static void MusPlay(const char* label, const char* music, bool loop)
{
if (isWorldTour())
{
if (wt_forcemidi)
{
FString alternative = music;
alternative.Substitute(".ogg", ".mid");
int num = fileSystem.FindFile(alternative);
if (num >= 0)
{
int file = fileSystem.GetFileContainer(num);
if (file == 1)
{
Mus_Play(label, alternative, loop);
return;
}
}
}
}
int result = Mus_Play(label, music, loop);
// do not remain silent if playing World Tour when the user has deleted the music.
if (!result && isWorldTour())
{
FString alternative = music;
alternative.Substitute(".ogg", ".mid");
Mus_Play(label, alternative, loop);
}
}
void S_PlayLevelMusic(MapRecord *mi)
{
if (isRR() && mi->music.IsEmpty() && mus_redbook && !cd_disabled) return;
Mus_Play(mi->labelName, mi->music, true);
MusPlay(mi->labelName, mi->music, true);
}
void S_PlaySpecialMusic(unsigned int m)
@ -601,7 +633,7 @@ void S_PlaySpecialMusic(unsigned int m)
auto& musicfn = specialmusic[m];
if (musicfn.IsNotEmpty())
{
Mus_Play(nullptr, musicfn, true);
MusPlay(nullptr, musicfn, true);
}
}