diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-01-01 00:42:00 +0100 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-01-01 00:42:00 +0100 |
commit | 5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5 (patch) | |
tree | 2e2bca559ef34473733d63a022c74a711c894830 /src/audio | |
parent | some not fully tested stuff (diff) | |
parent | making particleobject compile on vs2015 (diff) | |
download | re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar.gz re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar.bz2 re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar.lz re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar.xz re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.tar.zst re3-5b0cf80a76e49cee88e796bb8c4b53fd3ca8f3c5.zip |
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/AudioManager.cpp | 162 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 12 | ||||
-rw-r--r-- | src/audio/sampman.cpp | 14 |
3 files changed, 117 insertions, 71 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index facf3a4a..abfbde00 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" @@ -517,11 +518,11 @@ cAudioManager::AgeCrimes() } void -cAudioManager::CalculateDistance(bool *ptr, float dist) +cAudioManager::CalculateDistance(bool &distCalculated, float dist) { - if(*ptr == false) { + if(!distCalculated) { m_sQueueSample.m_fDistance = Sqrt(dist); - *ptr = true; + distCalculated = true; } } @@ -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); } @@ -2601,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 { @@ -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; @@ -3180,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) { @@ -3272,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; @@ -3378,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; @@ -3417,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) { @@ -3447,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: @@ -3583,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; @@ -3749,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; @@ -3932,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; @@ -4154,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; @@ -4253,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]; @@ -5213,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) { @@ -5535,12 +5536,12 @@ 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); + 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; @@ -6450,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; @@ -6491,7 +6492,6 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * float relativeVelocityChange; float accelerationMultipler; uint8 wheelInUseCounter; - uint8 i; float time; int baseFreq; uint8 vol; @@ -6539,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]) && @@ -6622,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 || @@ -6994,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) { @@ -7043,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; @@ -7261,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); @@ -7326,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; @@ -7419,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; @@ -7475,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; @@ -7507,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; @@ -7553,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; @@ -7595,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); @@ -7635,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(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; + 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 @@ -7654,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; @@ -7843,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; @@ -8872,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; @@ -8933,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; @@ -9594,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..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 @@ -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 diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index 53b81a36..6edb6028 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]; @@ -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 @@ -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; } } @@ -1437,7 +1441,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) bool cSampleManager::IsPedCommentLoaded(uint32 nComment) { - int32 slot; + uint8 slot; for ( int32 i = 0; i < _TODOCONST(3); i++ ) { @@ -1452,7 +1456,7 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) int32 cSampleManager::_GetPedCommentSlot(uint32 nComment) { - int32 slot; + uint8 slot; for ( int32 i = 0; i < _TODOCONST(3); i++ ) { |