From 2da6f2325eceee025aceae021944c8bf9d550c9b Mon Sep 17 00:00:00 2001 From: tehe Date: Sun, 7 Jul 2024 11:23:38 +0200 Subject: [PATCH] Bugfix: don't play theme if music off (#43) * Bugfix: don't play theme if music off Otherwise, it causes Access Violation error. * Fix PR code, update union-api submodule --------- Co-authored-by: damianut --- dependencies/union-api | 2 +- docs/docs/reference/externals/index.md | 2 +- src/Gothic/Externals.hpp | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dependencies/union-api b/dependencies/union-api index 406e3fb..f492eb0 160000 --- a/dependencies/union-api +++ b/dependencies/union-api @@ -1 +1 @@ -Subproject commit 406e3fb32232300bae2ff2ee0018685c15c7f1ef +Subproject commit f492eb06395ebb036c4171aa897c11e619007d41 diff --git a/docs/docs/reference/externals/index.md b/docs/docs/reference/externals/index.md index afff37a..4a32d17 100644 --- a/docs/docs/reference/externals/index.md +++ b/docs/docs/reference/externals/index.md @@ -4,7 +4,7 @@ ## BassMusic_Play -Triggers an event to start a new music theme. +Triggers an event to start a new music theme. If the player has turned off the music in the menu, the theme will not be played. ```dae func void BassMusic_Play(var string id) diff --git a/src/Gothic/Externals.hpp b/src/Gothic/Externals.hpp index 67dbd07..d371323 100644 --- a/src/Gothic/Externals.hpp +++ b/src/Gothic/Externals.hpp @@ -8,6 +8,12 @@ namespace GOTHIC_NAMESPACE { zSTRING id; parser->GetParameter(id); + if (zCMusicSystem::s_musicSystemDisabled) + { + static NH::Logger* log = NH::CreateLogger("zBassMusic::BassMusic_Play"); + log->Error("Music system disabled."); + return 0; + } zCMusicTheme* theme = zmusic->LoadThemeByScript(id); zmusic->PlayTheme(theme, zMUS_THEME_VOL_DEFAULT, zMUS_TR_DEFAULT, zMUS_TRSUB_DEFAULT); return 0;