summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio/AudioManager.cpp19
-rw-r--r--src/audio/AudioManager.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index d9b7fee2..0a7cd93a 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -12,6 +12,24 @@ cAudioManager &AudioManager = *(cAudioManager *)0x880FC0;
constexpr int totalAudioEntitiesSlots = 200;
+int32
+cAudioManager::RandomDisplacement(uint32 seed)
+{
+ int32 value;
+
+ static bool bIsEven = true;
+ static uint8 base = 0;
+
+ if(!seed) return 0;
+
+ value = m_anRandomTable[(base + seed) % 5] % seed;
+ base += value;
+
+ if(value % 2) { bIsEven = !bIsEven; }
+ if(!bIsEven) value = -value;
+ return value;
+}
+
void
cAudioManager::ReleaseDigitalHandle()
{
@@ -2814,6 +2832,7 @@ cAudioManager::Service()
}
STARTPATCHES
+InjectHook(0x57AF90, &cAudioManager::RandomDisplacement, PATCH_JUMP);
InjectHook(0x57A9E0, &cAudioManager::ReleaseDigitalHandle, PATCH_JUMP);
InjectHook(0x57A9F0, &cAudioManager::RequireDigitalHandle, PATCH_JUMP);
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 6b320b60..95478922 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -216,6 +216,8 @@ public:
char field_19195;
int m_nTimeOfRecentCrime;
+ int32 RandomDisplacement(uint32 seed);
+
void ReleaseDigitalHandle();
void RequireDigitalHandle();
void SetDynamicAcousticModelingStatus(bool status);