From a9c3fdd63fd4ef985b708318a0e28353a11bba90 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 22 Sep 2020 03:28:14 +0300 Subject: [PATCH 01/22] rewisited: ProcessReverseGear ProcessWeather ProcessScriptObject ProcessExtraSounds ProcessEntity and so, more info in my repo --- src/audio/AudioLogic.cpp | 157 ++++++++++++++++++++++++++++----------- src/audio/AudioManager.h | 2 + 2 files changed, 117 insertions(+), 42 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index e76bb99d..cf2fd140 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -38,6 +38,7 @@ #include "ZoneCull.h" #include "sampman.h" #include "Bike.h" +#include "WindModifiers.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); @@ -292,7 +293,6 @@ cAudioManager::CalculateDistance(bool &distCalculated, float dist) if (!distCalculated) { if (dist > 0.0f) m_sQueueSample.m_fDistance = Sqrt(dist); - else m_sQueueSample.m_fDistance = 0.0f; distCalculated = true; @@ -337,7 +337,7 @@ cAudioManager::ProcessSpecial() void cAudioManager::ProcessEntity(int32 id) { - if (m_asAudioEntities[id].m_nStatus) { + if (m_asAudioEntities[id].m_nStatus != STATUS_PLAYER) { m_sQueueSample.m_nEntityIndex = id; switch (m_asAudioEntities[id].m_nType) { case AUDIOTYPE_PHYSICAL: @@ -361,29 +361,16 @@ cAudioManager::ProcessEntity(int32 id) case AUDIOTYPE_WEATHER: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; - ProcessWeather(id); + if(CGame::currArea == AREA_MAIN_MAP || CGame::currArea == AREA_EVERYWHERE) + ProcessWeather(id); } break; -/* case AUDIOTYPE_CRANE: - if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; - ProcessCrane(); - } - break;*/ case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; ProcessScriptObject(id); } break; -#ifdef GTA_BRIDGE - case AUDIOTYPE_BRIDGE: - if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; - ProcessBridge(); - } - break; -#endif case AUDIOTYPE_FRONTEND: m_sQueueSample.m_bReverbFlag = false; ProcessFrontEnd(); @@ -410,6 +397,18 @@ cAudioManager::ProcessEntity(int32 id) ProcessWaterCannon(id); } break; + case AUDIOTYPE_ESCALATOR: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + //ProcessEscalators(); //TODO + } + break; + case AUDIOTYPE_EXTRA_SOUNDS: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessExtraSounds(); + } + break; default: return; } @@ -869,27 +868,28 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) { const int reverseGearIntensity = 30; - CVehicle *veh; - CAutomobile *automobile; - int32 emittingVol; + CAutomobile* automobile; float modificator; + uint8 emittingVolume; if (params->m_fDistance >= SQR(reverseGearIntensity)) return false; - veh = params->m_pVehicle; - if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || veh->m_nCurrentGear == 0)) { + automobile = (CAutomobile*)params->m_pVehicle; + if (automobile->m_modelIndex == MI_CADDY) + return true; + if (automobile->bEngineOn && (automobile->m_fGasPedal < 0.0f || automobile->m_nCurrentGear == 0)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->m_nWheelsOnGround != 0) { + if (automobile->m_nDriveWheelsOnGround != 0) { modificator = params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity; } else { - if (automobile->m_nDriveWheelsOnGround != 0) + if (automobile->m_nDriveWheelsOnGroundPrev != 0) automobile->m_fGasPedalAudio *= 0.4f; modificator = automobile->m_fGasPedalAudio; } modificator = Abs(modificator); - emittingVol = (24.f * modificator); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance); + emittingVolume = modificator * 24.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, reverseGearIntensity, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { if (params->m_pVehicle->m_fGasPedal >= 0.0f) { m_sQueueSample.m_nCounter = 62; @@ -901,9 +901,9 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; + m_sQueueSample.m_nFrequency = (6000.0f * modificator) + 7000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; @@ -1197,7 +1197,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) break; } } - } else if (0.0f == params->m_fVelocityChange) { + } else if (params->m_fVelocityChange == 0.0f) { traction = 0.9f; } if (transmission->fMaxVelocity <= 0.0) { @@ -4186,7 +4186,6 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) return; break; } - soundIntensity = 50.0f; } else { switch (sound) { @@ -4558,6 +4557,47 @@ cAudioManager::ProcessWaterCannon(int32) } } +CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; + +void +cAudioManager::ProcessExtraSounds() +{ + const float extraSoundIntensity = 18; + + float distance; + + for (int i = 0; i < ARRAY_SIZE(aVecExtraSoundPosition); i++) { + m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; + distance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (distance < SQR(extraSoundIntensity)) { + if (distance > 0.0) + m_sQueueSample.m_fDistance = Sqrt(distance); + else + m_sQueueSample.m_fDistance = 0.0f; + m_sQueueSample.m_nVolume = ComputeVolume(50, 18.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + this->m_sQueueSample.m_nCounter = i; + this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; + this->m_sQueueSample.m_nBankIndex = 0; + this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); + this->m_sQueueSample.m_bIs2D = false; + this->m_sQueueSample.m_nLoopCount = 0; + this->m_sQueueSample.m_bReleasingSoundFlag = false; + this->m_sQueueSample.m_nReleasingVolumeModificator = 4; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0; + this->m_sQueueSample.m_nEmittingVolume = 50; + this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); + this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); + this->m_sQueueSample.m_bReverbFlag = true; + this->m_sQueueSample.m_fSoundIntensity = 18.0f; + this->m_sQueueSample.m_bRequireReflection = false; + this->m_sQueueSample.m_nReleasingVolumeDivider = 3; + AddSampleToRequestedQueue(); + } + } + } +} + #pragma region SCRIPT_OBJECTS const int SCRIPT_OBJECT_INTENSITY_S = 30; const int SCRIPT_OBJECT_INTENSITY_L = 80; @@ -4565,13 +4605,15 @@ const int SCRIPT_OBJECT_INTENSITY_L = 80; void cAudioManager::ProcessScriptObject(int32 id) { - cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; - if (entity != nil) { - m_sQueueSample.m_vecPos = entity->Posn; - if (m_asAudioEntities[id].m_AudioEvents == 1) - ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); - else - ProcessLoopingScriptObject(entity->AudioId); + if (MusicManager.m_nMusicMode == MUSICMODE_GAME) { + cAudioScriptObject* entity = (cAudioScriptObject*)m_asAudioEntities[id].m_pEntity; + if (entity != nil) { + m_sQueueSample.m_vecPos = entity->Posn; + if (m_asAudioEntities[id].m_AudioEvents == 1) + ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); + else + ProcessLoopingScriptObject(entity->AudioId); + } } } @@ -4959,14 +5001,19 @@ void cAudioManager::ProcessWeather(int32 id) { uint8 vol; + float x; + float y; + float modifier; + float wind; + static uint8 iSound = 0; - if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { + if (m_asAudioEntities[id].m_AudioEvents != 0 && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; - vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; + vol = (m_asAudioEntities[id].m_afVolume[0] - 10.0f) + 40; } else { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -4974,7 +5021,7 @@ cAudioManager::ProcessWeather(int32 id) vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; } m_sQueueSample.m_nVolume = vol; - if (TheCamera.SoundDistUp < 20.f) + if (TheCamera.SoundDistUp < 20.0f) m_sQueueSample.m_nVolume /= 2; if (iSound == 4) iSound = 0; @@ -4994,7 +5041,7 @@ cAudioManager::ProcessWeather(int32 id) if (CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { m_sQueueSample.m_nSampleIndex = SFX_RAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN); - m_sQueueSample.m_nVolume = (int32)(25.f * CWeather::Rain); + m_sQueueSample.m_nVolume = (uint8)(25.0f * CWeather::Rain); m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; @@ -5010,6 +5057,32 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } + x = 0.0f; + y = 0.0f; + CWindModifiers::FindWindModifier(TheCamera.GetPosition(), &x, &y); + modifier = Max(Abs(x), Abs(y)) * 10.0f; + modifier = Min(1.0f, modifier); + wind = Max(CWeather::Wind, modifier); + if (wind > 0.0f && CObject::fDistToNearestTree < 75.0) { + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PALM_TREE_LO); + m_sQueueSample.m_nVolume = (m_anRandomTable[1] % 10 + 45.0f) * (75.0f - CObject::fDistToNearestTree) * (4.0f / 300.0f) * wind; + m_sQueueSample.m_nCounter = 5; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nOffset = 63; + m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + CObject::fDistToNearestTree = 999999.9f; + } } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a93aa6f7..a598b698 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -370,6 +370,8 @@ public: void ProcessWaterCannon(int32); void ProcessWeather(int32 id); bool ProcessWetRoadNoise(cVehicleParams *params); + void ProcessEscalators(); + void ProcessExtraSounds(); int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; From b2e3d90734b46b36dce0a0fe3b4dd278168b6de2 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 22 Sep 2020 19:32:05 +0300 Subject: [PATCH 02/22] ProcessEscalators + some fixes --- src/audio/AudioLogic.cpp | 60 +++++++++++++++++++++++++++++++++++----- src/render/Fluff.h | 6 ++-- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index cf2fd140..1f6c4a53 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -39,6 +39,7 @@ #include "sampman.h" #include "Bike.h" #include "WindModifiers.h" +#include "Fluff.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); @@ -400,7 +401,7 @@ cAudioManager::ProcessEntity(int32 id) case AUDIOTYPE_ESCALATOR: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; - //ProcessEscalators(); //TODO + ProcessEscalators(); } break; case AUDIOTYPE_EXTRA_SOUNDS: @@ -3072,6 +3073,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } +//TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) { @@ -4557,12 +4559,14 @@ cAudioManager::ProcessWaterCannon(int32) } } +//positon of arcade machines CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; void cAudioManager::ProcessExtraSounds() { - const float extraSoundIntensity = 18; + const float extraSoundIntensity = 18.0f; + const uint8 extraSoundVolume = 50; float distance; @@ -4574,22 +4578,22 @@ cAudioManager::ProcessExtraSounds() m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(50, 18.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(extraSoundVolume, extraSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { this->m_sQueueSample.m_nCounter = i; this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; - this->m_sQueueSample.m_nBankIndex = 0; + this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); this->m_sQueueSample.m_bIs2D = false; this->m_sQueueSample.m_nLoopCount = 0; this->m_sQueueSample.m_bReleasingSoundFlag = false; this->m_sQueueSample.m_nReleasingVolumeModificator = 4; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0; - this->m_sQueueSample.m_nEmittingVolume = 50; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; + this->m_sQueueSample.m_nEmittingVolume = extraSoundVolume; this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_fSoundIntensity = 18.0f; + this->m_sQueueSample.m_fSoundIntensity = extraSoundIntensity; this->m_sQueueSample.m_bRequireReflection = false; this->m_sQueueSample.m_nReleasingVolumeDivider = 3; AddSampleToRequestedQueue(); @@ -4598,6 +4602,48 @@ cAudioManager::ProcessExtraSounds() } } +void +cAudioManager::ProcessEscalators() +{ + const float escalatorsSoundIntensity = 30.0f; + const uint8 escalatorsSoundVolume = 26; + + float distance; + + for (int i = 0; i < CEscalators::NumEscalators; i++) { + if (!CEscalators::aEscalators[i].m_bIsActive) + continue; + m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; + distance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (distance < SQR(escalatorsSoundIntensity)) { + if (distance > 0.0) + m_sQueueSample.m_fDistance = Sqrt(distance); + else + m_sQueueSample.m_fDistance = 0.0f; + m_sQueueSample.m_nVolume = ComputeVolume(escalatorsSoundVolume, escalatorsSoundIntensity, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + this->m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; + this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; + this->m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; + this->m_sQueueSample.m_nReleasingVolumeModificator = 3; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; + this->m_sQueueSample.m_nReleasingVolumeDivider = 5; + this->m_sQueueSample.m_fSoundIntensity = escalatorsSoundIntensity; + this->m_sQueueSample.m_nCounter = i; + this->m_sQueueSample.m_bIs2D = false; + this->m_sQueueSample.m_nLoopCount = 0; + this->m_sQueueSample.m_nEmittingVolume = escalatorsSoundVolume; + this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); + this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); + this->m_sQueueSample.m_bReverbFlag = true; + this->m_sQueueSample.m_bReleasingSoundFlag = false; + this->m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } +} + #pragma region SCRIPT_OBJECTS const int SCRIPT_OBJECT_INTENSITY_S = 30; const int SCRIPT_OBJECT_INTENSITY_L = 80; diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 0fc57c73..5a4458a8 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -90,15 +90,15 @@ class CEscalator CVector m_pos2; CVector m_pos3; CMatrix m_matrix; - bool m_bIsActive; bool m_bIsMovingDown; int32 m_stepsCount; float m_lowerEnd; float m_upperEnd; - CVector m_midPoint; float m_radius; CObject *m_pSteps[24]; public: + bool m_bIsActive;//TODO also recheck! + CVector m_midPoint; CEscalator(); void Update(void); void SwitchOff(void); @@ -107,8 +107,8 @@ public: class CEscalators { - static CEscalator aEscalators[NUM_ESCALATORS]; public: + static CEscalator aEscalators[NUM_ESCALATORS];//TODO need recheck this! static int32 NumEscalators; static void Init(void); static void Update(void); From 1d22c78f9fa9bcfcbca663a78b1e92b4b52478cc Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 01:43:19 +0300 Subject: [PATCH 03/22] processCarHeli half done --- src/audio/AudioLogic.cpp | 407 +++++++++++++++++++++++++++++++++++++-- src/audio/AudioManager.h | 1 + 2 files changed, 394 insertions(+), 14 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 1f6c4a53..9da2c1a6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -747,7 +747,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) } else { switch (veh->GetVehicleAppearance()) { case VEHICLE_APPEARANCE_HELI: - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); //ProcessVehicleFlatTyre(¶ms); ProcessEngineDamage(¶ms); break; @@ -780,27 +780,18 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) break; case VEHICLE_TYPE_BOAT: if (veh->m_modelIndex == MI_SKIMMER) - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); else ProcessBoatEngine(¶ms); ProcessBoatMovingOverWater(¶ms); ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_HELI: - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_PLANE: - switch (params.m_nIndex) { - case AIRTRAIN: - ProcessJumbo(¶ms); - break; - case DEADDODO: - ProcessCesna(¶ms); - break; - default: - break; - } + ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); //ProcessVehicleFlatType(¶ms); break; @@ -3073,6 +3064,394 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } +void cAudioManager::ProcessCarHeli(cVehicleParams* params) +{ + CVehicle* playerVeh; // eax + CVehicle* veh; // ecx + CAutomobile* automobile; // [esp+10h] [ebp-CCh] + CBoat* boat; // [esp+1Ch] [ebp-C0h] + + signed int volume; // ebx + float volumeTmp; // st5 + unsigned int freqModifier; // eax + signed int v30; // ebx + uint32 freq_6; // eax + signed int volume_3; // ebx + + signed int volume_2; // ebx + char distCalcBool; // [esp+Ch] [ebp-D0h] + signed int freqModifier_2; // [esp+14h] [ebp-C8h] + char hunterBool; // [esp+18h] [ebp-C4h] + signed int brake; // [esp+20h] [ebp-BCh] + signed int accelerate; // [esp+24h] [ebp-B8h] + signed int volume_4; // [esp+28h] [ebp-B4h] + signed int volume_1; // [esp+2Ch] [ebp-B0h] + float vehAtYAbs; // [esp+34h] [ebp-A8h] + float vehCameraDot; // [esp+38h] [ebp-A4h] + float speedMultiplied; // [esp+3Ch] [ebp-A0h] + float volumeModifier; // [esp+40h] [ebp-9Ch] + float distance_3; // [esp+44h] [ebp-98h] + CVector posBackup; // [esp+48h] [ebp-94h] + + CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] + CVector pos; // [esp+A8h] [ebp-34h] + //CVector multipliedVector; // [esp+B4h] [ebp-28h] + //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] + + static uint32 freqPrev = 14287; + static uint32 freqPrev_1 = 7143; + static uint32 freqPrev_0 = 14287; + + const float CarHeliDistance = 250.0f; + + boat = 0; + hunterBool = 0; + automobile = 0; + cameraMatrix.m_attachment = 0; + cameraMatrix.m_hasRwMatrix = 0; + + if (params->m_fDistance < SQR(CarHeliDistance)) {//!! + playerVeh = FindPlayerVehicle(); + veh = params->m_pVehicle; + if (playerVeh == veh) { + accelerate = Pads[0].GetAccelerate(); + brake = Pads[0].GetBrake(); + } else { + accelerate = veh->m_fGasPedal * 255.0f; + brake = veh->m_fBrakePedal * 255.0f; + } + cameraMatrix = TheCamera.m_matrix; + vehAtYAbs = Abs(veh->m_matrix.GetUp().y); + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; + + //123-139 + if (veh->m_modelIndex == MI_SKIMMER) {//!! + boat = (CBoat*)params->m_pVehicle; + speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + speedMultiplied = 1.0; + } else { + automobile = (CAutomobile*)params->m_pVehicle; + speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + } + //140-162 + if (0.0 == speedMultiplied) {//?? + cameraMatrix.~CMatrix(); + return; + } + speedMultiplied = Min(1.0f, speedMultiplied); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + //163- + if (m_sQueueSample.m_fDistance >= 40.0f) {//?? + volumeTmp = speedMultiplied * 75.0f; + } else { + if (m_sQueueSample.m_fDistance >= 25.0f) {//!! + volume = 0; + LABEL_34: + //173-243 + if (volume != 0) {//!! + m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { //!! + m_sQueueSample.m_nCounter = 88; + if (boat != nil) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + if (accelerate <= 0 && brake <= 0) { //!! + freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? + m_sQueueSample.m_nFrequency = 3651 + freqModifier; + } else { + freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + freqModifier; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_HELI_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 250.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + //244- + if (automobile) { //!! + automobile->GetComponentWorldPosition(CAR_BOOT, pos); + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! + //MatrixMultiplier.z = 0.0; + //MatrixMultiplier.x = 0.0; + //MatrixMultiplier.y = -10.0; + //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + } else { + pos = m_sQueueSample.m_vecPos; + } + //263-270 + if (params->m_fDistance >= 19600.0f) //?? + goto LABEL_EXIT; + if (speedMultiplied >= 0.4f) //?? + volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + else + volumeModifier = 0.0f; + //270-286 + if (!boat) { //!! + freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + freqModifier_2 = 1300; + if (veh->m_modelIndex == MI_HUNTER) //!! + hunterBool = true; + } + + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + //288-339 + if (boat) { //!! + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? + } else { + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + } + + + + m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) { //!! + LABEL_105: + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0) { //!! + if (automobile->bEngineOn) { + if (speedMultiplied >= 1.0) { + v30 = (signed int)((1.0 - 0.5 * speedMultiplied) * 70.0f); + m_sQueueSample.m_nVolume = ComputeVolume(v30, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = 456; + m_sQueueSample.m_nBankIndex = 0; + freq_6 = 3000.0 * speedMultiplied + 30000; + } else { + m_sQueueSample.m_nSampleIndex = 11; + m_sQueueSample.m_nBankIndex = 0; + freq_6 = 3000.0 * speedMultiplied + 6000; + } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = v30; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0; + m_sQueueSample.m_fSoundIntensity = 30.0; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 30; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) + goto LABEL_147; + m_sQueueSample.m_nCounter = 1; + if (hunterBool) { //488 andro + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + } else { + if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + LABEL_146: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; + } + LABEL_EXIT: + cameraMatrix.~CMatrix(); + return; + } + m_sQueueSample.m_nSampleIndex = 9; + } + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_nFrequency = (unsigned __int64)(signed __int64)(16000.0 * volumeModifier) + + 16000; + m_sQueueSample.m_nFrequency += freqModifier_2; + goto LABEL_146; + } + + + + + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + } else { + if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + //LABEL_104: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + m_sQueueSample.m_nSampleIndex = 8; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (16000.0 * volumeModifier) + 16000; + m_sQueueSample.m_nFrequency += freqModifier_2; + //goto LABEL_104; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + volumeTmp = (m_sQueueSample.m_fDistance - 25.0) * 0.06666667 * (75.0 * speedMultiplied); + } + volume = (signed int)volumeTmp; + goto LABEL_34; + } + cameraMatrix.~CMatrix(); +} + //TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) @@ -4560,7 +4939,7 @@ cAudioManager::ProcessWaterCannon(int32) } //positon of arcade machines -CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; +CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.476f, 181.69701f, 11.324f} }; void cAudioManager::ProcessExtraSounds() diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a598b698..cae606fd 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -331,6 +331,7 @@ public: void ProcessFrontEnd(); void ProcessGarages(); bool ProcessHelicopter(cVehicleParams *params); + void ProcessCarHeli(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); From b3cbe3d33886ff665ed08805e122f1853144fbbd Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 02:17:58 +0300 Subject: [PATCH 04/22] removed some goto --- src/audio/AudioLogic.cpp | 619 +++++++++++++++++++-------------------- 1 file changed, 309 insertions(+), 310 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 9da2c1a6..f553bef6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3072,9 +3072,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CBoat* boat; // [esp+1Ch] [ebp-C0h] signed int volume; // ebx - float volumeTmp; // st5 unsigned int freqModifier; // eax - signed int v30; // ebx + signed int volume; // ebx uint32 freq_6; // eax signed int volume_3; // ebx @@ -3104,335 +3103,212 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) const float CarHeliDistance = 250.0f; - boat = 0; - hunterBool = 0; - automobile = 0; + boat = nil; + hunterBool = false; + automobile = nil; cameraMatrix.m_attachment = 0; cameraMatrix.m_hasRwMatrix = 0; - if (params->m_fDistance < SQR(CarHeliDistance)) {//!! - playerVeh = FindPlayerVehicle(); - veh = params->m_pVehicle; - if (playerVeh == veh) { - accelerate = Pads[0].GetAccelerate(); - brake = Pads[0].GetBrake(); - } else { - accelerate = veh->m_fGasPedal * 255.0f; - brake = veh->m_fBrakePedal * 255.0f; - } - cameraMatrix = TheCamera.m_matrix; - vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; + if (params->m_fDistance >= SQR(CarHeliDistance)) {//!! + cameraMatrix.~CMatrix(); + return; + } + playerVeh = FindPlayerVehicle(); + veh = params->m_pVehicle; + if (playerVeh == veh) { + accelerate = Pads[0].GetAccelerate(); + brake = Pads[0].GetBrake(); + } else { + accelerate = veh->m_fGasPedal * 255.0f; + brake = veh->m_fBrakePedal * 255.0f; + } + cameraMatrix = TheCamera.m_matrix; + vehAtYAbs = Abs(veh->m_matrix.GetUp().y); + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; + if (veh->m_modelIndex == MI_SKIMMER) {//!! + boat = (CBoat*)params->m_pVehicle; + speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + speedMultiplied = 1.0f; + } else { + automobile = (CAutomobile*)params->m_pVehicle; + speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + } + if (speedMultiplied == 0.0f) {//?? + cameraMatrix.~CMatrix(); + return; + } + speedMultiplied = Min(1.0f, speedMultiplied); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - //123-139 - if (veh->m_modelIndex == MI_SKIMMER) {//!! - boat = (CBoat*)params->m_pVehicle; - speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! - speedMultiplied = 1.0; - } else { - automobile = (CAutomobile*)params->m_pVehicle; - speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + + if (m_sQueueSample.m_fDistance >= 40.0f) + volume = speedMultiplied * 75.0f; + else if (m_sQueueSample.m_fDistance >= 25.0f) + volume = 0; + else + volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); + + + + + //173-243 + if (volume != 0) {//!! + m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { //!! + m_sQueueSample.m_nCounter = 88; + if (boat != nil) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + if (accelerate <= 0 && brake <= 0) { //!! + freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? + m_sQueueSample.m_nFrequency = 3651 + freqModifier; + } else { + freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + freqModifier; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_HELI_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 250.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); } - //140-162 - if (0.0 == speedMultiplied) {//?? - cameraMatrix.~CMatrix(); - return; - } - speedMultiplied = Min(1.0f, speedMultiplied); - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - //163- - if (m_sQueueSample.m_fDistance >= 40.0f) {//?? - volumeTmp = speedMultiplied * 75.0f; + } + //244- + if (automobile) { //!! + automobile->GetComponentWorldPosition(CAR_BOOT, pos); + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! + //MatrixMultiplier.z = 0.0; + //MatrixMultiplier.x = 0.0; + //MatrixMultiplier.y = -10.0; + //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + } else { + pos = m_sQueueSample.m_vecPos; + } + + + //263-270 + if (params->m_fDistance >= 19600.0f) { //?? + cameraMatrix.~CMatrix(); + return; + } + + if (speedMultiplied >= 0.4f) //?? + volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + else + volumeModifier = 0.0f; + //270-286 + if (!boat) { //!! + freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + freqModifier_2 = 1300; + if (veh->m_modelIndex == MI_HUNTER) //!! + hunterBool = true; + } + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + //288-339 + if (boat) { //!! + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? } else { - if (m_sQueueSample.m_fDistance >= 25.0f) {//!! - volume = 0; - LABEL_34: - //173-243 - if (volume != 0) {//!! - m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { //!! - m_sQueueSample.m_nCounter = 88; - if (boat != nil) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + } + + + + m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) { //!! + LABEL_105: + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! + if (automobile->bEngineOn) { + if (speedMultiplied >= 1.0f) { + volume = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? - m_sQueueSample.m_nFrequency = 3651 + freqModifier; - } else { - freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; - m_sQueueSample.m_nFrequency = 4600 + freqModifier; - } + freq_6 = 3000.0f * speedMultiplied + 30000; } else { - m_sQueueSample.m_nSampleIndex = SFX_HELI_1; + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + freq_6 = 3000.0f * speedMultiplied + 6000; } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 250.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - //244- - if (automobile) { //!! - automobile->GetComponentWorldPosition(CAR_BOOT, pos); - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! - //MatrixMultiplier.z = 0.0; - //MatrixMultiplier.x = 0.0; - //MatrixMultiplier.y = -10.0; - //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; - } else { - pos = m_sQueueSample.m_vecPos; - } - //263-270 - if (params->m_fDistance >= 19600.0f) //?? - goto LABEL_EXIT; - if (speedMultiplied >= 0.4f) //?? - volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; - else - volumeModifier = 0.0f; - //270-286 - if (!boat) { //!! - freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! - freqModifier_2 = 1300; - if (veh->m_modelIndex == MI_HUNTER) //!! - hunterBool = true; - } - - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - //288-339 - if (boat) { //!! - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } - - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! - } - - - - m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) { //!! - LABEL_105: - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0) { //!! - if (automobile->bEngineOn) { - if (speedMultiplied >= 1.0) { - v30 = (signed int)((1.0 - 0.5 * speedMultiplied) * 70.0f); - m_sQueueSample.m_nVolume = ComputeVolume(v30, 30.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = 456; - m_sQueueSample.m_nBankIndex = 0; - freq_6 = 3000.0 * speedMultiplied + 30000; - } else { - m_sQueueSample.m_nSampleIndex = 11; - m_sQueueSample.m_nBankIndex = 0; - freq_6 = 3000.0 * speedMultiplied + 6000; - } - m_sQueueSample.m_nFrequency = freq_6; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = v30; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0; - m_sQueueSample.m_fSoundIntensity = 30.0; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - } - } - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - goto LABEL_147; - m_sQueueSample.m_nCounter = 1; - if (hunterBool) { //488 andro - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; - } else { - if (boat) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - LABEL_146: - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; - } - LABEL_EXIT: - cameraMatrix.~CMatrix(); - return; - } - m_sQueueSample.m_nSampleIndex = 9; - } - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_nFrequency = (unsigned __int64)(signed __int64)(16000.0 * volumeModifier) - + 16000; - m_sQueueSample.m_nFrequency += freqModifier_2; - goto LABEL_146; - } - - - - - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; - } else { - if (boat) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - //LABEL_104: - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_nReleasingVolumeDivider = 30; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - goto LABEL_105; } - m_sQueueSample.m_nSampleIndex = 8; } + } + } + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) + goto LABEL_147; + m_sQueueSample.m_nCounter = 1; + if (hunterBool) { //488 andro + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + } else { + if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (16000.0 * volumeModifier) + 16000; - m_sQueueSample.m_nFrequency += freqModifier_2; - //goto LABEL_104; + LABEL_146: m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume_4; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3442,14 +3318,137 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - goto LABEL_105; + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; + } + cameraMatrix.~CMatrix(); + return; } - volumeTmp = (m_sQueueSample.m_fDistance - 25.0) * 0.06666667 * (75.0 * speedMultiplied); + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; } - volume = (signed int)volumeTmp; - goto LABEL_34; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + goto LABEL_146; } - cameraMatrix.~CMatrix(); + + + + + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + } else { + if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + //LABEL_104: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + m_sQueueSample.m_nSampleIndex = 8; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + //goto LABEL_104; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + + } //TODO use it in ProcessVehicle From 4414288b86f1f9630ad124cda6df8b30b43e7f36 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 02:30:51 +0300 Subject: [PATCH 05/22] remove anther goto --- src/audio/AudioLogic.cpp | 206 ++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 100 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index f553bef6..4d97ba20 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3298,108 +3298,116 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (!m_sQueueSample.m_nVolume) goto LABEL_147; m_sQueueSample.m_nCounter = 1; - if (hunterBool) { //488 andro + + + + + + + + + if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + } else if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; } else { - if (boat) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - LABEL_146: - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; - } - cameraMatrix.~CMatrix(); - return; - } m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - goto LABEL_146; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; + } + cameraMatrix.~CMatrix(); + return; + } @@ -3412,7 +3420,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat) { //!! m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - //LABEL_104: m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -3432,7 +3439,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - //goto LABEL_104; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; From f097b9c972c541445ed1fe8f80dbc90ebcf7b92a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 03:10:11 +0300 Subject: [PATCH 06/22] fix deaddodo --- src/audio/AudioLogic.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 4d97ba20..1df7e773 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3071,7 +3071,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] - signed int volume; // ebx + signed int volume_5; // ebx unsigned int freqModifier; // eax signed int volume; // ebx uint32 freq_6; // eax @@ -3142,13 +3142,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - if (m_sQueueSample.m_fDistance >= 40.0f) + if (m_sQueueSample.m_fDistance >= 40.0f) //!! volume = speedMultiplied * 75.0f; - else if (m_sQueueSample.m_fDistance >= 25.0f) - volume = 0; - else + else if (m_sQueueSample.m_fDistance >= 25.0f) //!! volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); - + else + volume = 0; @@ -3250,8 +3249,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! if (automobile->bEngineOn) { if (speedMultiplied >= 1.0f) { - volume = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); + volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; @@ -3267,7 +3266,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = volume_5; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; From 4d1023ca3015cd62fc1147b472f94c206115966d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 04:57:11 +0300 Subject: [PATCH 07/22] safe before clean up --- src/audio/AudioLogic.cpp | 351 ++++++++++++++++++++------------------- 1 file changed, 178 insertions(+), 173 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 1df7e773..7089497d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3151,9 +3151,9 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - //173-243 + //on height distance if (volume != 0) {//!! - m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { //!! m_sQueueSample.m_nCounter = 88; if (boat != nil) { //!! @@ -3242,69 +3242,118 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } - + //sound from front of helicopter m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) { //!! - LABEL_105: - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! - if (automobile->bEngineOn) { - if (speedMultiplied >= 1.0f) { - volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 30000; - } else { - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 6000; - } - m_sQueueSample.m_nFrequency = freq_6; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_5; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } else if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! + //engine starting sound + if (automobile->bEngineOn) { + if (speedMultiplied < 1.0f) { + volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 30000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 6000; } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_5; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 30; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } } - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + } - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - goto LABEL_147; + + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + //after accel rotor sound + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; - - - - - - - - if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3330,130 +3379,86 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; - } - cameraMatrix.~CMatrix(); - return; - } - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } } else { - if (boat) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - goto LABEL_105; + //vacuum cleaner sound + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } } - m_sQueueSample.m_nSampleIndex = 8; + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - goto LABEL_105; - - + cameraMatrix.~CMatrix(); + return; } //TODO use it in ProcessVehicle From 6e3523d59452a970d8d1ef88bcc1b998857fcd38 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 23:27:28 +0300 Subject: [PATCH 08/22] flat tyre and minimal refractoring --- src/audio/AudioLogic.cpp | 187 ++++++++++++++++++++++++++++----------- src/audio/AudioManager.h | 1 + 2 files changed, 138 insertions(+), 50 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 7089497d..3bc7f279 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -748,7 +748,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) switch (veh->GetVehicleAppearance()) { case VEHICLE_APPEARANCE_HELI: ProcessCarHeli(¶ms); - //ProcessVehicleFlatTyre(¶ms); + ProcessVehicleFlatTyre(¶ms); ProcessEngineDamage(¶ms); break; case VEHICLE_APPEARANCE_BOAT: @@ -760,7 +760,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) if (CWeather::WetRoads > 0.0) ProcessWetRoadNoise(¶ms); ProcessVehicleSkidding(¶ms); - //ProcessVehicleFlatTyre(params); + ProcessVehicleFlatTyre(¶ms); ProcessVehicleHorn(¶ms); ProcessVehicleSirenOrAlarm(¶ms); if (UsesReverseWarning(params.m_nIndex)) @@ -793,7 +793,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) case VEHICLE_TYPE_PLANE: ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); - //ProcessVehicleFlatType(¶ms); + ProcessVehicleFlatTyre(¶ms); break; case VEHICLE_TYPE_BIKE: bike = (CBike*)veh; @@ -807,7 +807,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessCarBombTick(¶ms); ProcessEngineDamage(¶ms); ProcessVehicleEngine(¶ms); - //ProcessVehicleFlatTyre(); + ProcessVehicleFlatTyre(¶ms); } ProcessVehicleOneShots(¶ms); bike->m_fVelocityChangeForAudio = params.m_fVelocityChange; @@ -3071,27 +3071,28 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] - signed int volume_5; // ebx - unsigned int freqModifier; // eax signed int volume; // ebx - uint32 freq_6; // eax + signed int volume_5; // ebx signed int volume_3; // ebx - signed int volume_2; // ebx - char distCalcBool; // [esp+Ch] [ebp-D0h] + signed int volume_4; // [esp+28h] [ebp-B4h] + signed int volume_1; // [esp+2Ch] [ebp-B0h] + float volumeModifier; // [esp+40h] [ebp-9Ch] + + uint32 freq_6; // eax + unsigned int freqModifier; // eax signed int freqModifier_2; // [esp+14h] [ebp-C8h] + + bool distCalcBool; // [esp+Ch] [ebp-D0h] char hunterBool; // [esp+18h] [ebp-C4h] signed int brake; // [esp+20h] [ebp-BCh] signed int accelerate; // [esp+24h] [ebp-B8h] - signed int volume_4; // [esp+28h] [ebp-B4h] - signed int volume_1; // [esp+2Ch] [ebp-B0h] float vehAtYAbs; // [esp+34h] [ebp-A8h] float vehCameraDot; // [esp+38h] [ebp-A4h] float speedMultiplied; // [esp+3Ch] [ebp-A0h] - float volumeModifier; // [esp+40h] [ebp-9Ch] float distance_3; // [esp+44h] [ebp-98h] - CVector posBackup; // [esp+48h] [ebp-94h] + CVector posBackup; // [esp+48h] [ebp-94h] CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] CVector pos; // [esp+A8h] [ebp-34h] //CVector multipliedVector; // [esp+B4h] [ebp-28h] @@ -3186,6 +3187,9 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) AddSampleToRequestedQueue(); } } + + + //244- if (automobile) { //!! automobile->GetComponentWorldPosition(CAR_BOOT, pos); @@ -3194,6 +3198,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) //MatrixMultiplier.x = 0.0; //MatrixMultiplier.y = -10.0; //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + pos = { 0.0f, -10.0f, 0.0f }; } else { pos = m_sQueueSample.m_vecPos; } @@ -3217,32 +3222,10 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (veh->m_modelIndex == MI_HUNTER) //!! hunterBool = true; } - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - //288-339 - if (boat) { //!! - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } - - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! - } //sound from front of helicopter + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; //347 andro @@ -3266,6 +3249,27 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } else if (boat) { //!! m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; + + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? + } else { + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -3299,6 +3303,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } } + + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! //engine starting sound if (automobile->bEngineOn) { @@ -3337,20 +3343,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } //after accel rotor sound - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + volume_4 = ((vehCameraDot + 1) * volumeModifier * 127.0f) / 2; m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; @@ -3361,6 +3355,17 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } else if (boat) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; + + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3383,12 +3388,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - if (boat) { //489-568 if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro volume_3 = speedMultiplied * 100.0f; m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; else @@ -3397,6 +3402,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3461,6 +3467,87 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) return; } +void +cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) +{ + CAutomobile* automobile; + CBike* bike; + + + cAudioManager* this_1; // ebp + int vehType; // edx + unsigned __int8 j; // dl + float tmp_2; // ST1C_4 + double tmp_4; // st6 + float tmp_3; + signed int volume; // ebx + bool someBool; // [esp+4h] [ebp-20h] + float modifier; // [esp+Ch] [ebp-18h] + + this_1 = this; + someBool = 0; + if (params->m_fDistance >= 3600.0) + return; + + vehType = params->m_VehicleType; + switch (params->m_VehicleType) { + case 0: + automobile = (CAutomobile*)params->m_pVehicle; + someBool = false; + for (int i = 0; i < 4; i++) + if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) + someBool = true; + if (!someBool) + //return; + break; + case 5: + bike = (CBike*)params->m_pVehicle; + someBool = false; + for(int i = 0; i < 2; i++) + if (bike->m_wheelStatus[i] == 1 && bike->m_aWheelTimer[i] > 0.0) + someBool = true; + if (!someBool) + return; + break; + default: + return; + } + + tmp_2 = fabs(params->m_fVelocityChange); + if (tmp_2 / (0.3 * params->m_pTransmission->fMaxVelocity) <= 1.0) { //!! + tmp_3 = fabs(params->m_fVelocityChange); + tmp_4 = tmp_3 / (0.3 * params->m_pTransmission->fMaxVelocity); + } else { + tmp_4 = 1.0; + } + modifier = tmp_4+0.5f; + if (modifier > 0.01) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + volume = (100.0 * modifier); + this_1->m_sQueueSample.m_nVolume = ComputeVolume(volume, 60.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nCounter = 95; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_L; + m_sQueueSample.m_nFrequency = (5500.0f * modifier) + + 8000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_TYRE_BURST_L); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_TYRE_BURST_L); + m_sQueueSample.m_fSpeedMultiplier = 2.0; + m_sQueueSample.m_fSoundIntensity = 60.0; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } +} + //TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index cae606fd..aa7c80ec 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -332,6 +332,7 @@ public: void ProcessGarages(); bool ProcessHelicopter(cVehicleParams *params); void ProcessCarHeli(cVehicleParams* params); + void ProcessVehicleFlatTyre(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); From a75ddd0d0ca4465f9b10305045b18dbecc76e504 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 04:10:00 +0300 Subject: [PATCH 09/22] processVehicleOneShots for heli, and heli blade fix --- src/audio/AudioLogic.cpp | 23 ++++++++++++++++++++++- src/vehicles/Automobile.cpp | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3bc7f279..10e0c78b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2349,6 +2349,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) static uint8 GunIndex = 53; static uint8 iWheelIndex = 82; static uint8 CrunchOffset = 0; + static uint8 heliIndex = 0; + for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = 0; @@ -2623,6 +2625,25 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[4] % 25 + 75; break; } + case SOUND_31:{ + const float SOUND_INTENSITY = 35.0f; + relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; + if (relVol < 0.2 || 1.0 == relVol) + continue; + relVol /= 20; + emittingVol = (1.0f - relVol) * 70.0f; + maxDist = SQR(SOUND_INTENSITY); + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = heliIndex + 89; + heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; + m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + break; + } case SOUND_WEAPON_SHOT_FIRED: { const float SOUND_INTENSITY = 120.0f; emittingVol = m_anRandomTable[2]; @@ -3498,7 +3519,7 @@ cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) someBool = true; if (!someBool) - //return; + return; break; case 5: bike = (CBike*)params->m_pVehicle; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index eec44c35..0154ae05 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1486,7 +1486,7 @@ CAutomobile::ProcessControl(void) CMatrix mat; mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET])); CVector blade = mat.GetRight(); - blade = GetMatrix() * blade; + blade = Multiply3x3(blade, GetMatrix()); camDist /= Max(Sqrt(distSq), 0.01f); if(Abs(DotProduct(camDist, blade)) > 0.95f){ DMAudio.PlayOneShot(m_audioEntityId, SOUND_31, 0.0f); From e256eaf0149d9851c87ac236772f9a57a6b39010 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 05:41:10 +0300 Subject: [PATCH 10/22] cleanup carHeli --- src/audio/AudioLogic.cpp | 237 +++++++++++++++------------------------ 1 file changed, 93 insertions(+), 144 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 10e0c78b..3b7f55ec 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2628,9 +2628,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; - if (relVol < 0.2 || 1.0 == relVol) + if (relVol < 0.2f || 1.0f == relVol) continue; - relVol /= 20; emittingVol = (1.0f - relVol) * 70.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; @@ -3085,19 +3084,19 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } -void cAudioManager::ProcessCarHeli(cVehicleParams* params) +void +cAudioManager::ProcessCarHeli(cVehicleParams* params) { + const float SOUND_INTENSITY = 250.0f; + CVehicle* playerVeh; // eax CVehicle* veh; // ecx CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] signed int volume; // ebx - signed int volume_5; // ebx signed int volume_3; // ebx signed int volume_2; // ebx - signed int volume_4; // [esp+28h] [ebp-B4h] - signed int volume_1; // [esp+2Ch] [ebp-B0h] float volumeModifier; // [esp+40h] [ebp-9Ch] uint32 freq_6; // eax @@ -3114,7 +3113,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) float distance_3; // [esp+44h] [ebp-98h] CVector posBackup; // [esp+48h] [ebp-94h] - CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] CVector pos; // [esp+A8h] [ebp-34h] //CVector multipliedVector; // [esp+B4h] [ebp-28h] //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] @@ -3123,18 +3121,13 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) static uint32 freqPrev_1 = 7143; static uint32 freqPrev_0 = 14287; - const float CarHeliDistance = 250.0f; - boat = nil; - hunterBool = false; automobile = nil; - cameraMatrix.m_attachment = 0; - cameraMatrix.m_hasRwMatrix = 0; + hunterBool = false; - if (params->m_fDistance >= SQR(CarHeliDistance)) {//!! - cameraMatrix.~CMatrix(); + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return; - } + playerVeh = FindPlayerVehicle(); veh = params->m_pVehicle; if (playerVeh == veh) { @@ -3144,50 +3137,43 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) accelerate = veh->m_fGasPedal * 255.0f; brake = veh->m_fBrakePedal * 255.0f; } - cameraMatrix = TheCamera.m_matrix; vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; - if (veh->m_modelIndex == MI_SKIMMER) {//!! - boat = (CBoat*)params->m_pVehicle; + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; + if (veh->m_modelIndex == MI_SKIMMER) { + boat = (CBoat*)veh; speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { speedMultiplied = 1.0f; } else { - automobile = (CAutomobile*)params->m_pVehicle; + automobile = (CAutomobile*)veh; speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; } - if (speedMultiplied == 0.0f) {//?? - cameraMatrix.~CMatrix(); + + if (speedMultiplied == 0.0f) return; - } + speedMultiplied = Min(1.0f, speedMultiplied); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - if (m_sQueueSample.m_fDistance >= 40.0f) //!! + //sound on long distances + if (m_sQueueSample.m_fDistance >= 40.0f) volume = speedMultiplied * 75.0f; - else if (m_sQueueSample.m_fDistance >= 25.0f) //!! + else if (m_sQueueSample.m_fDistance >= 25.0f) volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); else volume = 0; - - - - //on height distance - if (volume != 0) {//!! - m_sQueueSample.m_nVolume = ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { //!! + if (volume != 0) { + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 88; - if (boat != nil) { //!! + if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? - m_sQueueSample.m_nFrequency = 3651 + freqModifier; - } else { - freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; - m_sQueueSample.m_nFrequency = 4600 + freqModifier; - } + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, vehAtYAbs) * 949; + else + m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 563; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3200,64 +3186,44 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 250.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } - - - //244- - if (automobile) { //!! - automobile->GetComponentWorldPosition(CAR_BOOT, pos); - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! - //MatrixMultiplier.z = 0.0; - //MatrixMultiplier.x = 0.0; - //MatrixMultiplier.y = -10.0; - //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; - pos = { 0.0f, -10.0f, 0.0f }; - } else { - pos = m_sQueueSample.m_vecPos; - } - - - //263-270 - if (params->m_fDistance >= 19600.0f) { //?? - cameraMatrix.~CMatrix(); + if (params->m_fDistance >= 19600.0f) return; - } - if (speedMultiplied >= 0.4f) //?? + if (speedMultiplied >= 0.4f) volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; else volumeModifier = 0.0f; - //270-286 - if (!boat) { //!! + if (!boat) { freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300)//unnesesary freqModifier alredy <= 1300 freqModifier_2 = 1300; - if (veh->m_modelIndex == MI_HUNTER) //!! + if (veh->m_modelIndex == MI_HUNTER) hunterBool = true; } //sound from front of helicopter - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + volume = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! + m_sQueueSample.m_nCounter = 3; + if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freqModifier_2; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3267,34 +3233,22 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - } else if (boat) { //!! + } else if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } - - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255.0f)) * 2204; + if (speedMultiplied < 1.0f) + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev - 197, freqPrev + 197); m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3311,7 +3265,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3325,13 +3279,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } - - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! - //engine starting sound + //engine starting sound + if (boat == nil && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //strange way to check if automobile != nil if (automobile->bEngineOn) { if (speedMultiplied < 1.0f) { - volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); + volume = (1.0f - speedMultiplied / 2.0f) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; @@ -3347,7 +3300,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_5; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3365,8 +3318,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) //after accel rotor sound - volume_4 = ((vehCameraDot + 1) * volumeModifier * 127.0f) / 2; - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + volume = ((vehCameraDot + 1.0f) * volumeModifier * 127.0f) / 2.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; if (hunterBool) { @@ -3377,12 +3330,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) //!! + if (accelerate <= 0 && brake <= 0) m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; else m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - if (speedMultiplied < 1.0) //?? + if (speedMultiplied < 1.0f) m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); @@ -3395,7 +3348,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3410,30 +3363,28 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { + m_sQueueSample.m_nVolume = ComputeVolume(speedMultiplied * 100.0f, 20.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { + + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_nEmittingVolume = speedMultiplied * 100.0f; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_SEAPLANE_PRO4); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_fSpeedMultiplier = 5.0f; m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_bReleasingSoundFlag = false; @@ -3449,33 +3400,33 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) distCalcBool = params->m_bDistanceCalculated; distance_3 = params->m_fDistance; - m_sQueueSample.m_vecPos = pos; + if (automobile != nil) + automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); + else if (params->m_VehicleType == VEHICLE_TYPE_HELI) + m_sQueueSample.m_vecPos = { 0.0f, -10.0f, 0.0f }; //this is from android, but for real it's not used + params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (params->m_fDistance < 729.0f) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volumeModifier * 25.0f, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nSampleIndex = hunterBool ? SFX_HELI_APACHE_3 : SFX_CAR_HELI_REA; m_sQueueSample.m_nBankIndex = 0; m_sQueueSample.m_bIs2D = 0; m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nEmittingVolume = volumeModifier * 25.0f; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } @@ -3484,8 +3435,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) params->m_bDistanceCalculated = distCalcBool; params->m_fDistance = distance_3; } - cameraMatrix.~CMatrix(); - return; } void From 1bd497effcceeecf2873c3b2e33f3006cf986cf8 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 06:52:15 +0300 Subject: [PATCH 11/22] complete cleanup heli and flatTyre --- src/audio/AudioLogic.cpp | 387 ++++++++++++++++----------------------- src/audio/AudioManager.h | 1 - 2 files changed, 155 insertions(+), 233 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3b7f55ec..45f9b81b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3034,92 +3034,33 @@ struct tHelicopterSampleData { uint8 m_bBaseVolume; }; -bool -cAudioManager::ProcessHelicopter(cVehicleParams *params) -{ - CHeli *heli; - float MaxDist; - float dist; - float baseDist; - int32 emittingVol; - static const tHelicopterSampleData gHeliSfxRanges[3] = {{400.f, 380.f, 100}, {100.f, 70.f, MAX_VOLUME}, {60.f, 30.f, MAX_VOLUME}}; - - if (SQR(gHeliSfxRanges[0].m_fMaxDistance) <= params->m_fDistance) - return false; - - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - heli = (CHeli *)params->m_pVehicle; - for (uint32 i = 0; i < ARRAY_SIZE(gHeliSfxRanges); i++) { - MaxDist = gHeliSfxRanges[i].m_fMaxDistance; - dist = m_sQueueSample.m_fDistance; - if (dist >= MaxDist) - return true; - baseDist = gHeliSfxRanges[i].m_fBaseDistance; - if (dist < baseDist) - emittingVol = (gHeliSfxRanges[i].m_bBaseVolume * ((MaxDist - dist) / (MaxDist - baseDist))); - else - emittingVol = gHeliSfxRanges[i].m_bBaseVolume; - - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = i + 65; - m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - return true; -} - void cAudioManager::ProcessCarHeli(cVehicleParams* params) { const float SOUND_INTENSITY = 250.0f; - CVehicle* playerVeh; // eax - CVehicle* veh; // ecx - CAutomobile* automobile; // [esp+10h] [ebp-CCh] - CBoat* boat; // [esp+1Ch] [ebp-C0h] + CVehicle* playerVeh; + CVehicle* veh; + CAutomobile* automobile; + CBoat* boat; - signed int volume; // ebx - signed int volume_3; // ebx - signed int volume_2; // ebx - float volumeModifier; // [esp+40h] [ebp-9Ch] + uint8 emittingVol; + int16 brakeState; + int16 accelerateState; + uint32 freq; + float propellerSpeed; + float freqModifier; //may be hieght + float cameraAngle; + bool distanceCalculatedOld; + float distanceOld; + CVector vecPosOld; - uint32 freq_6; // eax - unsigned int freqModifier; // eax - signed int freqModifier_2; // [esp+14h] [ebp-C8h] - - bool distCalcBool; // [esp+Ch] [ebp-D0h] - char hunterBool; // [esp+18h] [ebp-C4h] - signed int brake; // [esp+20h] [ebp-BCh] - signed int accelerate; // [esp+24h] [ebp-B8h] - float vehAtYAbs; // [esp+34h] [ebp-A8h] - float vehCameraDot; // [esp+38h] [ebp-A4h] - float speedMultiplied; // [esp+3Ch] [ebp-A0h] - float distance_3; // [esp+44h] [ebp-98h] - - CVector posBackup; // [esp+48h] [ebp-94h] - CVector pos; // [esp+A8h] [ebp-34h] - //CVector multipliedVector; // [esp+B4h] [ebp-28h] - //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] - - static uint32 freqPrev = 14287; - static uint32 freqPrev_1 = 7143; - static uint32 freqPrev_0 = 14287; + float volumeModifier; + bool hunterBool; + + static uint32 freqFrontPrev = 14287; + static uint32 freqPropellerPrev = 7143; + static uint32 freqSkimmerPrev = 14287; boat = nil; automobile = nil; @@ -3131,49 +3072,49 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) playerVeh = FindPlayerVehicle(); veh = params->m_pVehicle; if (playerVeh == veh) { - accelerate = Pads[0].GetAccelerate(); - brake = Pads[0].GetBrake(); + accelerateState = Pads[0].GetAccelerate(); + brakeState = Pads[0].GetBrake(); } else { - accelerate = veh->m_fGasPedal * 255.0f; - brake = veh->m_fBrakePedal * 255.0f; + accelerateState = veh->m_fGasPedal * 255.0f; + brakeState = veh->m_fBrakePedal * 255.0f; } - vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; + freqModifier = Abs(veh->GetUp().y); + cameraAngle = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; if (veh->m_modelIndex == MI_SKIMMER) { boat = (CBoat*)veh; - speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + propellerSpeed = boat->m_fMovingSpeed * 50.0f / 11.0f; } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { - speedMultiplied = 1.0f; + propellerSpeed = 1.0f; } else { automobile = (CAutomobile*)veh; - speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + propellerSpeed = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; } - if (speedMultiplied == 0.0f) + if (propellerSpeed == 0.0f) return; - speedMultiplied = Min(1.0f, speedMultiplied); + propellerSpeed = Min(1.0f, propellerSpeed); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); //sound on long distances if (m_sQueueSample.m_fDistance >= 40.0f) - volume = speedMultiplied * 75.0f; + emittingVol = propellerSpeed * 75.0f; else if (m_sQueueSample.m_fDistance >= 25.0f) - volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); + emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * propellerSpeed); else - volume = 0; - if (volume != 0) { - m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + emittingVol = 0; + if (emittingVol != 0) { + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 88; if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, vehAtYAbs) * 949; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; else - m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 563; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3182,7 +3123,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3198,32 +3139,32 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (params->m_fDistance >= 19600.0f) return; - if (speedMultiplied >= 0.4f) - volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + if (propellerSpeed >= 0.4f) + volumeModifier = (propellerSpeed - 0.4f) * 5.0f / 3.0f; else volumeModifier = 0.0f; if (!boat) { - freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300)//unnesesary freqModifier alredy <= 1300 - freqModifier_2 = 1300; + freq = Min(1300, 7000.0f * freqModifier); + if (playerVeh == veh && (accelerateState > 0 || brakeState > 0) && freq < 1300)//unnesesary freqModifier alredy <= 1300 + freq = 1300; if (veh->m_modelIndex == MI_HUNTER) hunterBool = true; } //sound from front of helicopter - volume = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0f, m_sQueueSample.m_fDistance); + emittingVol = (1.0f - cameraAngle) * volumeModifier * 127.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freq; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3237,18 +3178,19 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255.0f)) * 2204; - if (speedMultiplied < 1.0f) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev - 197, freqPrev + 197); + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, freqModifier * (Max(accelerateState, brakeState) / 255.0f)) * 2204; + if (propellerSpeed < 1.0f) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); + freqFrontPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3261,11 +3203,11 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3279,28 +3221,72 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } + //after accel rotor sound + emittingVol = ((cameraAngle + 1.0f) * volumeModifier * 127.0f) / 2.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 140.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 1; + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; + } else if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerateState, brakeState) / 255) * freqModifier) * 1102; + + if (propellerSpeed < 1.0f) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPropellerPrev - 98, freqPropellerPrev + 98); + freqPropellerPrev = m_sQueueSample.m_nFrequency; + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + + //engine starting sound if (boat == nil && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //strange way to check if automobile != nil if (automobile->bEngineOn) { - if (speedMultiplied < 1.0f) { - volume = (1.0f - speedMultiplied / 2.0f) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); + if (propellerSpeed < 1.0f) { + emittingVol = (1.0f - propellerSpeed / 2.0f) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 30000; + freq = 3000.0f * propellerSpeed + 30000; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 6000; + freq = 3000.0f * propellerSpeed + 6000; } - m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3316,65 +3302,19 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } - - //after accel rotor sound - volume = ((vehCameraDot + 1.0f) * volumeModifier * 127.0f) / 2.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 1; - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - } else if (boat) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - - if (speedMultiplied < 1.0f) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } else { - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - } - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - - - if (boat) { - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { - m_sQueueSample.m_nVolume = ComputeVolume(speedMultiplied * 100.0f, 20.0f, m_sQueueSample.m_fDistance); + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && propellerSpeed > 0.0f) { + m_sQueueSample.m_nVolume = ComputeVolume(propellerSpeed * 100.0f, 20.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 2204; + if (propellerSpeed < 1.0) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); + freqSkimmerPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3382,7 +3322,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = speedMultiplied * 100.0f; + m_sQueueSample.m_nEmittingVolume = propellerSpeed * 100.0f; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_fSpeedMultiplier = 5.0f; @@ -3396,9 +3336,9 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } else { //vacuum cleaner sound - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; + vecPosOld = m_sQueueSample.m_vecPos; + distanceCalculatedOld = params->m_bDistanceCalculated; + distanceOld = params->m_fDistance; if (automobile != nil) automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); @@ -3431,88 +3371,71 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; + m_sQueueSample.m_vecPos = vecPosOld; + params->m_bDistanceCalculated = distanceCalculatedOld; + params->m_fDistance = distanceOld; } } void cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) { + const float SOUND_INTENSITY = 60.0f; + CAutomobile* automobile; CBike* bike; + bool wheelBurst; + uint8 emittingVol; + float modifier; - cAudioManager* this_1; // ebp - int vehType; // edx - unsigned __int8 j; // dl - float tmp_2; // ST1C_4 - double tmp_4; // st6 - float tmp_3; - signed int volume; // ebx - bool someBool; // [esp+4h] [ebp-20h] - float modifier; // [esp+Ch] [ebp-18h] - - this_1 = this; - someBool = 0; - if (params->m_fDistance >= 3600.0) + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return; - vehType = params->m_VehicleType; switch (params->m_VehicleType) { - case 0: + case VEHICLE_TYPE_CAR: automobile = (CAutomobile*)params->m_pVehicle; - someBool = false; + wheelBurst = false; for (int i = 0; i < 4; i++) - if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) - someBool = true; - if (!someBool) + if (automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST && automobile->m_aWheelTimer[i] > 0.0f) + wheelBurst = true; + if (!wheelBurst) return; break; - case 5: + case VEHICLE_TYPE_BIKE: bike = (CBike*)params->m_pVehicle; - someBool = false; + wheelBurst = false; for(int i = 0; i < 2; i++) - if (bike->m_wheelStatus[i] == 1 && bike->m_aWheelTimer[i] > 0.0) - someBool = true; - if (!someBool) + if (bike->m_wheelStatus[i] == WHEEL_STATUS_BURST && bike->m_aWheelTimer[i] > 0.0f) + wheelBurst = true; + if (!wheelBurst) return; break; default: return; } - - tmp_2 = fabs(params->m_fVelocityChange); - if (tmp_2 / (0.3 * params->m_pTransmission->fMaxVelocity) <= 1.0) { //!! - tmp_3 = fabs(params->m_fVelocityChange); - tmp_4 = tmp_3 / (0.3 * params->m_pTransmission->fMaxVelocity); - } else { - tmp_4 = 1.0; - } - modifier = tmp_4+0.5f; - if (modifier > 0.01) { //!! + modifier = Min(1.0f, Abs(params->m_fVelocityChange) / (0.3f * params->m_pTransmission->fMaxVelocity)); + if (modifier > 0.01) { //mb can be replaced by (emittingVol > 1) + emittingVol = (100.0 * modifier); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - volume = (100.0 * modifier); - this_1->m_sQueueSample.m_nVolume = ComputeVolume(volume, 60.0, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = 95; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_L; - m_sQueueSample.m_nFrequency = (5500.0f * modifier) - + 8000; + m_sQueueSample.m_nFrequency = (5500.0f * modifier) + 8000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_TYRE_BURST_L); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_TYRE_BURST_L); - m_sQueueSample.m_fSpeedMultiplier = 2.0; - m_sQueueSample.m_fSoundIntensity = 60.0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index aa7c80ec..a11d8619 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -330,7 +330,6 @@ public: void ProcessFires(int32 entity); void ProcessFrontEnd(); void ProcessGarages(); - bool ProcessHelicopter(cVehicleParams *params); void ProcessCarHeli(cVehicleParams* params); void ProcessVehicleFlatTyre(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); From c61160fee351f898e36e9db505787fac31ecdf9b Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:24:25 +0300 Subject: [PATCH 12/22] small fixes and cleanup --- src/audio/AudioLogic.cpp | 96 +++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 45f9b81b..b04030dc 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2628,14 +2628,14 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; - if (relVol < 0.2f || 1.0f == relVol) + if (relVol < 0.2f || relVol == 1.0f) continue; emittingVol = (1.0f - relVol) * 70.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = heliIndex + 89; - heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; + heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -3028,12 +3028,6 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) return true; } -struct tHelicopterSampleData { - float m_fMaxDistance; - float m_fBaseDistance; - uint8 m_bBaseVolume; -}; - void cAudioManager::ProcessCarHeli(cVehicleParams* params) { @@ -3049,13 +3043,13 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) int16 accelerateState; uint32 freq; float propellerSpeed; - float freqModifier; //may be hieght + float freqModifier; //may be relate to angle with horison float cameraAngle; bool distanceCalculatedOld; float distanceOld; CVector vecPosOld; - float volumeModifier; + float volumeModifier;//TODO find better name bool hunterBool; static uint32 freqFrontPrev = 14287; @@ -4933,37 +4927,37 @@ CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.4 void cAudioManager::ProcessExtraSounds() { - const float extraSoundIntensity = 18.0f; - const uint8 extraSoundVolume = 50; + const float SOUND_INTENSITY = 18.0f; + const uint8 EMITTING_VOLUME = 50; float distance; for (int i = 0; i < ARRAY_SIZE(aVecExtraSoundPosition); i++) { m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distance < SQR(extraSoundIntensity)) { + if (distance < SQR(SOUND_INTENSITY)) { if (distance > 0.0) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(extraSoundVolume, extraSoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - this->m_sQueueSample.m_nCounter = i; - this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; - this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; - this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); - this->m_sQueueSample.m_bIs2D = false; - this->m_sQueueSample.m_nLoopCount = 0; - this->m_sQueueSample.m_bReleasingSoundFlag = false; - this->m_sQueueSample.m_nReleasingVolumeModificator = 4; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; - this->m_sQueueSample.m_nEmittingVolume = extraSoundVolume; - this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); - this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); - this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_fSoundIntensity = extraSoundIntensity; - this->m_sQueueSample.m_bRequireReflection = false; - this->m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_nSampleIndex = SFX_ARCADE; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeModificator = 4; + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_nReleasingVolumeDivider = 3; AddSampleToRequestedQueue(); } } @@ -4973,8 +4967,8 @@ cAudioManager::ProcessExtraSounds() void cAudioManager::ProcessEscalators() { - const float escalatorsSoundIntensity = 30.0f; - const uint8 escalatorsSoundVolume = 26; + const float SOUND_INTENSITY = 30.0f; + const uint8 EMITTING_VOLUME = 26; float distance; @@ -4983,29 +4977,29 @@ cAudioManager::ProcessEscalators() continue; m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distance < SQR(escalatorsSoundIntensity)) { - if (distance > 0.0) + if (distance < SQR(SOUND_INTENSITY)) { + if (distance > 0.0f) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(escalatorsSoundVolume, escalatorsSoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - this->m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; - this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; - this->m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; - this->m_sQueueSample.m_nReleasingVolumeModificator = 3; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; - this->m_sQueueSample.m_nReleasingVolumeDivider = 5; - this->m_sQueueSample.m_fSoundIntensity = escalatorsSoundIntensity; - this->m_sQueueSample.m_nCounter = i; - this->m_sQueueSample.m_bIs2D = false; - this->m_sQueueSample.m_nLoopCount = 0; - this->m_sQueueSample.m_nEmittingVolume = escalatorsSoundVolume; - this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); - this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); - this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_bReleasingSoundFlag = false; - this->m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } From ec8ac117ed061abbd72215e4efef18e7f48294cf Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:36:07 +0300 Subject: [PATCH 13/22] Improve dodo cheat to allow fly on cars --- src/vehicles/Vehicle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 378a4c0a..795219ba 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -351,6 +351,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust +#ifdef ALT_DODO_CHEAT //allow fly on cars + float dooCompinsator = ((CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f) * 2; + if (bAltDodoCheat) + ApplyMoveForce(GetForward() * CTimer::GetTimeStep() * dooCompinsator); +#endif float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; From 356c50ec1e6097eaf57bb8135f5308899bd8263c Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:50:51 +0300 Subject: [PATCH 14/22] mark completed functions in audioManager.h --- src/audio/AudioManager.h | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a11d8619..0cd86219 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -241,13 +241,13 @@ public: // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, - uint8 counter, bool notLooping); + uint8 counter, bool notLooping); //done void AddReflectionsToRequestedQueue(); void AddReleasingSounds(); void AddSampleToRequestedQueue(); void AgeCrimes(); - void CalculateDistance(bool &condition, float dist); + void CalculateDistance(bool &condition, float dist); //done bool CheckForAnAudioFileOnCD() const; void ClearActiveSamples(); void ClearMissionAudio(uint8 slot); @@ -275,7 +275,7 @@ public: float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionOneShotRatio(int32 a, float b) const; float GetCollisionRatio(float a, float b, float c, float d) const; - float GetDistanceSquared(const CVector &v) const; + float GetDistanceSquared(const CVector &v) const; //done int32 GetJumboTaxiFreq() const; uint8 GetMissionAudioLoadingStatus(uint8 slot) const; int8 GetMissionScriptPoliceAudioPlayingStatus() const; @@ -287,7 +287,7 @@ public: float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); - bool HasAirBrakes(int32 model) const; + bool HasAirBrakes(int32 model) const; //done void Initialise(); void InitialisePoliceRadio(); @@ -302,13 +302,13 @@ public: void PlayLoadedMissionAudio(uint8 slot); void PlayOneShot(int32 index, int16 sound, float vol); void PlaySuspectLastSeen(float x, float y, float z); - void PlayerJustGotInCar() const; - void PlayerJustLeftCar() const; + void PlayerJustGotInCar() const; //done + void PlayerJustLeftCar() const; //done void PostInitialiseGameSpecificSetup(); - void PostTerminateGameSpecificShutdown(); - void PreInitialiseGameSpecificSetup() const; + void PostTerminateGameSpecificShutdown(); //done + void PreInitialiseGameSpecificSetup() const; //done void PreloadMissionAudio(uint8 slot, Const char *name); - void PreTerminateGameSpecificShutdown(); + void PreTerminateGameSpecificShutdown(); //done /// processX - main logic of adding new sounds void ProcessActiveQueues(); bool ProcessAirBrakes(cVehicleParams *params); @@ -324,14 +324,14 @@ public: void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); bool ProcessEngineDamage(cVehicleParams *params); - void ProcessEntity(int32 sound); + void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); void ProcessFires(int32 entity); void ProcessFrontEnd(); void ProcessGarages(); - void ProcessCarHeli(cVehicleParams* params); - void ProcessVehicleFlatTyre(cVehicleParams* params); + void ProcessCarHeli(cVehicleParams* params); //done + void ProcessVehicleFlatTyre(cVehicleParams* params); //done void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); @@ -346,22 +346,22 @@ public: void ProcessOneShotScriptObject(uint8 sound); void ProcessPed(CPhysical *ped); void ProcessPedOneShots(cPedParams *params); - void ProcessPhysical(int32 id); - void ProcessPlane(cVehicleParams *params); - void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); + void ProcessPhysical(int32 id); //done + void ProcessPlane(cVehicleParams *params); //done + void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); //done void ProcessProjectiles(); void ProcessRainOnVehicle(cVehicleParams *params); void ProcessReverb() const; - bool ProcessReverseGear(cVehicleParams *params); - void ProcessScriptObject(int32 id); + bool ProcessReverseGear(cVehicleParams *params); //done + void ProcessScriptObject(int32 id); //done void ProcessSpecial(); #ifdef GTA_TRAIN bool ProcessTrainNoise(cVehicleParams *params); #endif - void ProcessVehicle(CVehicle *vehicle); + void ProcessVehicle(CVehicle *vehicle); //done, but need add model functions bool ProcessVehicleDoors(cVehicleParams *params); - void ProcessVehicleEngine(cVehicleParams *params); - void UpdateGasPedalAudio(CVehicle* veh, int vehType); + void ProcessVehicleEngine(cVehicleParams *params); //done + void UpdateGasPedalAudio(CVehicle* veh, int vehType); //done void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); @@ -369,10 +369,10 @@ public: bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); bool ProcessVehicleSkidding(cVehicleParams *params); void ProcessWaterCannon(int32); - void ProcessWeather(int32 id); + void ProcessWeather(int32 id); //done bool ProcessWetRoadNoise(cVehicleParams *params); - void ProcessEscalators(); - void ProcessExtraSounds(); + void ProcessEscalators(); //done + void ProcessExtraSounds(); //done int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; @@ -417,11 +417,11 @@ public: void TranslateEntity(Const CVector *v1, CVector *v2) const; void UpdateReflections(); - bool UsesReverseWarning(int32 model) const; + bool UsesReverseWarning(int32 model) const; //done bool UsesSiren(int32 model) const; bool UsesSirenSwitching(int32 model) const; - CVehicle *FindVehicleOfPlayer(); + CVehicle *FindVehicleOfPlayer(); //done void SetPedTalkingStatus(CPed *ped, uint8 status); void SetPlayersMood(uint8 mood, int32 time); From 4c220b1f9583e2db3cdbb99fcdecd82ae4fe9e0d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 21:07:51 +0300 Subject: [PATCH 15/22] return bridge, crane and fix structures in fluff.h --- src/audio/AudioLogic.cpp | 18 ++++++++++++++++-- src/render/Fluff.h | 9 ++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b04030dc..60989aba 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -366,12 +366,26 @@ cAudioManager::ProcessEntity(int32 id) ProcessWeather(id); } break; +/* case AUDIOTYPE_CRANE: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessCrane(); + } + break;*/ case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; ProcessScriptObject(id); } break; +#ifdef GTA_BRIDGE + case AUDIOTYPE_BRIDGE: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessBridge(); + } + break; +#endif case AUDIOTYPE_FRONTEND: m_sQueueSample.m_bReverbFlag = false; ProcessFrontEnd(); @@ -4973,9 +4987,9 @@ cAudioManager::ProcessEscalators() float distance; for (int i = 0; i < CEscalators::NumEscalators; i++) { - if (!CEscalators::aEscalators[i].m_bIsActive) + if (!CEscalators::GetEscalator(i).IsActive()) continue; - m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; + m_sQueueSample.m_vecPos = CEscalators::GetEscalator(i).GetPosition(); distance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distance < SQR(SOUND_INTENSITY)) { if (distance > 0.0f) diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 5a4458a8..460c12a8 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -90,30 +90,33 @@ class CEscalator CVector m_pos2; CVector m_pos3; CMatrix m_matrix; + bool m_bIsActive; bool m_bIsMovingDown; int32 m_stepsCount; float m_lowerEnd; float m_upperEnd; + CVector m_midPoint; float m_radius; CObject *m_pSteps[24]; public: - bool m_bIsActive;//TODO also recheck! - CVector m_midPoint; CEscalator(); void Update(void); void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); + bool IsActive() { return m_bIsActive; }; + CVector GetPosition() { return m_midPoint; }; }; class CEscalators { + static CEscalator aEscalators[NUM_ESCALATORS]; public: - static CEscalator aEscalators[NUM_ESCALATORS];//TODO need recheck this! static int32 NumEscalators; static void Init(void); static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); + static CEscalator GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing From c403df08611c857f43ebf708799974f06b4e8a8a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 02:03:36 +0300 Subject: [PATCH 16/22] processEngineDamage --- src/audio/AudioLogic.cpp | 33 +++++++++++++++++---------------- src/audio/AudioManager.h | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 60989aba..b174a924 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2265,34 +2265,36 @@ cAudioManager::HasAirBrakes(int32 model) const || model == COACH || model == PACKER || model == FLATBED; } -bool +void cAudioManager::ProcessEngineDamage(cVehicleParams *params) { const int engineDamageIntensity = 40; - CAutomobile *veh; - uint8 engineStatus; + float health; uint8 emittingVolume; if (params->m_fDistance >= SQR(engineDamageIntensity)) - return false; - veh = (CAutomobile *)params->m_pVehicle; - if (veh->bEngineOn) { - engineStatus = veh->Damage.GetEngineStatus(); - if (engineStatus > 250 || engineStatus < 100) - return true; - if (engineStatus < 225) { - m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - emittingVolume = 6; - m_sQueueSample.m_nReleasingVolumeModificator = 7; - m_sQueueSample.m_nFrequency = 40000; - } else { + return; + if (params->m_pVehicle->m_modelIndex == MI_CADDY) + return; + if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) + return; + health = params->m_pVehicle->m_fHealth; + if (health < 390.0f) { + if (health < 250.0f) { emittingVolume = 60; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); + } else { + emittingVolume = 30; + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; + m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nFrequency = 27000; } CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + if (params->m_pVehicle->bIsDrowning) + emittingVolume /= 2; m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; @@ -2311,7 +2313,6 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) AddSampleToRequestedQueue(); } } - return true; } bool diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0cd86219..c3462291 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -323,7 +323,7 @@ public: bool ProcessCarBombTick(cVehicleParams *params); void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); - bool ProcessEngineDamage(cVehicleParams *params); + void ProcessEngineDamage(cVehicleParams *params); //done void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); From f67275be138d087106ad05c241a3cda9ca2d0373 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 03:35:15 +0300 Subject: [PATCH 17/22] correction of defects and another two audio functions --- src/audio/AudioLogic.cpp | 109 ++++++++++++++++++++++----------------- src/audio/AudioManager.h | 6 +-- src/render/Fluff.h | 4 +- 3 files changed, 68 insertions(+), 51 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b174a924..28fa9343 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2189,7 +2189,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) { velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); if (velocity > 0.0035f) { - emittingVol = (100.f * velocity * 10.f / 3.f); + emittingVol = (100.0f * velocity * 10.0f / 3.0f); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i + 6; @@ -2265,20 +2265,20 @@ cAudioManager::HasAirBrakes(int32 model) const || model == COACH || model == PACKER || model == FLATBED; } -void +bool cAudioManager::ProcessEngineDamage(cVehicleParams *params) { - const int engineDamageIntensity = 40; + const float SOUND_INTENSITY = 40.0f; float health; uint8 emittingVolume; - if (params->m_fDistance >= SQR(engineDamageIntensity)) - return; + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return false; if (params->m_pVehicle->m_modelIndex == MI_CADDY) - return; + return true; if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) - return; + return true; health = params->m_pVehicle->m_fHealth; if (health < 390.0f) { if (health < 250.0f) { @@ -2295,7 +2295,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if (params->m_pVehicle->bIsDrowning) emittingVolume /= 2; - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2305,7 +2305,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = engineDamageIntensity; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; @@ -2313,37 +2313,54 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) AddSampleToRequestedQueue(); } } + return true; } bool cAudioManager::ProcessCarBombTick(cVehicleParams *params) { - CAutomobile *automobile; + const float SOUND_INTENSITY = 40.0f; + const uint8 EMITTING_VOLUME = 60; - if (params->m_fDistance >= SQR(40.f)) + uint8 bombType; + + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 35; - m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = 60; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); + if (params->m_pVehicle->bEngineOn) { + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + bombType = params->m_pVehicle->m_bombType; + break; + case VEHICLE_TYPE_BIKE: + bombType = params->m_pVehicle->m_bombType; + break; + default: + debug("\n * AUDIOLOG: ProcessCarBombTick() Unsupported vehicle type %d * \n", params->m_VehicleType); + return true; + break; + } + if (bombType == CARBOMB_TIMEDACTIVE) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 35; + m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } } } return true; @@ -3110,7 +3127,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (m_sQueueSample.m_fDistance >= 40.0f) emittingVol = propellerSpeed * 75.0f; else if (m_sQueueSample.m_fDistance >= 25.0f) - emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * propellerSpeed); + emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * (75.0f * propellerSpeed) / 15.0f; else emittingVol = 0; if (emittingVol != 0) { @@ -3145,7 +3162,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } - if (params->m_fDistance >= 19600.0f) + if (params->m_fDistance >= SQR(140.0f)) return; if (propellerSpeed >= 0.4f) @@ -3187,10 +3204,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, freqModifier * (Max(accelerateState, brakeState) / 255.0f)) * 2204; + else + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); @@ -3243,10 +3260,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerateState, brakeState) / 255) * freqModifier) * 1102; + else + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); @@ -3316,10 +3333,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nVolume = ComputeVolume(propellerSpeed * 100.0f, 20.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 2204; + else + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); @@ -3356,7 +3373,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) params->m_bDistanceCalculated = false; params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (params->m_fDistance < 729.0f) { + if (params->m_fDistance < SQR(27.0f)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(volumeModifier * 25.0f, 27.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { @@ -4937,7 +4954,7 @@ cAudioManager::ProcessWaterCannon(int32) } //positon of arcade machines -CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.476f, 181.69701f, 11.324f} }; +CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.794f, 11.324f}, {-1004.476f, 181.697f, 11.324f} }; void cAudioManager::ProcessExtraSounds() diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index c3462291..949de7d1 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -320,10 +320,10 @@ public: void ProcessBridgeOneShots(); void ProcessBridgeWarning(); #endif - bool ProcessCarBombTick(cVehicleParams *params); + bool ProcessCarBombTick(cVehicleParams *params); //done void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); - void ProcessEngineDamage(cVehicleParams *params); //done + bool ProcessEngineDamage(cVehicleParams *params); //done void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); @@ -359,7 +359,7 @@ public: bool ProcessTrainNoise(cVehicleParams *params); #endif void ProcessVehicle(CVehicle *vehicle); //done, but need add model functions - bool ProcessVehicleDoors(cVehicleParams *params); + bool ProcessVehicleDoors(cVehicleParams *params); //done void ProcessVehicleEngine(cVehicleParams *params); //done void UpdateGasPedalAudio(CVehicle* veh, int vehType); //done void ProcessVehicleHorn(cVehicleParams *params); diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 460c12a8..d600def7 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -104,7 +104,7 @@ public: void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); bool IsActive() { return m_bIsActive; }; - CVector GetPosition() { return m_midPoint; }; + const CVector& GetPosition() const { return m_midPoint; }; }; class CEscalators @@ -116,7 +116,7 @@ public: static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); - static CEscalator GetEscalator(int ind) { return aEscalators[ind]; }; + static CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing From b956be0f44930fe1d764c07e680f7cee47c1587a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 04:22:59 +0300 Subject: [PATCH 18/22] another clamp --- src/audio/AudioLogic.cpp | 12 ++++++------ src/core/common.h | 2 ++ src/render/Fluff.h | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 28fa9343..9154e6a6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3210,7 +3210,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197); freqFrontPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_bIs2D = false; @@ -3268,7 +3268,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPropellerPrev - 98, freqPropellerPrev + 98); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98); freqPropellerPrev = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; @@ -3339,7 +3339,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197); freqSkimmerPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; @@ -3441,8 +3441,8 @@ cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) return; } modifier = Min(1.0f, Abs(params->m_fVelocityChange) / (0.3f * params->m_pTransmission->fMaxVelocity)); - if (modifier > 0.01) { //mb can be replaced by (emittingVol > 1) - emittingVol = (100.0 * modifier); + if (modifier > 0.01f) { //mb can be replaced by (emittingVol > 1) + emittingVol = (100.0f * modifier); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { @@ -4968,7 +4968,7 @@ cAudioManager::ProcessExtraSounds() m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distance < SQR(SOUND_INTENSITY)) { - if (distance > 0.0) + if (distance > 0.0f) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; diff --git a/src/core/common.h b/src/core/common.h index ba1d24ef..0a2a236e 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -219,6 +219,8 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len); #define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) +#define clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius)) + inline float sq(float x) { return x*x; } #define SQR(x) ((x) * (x)) diff --git a/src/render/Fluff.h b/src/render/Fluff.h index d600def7..a6a28cb7 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -103,7 +103,7 @@ public: void Update(void); void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); - bool IsActive() { return m_bIsActive; }; + bool IsActive() const { return m_bIsActive; }; const CVector& GetPosition() const { return m_midPoint; }; }; @@ -116,7 +116,7 @@ public: static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); - static CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; + static const CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing From ca73f0344ca61b4741b392fa0332d42d623625ff Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 01:38:05 +0300 Subject: [PATCH 19/22] fixed original bug, when heli go ma if cars fly cheat activated --- src/core/ControllerConfig.cpp | 2 +- src/vehicles/Automobile.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index b0e04e2b..68a29b28 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -732,7 +732,7 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving(int32 if (FindPlayerVehicle() && (FindPlayerVehicle()->IsVehicle() && ( FindPlayerVehicle()->GetModelIndex() == MI_DODO #ifdef FIX_BUGS - || CVehicle::bAllDodosCheat + || (CVehicle::bAllDodosCheat && !FindPlayerVehicle()->IsRealHeli()) #ifdef ALLCARSHELI_CHEAT || bAllCarCheat #endif diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index eec44c35..7863b4a1 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1384,7 +1384,10 @@ CAutomobile::ProcessControl(void) playRotorSound = true; } }else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) && - m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){ +#ifdef FIX_BUGS + !IsRealHeli() && +#endif + m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){ #ifdef ALT_DODO_CHEAT if (bAltDodoCheat) FlyingControl(FLIGHT_MODEL_PLANE); From c317d3d9b14d8169a9e5c920ebf2a5b9db4f8cc4 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 21:09:06 +0300 Subject: [PATCH 20/22] tiny style fix --- src/audio/AudioLogic.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 9154e6a6..28da2a75 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2377,13 +2377,6 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) float maxDist; cPedParams pedParams; - static uint8 WaveIndex = 41; - static uint8 GunIndex = 53; - static uint8 iWheelIndex = 82; - static uint8 CrunchOffset = 0; - static uint8 heliIndex = 0; - - for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = 0; m_sQueueSample.m_bRequireReflection = false; @@ -2471,13 +2464,14 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } break; case SOUND_CAR_JUMP: { const float SOUND_INTENSITY = 35.0f; + static uint8 WheelIndex = 82; emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = iWheelIndex++; - if (iWheelIndex > 85) - iWheelIndex = 82; + m_sQueueSample.m_nCounter = WheelIndex++; + if (WheelIndex > 85) + WheelIndex = 82; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TYRE_BUMP); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); if (params->m_nIndex == RCBANDIT) { @@ -2566,6 +2560,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_CAR_SPLASH: { const float SOUND_INTENSITY = 40.0f; + static uint8 WaveIndex = 41; vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]; if (vol <= 300.f) continue; @@ -2659,6 +2654,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; + static uint8 HeliIndex = 0; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; if (relVol < 0.2f || relVol == 1.0f) continue; @@ -2666,8 +2662,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = heliIndex + 89; - heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values + m_sQueueSample.m_nCounter = HeliIndex + 89; + HeliIndex = HeliIndex != 1 ? HeliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2677,6 +2673,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_WEAPON_SHOT_FIRED: { const float SOUND_INTENSITY = 120.0f; + static uint8 GunIndex = 53; emittingVol = m_anRandomTable[2]; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; @@ -2755,6 +2752,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_SPLATTER: { const float SOUND_INTENSITY = 40.0f; + static uint8 CrunchOffset = 0; m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 48; @@ -3369,7 +3367,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (automobile != nil) automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); else if (params->m_VehicleType == VEHICLE_TYPE_HELI) - m_sQueueSample.m_vecPos = { 0.0f, -10.0f, 0.0f }; //this is from android, but for real it's not used + m_sQueueSample.m_vecPos = CVector(0.0f, -10.0f, 0.0f); //this is from android, but for real it's not used params->m_bDistanceCalculated = false; params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); From a5269b998baa5db5c37674f506d9a41c61939cdf Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 21:11:24 +0300 Subject: [PATCH 21/22] reverse compare --- src/audio/AudioLogic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 28da2a75..e98151e7 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3135,10 +3135,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 563; + else + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; From a729f32c83c93cab54596911e957b0fbee028ebc Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 29 Sep 2020 01:39:59 +0300 Subject: [PATCH 22/22] TEMPORALY remove flying cars --- src/vehicles/Vehicle.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 795219ba..378a4c0a 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -351,11 +351,6 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust -#ifdef ALT_DODO_CHEAT //allow fly on cars - float dooCompinsator = ((CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f) * 2; - if (bAltDodoCheat) - ApplyMoveForce(GetForward() * CTimer::GetTimeStep() * dooCompinsator); -#endif float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f;