aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/audio.cpp
diff options
context:
space:
mode:
authorHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2022-01-04 20:15:36 +0300
committerHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2022-01-04 20:15:36 +0300
commit550a5daa072fe1c1a963f3ee0a6b7578a770338a (patch)
tree5cffab77f5401d00522620a2ca6210ba169639cd /NorthstarDedicatedTest/audio.cpp
parentc21124cffa63b4bb86a66de51499a2b9da77332e (diff)
downloadNorthstarLauncher-550a5daa072fe1c1a963f3ee0a6b7578a770338a.tar.gz
NorthstarLauncher-550a5daa072fe1c1a963f3ee0a6b7578a770338a.zip
fix crash when reloading mods when an override is played
Diffstat (limited to 'NorthstarDedicatedTest/audio.cpp')
-rw-r--r--NorthstarDedicatedTest/audio.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/audio.cpp b/NorthstarDedicatedTest/audio.cpp
index 5aa7354f..d56762e0 100644
--- a/NorthstarDedicatedTest/audio.cpp
+++ b/NorthstarDedicatedTest/audio.cpp
@@ -214,6 +214,9 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
bool CustomAudioManager::TryLoadAudioOverride(const fs::path& defPath)
{
+ if (IsDedicated())
+ return true; // silently fail
+
std::ifstream jsonStream(defPath);
std::stringstream jsonStringStream;
@@ -249,8 +252,24 @@ bool CustomAudioManager::TryLoadAudioOverride(const fs::path& defPath)
return true;
}
+typedef void (*MilesStopAll_Type)();
+MilesStopAll_Type MilesStopAll;
+
void CustomAudioManager::ClearAudioOverrides()
{
+ if (IsDedicated())
+ return;
+
+ if (m_loadedAudioOverrides.size() > 0 || m_loadedAudioOverridesRegex.size() > 0)
+ {
+ // stop all miles sounds beforehand
+ // miles_stop_all
+ MilesStopAll();
+
+ // this is cancer but it works
+ Sleep(50);
+ }
+
m_loadedAudioOverrides.clear();
m_loadedAudioOverridesRegex.clear();
}
@@ -440,4 +459,6 @@ void InitialiseMilesAudioHooks(HMODULE baseAddress)
ENABLER_CREATEHOOK(hook, (char*)milesAudioBase + 0xF110, &LoadSampleMetadata_Hook, reinterpret_cast<LPVOID*>(&LoadSampleMetadata_Original));
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x57DAD0, &MilesLog_Hook, reinterpret_cast<LPVOID*>(&MilesLog_Original));
+
+ MilesStopAll = (MilesStopAll_Type)((char*)baseAddress + 0x580850);
} \ No newline at end of file