From c202fc3b550b8fc569f510e2002241eec399c18d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 30 Oct 2019 01:12:58 +0200 Subject: Implemented faststrcmp, faststricmp, strcasecmp --- src/audio/AudioManager.cpp | 23 ++++++++++++----------- src/audio/sampman.cpp | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 910d9dd1..f136e6b2 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -1,5 +1,6 @@ #include "common.h" #include "patcher.h" +#include "General.h" #include "audio_enums.h" #include "AudioManager.h" @@ -2130,16 +2131,16 @@ uint32 cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound) { char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetName(); - if(strcmpi(modelName, "eight") == 0 || strcmpi(modelName, "eight2") == 0) { return GetEightTalkSfx(sound); } - if(strcmpi(modelName, "frankie") == 0) { return GetFrankieTalkSfx(sound); } - if(strcmpi(modelName, "misty") == 0) { return GetMistyTalkSfx(sound); } - if(strcmpi(modelName, "ojg") == 0 || strcmpi(modelName, "ojg_p") == 0) { return GetOJGTalkSfx(sound); } - if(strcmpi(modelName, "cat") == 0) { return GetCatatalinaTalkSfx(sound); } - if(strcmpi(modelName, "bomber") == 0) { return GetBomberTalkSfx(sound); } - if(strcmpi(modelName, "s_guard") == 0) { return GetSecurityGuardTalkSfx(sound); } - if(strcmpi(modelName, "chunky") == 0) { return GetChunkyTalkSfx(sound); } - if(strcmpi(modelName, "asuka") == 0) { return GetGenericFemaleTalkSfx(sound); } - if(strcmpi(modelName, "maria") == 0) { return GetGenericFemaleTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "eight") || !CGeneral::faststricmp(modelName, "eight2")) { return GetEightTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "frankie")) { return GetFrankieTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "misty")) { return GetMistyTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "ojg") || !CGeneral::faststricmp(modelName, "ojg_p")) { return GetOJGTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "cat")) { return GetCatatalinaTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "bomber")) { return GetBomberTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "s_guard")) { return GetSecurityGuardTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "chunky")) { return GetChunkyTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "asuka")) { return GetGenericFemaleTalkSfx(sound); } + if(!CGeneral::faststricmp(modelName, "maria")) { return GetGenericFemaleTalkSfx(sound); } return GetGenericMaleTalkSfx(sound); } @@ -3100,7 +3101,7 @@ int32 FindMissionAudioSfx(const char *name) { for(uint32 i = 0; i < ARRAY_SIZE(MissionAudioNameSfxAssoc); ++i) { - if(strcmpi(MissionAudioNameSfxAssoc[i].m_pName, name) == 0) return MissionAudioNameSfxAssoc[i].m_nId; + if(!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name)) return MissionAudioNameSfxAssoc[i].m_nId; } debug("Can't find mission audio %s", name); return NO_SAMPLE; diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index 53b81a36..c9b4cb32 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -116,7 +116,7 @@ typedef struct provider_stuff static int __cdecl comp(const provider_stuff*s1,const provider_stuff*s2) { - return( _stricmp(s1->name,s2->name) ); + return(strcasecmp(s1->name, s2->name)); } static void -- cgit v1.2.3 From de09fc022574a491a54ff489e1e489ca7383f67c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Mon, 11 Nov 2019 15:33:24 +0100 Subject: Fix max iterator value in `InitialisePoliceRadio` --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a6f357c2..6a37e462 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -2602,7 +2602,7 @@ cAudioManager::InitialisePoliceRadio() SampleManager.SetChannelReverbFlag(policeChannel, 0); gSpecialSuspectLastSeenReport = 0; - for(int32 i = 0; i < 18; i++) { gMinTimeToNextReport[i] = m_nTimeOfRecentCrime; } + for(int32 i = 0; i < 17; i++) { gMinTimeToNextReport[i] = m_nTimeOfRecentCrime; } } struct tPoliceRadioZone { -- cgit v1.2.3 From be7d1d1a6327426dbe24c5b7b8eb16e5bb83a587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 9 Nov 2019 18:17:54 +0300 Subject: Frontend, Peds & logic and overflow fixes --- src/audio/sampman.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index c9b4cb32..9c79e1b1 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -35,7 +35,7 @@ int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX]; -int32 nCurrentPedSlot; +uint8 nCurrentPedSlot; uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; @@ -1437,7 +1437,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) bool cSampleManager::IsPedCommentLoaded(uint32 nComment) { - int32 slot; + uint8 slot; for ( int32 i = 0; i < _TODOCONST(3); i++ ) { @@ -1452,7 +1452,7 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) int32 cSampleManager::_GetPedCommentSlot(uint32 nComment) { - int32 slot; + uint8 slot; for ( int32 i = 0; i < _TODOCONST(3); i++ ) { -- cgit v1.2.3 From 41c9e6638276b39f8ac897a3def8fea593c601f9 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 30 Nov 2019 23:52:57 +0100 Subject: Fix sound when "up" and "down" are pressed together --- src/audio/AudioManager.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 6a37e462..cdc7812a 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -6492,7 +6492,6 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * float relativeVelocityChange; float accelerationMultipler; uint8 wheelInUseCounter; - uint8 i; float time; int baseFreq; uint8 vol; @@ -6540,19 +6539,15 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * velocityChange = params->m_fVelocityChange; relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; - accelerationMultipler = 0.0f; - - if(relativeVelocityChange > 1.0f) accelerationMultipler = relativeVelocityChange; - + accelerationMultipler = min(min(1.f, relativeVelocityChange), 0.f); gasPedalAudio = accelerationMultipler; currentGear = params->m_pVehicle->m_nCurrentGear; + if(transmission->nDriveType == '4') { wheelInUseCounter = 0; - i = 0; - do { + for (uint8 i = 0; i < 4; i++){ if(automobile->m_aWheelState[i]) ++wheelInUseCounter; - ++i; - } while(i < 4); + } if(wheelInUseCounter > 2) lostTraction = 1; } else if(transmission->nDriveType == 'F') { if((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) && @@ -6623,7 +6618,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * if(!nCruising) { if(accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || - currentGear < 2u && velocityChange - automobile->m_fVelocityChangeForAudio >= 0.01f) { + currentGear < 2 && + velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) { if(!automobile->m_nWheelsOnGround && automobile->m_nDriveWheelsOnGround || (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || -- cgit v1.2.3 From 9afac431b0ed13121ba4db4eb4b0d55b370ea036 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Thu, 28 Nov 2019 20:02:21 +0100 Subject: Implement ProcessVehicleSirenOrAlarm --- src/audio/AudioManager.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++--- src/audio/AudioManager.h | 2 +- 2 files changed, 49 insertions(+), 4 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index cdc7812a..e70fce8a 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -7632,11 +7632,55 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) return 1; } -WRAPPER void -cAudioManager::ProcessVehicleSirenOrAlarm(void *) +cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) { - EAXJMP(0x56C420); + if(params->m_fDistance < 12100.f) { + CVehicle *veh = params->m_pVehicle; + if(veh->m_bSirenOrAlarm == 0 && veh->m_nAlarmState <= 0) return; + + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = ComputeVolume(80, 110.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 5; + if(UsesSiren(params->m_nIndex)) { + if(params->m_pVehicle->m_status == STATUS_ABANDONED) return; + if(veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) { + m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST; + if(params->m_nIndex == FBICAR) + m_sQueueSample.m_nFrequency = 16113; + else + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(SFX_SIREN_FAST); + m_sQueueSample.m_counter = 60; + } else { + m_sQueueSample.m_nSampleIndex = + CarSounds[params->m_nIndex].m_nSirenOrAlarmSample; + m_sQueueSample.m_nFrequency = + CarSounds[params->m_nIndex].m_nSirenOrAlarmFrequency; + } + } else { + m_sQueueSample.m_nSampleIndex = CarSounds[params->m_nIndex].m_nSirenOrAlarmSample; + m_sQueueSample.m_nFrequency = CarSounds[params->m_nIndex].m_nSirenOrAlarmFrequency; + } + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = 80; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 7.0f; + m_sQueueSample.m_fSoundIntensity = 110.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + return; + } + } } void @@ -9591,6 +9635,7 @@ InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP); InjectHook(0x56C200, &cAudioManager::ProcessVehicleHorn, PATCH_JUMP); InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP); InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP); +InjectHook(0x56C420, &cAudioManager::ProcessVehicleSirenOrAlarm, PATCH_JUMP); InjectHook(0x56BCB0, &cAudioManager::ProcessVehicleSkidding, PATCH_JUMP); InjectHook(0x575F30, &cAudioManager::ProcessWaterCannon, PATCH_JUMP); InjectHook(0x578370, &cAudioManager::ProcessWeather, PATCH_JUMP); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 19809286..0a2a081d 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -640,7 +640,7 @@ public: void ProcessVehicleOneShots(void *); // todo bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok - void ProcessVehicleSirenOrAlarm(void *); // todo + void ProcessVehicleSirenOrAlarm(cVehicleParams *params); /// ok void ProcessVehicleSkidding(cVehicleParams *params); /// ok void ProcessWaterCannon(int32); /// ok void ProcessWeather(int32 id); /// ok -- cgit v1.2.3 From c7e9ddb56624d73a3373a8246cc49ed2728d49a3 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 29 Nov 2019 16:30:04 +0100 Subject: Audio fixes for erorcun review --- src/audio/AudioManager.cpp | 66 +++++++++++++++++++++++----------------------- src/audio/AudioManager.h | 10 +++---- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e70fce8a..19f5ba5b 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -518,11 +518,11 @@ cAudioManager::AgeCrimes() } void -cAudioManager::CalculateDistance(bool *ptr, float dist) +cAudioManager::CalculateDistance(bool &condition, float dist) { - if(*ptr == false) { + if(condition == false) { m_sQueueSample.m_fDistance = Sqrt(dist); - *ptr = true; + condition = true; } } @@ -3181,7 +3181,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) (automobile->m_fVelocityChangeForAudio > -0.025f || params->m_fVelocityChange <= 0.025f)) return 1; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); rand = m_anRandomTable[0] % 10 + 70; m_sQueueSample.m_bVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { @@ -3273,7 +3273,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(params->m_fDistance < 2500.f) { boat = (CBoat *)params->m_pVehicle; if(params->m_nIndex == REEFER) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 39; @@ -3379,7 +3379,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; } } - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); if(!m_sQueueSample.m_bVolume) return 1; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; @@ -3418,7 +3418,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) velocityChange = min(0.75f, velocityChange); multiplier = (velocityChange - 0.0005f) * 1.3342f; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); vol = (30.f * multiplier); m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { @@ -3448,13 +3448,13 @@ void cAudioManager::ProcessBridge() { float dist; - bool something = false; + bool distCalculated = false; if(CBridge::pLiftRoad) { m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition(); dist = GetDistanceSquared(&m_sQueueSample.m_vecPos); if(dist < 202500.0f) { - CalculateDistance(&something, dist); + CalculateDistance(distCalculated, dist); switch(CBridge::State) { case STATE_BRIDGE_LOCKED: case STATE_LIFT_PART_IS_UP: @@ -3584,7 +3584,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) if(params->m_fDistance >= 1600.f) return 0; automobile = (CAutomobile *)params->m_pVehicle; if(automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 35; @@ -3750,7 +3750,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.field_16 = 7; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); } - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 28; @@ -3933,12 +3933,12 @@ void cAudioManager::ProcessFireHydrant() { float distSquared; - bool something = false; + bool distCalculated = false; m_sQueueSample.m_vecPos = *(CVector *)((size_t)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity + 52); distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); if(distSquared < 1225.f) { - CalculateDistance(&something, distSquared); + CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_bVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 0; @@ -4155,7 +4155,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) if(gHeliSfxRanges[0].m_fMaxDistance * gHeliSfxRanges[0].m_fMaxDistance <= params->m_fDistance) return 0; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); heli = (CHeli *)params->m_pVehicle; for(uint32 i = 0; i < 3; i++) { MaxDist = gHeliSfxRanges[i].m_fMaxDistance; @@ -4254,7 +4254,7 @@ cAudioManager::ProcessJumbo(cVehicleParams *params) float position; if(params->m_fDistance < 193600.0f) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); plane = (CPlane *)params->m_pVehicle; DoJumboVolOffset(); position = PlanePathPosition[plane->m_nPlaneId]; @@ -5214,7 +5214,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) else emittingVol = 90; if(emittingVol) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { @@ -5537,7 +5537,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) if(params->m_fDistance < 49.f) { ped = params->m_pPed; if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != 2) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) { emittingVol = 10; veh = ped->m_pMyVehicle; @@ -6991,7 +6991,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) veh = params->m_pVehicle; if(veh->m_bRainAudioCounter >= 2) { veh->m_bRainAudioCounter = 0; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); emittingVol = 30.f * CWeather::Rain; m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 22.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { @@ -7040,7 +7040,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) if(params->m_fDistance >= 900.f) return 0; veh = params->m_pVehicle; if(veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); automobile = (CAutomobile *)params->m_pVehicle; if(automobile->m_nWheelsOnGround) { modificator = params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity; @@ -7258,7 +7258,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if(params->m_fDistance >= 90000.f) return 0; if(params->m_fVelocityChange > 0.0f) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); train = (CTrain *)params->m_pVehicle; speedMultipler = min(1.0f, train->m_fSpeed * 250.f / 51.f); emittingVol = (75.f * speedMultipler); @@ -7323,7 +7323,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) cVehicleParams params; m_sQueueSample.m_vecPos = veh->GetPosition(); - params.m_bDistancECalculated = 0; + params.m_bDistanceCalculated = false; params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); params.m_pVehicle = veh; params.m_pTransmission = nil; @@ -7416,7 +7416,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if(params->m_fDistance >= 1600.f) return 0; automobile = (CAutomobile *)params->m_pVehicle; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); for(int32 i = 0; i < 6; i++) { if(automobile->Damage.GetDoorStatus(i) == 2) { doorState = automobile->Doors[i].m_nDoorState; @@ -7472,7 +7472,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) automobile->m_modelIndex != MI_MRWHOOP) { if(automobile->m_nCarHornTimer) { if(!params->m_pVehicle->m_status) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 4; @@ -7504,7 +7504,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) automobile->field_22D = (LOBYTE(m_nTimeOfRecentCrime) + LOBYTE(m_sQueueSample.m_nEntityIndex)) & 7; if(hornPatternsArray[automobile->field_22D][44 - automobile->m_nCarHornTimer]) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 4; @@ -7550,7 +7550,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) if(params->m_fDistance >= 2500.f) return 0; if(veh->bEngineOn && veh->m_fGasPedal < 0.0f) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(60, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 12; @@ -7592,7 +7592,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) if(params->m_pVehicle->m_vecMoveSpeed.z) { velocity = Abs(params->m_fVelocityChange); if(velocity > 0.0f) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); emittingVol = 30.f * min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); @@ -7639,7 +7639,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) CVehicle *veh = params->m_pVehicle; if(veh->m_bSirenOrAlarm == 0 && veh->m_nAlarmState <= 0) return; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 110.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_counter = 5; @@ -7695,7 +7695,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) if(params->m_fDistance >= 1600.f) return; automobile = (CAutomobile *)params->m_pVehicle; if(!automobile->m_nWheelsOnGround) return; - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); for(int32 i = 0; i < 4; i++) { if(!automobile->m_aWheelState[i] || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) continue; @@ -7884,7 +7884,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) if(params->m_pVehicle->m_vecMoveSpeed.z) { velChange = Abs(params->m_fVelocityChange); if(velChange > 0.f) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); relativeVelocity = min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; @@ -8913,14 +8913,14 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) soundIntensity = 50.f; if(params->m_fDistance < maxDist) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if(sound != SOUND_PAGER) { switch(sound) { case SOUND_AMMUNATION_WELCOME_1: case SOUND_AMMUNATION_WELCOME_2: case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break; default: - if(CWorld::GetIsLineOfSightClear(TheCamera.GetGameCamPosition(), + if(CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), m_sQueueSample.m_vecPos, 1, 0, 0, 0, 0, 0, 0)) { emittingVol = maxVolume; @@ -8974,14 +8974,14 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) } if(params->m_fDistance < maxDist) { - CalculateDistance((bool *)params, params->m_fDistance); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if(sound != SOUND_PAGER) { switch(sound) { case SOUND_AMMUNATION_WELCOME_1: case SOUND_AMMUNATION_WELCOME_2: case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break; default: - if(CWorld::GetIsLineOfSightClear(TheCamera.GetGameCamPosition(), + if(CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), m_sQueueSample.m_vecPos, 1, 0, 0, 0, 0, 0, 0)) { emittingVol = maxVolume; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0a2a081d..7df6dcbe 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -440,11 +440,11 @@ public: void AddSampleToRequestedQueue(); /// ok void AgeCrimes(); /// ok - void CalculateDistance(bool *ptr, float dist); /// ok - bool CheckForAnAudioFileOnCD() const; /// ok - void ClearActiveSamples(); /// ok - void ClearMissionAudio(); /// ok - void ClearRequestedQueue(); /// ok + void CalculateDistance(bool &condition, float dist); /// ok + bool CheckForAnAudioFileOnCD() const; /// ok + void ClearActiveSamples(); /// ok + void ClearMissionAudio(); /// ok + void ClearRequestedQueue(); /// ok int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const; /// ok int32 ComputePan(float, CVector *); /// ok -- cgit v1.2.3 From 5289f398ea7718d56d38f97e36f1f6386760d5fc Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 1 Dec 2019 00:32:47 +0100 Subject: Fix CalculateDistance --- src/audio/AudioManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 19f5ba5b..f823cf19 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -518,11 +518,11 @@ cAudioManager::AgeCrimes() } void -cAudioManager::CalculateDistance(bool &condition, float dist) +cAudioManager::CalculateDistance(bool &distCalculated, float dist) { - if(condition == false) { + if(!distCalculated) { m_sQueueSample.m_fDistance = Sqrt(dist); - condition = true; + distCalculated = true; } } -- cgit v1.2.3 From dad7782ff0be00775f99ad54c656e58b39190b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 2 Dec 2019 23:02:32 +0300 Subject: CPhone, CPlayerInfo, CFire, CWorld --- src/audio/AudioManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index f823cf19..abfbde00 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -5536,12 +5536,12 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) if(params->m_fDistance < 49.f) { ped = params->m_pPed; - if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != 2) { + if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != PED_HEAD) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) { emittingVol = 10; veh = ped->m_pMyVehicle; - if(veh && veh->m_type == 0) { + if(veh && veh->IsCar()) { for(int32 i = 2; i < 6; i++) { if(!veh->IsDoorClosed((eDoors)i) || veh->IsDoorMissing((eDoors)i)) { emittingVol = 42; @@ -6451,7 +6451,7 @@ cAudioManager::ProcessPhysical(int32 id) { CPhysical *entity = (CPhysical *)m_asAudioEntities[id].m_pEntity; if(entity) { - switch(entity->m_type & 7) { + switch(entity->m_type) { case ENTITY_TYPE_VEHICLE: ProcessVehicle((CVehicle *)m_asAudioEntities[id].m_pEntity); break; case ENTITY_TYPE_PED: ProcessPed((CPhysical *)m_asAudioEntities[id].m_pEntity); break; default: return; -- cgit v1.2.3 From bb5e31470da4e74695b18060c7c9947432cc4813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 27 Dec 2019 01:15:27 +0300 Subject: CPlayerPed & fixes --- src/audio/sampman.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index 9c79e1b1..6edb6028 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -352,7 +352,11 @@ _ResolveLink(char const *path, char *out) OutputDebugString(fd.cFileName); strcpy(out, filepath); - + // FIX: Release the objects. Taken from SA. +#ifdef FIX_BUGS + ppf->Release(); + psl->Release(); +#endif return true; } } -- cgit v1.2.3