Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

music: fix the main music playing at the wrong volume with certain sound options #1544

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

walkawayy
Copy link
Collaborator

Fixed quiet or mute main menu music if a level was exited while underwater and the quiet, full but no ambient, quiet but no ambient, or none underwater music behavior option was set.

Resolves #1540.

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change

Description

Fixed the main menu music being quiet or mute if a level was exited while underwater and the quiet, full but no ambient, quiet but no ambient, or none underwater music behavior option was set (regression from 4.4). I tried to apply the fix to the volume in a logical place which is where the other config option to mute main menu music is. M_EnsureEnvironment couldn't be called because Game_DrawScene isn't called when in the title menu inventory soCamera_Apply is never called. Might need to be hotfixed though it's not a game breaking issue, and it should be a rare bug.

@walkawayy walkawayy self-assigned this Sep 25, 2024
@walkawayy walkawayy requested review from a team as code owners September 25, 2024 23:58
@walkawayy walkawayy requested review from rr- and lahm86 and removed request for a team September 25, 2024 23:58
@walkawayy walkawayy changed the title music: fix the main music playing at the wrong volume music: fix the main music playing at the wrong volume with certain sound options Sep 26, 2024
Copy link
Collaborator

@aredfan aredfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@rr-
Copy link
Collaborator

rr- commented Sep 26, 2024

Thanks. I think that a more fitting place for both this volume fix and the title level music check would be in Level_Initialise, like so:

diff --git a/src/game/level.c b/src/game/level.c
index 42c50c0f..c60f2143 100644
--- a/src/game/level.c
+++ b/src/game/level.c
@@ -1149,11 +1149,14 @@ bool Level_Initialise(int32_t level_num)
     Overlay_BarSetHealthTimer(100);
 
     Music_Stop();
+    Music_SetVolume(g_Config.music_volume);
     Sound_ResetEffects();
 
     Viewport_SetFOV(Viewport_GetUserFOV());
 
-    if (g_GameFlow.levels[level_num].music) {
+    const bool disable_music = level_num == g_GameFlow.title_level_num
+        && !g_Config.enable_music_in_menu;
+    if (g_GameFlow.levels[level_num].music && !disable_music) {
         Music_PlayLooped(g_GameFlow.levels[level_num].music);
     }
 
diff --git a/src/game/music.c b/src/game/music.c
index c24810a5..382bf82f 100644
--- a/src/game/music.c
+++ b/src/game/music.c
@@ -131,11 +131,6 @@ bool Music_PlayLooped(MUSIC_TRACK_ID track)
         return false;
     }
 
-    if (g_CurrentLevel == g_GameFlow.title_level_num
-        && !g_Config.enable_music_in_menu) {
-        return false;
-    }
-
     M_StopActiveStream();
 
     char *file_path = M_GetTrackFileName(track);

@walkawayy walkawayy added this to the 4.5 milestone Sep 26, 2024
@walkawayy walkawayy force-pushed the underwater-title-music branch from 2fb6f0b to 9c47069 Compare September 26, 2024 14:52
@walkawayy
Copy link
Collaborator Author

Ok done. Amended the issue commit and added a second commit which moves the enable_music_in_menu option check to Level_Initialise. This looks much better. I just didn't want to move it without permission lol.

CHANGELOG.md Outdated Show resolved Hide resolved
@walkawayy walkawayy force-pushed the underwater-title-music branch from 9c47069 to 60f033a Compare September 26, 2024 22:19
Fixed quiet or mute main menu music if a level was exited while
underwater and the quiet, full but no ambient, quiet but no
ambient, or none underwater music behavior option was set.

Resolves LostArtefacts#1540.
@walkawayy walkawayy force-pushed the underwater-title-music branch from 60f033a to 13b9d40 Compare September 26, 2024 22:21
@walkawayy walkawayy merged commit 82bfe16 into LostArtefacts:develop Sep 26, 2024
5 checks passed
@rr- rr- added TR1 and removed Priority: high labels Oct 3, 2024
@walkawayy walkawayy deleted the underwater-title-music branch November 9, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TR1 TRX bug A bug with TRX
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

TR1X bug: main menu music is affected when exiting to title while UW
4 participants