aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
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
parentc21124cffa63b4bb86a66de51499a2b9da77332e (diff)
downloadNorthstarLauncher-550a5daa072fe1c1a963f3ee0a6b7578a770338a.tar.gz
NorthstarLauncher-550a5daa072fe1c1a963f3ee0a6b7578a770338a.zip
fix crash when reloading mods when an override is played
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj6
-rw-r--r--NorthstarDedicatedTest/audio.cpp21
2 files changed, 25 insertions, 2 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index 2b1cfb2d..abd50fc8 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
+ <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -63,6 +63,7 @@
<AdditionalIncludeDirectories>$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BufferSecurityCheck>
</BufferSecurityCheck>
+ <ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -93,6 +94,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>
</BufferSecurityCheck>
+ <ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
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