From da74b9df9510a058a888af999279204e7868a2fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Mar 2018 13:06:37 +0100 Subject: [PATCH] - serialize the temporary music volume that can be set through ACS. --- src/g_level.cpp | 14 ++++++++++++++ src/g_levellocals.h | 3 +++ src/p_acs.cpp | 2 +- src/p_conversation.cpp | 2 +- src/p_saveg.cpp | 5 ++++- src/p_setup.cpp | 1 + src/win32/win32gliface.cpp | 2 +- 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index d6c712b24..cdb08ab67 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -87,6 +87,7 @@ #include "vm.h" #include "events.h" #include "dobjgc.h" +#include "i_music.h" #include "gi.h" @@ -600,6 +601,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill startpos = position; gameaction = ga_completed; + level.SetMusicVolume(1.0); if (nextinfo != NULL) { @@ -1469,6 +1471,7 @@ void G_InitLevelLocals () level.levelnum = info->levelnum; level.Music = info->Music; level.musicorder = info->musicorder; + level.MusicVolume = 1.f; level.LevelName = level.info->LookupLevelName(); level.NextMap = info->NextMap; @@ -1960,6 +1963,17 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, SetInterMusic) // //========================================================================== +void FLevelLocals::SetMusicVolume(float f) +{ + MusicVolume = f; + I_SetMusicVolume(f); +} + +//========================================================================== +// +// +//========================================================================== + template inline T VecDiff(const T& v1, const T& v2) { diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 60cb30df0..868423491 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -46,6 +46,7 @@ struct FLevelLocals void Tick (); void AddScroller (int secnum); void SetInterMusic(const char *nextmap); + void SetMusicVolume(float v); uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. int time; // time in the hub @@ -149,6 +150,7 @@ struct FLevelLocals int skyfog; float pixelstretch; + float MusicVolume; bool IsJumpingAllowed() const; bool IsCrouchingAllowed() const; @@ -162,6 +164,7 @@ struct FLevelLocals { return headgamenode; } + }; extern FLevelLocals level; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 6f1d1635d..200df28c5 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -6689,7 +6689,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) break; case ACSF_SetMusicVolume: - I_SetMusicVolume(ACSToFloat(args[0])); + level.SetMusicVolume(ACSToFloat(args[0])); break; case ACSF_CheckProximity: diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 37903021e..401541e24 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1094,7 +1094,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply if (isconsole) { - I_SetMusicVolume (1.f); + I_SetMusicVolume (level.MusicVolume); } } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 6c8d29973..af6daf428 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -546,19 +546,22 @@ void P_SerializeSounds(FSerializer &arc) DSeqNode::SerializeSequences (arc); const char *name = NULL; uint8_t order; + float musvol = level.MusicVolume; if (arc.isWriting()) { order = S_GetMusic(&name); } arc.StringPtr("musicname", name) - ("musicorder", order); + ("musicorder", order) + ("musicvolume", musvol); if (arc.isReading()) { if (!S_ChangeMusic(name, order)) if (level.cdtrack == 0 || !S_ChangeCDMusic(level.cdtrack, level.cdid)) S_ChangeMusic(level.Music, level.musicorder); + level.SetMusicVolume(musvol); } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index dbc3d31d2..4a74800c3 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3651,6 +3651,7 @@ void P_SetupLevel (const char *lumpname, int position) if (!savegamerestore) { + level.SetMusicVolume(level.MusicVolume); for (i = 0; i < MAXPLAYERS; ++i) { players[i].killcount = players[i].secretcount diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index d5df5d8df..3726050e0 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -886,7 +886,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) { // let's try to get the best version possible. Some drivers only give us the version we request // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. - static int versions[] = { 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 }; + static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 }; for (int i = 0; versions[i] > 0; i++) {