From 01dafabf2509c60950a64f44ad4a53d3cf889486 Mon Sep 17 00:00:00 2001 From: Piotr Macha Date: Fri, 10 May 2024 06:04:46 +0200 Subject: [PATCH 1/3] #5 Deactivate CGameManager::Init_Hook for non-supported versions --- plugin/src/Gothic/Hooks.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/src/Gothic/Hooks.hpp b/plugin/src/Gothic/Hooks.hpp index b77e09f..61bc785 100644 --- a/plugin/src/Gothic/Hooks.hpp +++ b/plugin/src/Gothic/Hooks.hpp @@ -2,9 +2,11 @@ namespace GOTHIC_NAMESPACE { // G1: 0x004240C0 public: void __thiscall CGameManager::Init(struct HWND__ * &) // G2A: 0x00424C70 public: void __thiscall CGameManager::Init(struct HWND__ * &) - auto Ivk_CGameManager_Init = Union::CreateHook(reinterpret_cast(zSwitch(0x004240C0, 0x00424C70)), &CGameManager::Init_Hook, Union::HookType::Hook_CallPatch); + auto Ivk_CGameManager_Init = Union::CreateHook( + GetGameVersion() == ENGINE ? reinterpret_cast(zSwitch(0x004240C0, 0x00424C70)) : 0, + &CGameManager::Init_Hook, Union::HookType::Hook_CallPatch); inline void CGameManager::Init_Hook(HWND__*& hwnd) - { + { static NH::Logger* log = NH::CreateLogger("zBassMusic::CGameManager::Init_Hook"); if (GetGameVersion() != ENGINE) From 4eacb486da61640074ba3bc1193e799283c81333 Mon Sep 17 00:00:00 2001 From: Piotr Macha Date: Fri, 10 May 2024 06:15:53 +0200 Subject: [PATCH 2/3] Fix music playback stopping after starting new game --- plugin/src/Gothic/CMusicSys_Bass.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/src/Gothic/CMusicSys_Bass.hpp b/plugin/src/Gothic/CMusicSys_Bass.hpp index 474b026..f219267 100644 --- a/plugin/src/Gothic/CMusicSys_Bass.hpp +++ b/plugin/src/Gothic/CMusicSys_Bass.hpp @@ -321,7 +321,6 @@ namespace GOTHIC_NAMESPACE { log->Debug("Stop"); m_ActiveTheme = nullptr; - m_BassEngine->StopMusic(); m_DirectMusic->Stop(); } From 1b366ba23a2472e5368cefbc1408f87b708861a5 Mon Sep 17 00:00:00 2001 From: Piotr Macha Date: Fri, 10 May 2024 06:17:59 +0200 Subject: [PATCH 3/3] Decrease interval of checking if music is ready to play --- plugin/src/NH/Bass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/NH/Bass.cpp b/plugin/src/NH/Bass.cpp index 78f4b1e..6e59b8f 100644 --- a/plugin/src/NH/Bass.cpp +++ b/plugin/src/NH/Bass.cpp @@ -55,7 +55,7 @@ namespace NH if (!file->Ready && file->Loading) { - static int32_t delay = 500; + static int32_t delay = 10; log->Debug("{0} is loading, will retry after {1} ms", musicDef.Filename, delay); MusicDefRetry retry{ MusicDef(musicDef), delay }; m_PlayMusicRetryList.emplace_back(retry);