From e68d3ee2380dba98a72f2668a2c2664fc993bb4a Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 19 Nov 2023 05:08:01 +0900 Subject: Fix off-by-one music selection Fixes: https://todo.sr.ht/~cnx/blackshades/25 --- src/GameLoop.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/GameLoop.cpp') diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 66b7395..da531e1 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -41,23 +41,18 @@ void handleKey(Game* game, int key, int action, int mods) return; auto& player = game->person[0]; if (key == GLFW_KEY_ESCAPE) { - alSourcePause(gSourceID[rainsound]); - setMenu(game, true); + alSourceStop(gSourceID[rainsound]); + alSourceStop(gSourceID[visionsound]); + if (game->musictoggle) { + alSourceStop(gSourceID[game->whichsong]); + game->whichsong = mainmenusong; + alSourcef(gSourceID[game->whichsong], AL_PITCH, 1); + alSourcePlay(gSourceID[game->whichsong]); + } alSourcePlay(gSourceID[souloutsound]); + setMenu(game, true); game->flashamount = 1.0f; game->flashr = game->flashg = game->flashb = 1.0f; - alSourceStop(gSourceID[visionsound]); - game->whichsong = mainmenusong; - alSourceStop(gSourceID[knifesong]); - alSourceStop(gSourceID[shootsong]); - alSourceStop(gSourceID[zombiesong]); - alSourceStop(gSourceID[mainmenusong]); - alSourcef(gSourceID[knifesong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[shootsong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[zombiesong], AL_MIN_GAIN, 0); - alSourcef(gSourceID[mainmenusong], AL_MIN_GAIN, 0); - alSourcePlay(gSourceID[game->whichsong]); - alSourcef(gSourceID[game->whichsong], AL_MIN_GAIN, 1); } else if (key == keymap.dive) { if (player.playerrotation == player.playerlowrotation && player.targetanimation == joganim -- cgit 1.4.1