Skip to content

Commit

Permalink
tr2/option: fix music resuming on volume change
Browse files Browse the repository at this point in the history
Resolves #1707.
  • Loading branch information
rr- committed Nov 2, 2024
1 parent cef24d9 commit 94607d3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- removed hardcoded `0` key binding for flares
- removed hardcoded cooldown of 15 frames for medipacks
- changed text backend to accept named sequences (eg. "\{arrow up}" and similar)
- changed inventory to pause the music rather than muting it (#1707)
- improved FMV mode appearance - removed black scanlines (#1729)
- improved FMV mode behavior - stopped switching screen resolutions (#1729)
- improved screenshots: now saved in the screenshots/ directory with level titles and timestamps as JPG or PNG, similar to TR1X (#1773)
Expand Down Expand Up @@ -56,6 +57,7 @@
- fixed the dragon counting as more than one kill if allowed to revive (#1771)
- fixed a crash when firing grenades at Xian guards in statue form (#1561)
- fixed harpoon bolts damaging inactive enemies (#1804)
- fixed sound settings resuming the music (#1707)

## [0.5](https://github.com/LostArtefacts/TRX/compare/afaf12a...tr2-0.5) - 2024-10-08
- added `/sfx` command
Expand Down
10 changes: 5 additions & 5 deletions src/tr2/game/inventory/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)

Sound_StopAllSamples();
if (inventory_mode != INV_TITLE_MODE) {
Music_SetVolume(0);
Music_Pause();
}

switch (inventory_mode) {
Expand Down Expand Up @@ -765,15 +765,15 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)

if (g_Inv_Chosen == NO_OBJECT) {
if (inventory_mode != INV_TITLE_MODE && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
Music_Unpause();
}
return 0;
}

switch (g_Inv_Chosen) {
case O_PASSPORT_OPTION:
if (g_Inv_ExtraData[0] == 1 && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
Music_Unpause();
}
return 1;

Expand Down Expand Up @@ -801,8 +801,8 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)
break;
}

if (inventory_mode != INV_TITLE_MODE && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
if (inventory_mode != INV_TITLE_MODE) {
Music_Unpause();
}
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/game/music.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ void __cdecl Music_Stop(void);
bool __cdecl Music_PlaySynced(int16_t track_id);
double __cdecl Music_GetTimestamp(void);
void __cdecl Music_SetVolume(int32_t volume);
void Music_Pause(void);
void Music_Unpause(void);
16 changes: 16 additions & 0 deletions src/tr2/game/music/music_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,19 @@ void __cdecl Music_SetVolume(int32_t volume)
Audio_Stream_SetVolume(m_AudioStreamID, m_MusicVolume);
}
}

void Music_Pause(void)
{
if (m_AudioStreamID < 0) {
return;
}
Audio_Stream_Pause(m_AudioStreamID);
}

void Music_Unpause(void)
{
if (m_AudioStreamID < 0) {
return;
}
Audio_Stream_Unpause(m_AudioStreamID);
}

0 comments on commit 94607d3

Please sign in to comment.