diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp
index 9f098f1..e95d1da 100644
--- a/DDraw/dllmain.cpp
+++ b/DDraw/dllmain.cpp
@@ -196,9 +196,11 @@ static bool PatchIAT()
static bool PatchIAT_ByPointers()
{
+ using namespace Memory::VP;
+
pOrgSystemParametersInfoA = SystemParametersInfoA;
memcpy( orgCode, pOrgSystemParametersInfoA, sizeof(orgCode) );
- Memory::VP::InjectHook( pOrgSystemParametersInfoA, SystemParametersInfoA_OverwritingHook, Memory::HookType::Jump );
+ InjectHook( pOrgSystemParametersInfoA, SystemParametersInfoA_OverwritingHook, HookType::Jump );
return true;
}
diff --git a/DDraw/versionmeta.props b/DDraw/versionmeta.props
index 44e58c0..7500201 100644
--- a/DDraw/versionmeta.props
+++ b/DDraw/versionmeta.props
@@ -6,7 +6,7 @@
.dll
SilentPatch DDraw Component
6
- 0
+ 1
2014-2024
diff --git a/SilentPatch/Utils b/SilentPatch/Utils
index 95e523f..70cab49 160000
--- a/SilentPatch/Utils
+++ b/SilentPatch/Utils
@@ -1 +1 @@
-Subproject commit 95e523fa7494c0353b7ecfab408024a9d7b7e161
+Subproject commit 70cab494523e76d56063b5044c34345c14803c96
diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp
index fbb25ac..c29385a 100644
--- a/SilentPatchIII/SilentPatchIII.cpp
+++ b/SilentPatchIII/SilentPatchIII.cpp
@@ -722,7 +722,7 @@ namespace DodoKeyboardControls
// ============= Resetting stats and variables on New Game =============
namespace VariableResets
{
- static auto TimerInitialise = reinterpret_cast(hook::get_pattern("83 E4 F8 68 ? ? ? ? E8", -6));
+ static void (*TimerInitialise)();
using VarVariant = std::variant< bool*, int* >;
std::vector GameVariablesToReset;
@@ -736,8 +736,6 @@ namespace VariableResets
}, var );
}
- // Functions that should have been called by the game but aren't...
- TimerInitialise();
PurpleNinesGlitchFix();
}
@@ -757,8 +755,22 @@ namespace VariableResets
void GameInitialise(const char* path)
{
ReInitOurVariables();
+ TimerInitialise();
orgGameInitialise(path);
}
+
+ static void (__fastcall* DestroyAllGameCreatedEntities)(void* DMAudio);
+
+ template
+ static void (__fastcall* orgService)(void* DMAudio);
+
+ template
+ static void __fastcall Service_AndDestroyEntities(void* DMAudio)
+ {
+ DestroyAllGameCreatedEntities(DMAudio);
+ orgService(DMAudio);
+ }
+ HOOK_EACH_INIT(Service, orgService, Service_AndDestroyEntities);
}
@@ -2354,8 +2366,22 @@ void Patch_III_Common()
get_pattern("C6 05 ? ? ? ? ? E8 ? ? ? ? C7 05", 7)
};
+ TimerInitialise = reinterpret_cast(get_pattern("83 E4 F8 68 ? ? ? ? E8", -6));
+
+ // In GTA III, we also need to backport one more fix from VC to avoid issues with looping audio entities:
+ // CMenuManager::DoSettingsBeforeStartingAGame needs to call cDMAudio::DestroyAllGameCreatedEntities
+ DestroyAllGameCreatedEntities = reinterpret_cast(ReadCallFrom(
+ get_pattern("B9 ? ? ? ? E8 ? ? ? ? 31 DB BD ? ? ? ? 8D 40 00", 5)));
+
+ auto audio_service = pattern("B9 ? ? ? ? E8 ? ? ? ? B9 ? ? ? ? C6 05 ? ? ? ? ? E8").count(2);
+ std::array audio_service_instances = {
+ audio_service.get(0).get(5),
+ audio_service.get(1).get(5),
+ };
+
InterceptCall(game_initialise, orgGameInitialise, GameInitialise);
HookEach_ReInitGameObjectVariables(reinit_game_object_variables, InterceptCall);
+ HookEach_Service(audio_service_instances, InterceptCall);
// Variables to reset
GameVariablesToReset.emplace_back(*get_pattern("80 3D ? ? ? ? ? 74 2A", 2)); // Free resprays
diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp
index c7ba296..003b4ad 100644
--- a/SilentPatchVC/SilentPatchVC.cpp
+++ b/SilentPatchVC/SilentPatchVC.cpp
@@ -1133,7 +1133,7 @@ namespace IsPlayerTargettingCharFix
// ============= Resetting stats and variables on New Game =============
namespace VariableResets
{
- static auto TimerInitialise = reinterpret_cast(hook::get_pattern("83 E4 F8 68 ? ? ? ? E8", -6));
+ static void (*TimerInitialise)();
using VarVariant = std::variant< bool*, int* >;
std::vector GameVariablesToReset;
@@ -1146,9 +1146,6 @@ namespace VariableResets
*v = {};
}, var );
}
-
- // Functions that should have been called by the game but aren't...
- TimerInitialise();
}
template
@@ -1167,6 +1164,7 @@ namespace VariableResets
void GameInitialise(const char* path)
{
ReInitOurVariables();
+ TimerInitialise();
orgGameInitialise(path);
}
}
@@ -2798,6 +2796,8 @@ void Patch_VC_Common()
get_pattern("C6 05 ? ? ? ? ? E8 ? ? ? ? C7 05", 7)
};
+ TimerInitialise = reinterpret_cast(get_pattern("83 E4 F8 68 ? ? ? ? E8", -6));
+
InterceptCall(game_initialise, orgGameInitialise, GameInitialise);
HookEach_ReInitGameObjectVariables(reinit_game_object_variables, InterceptCall);
diff --git a/SilentPatchVC/versionmeta.props b/SilentPatchVC/versionmeta.props
index 66afbb3..28386b1 100644
--- a/SilentPatchVC/versionmeta.props
+++ b/SilentPatchVC/versionmeta.props
@@ -6,7 +6,7 @@
.asi
SilentPatch for Vice City
11
- 1
+ 2
2013-2024