From 9db96f004bf916cd249df924420019aa116c62d6 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 19 Apr 2020 13:14:49 -0700 Subject: [PATCH] Remove Game::globalsound It looks like this variable was originally intended to keep track of th volume of the game, but then it was used as a boolean in main.cpp to make sure the game didn't call Mix_Volume() and Mix_VolumeMusic() every frame. However, it is now a problem, because I put the music mute handling code in the very branch that game.globalsound protects against, but since game.globalsound is here, if I mute the music, then mute the whole game, then unmute the music, and then unmute the whole game, sound effects will no longer be muted but the music will still be muted, until I mute and unmute the whole game again. This is annoying and inconsistent, so I'm removing this check from the 'if (!game.muted)' branch. Plus, given that the Mix_VolumeMusic() and Mix_Volume() calls happen every frame if the game is muted anyways, it doesn't seem to be a problem to call these every frame. --- desktop_version/src/Game.cpp | 1 - desktop_version/src/Game.h | 1 - desktop_version/src/main.cpp | 4 +--- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index e87973f6..99b3b445 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -121,7 +121,6 @@ void Game::init(void) muted = false; musicmuted = false; musicmutebutton = 0; - globalsound = 128; glitchrunkludge = false; hascontrol = true; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index c1769bd2..f16ea6db 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -350,7 +350,6 @@ public: bool quickrestartkludge; bool paused; - int globalsound; //Custom stuff std::string customscript[50]; diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 71a1f3b4..0ef847ac 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -528,14 +528,12 @@ int main(int argc, char *argv[]) if (game.muted) { - game.globalsound = 0; Mix_VolumeMusic(0) ; Mix_Volume(-1,0); } - if (!game.muted && game.globalsound == 0) + if (!game.muted) { - game.globalsound = 1; Mix_Volume(-1,MIX_MAX_VOLUME); if (game.musicmuted)