mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- fixed handling of music in Redneck Rampage and Shadow Warrior.
After merging the CD enabling CVAR they had the same default (off) as Blood which is wrong. This also addresses other music related issues, like not properly cycling through the RR music.
This commit is contained in:
parent
c8edef4e0c
commit
d8dfe752b5
14 changed files with 59 additions and 35 deletions
|
@ -177,7 +177,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
|
|||
gGameStarted = 1;
|
||||
bVanilla = false;
|
||||
|
||||
MUS_ResumeSaved();
|
||||
Mus_ResumeSaved();
|
||||
|
||||
netBroadcastPlayerInfo(myconnectindex);
|
||||
return true;
|
||||
|
|
|
@ -544,6 +544,13 @@ int RunGame()
|
|||
InitFileSystem(usedgroups);
|
||||
if (usedgroups.Size() == 0) return 0;
|
||||
|
||||
if (g_gameType & GAMEFLAG_BLOOD)
|
||||
{
|
||||
UCVarValue v;
|
||||
v.Bool = false;
|
||||
mus_redbook.SetGenericRepDefault(v, CVAR_Bool); // Blood should default to CD Audio off - all other games must default to on.
|
||||
}
|
||||
|
||||
G_ReadConfig(currentGame);
|
||||
|
||||
V_InitFontColors();
|
||||
|
@ -682,7 +689,7 @@ CCMD(snd_reset)
|
|||
{
|
||||
Mus_Stop();
|
||||
if (soundEngine) soundEngine->Reset();
|
||||
MUS_ResumeSaved();
|
||||
Mus_ResumeSaved();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -134,7 +134,7 @@ CVARD(Bool, snd_tryformats, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disab
|
|||
CVARD(Bool, snd_doppler, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable 3d sound")
|
||||
|
||||
CVARD(Bool, mus_restartonload, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "restart the music when loading a saved game with the same map or not") // only implemented for Blood - todo: generalize
|
||||
CVARD(Bool, mus_redbook, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_FRONTEND_BLOOD, "enables/disables redbook audio (Blood only!)") // only Blood has assets for this.
|
||||
CVARD(Bool, mus_redbook, true, CVAR_ARCHIVE, "enables/disables redbook audio")
|
||||
|
||||
CUSTOM_CVARD(Int, snd_fxvolume, 255, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls volume for sound effects")
|
||||
{
|
||||
|
|
|
@ -536,7 +536,7 @@ CCMD (stopmus)
|
|||
static FString lastMusicLevel, lastMusic;
|
||||
int Mus_Play(const char *mapname, const char *fn, bool loop)
|
||||
{
|
||||
if (mus_blocked) return 0;
|
||||
if (mus_blocked) return 1; // Caller should believe it succeeded.
|
||||
// Store the requested names for resuming.
|
||||
lastMusicLevel = mapname;
|
||||
lastMusic = fn;
|
||||
|
@ -579,6 +579,11 @@ int Mus_Play(const char *mapname, const char *fn, bool loop)
|
|||
return mus_playing.handle != nullptr;
|
||||
}
|
||||
|
||||
bool Mus_IsPlaying()
|
||||
{
|
||||
return mus_playing.handle != nullptr;
|
||||
}
|
||||
|
||||
void Mus_Stop()
|
||||
{
|
||||
if (mus_blocked) return;
|
||||
|
@ -654,7 +659,7 @@ bool MUS_Restore()
|
|||
return true;
|
||||
}
|
||||
|
||||
void MUS_ResumeSaved()
|
||||
void Mus_ResumeSaved()
|
||||
{
|
||||
S_RestartMusic();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
void Mus_Init();
|
||||
int Mus_Play(const char *mapname, const char *fn, bool loop);
|
||||
void Mus_Stop();
|
||||
bool Mus_IsPlaying();
|
||||
void Mus_Fade(double seconds);
|
||||
void Mus_SetPaused(bool on);
|
||||
void MUS_ResumeSaved();
|
||||
void Mus_ResumeSaved();
|
||||
|
|
|
@ -1929,7 +1929,7 @@ static void postloadplayer(int32_t savegamep)
|
|||
Bmemset(gotpic, 0, sizeof(gotpic));
|
||||
S_ClearSoundLocks();
|
||||
G_CacheMapData();
|
||||
MUS_ResumeSaved();
|
||||
Mus_ResumeSaved();
|
||||
|
||||
g_player[myconnectindex].ps->gm = MODE_GAME;
|
||||
ud.recstat = 0;
|
||||
|
|
|
@ -1994,7 +1994,7 @@ void G_BonusScreen(int32_t bonusonly)
|
|||
videoClearScreen(0);
|
||||
G_DisplayMPResultsScreen();
|
||||
|
||||
if (MusicEnabled())
|
||||
if (MusicEnabled() && mus_enabled)
|
||||
S_PlaySound(BONUSMUSIC);
|
||||
|
||||
videoNextPage();
|
||||
|
@ -2033,7 +2033,7 @@ void G_BonusScreen(int32_t bonusonly)
|
|||
|
||||
gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade);
|
||||
|
||||
if (MusicEnabled())
|
||||
if (MusicEnabled() && mus_enabled)
|
||||
S_PlaySound(BONUSMUSIC);
|
||||
|
||||
videoNextPage();
|
||||
|
|
|
@ -2413,6 +2413,10 @@ int G_EnterLevel(int gameMode)
|
|||
G_CacheMapData();
|
||||
// G_FadeLoad(0,0,0, 0,252, 28, 4, -2);
|
||||
|
||||
// Try this first so that it can disable the CD player if no tracks are found.
|
||||
if (RR && !(gameMode & MODE_DEMO))
|
||||
S_PlayRRMusic();
|
||||
|
||||
if (ud.recstat != 2)
|
||||
{
|
||||
if (Menu_HaveUserMap())
|
||||
|
@ -2422,9 +2426,6 @@ int G_EnterLevel(int gameMode)
|
|||
else S_PlayLevelMusicOrNothing(mii);
|
||||
}
|
||||
|
||||
if (RR && !(gameMode & MODE_DEMO))
|
||||
S_PlayRRMusic();
|
||||
|
||||
if (gameMode & (MODE_GAME|MODE_EOL))
|
||||
{
|
||||
for (TRAVERSE_CONNECT(i))
|
||||
|
|
|
@ -1543,7 +1543,7 @@ static void postloadplayer(int32_t savegamep)
|
|||
Bmemset(gotpic, 0, sizeof(gotpic));
|
||||
S_ClearSoundLocks();
|
||||
G_CacheMapData();
|
||||
MUS_ResumeSaved();
|
||||
Mus_ResumeSaved();
|
||||
Mus_SetPaused(false);
|
||||
|
||||
g_player[myconnectindex].ps->gm = MODE_GAME;
|
||||
|
|
|
@ -2000,7 +2000,7 @@ void G_BonusScreen(int32_t bonusonly)
|
|||
videoClearScreen(0);
|
||||
G_DisplayMPResultsScreen();
|
||||
|
||||
if (MusicEnabled())
|
||||
if (MusicEnabled() && mus_enabled)
|
||||
S_PlaySound(BONUSMUSIC);
|
||||
|
||||
videoNextPage();
|
||||
|
@ -2042,7 +2042,7 @@ void G_BonusScreen(int32_t bonusonly)
|
|||
|
||||
gametext_center_shade(192, GStrings("PRESSKEY"), quotepulseshade);
|
||||
|
||||
if (MusicEnabled())
|
||||
if (MusicEnabled() && mus_enabled)
|
||||
S_PlaySound(BONUSMUSIC);
|
||||
}
|
||||
else
|
||||
|
@ -2579,7 +2579,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
|
|||
videoClearScreen(0);
|
||||
G_DisplayMPResultsScreen();
|
||||
|
||||
if (MusicEnabled())
|
||||
if (MusicEnabled() && mus_enabled)
|
||||
S_PlaySound(BONUSMUSIC);
|
||||
|
||||
videoNextPage();
|
||||
|
|
|
@ -314,10 +314,8 @@ void S_Update(void)
|
|||
vec3_t* c;
|
||||
int32_t ca, cs;
|
||||
|
||||
#if 0
|
||||
if (RR /*&& todo: fix the conditions here */ )
|
||||
if (RR && Mus_IsPlaying())
|
||||
S_PlayRRMusic();
|
||||
#endif
|
||||
|
||||
S_GetCamera(&c, &ca, &cs);
|
||||
|
||||
|
@ -552,6 +550,8 @@ void S_MenuSound(void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
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 S_SetMusicIndex(unsigned int m)
|
||||
{
|
||||
ud.music_episode = m / MAXLEVELS;
|
||||
|
@ -560,6 +560,7 @@ static void S_SetMusicIndex(unsigned int m)
|
|||
|
||||
void S_PlayLevelMusicOrNothing(unsigned int m)
|
||||
{
|
||||
if (RR && mus_redbook && !cd_disabled) return;
|
||||
auto& mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m];
|
||||
Mus_Play(mr.labelName, mr.music, true);
|
||||
S_SetMusicIndex(m);
|
||||
|
@ -567,6 +568,7 @@ void S_PlayLevelMusicOrNothing(unsigned int m)
|
|||
|
||||
int S_TryPlaySpecialMusic(unsigned int m)
|
||||
{
|
||||
if (RR) return 0; // Can only be MUS_LOADING, RR does not use it.
|
||||
auto& musicfn = mapList[m].music;
|
||||
if (musicfn.IsNotEmpty())
|
||||
{
|
||||
|
@ -590,16 +592,21 @@ void S_PlaySpecialMusicOrNothing(unsigned int m)
|
|||
|
||||
void S_PlayRRMusic(int newTrack)
|
||||
{
|
||||
char fileName[16];
|
||||
if (!RR || !mus_redbook)
|
||||
if (!RR || !mus_redbook || cd_disabled)
|
||||
return;
|
||||
Mus_Stop();
|
||||
g_cdTrack = newTrack != -1 ? newTrack : g_cdTrack + 1;
|
||||
if (newTrack != 10 && (g_cdTrack > 9 || g_cdTrack < 2))
|
||||
g_cdTrack = 2;
|
||||
|
||||
Bsprintf(fileName, "track%.2d.ogg", g_cdTrack);
|
||||
Mus_Play(fileName, 0, true);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
g_cdTrack = newTrack != -1 ? newTrack : g_cdTrack + 1;
|
||||
if (newTrack != 10 && (g_cdTrack > 9 || g_cdTrack < 2))
|
||||
g_cdTrack = 2;
|
||||
|
||||
FStringf filename("track%02d.ogg", g_cdTrack);
|
||||
if (Mus_Play(nullptr, 0, false)) return;
|
||||
}
|
||||
// If none of the tracks managed to start, disable the CD music for this session so that regular music can play if defined.
|
||||
cd_disabled = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1209,7 +1209,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
|
|||
screenpeek = myconnectindex;
|
||||
PlayingLevel = Level;
|
||||
|
||||
MUS_ResumeSaved();
|
||||
Mus_ResumeSaved();
|
||||
if (snd_ambience)
|
||||
StartAmbientSound();
|
||||
|
||||
|
|
|
@ -616,25 +616,24 @@ void LoadCustomInfoFromScript(const char *filename)
|
|||
case CM_BESTTIME:
|
||||
{
|
||||
int n;
|
||||
char s[10];
|
||||
if (scriptfile_getnumber(script, &n)) break;
|
||||
|
||||
mapList[curmap].designerTime = (int)strtoll(s, nullptr, 0);
|
||||
mapList[curmap].designerTime = n;
|
||||
break;
|
||||
}
|
||||
case CM_PARTIME:
|
||||
{
|
||||
int n;
|
||||
char s[10];
|
||||
if (scriptfile_getnumber(script, &n)) break;
|
||||
|
||||
mapList[curmap].parTime = (int)strtoll(s, nullptr, 0);
|
||||
mapList[curmap].parTime = n;
|
||||
break;
|
||||
}
|
||||
case CM_CDATRACK:
|
||||
{
|
||||
int n;
|
||||
if (scriptfile_getnumber(script, &n)) break;
|
||||
mapList[curmap].cdSongId = n;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -922,7 +922,6 @@ int PlayerYellVocs[] =
|
|||
//==========================================================================
|
||||
|
||||
extern short Level;
|
||||
CVAR(Bool, sw_nothememidi, false, CVAR_ARCHIVE)
|
||||
|
||||
SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music.
|
||||
{
|
||||
|
@ -935,13 +934,18 @@ SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_tra
|
|||
if (cdaudio_track >= 0 && mus_redbook)
|
||||
{
|
||||
FStringf trackname("track%02d.ogg", cdaudio_track);
|
||||
if (!Mus_Play(nullptr, trackname, true))
|
||||
if (!Mus_Play(mapname, trackname, true))
|
||||
{
|
||||
buildprintf("Can't find CD track %i!\n", cdaudio_track);
|
||||
}
|
||||
}
|
||||
else if (isThemeTrack && sw_nothememidi) return false; // The original SW source only used CD Audio for theme tracks, so this is optional.
|
||||
return Mus_Play(nullptr, song_file_name, true);
|
||||
if (!Mus_Play(mapname, song_file_name, true))
|
||||
{
|
||||
// try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing id mus_redbook is off.)
|
||||
FStringf trackname("track%02d.ogg", cdaudio_track);
|
||||
if (!Mus_Play(nullptr, trackname, true)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void StopSound(void)
|
||||
|
|
Loading…
Reference in a new issue