summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-08-30 09:58:51 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2021-08-30 09:58:51 +0200
commit8cbdf272289240913884ef9a484a2fb027349c8d (patch)
treea853b02aaef34a33ddaec5f5d621aaa9be06c5f2
parentscript revision p2 (diff)
parentFix yet another DirectlyEnqueueSample (diff)
downloadre3-8cbdf272289240913884ef9a484a2fb027349c8d.tar
re3-8cbdf272289240913884ef9a484a2fb027349c8d.tar.gz
re3-8cbdf272289240913884ef9a484a2fb027349c8d.tar.bz2
re3-8cbdf272289240913884ef9a484a2fb027349c8d.tar.lz
re3-8cbdf272289240913884ef9a484a2fb027349c8d.tar.xz
re3-8cbdf272289240913884ef9a484a2fb027349c8d.tar.zst
re3-8cbdf272289240913884ef9a484a2fb027349c8d.zip
-rw-r--r--src/audio/AudioLogic.cpp103
-rw-r--r--src/audio/AudioManager.cpp7
-rw-r--r--src/audio/AudioManager.h4
3 files changed, 108 insertions, 6 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index b8490563..ba9d7006 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -44,6 +44,7 @@
#include "Script.h"
#include "Wanted.h"
#include "KeyGen.h"
+#include "Ferry.h"
void
cAudioManager::PreInitialiseGameSpecificSetup()
@@ -554,6 +555,11 @@ enum
TRAIN_NOISE_NEAR_MAX_DIST = 70,
TRAIN_NOISE_VOLUME = 70,
+ FERRY_NOISE_MAX_DIST = 70,
+ FERRY_NOISE_WATER_VOLUME = 30,
+ FERRY_NOISE_ENGINE_MAX_DIST = 160,
+ FERRY_NOISE_ENGINE_VOLUME = 40,
+
BOAT_ENGINE_MAX_DIST = 90,
BOAT_ENGINE_REEFER_IDLE_VOLUME = 80,
@@ -1084,10 +1090,10 @@ cAudioManager::ProcessVehicle(CVehicle* veh)
ProcessVehicleOneShots(params);
break;
#ifdef GTA_TRAIN
- case VEHICLE_TYPE_TRAIN:
- ProcessTrainNoise(params);
- ProcessVehicleOneShots(params);
- break;
+ case VEHICLE_TYPE_TRAIN:
+ ProcessTrainNoise(params);
+ ProcessVehicleOneShots(params);
+ break;
#endif
case VEHICLE_TYPE_HELI:
ProcessCarHeli(params);
@@ -1114,6 +1120,10 @@ cAudioManager::ProcessVehicle(CVehicle* veh)
ProcessVehicleOneShots(params);
((CBike*)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
break;
+ case VEHICLE_TYPE_FERRY:
+ ProcessFerryNoise(params);
+ ProcessVehicleOneShots(params);
+ break;
default:
break;
}
@@ -3726,6 +3736,91 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params)
return FALSE;
}
#endif
+
+
+bool8
+cAudioManager::ProcessFerryNoise(cVehicleParams& params)
+{
+ CFerry *ferry = (CFerry*)params.m_pVehicle;
+ float volMultipler;
+
+#ifdef FIX_BUGS
+ if (!ferry->IsDocked() && params.m_fDistance < SQR(FERRY_NOISE_ENGINE_MAX_DIST)) {
+#else
+ if (!ferry->IsDocked() && params.m_fDistance < SQR(FERRY_NOISE_MAX_DIST)){
+#endif
+ if (params.m_fVelocityChange > 0.0f) {
+ CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
+#ifdef FIX_BUGS // most distant sound should go first
+ volMultipler = ((float)SQR(FERRY_NOISE_ENGINE_MAX_DIST) - params.m_fDistance) / (float)SQR(FERRY_NOISE_ENGINE_MAX_DIST);
+ m_sQueueSample.m_nVolume = (FERRY_NOISE_ENGINE_VOLUME * volMultipler);
+ if (m_sQueueSample.m_nVolume > 0) {
+ m_sQueueSample.m_nCounter = 40;
+ m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP;
+ m_sQueueSample.m_nBankIndex = SFX_BANK_0;
+ m_sQueueSample.m_bIs2D = FALSE;
+ m_sQueueSample.m_nPriority = 3;
+ m_sQueueSample.m_nFrequency = 12000;
+ m_sQueueSample.m_nLoopCount = 0;
+ SET_EMITTING_VOLUME(FERRY_NOISE_ENGINE_VOLUME);
+ SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
+ m_sQueueSample.m_fSpeedMultiplier = 2.0f;
+ m_sQueueSample.m_MaxDistance = FERRY_NOISE_ENGINE_MAX_DIST;
+ m_sQueueSample.m_bStatic = FALSE;
+ m_sQueueSample.m_nFramesToPlay = 7;
+ SET_SOUND_REVERB(FALSE);
+ SET_SOUND_REFLECTION(FALSE);
+ AddSampleToRequestedQueue();
+ }
+#endif
+
+ if (params.m_fDistance < SQR(FERRY_NOISE_MAX_DIST)) {
+ volMultipler = ((float)SQR(FERRY_NOISE_MAX_DIST) - params.m_fDistance) / (float)SQR(FERRY_NOISE_MAX_DIST);
+ m_sQueueSample.m_nVolume = (FERRY_NOISE_WATER_VOLUME * volMultipler);
+ if (m_sQueueSample.m_nVolume > 0) {
+ m_sQueueSample.m_nCounter = 33;
+ m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
+ m_sQueueSample.m_nBankIndex = SFX_BANK_0;
+ m_sQueueSample.m_bIs2D = FALSE;
+ m_sQueueSample.m_nPriority = 5;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BOAT_WATER_LOOP) + (100 * m_sQueueSample.m_nEntityIndex) % 987;
+ m_sQueueSample.m_nLoopCount = 0;
+ SET_EMITTING_VOLUME(FERRY_NOISE_WATER_VOLUME);
+ SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
+ m_sQueueSample.m_fSpeedMultiplier = 6.0f;
+ m_sQueueSample.m_MaxDistance = FERRY_NOISE_MAX_DIST;
+ m_sQueueSample.m_bStatic = FALSE;
+ m_sQueueSample.m_nFramesToPlay = 3;
+ SET_SOUND_REVERB(FALSE);
+ SET_SOUND_REFLECTION(FALSE);
+ AddSampleToRequestedQueue();
+#ifndef FIX_BUGS
+ m_sQueueSample.m_nCounter = 40;
+ m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP;
+ m_sQueueSample.m_nBankIndex = SFX_BANK_0;
+ m_sQueueSample.m_bIs2D = FALSE;
+ m_sQueueSample.m_nPriority = 3;
+ m_sQueueSample.m_nFrequency = 12000;
+ m_sQueueSample.m_nLoopCount = 0;
+ SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
+ m_sQueueSample.m_fSpeedMultiplier = 2.0f;
+ m_sQueueSample.m_MaxDistance = FERRY_NOISE_ENGINE_MAX_DIST;
+ m_sQueueSample.m_bStatic = FALSE;
+ m_sQueueSample.m_nFramesToPlay = 7;
+ SET_SOUND_REVERB(FALSE);
+ SET_SOUND_REFLECTION(FALSE);
+ m_sQueueSample.m_nVolume = volMultipler * FERRY_NOISE_ENGINE_VOLUME;
+ SET_EMITTING_VOLUME(FERRY_NOISE_ENGINE_VOLUME);
+ AddSampleToRequestedQueue();
+#endif
+ }
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
bool8
cAudioManager::ProcessBoatEngine(cVehicleParams& params)
{
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index b9970562..c3466b59 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -687,7 +687,7 @@ cAudioManager::InterrogateAudioEntities()
}
void
-cAudioManager::AddSampleToRequestedQueue()
+cAudioManager::AddSampleToRequestedQueue(uint8 unk_lcs)
{
uint32 finalPriority;
uint8 sampleIndex;
@@ -726,6 +726,7 @@ cAudioManager::AddSampleToRequestedQueue()
m_sQueueSample.m_bReverb = FALSE;
#endif
#endif
+ m_sQueueSample.field_51_lcs = unk_lcs;
m_aRequestedQueue[m_nActiveQueue][sampleIndex] = m_sQueueSample;
@@ -1405,6 +1406,10 @@ cAudioManager::GenerateIntegerRandomNumberTable()
void
cAudioManager::DirectlyEnqueueSample(uint32 sample, uint8 bank, uint32 counter, uint32 priority, uint32 freq, uint8 volume, uint8 framesToPlay, uint32 notStereo)
{
+#ifdef FIX_BUGS
+ if (!m_bIsInitialised || m_nExtraSoundsEntity < 0) return;
+ m_sQueueSample.m_nEntityIndex = m_nExtraSoundsEntity; // not setting entity ID could cause bugs, let's use extra sounds one
+#endif
m_sQueueSample.m_nSampleIndex = sample;
m_sQueueSample.m_nBankIndex = bank;
m_sQueueSample.m_nCounter = counter;
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index f9472a52..c5436cc0 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -59,6 +59,7 @@ public:
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
int8 m_nEmittingVolumeChange; // same as above but for m_nEmittingVolume
#endif
+ uint8 field_51_lcs;
};
VALIDATE_SIZE(tSound, 96);
@@ -347,7 +348,7 @@ public:
uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier);
int32 RandomDisplacement(uint32 seed);
void InterrogateAudioEntities(); // inlined
- void AddSampleToRequestedQueue();
+ void AddSampleToRequestedQueue(uint8 unk_lcs = 0);
void AddDetailsToRequestedOrderList(uint8 sample); // inlined in vc
#ifdef AUDIO_REFLECTIONS
void AddReflectionsToRequestedQueue();
@@ -415,6 +416,7 @@ public:
#ifdef GTA_TRAIN
bool8 ProcessTrainNoise(cVehicleParams &params);
#endif
+ bool8 ProcessFerryNoise(cVehicleParams &params);
bool8 ProcessBoatEngine(cVehicleParams &params);
bool8 ProcessBoatMovingOverWater(cVehicleParams &params);
void ProcessPlane(cVehicleParams &params);