summaryrefslogtreecommitdiffstats
path: root/src/audio
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2020-02-28 18:34:39 +0100
committerFilip Gawin <filip.gawin@zoho.com>2020-03-22 17:30:54 +0100
commit337924c7944115a9212edfb1097a8f83e7f6daf0 (patch)
tree2d64a0f5e45a0de92682c49db53c6cb8559d1cf4 /src/audio
parentRemove unneeded double to float casts (diff)
downloadre3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar.gz
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar.bz2
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar.lz
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar.xz
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.tar.zst
re3-337924c7944115a9212edfb1097a8f83e7f6daf0.zip
Diffstat (limited to '')
-rw-r--r--src/audio/AudioCollision.cpp22
-rw-r--r--src/audio/AudioManager.cpp439
-rw-r--r--src/audio/AudioManager.h30
3 files changed, 178 insertions, 313 deletions
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp
index 6c998a34..0e4fb748 100644
--- a/src/audio/AudioCollision.cpp
+++ b/src/audio/AudioCollision.cpp
@@ -8,6 +8,8 @@
#include "SurfaceTable.h"
#include "sampman.h"
+constexpr int CollisionSoundIntensity = 60;
+
void
cAudioCollisionManager::AddCollisionToRequestedQueue()
{
@@ -146,7 +148,8 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col);
if(emittingVol) {
m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 60.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_bVolume =
+ ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = counter;
m_sQueueSample.m_vecPos = col->m_vecPosition;
@@ -160,7 +163,7 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 60.0f;
+ m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 5;
m_sQueueSample.m_bReverbFlag = true;
@@ -212,7 +215,8 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
emittingVol = 40.f * ratio;
if(emittingVol) {
m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 60.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_bVolume =
+ ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_nSampleIndex = gOneShotCol[s1];
switch(m_sQueueSample.m_nSampleIndex) {
@@ -277,7 +281,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.field_48 = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 60.0f;
+ m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity;
m_sQueueSample.field_56 = 1;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
@@ -356,7 +360,7 @@ void
cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower,
float velocity)
{
- float dist;
+ float distSquared;
CVector v1;
CVector v2;
@@ -373,8 +377,8 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
v2 = entity2->GetPosition();
}
CVector pos = (v1 + v2) * 0.5f;
- dist = GetDistanceSquared(&pos);
- if(dist < SQR(60.f)) {
+ distSquared = GetDistanceSquared(&pos);
+ if(distSquared < SQR(CollisionSoundIntensity)) {
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
m_sCollisionManager.m_sQueue.m_bSurface1 = surface1;
@@ -382,7 +386,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower;
m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity;
m_sCollisionManager.m_sQueue.m_vecPosition = pos;
- m_sCollisionManager.m_sQueue.m_fDistance = dist;
+ m_sCollisionManager.m_sQueue.m_fDistance = distSquared;
m_sCollisionManager.AddCollisionToRequestedQueue();
}
}
@@ -396,4 +400,4 @@ InjectHook(0x5686D0, &cAudioManager::ServiceCollisions, PATCH_JUMP);
InjectHook(0x568E20, &cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol, PATCH_JUMP);
InjectHook(0x568D30, &cAudioManager::SetUpLoopingCollisionSound, PATCH_JUMP);
InjectHook(0x5689D0, &cAudioManager::SetUpOneShotCollisionSound, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+ENDPATCHES
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 201d8698..2940be85 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -165,8 +165,8 @@ cPedComments::Add(tPedComment *com)
{
uint8 index;
- if(nrOfCommentsInBank[activeBank] >= 20) {
- index = indexMap[activeBank][19];
+ if(nrOfCommentsInBank[activeBank] >= pedCommentsSlots) {
+ index = indexMap[activeBank][pedCommentsSlots - 1];
if(m_asPedComments[activeBank][index].m_bVolume > com->m_bVolume) return;
} else {
index = nrOfCommentsInBank[activeBank]++;
@@ -187,7 +187,7 @@ cPedComments::Add(tPedComment *com)
}
}
- if(i < index) memmove(&indexMap[activeBank][i + 1], &indexMap[activeBank][i], 19 - i);
+ if(i < index) memmove(&indexMap[activeBank][i + 1], &indexMap[activeBank][i], pedCommentsSlots -1 - i);
}
indexMap[activeBank][i] = index;
@@ -200,6 +200,9 @@ cPedComments::Process()
uint8 actualUsedBank;
tPedComment *comment;
+ static constexpr int defaultIntensity = 50;
+ static constexpr int policeHeliIntensity = 400;
+
if(!AudioManager.m_bUserPause) {
if(nrOfCommentsInBank[activeBank]) {
sampleIndex = m_asPedComments[activeBank][indexMap[activeBank][0]].m_nSampleIndex;
@@ -224,9 +227,9 @@ cPedComments::Process()
case SFX_POLICE_HELI_1:
case SFX_POLICE_HELI_2:
case SFX_POLICE_HELI_3:
- AudioManager.m_sQueueSample.m_fSoundIntensity = 400.0f;
+ AudioManager.m_sQueueSample.m_fSoundIntensity = policeHeliIntensity;
break;
- default: AudioManager.m_sQueueSample.m_fSoundIntensity = 50.0f; break;
+ default: AudioManager.m_sQueueSample.m_fSoundIntensity = defaultIntensity; break;
}
AudioManager.m_sQueueSample.field_56 = 1;
AudioManager.m_sQueueSample.m_vecPos =
@@ -265,7 +268,7 @@ cPedComments::Process()
}
}
- for(uint32 i = 0; i < 20; i++) { indexMap[actualUsedBank][i] = 20; }
+ for(uint32 i = 0; i < pedCommentsSlots; i++) { indexMap[actualUsedBank][i] = pedCommentsSlots; }
nrOfCommentsInBank[actualUsedBank] = 0;
}
}
@@ -378,7 +381,7 @@ cAudioManager::AddReleasingSounds()
}
}
if(!toProcess[i]) {
- if(sample.m_counter <= 255u || !sample.m_bLoopsRemaining) {
+ if(sample.m_counter <= 255 || !sample.m_bLoopsRemaining) {
if(!sample.field_76) continue;
if(!sample.m_nLoopCount) {
if(sample.field_88 == -1) {
@@ -616,7 +619,7 @@ void
cAudioManager::DestroyEntity(int32 id)
{
if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots && m_asAudioEntities[id].m_bIsUsed) {
- m_asAudioEntities[id].m_bIsUsed = 0;
+ m_asAudioEntities[id].m_bIsUsed = false;
for(int32 i = 0; i < m_nAudioEntitiesTotal; ++i) {
if(id == m_anAudioEntityIndices[i]) {
if(i < totalAudioEntitiesSlots - 1)
@@ -2773,28 +2776,22 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params)
void
cAudioManager::ProcessAirportScriptObject(uint8 sound)
{
- float dist;
- float maxDist;
-
static uint8 counter = 0;
uint32 time = CTimer::GetTimeInMilliseconds();
if(time > gAirportNextTime) {
switch(sound) {
case SCRIPT_SOUND_AIRPORT_LOOP_S:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_AIRPORT_LOOP_L:
- maxDist = 6400.f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
default: return;
}
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- dist = sqrt(distSquared);
- m_sQueueSample.m_fDistance = dist;
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -2833,7 +2830,9 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
static uint16 LastAccel = 0;
static uint8 LastVol = 0;
- if(params->m_fDistance < 2500.f) {
+ static constexpr int intensity = 50;
+
+ if(params->m_fDistance < SQR(intensity)) {
boat = (CBoat *)params->m_pVehicle;
if(params->m_nIndex == REEFER) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
@@ -2853,7 +2852,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 7;
m_sQueueSample.m_bReverbFlag = true;
@@ -2896,7 +2895,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 7;
m_sQueueSample.m_bReverbFlag = true;
@@ -2955,7 +2954,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 7;
m_sQueueSample.m_bReverbFlag = true;
@@ -3037,8 +3036,8 @@ cAudioManager::ProcessBridge()
void
cAudioManager::ProcessBridgeMotor()
{
- if(m_sQueueSample.m_fDistance < 400.f) {
- m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, 400.f, m_sQueueSample.m_fDistance);
+ if(m_sQueueSample.m_fDistance < bridgeIntensity) {
+ m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = 1;
m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE;
@@ -3052,7 +3051,7 @@ cAudioManager::ProcessBridgeMotor()
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 400.0f;
+ m_sQueueSample.m_fSoundIntensity = bridgeIntensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_bReverbFlag = false;
@@ -3064,32 +3063,26 @@ cAudioManager::ProcessBridgeMotor()
void
cAudioManager::ProcessBridgeOneShots()
{
- float maxDist;
-
if(CBridge::State == STATE_LIFT_PART_IS_UP && CBridge::OldState == STATE_LIFT_PART_MOVING_UP) {
- maxDist = 400.f;
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
if(CBridge::State == STATE_LIFT_PART_IS_DOWN && CBridge::OldState == STATE_LIFT_PART_MOVING_DOWN) {
- maxDist = 400.f;
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
if(CBridge::State == STATE_LIFT_PART_MOVING_UP &&
CBridge::OldState == STATE_LIFT_PART_ABOUT_TO_MOVE_UP) {
- maxDist = 400.f;
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
if(CBridge::State == STATE_LIFT_PART_MOVING_DOWN &&
CBridge::OldState == STATE_LIFT_PART_IS_UP) {
- maxDist = 400.f;
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else
return;
}
}
}
- if(m_sQueueSample.m_fDistance < maxDist) {
- m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, maxDist, m_sQueueSample.m_fDistance);
+ if(m_sQueueSample.m_fDistance < bridgeIntensity) {
+ m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = 2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -3102,7 +3095,7 @@ cAudioManager::ProcessBridgeOneShots()
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = maxDist;
+ m_sQueueSample.m_fSoundIntensity = bridgeIntensity;
m_sQueueSample.field_56 = 1;
m_sQueueSample.m_bReverbFlag = false;
m_sQueueSample.m_bRequireReflection = false;
@@ -3247,7 +3240,6 @@ void
cAudioManager::ProcessCinemaScriptObject(uint8 sound)
{
uint8 rand;
- float maxDist;
static uint8 counter = 0;
@@ -3255,18 +3247,16 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound)
if(time > gCinemaNextTime) {
switch(sound) {
case SCRIPT_SOUND_CINEMA_LOOP_S:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_CINEMA_LOOP_L:
- maxDist = 6400.f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
default: return;
}
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 90 + 30;
m_sQueueSample.m_bVolume =
ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -3299,15 +3289,15 @@ cAudioManager::ProcessCrane()
{
CCrane *crane = (CCrane *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity;
float distSquared;
-
bool distCalculated = false;
+ static constexpr int intensity = 80;
if(crane) {
if(crane->m_bCraneActive == 1) {
if(crane->m_bCraneStatus) {
m_sQueueSample.m_vecPos = crane->m_pObject->GetPosition();
distSquared = GetDistanceSquared(&this->m_sQueueSample.m_vecPos);
- if(distSquared < 6400.f) {
+ if(distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -3324,7 +3314,7 @@ cAudioManager::ProcessCrane()
m_sQueueSample.m_nLoopEnd =
SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -3339,7 +3329,7 @@ cAudioManager::ProcessCrane()
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.field_56 = 1;
m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bRequireReflection = 1;
+ m_sQueueSample.m_bRequireReflection = true;
AddSampleToRequestedQueue();
}
}
@@ -3354,7 +3344,6 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound)
uint32 time;
uint8 rand;
float distSquared;
- float maxDist;
static uint32 counter = 0;
@@ -3362,18 +3351,16 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound)
if(time > gDocksNextTime) {
switch(sound) {
case SCRIPT_SOUND_DOCKS_LOOP_S:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_DOCKS_LOOP_L:
- maxDist = 6400.f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 60 + 40;
m_sQueueSample.m_bVolume =
ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -3529,7 +3516,6 @@ cAudioManager::ProcessExplosions(int32 explosion)
{
uint8 type;
CVector *pos;
- float maxDist;
float distSquared;
for(uint8 i = 0; i < 48; i++) {
@@ -3541,7 +3527,6 @@ cAudioManager::ProcessExplosions(int32 explosion)
case EXPLOSION_ROCKET:
case EXPLOSION_BARREL:
case EXPLOSION_TANK_GRENADE:
- maxDist = 160000.f;
m_sQueueSample.m_fSoundIntensity = 400.0f;
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000;
@@ -3549,7 +3534,6 @@ cAudioManager::ProcessExplosions(int32 explosion)
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
break;
case EXPLOSION_MOLOTOV:
- maxDist = 40000.f;
m_sQueueSample.m_fSoundIntensity = 200.0f;
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_3;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 19000;
@@ -3558,7 +3542,6 @@ cAudioManager::ProcessExplosions(int32 explosion)
break;
case EXPLOSION_MINE:
case EXPLOSION_HELI_BOMB:
- maxDist = 90000.f;
m_sQueueSample.m_fSoundIntensity = 300.0f;
m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 12347;
@@ -3566,7 +3549,6 @@ cAudioManager::ProcessExplosions(int32 explosion)
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
break;
default:
- maxDist = 160000.f;
m_sQueueSample.m_fSoundIntensity = 400.0f;
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000;
@@ -3579,7 +3561,7 @@ cAudioManager::ProcessExplosions(int32 explosion)
pos = CExplosion::GetExplosionPosition(i);
m_sQueueSample.m_vecPos = *pos;
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity,
m_sQueueSample.m_fDistance);
@@ -3607,10 +3589,11 @@ cAudioManager::ProcessFireHydrant()
{
float distSquared;
bool distCalculated = false;
+ static constexpr int intensity = 35;
m_sQueueSample.m_vecPos = ((CEntity*)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition();
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < 1225.f) {
+ if(distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -3626,7 +3609,7 @@ cAudioManager::ProcessFireHydrant()
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
+ m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -3640,7 +3623,6 @@ void cAudioManager::ProcessFires(int32)
{
CEntity *entity;
uint8 emittingVol;
- float maxDist;
float distSquared;
for(uint8 i = 0; i < NUM_FIRES; i++) {
@@ -3649,7 +3631,6 @@ void cAudioManager::ProcessFires(int32)
if(entity) {
switch(entity->m_type & 7) {
case ENTITY_TYPE_BUILDING:
- maxDist = 2500.f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
emittingVol = 100;
@@ -3659,7 +3640,6 @@ void cAudioManager::ProcessFires(int32)
m_sQueueSample.field_16 = 6;
break;
case ENTITY_TYPE_PED:
- maxDist = 625.f;
m_sQueueSample.m_fSoundIntensity = 25.0f;
m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE;
m_sQueueSample.m_nFrequency =
@@ -3669,7 +3649,6 @@ void cAudioManager::ProcessFires(int32)
m_sQueueSample.field_16 = 10;
break;
default:
- maxDist = 2500.f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
m_sQueueSample.m_nFrequency =
@@ -3679,7 +3658,6 @@ void cAudioManager::ProcessFires(int32)
m_sQueueSample.field_16 = 8;
}
} else {
- maxDist = 2500.f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
@@ -3689,7 +3667,7 @@ void cAudioManager::ProcessFires(int32)
}
m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].m_vecPos;
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
m_sQueueSample.m_fDistance);
@@ -3859,7 +3837,7 @@ cAudioManager::ProcessFrontEnd()
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
if(stereo)
- m_sQueueSample.m_bOffset = m_anRandomTable[0] & 0x1F;
+ m_sQueueSample.m_bOffset = m_anRandomTable[0] & 31;
else
m_sQueueSample.m_bOffset = 63;
m_sQueueSample.m_bReverbFlag = false;
@@ -4079,7 +4057,6 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound)
uint32 time;
uint8 rand;
float dist;
- float maxDist;
static uint8 counter = 0;
@@ -4087,18 +4064,16 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound)
if(time > gHomeNextTime) {
switch(sound) {
case SCRIPT_SOUND_HOME_LOOP_S:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_HOME_LOOP_L:
- maxDist = 6400.f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
default: return;
}
dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(dist < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(dist);
+ if(dist < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(dist);
rand = m_anRandomTable[0] % 30 + 40;
m_sQueueSample.m_bVolume =
ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -4241,19 +4216,16 @@ cAudioManager::ProcessJumboTaxi()
void
cAudioManager::ProcessLaunderetteScriptObject(uint8 sound)
{
- float maxDist;
-
switch(sound) {
case SCRIPT_SOUND_LAUNDERETTE_LOOP_S:
case SCRIPT_SOUND_LAUNDERETTE_LOOP_L:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
break;
default: return;
}
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -4301,12 +4273,10 @@ void
cAudioManager::ProcessLoopingScriptObject(uint8 sound)
{
uint8 emittingVolume;
- float maxDist;
float distSquared;
switch(sound) {
case SCRIPT_SOUND_PARTY_1_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4317,7 +4287,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_1_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4328,7 +4297,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_2_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4339,7 +4307,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_2_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4350,7 +4317,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_3_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_3;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4361,7 +4327,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_3_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_3;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4372,7 +4337,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_4_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_4;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4383,7 +4347,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_4_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_4;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4394,7 +4357,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_5_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_5;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4405,7 +4367,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_5_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_5;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4416,7 +4377,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_6_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_6;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4427,7 +4387,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_6_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_6;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4438,7 +4397,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_7_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_7;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4449,7 +4407,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_7_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_7;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4460,7 +4417,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_8_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_8;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4471,7 +4427,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_8_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_8;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4482,7 +4437,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_9_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_9;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4493,7 +4447,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_9_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_9;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4504,7 +4457,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_10_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_10;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4515,7 +4467,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_10_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_10;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4526,7 +4477,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_11_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_11;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4537,7 +4487,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_11_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_11;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4548,7 +4497,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_12_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_12;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4559,7 +4507,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_12_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_12;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4570,7 +4517,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_13_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4581,7 +4527,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_13_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4592,7 +4537,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4603,7 +4547,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4614,7 +4557,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4625,7 +4567,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4640,7 +4581,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_SAWMILL_LOOP_S:
case SCRIPT_SOUND_SAWMILL_LOOP_L: ProcessSawMillScriptObject(sound); return;
case SCRIPT_SOUND_38:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4651,7 +4591,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_39:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4664,7 +4603,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_LAUNDERETTE_LOOP_S:
case SCRIPT_SOUND_LAUNDERETTE_LOOP_L: ProcessLaunderetteScriptObject(sound); return;
case SCRIPT_SOUND_CHINATOWN_RESTAURANT_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4675,7 +4613,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_CHINATOWN_RESTAURANT_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4686,7 +4623,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_CIPRIANI_RESAURANT_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4697,7 +4633,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_CIPRIANI_RESAURANT_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4707,8 +4642,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_76 = 3;
m_sQueueSample.field_48 = 2.0f;
break;
- case SCRIPT_SOUND_46:
- maxDist = 900.f;
+ case SCRIPT_SOUND_46_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4718,8 +4652,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_76 = 3;
m_sQueueSample.field_48 = 2.0f;
break;
- case SCRIPT_SOUND_47:
- maxDist = 6400.f;
+ case SCRIPT_SOUND_47_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4730,7 +4663,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_MARCO_BISTRO_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4741,7 +4673,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_MARCO_BISTRO_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4762,7 +4693,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_HOME_LOOP_S:
case SCRIPT_SOUND_HOME_LOOP_L: ProcessHomeScriptObject(sound); return;
case SCRIPT_SOUND_FRANKIE_PIANO:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_PIANO_BAR_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4773,7 +4703,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PARTY_1_LOOP:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4792,7 +4721,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_MISTY_SEX_S:
case SCRIPT_SOUND_MISTY_SEX_L: ProcessPornCinema(sound); return;
case SCRIPT_SOUND_BANK_ALARM_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4803,7 +4731,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_BANK_ALARM_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4814,7 +4741,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_POLICE_BALL_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4825,7 +4751,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_POLICE_BALL_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4836,7 +4761,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4847,7 +4771,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4861,7 +4784,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L: ProcessPoliceCellBeatingScriptObject(sound); return;
case SCRIPT_SOUND_RAVE_1_LOOP_S:
case SCRIPT_SOUND_RAVE_2_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4873,7 +4795,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
break;
case SCRIPT_SOUND_RAVE_1_LOOP_L:
case SCRIPT_SOUND_RAVE_2_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4884,7 +4805,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_RAVE_3_LOOP_S:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4895,7 +4815,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_RAVE_3_LOOP_L:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4906,7 +4825,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
m_sQueueSample.field_48 = 2.0f;
break;
case SCRIPT_SOUND_PRETEND_FIRE_LOOP:
- maxDist = 2500.f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -4920,7 +4838,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -5130,7 +5048,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
{
CPlayerPed *playerPed;
uint8 emittingVolume;
- float maxDist;
float distSquared;
cPedParams male;
@@ -5155,7 +5072,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
return;
case SCRIPT_SOUND_GATE_START_CLUNK:
case SCRIPT_SOUND_GATE_STOP_CLUNK:
- maxDist = 1600.f;
m_sQueueSample.m_fSoundIntensity = 40.0f;
m_sQueueSample.m_nSampleIndex = SFX_COL_GATE;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5172,7 +5088,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_BULLET_HIT_GROUND_1:
case SCRIPT_SOUND_BULLET_HIT_GROUND_2:
case SCRIPT_SOUND_BULLET_HIT_GROUND_3:
- maxDist = 2500.f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = m_anRandomTable[iSound % 5] % 3 + SFX_BULLET_WALL_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5186,7 +5101,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_110:
case SCRIPT_SOUND_111:
if(SampleManager.IsSampleBankLoaded(0) != 1) return;
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_TRAIN_STATION_ANNOUNCE;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5197,7 +5111,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_bIsDistant = false;
break;
case SCRIPT_SOUND_PAYPHONE_RINGING:
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_PHONE_RING;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5209,7 +5122,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_bRequireReflection = false;
break;
case SCRIPT_SOUND_GLASS_BREAK_L:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5220,7 +5132,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_bIsDistant = false;
break;
case SCRIPT_SOUND_GLASS_BREAK_S:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5231,7 +5142,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_bIsDistant = false;
break;
case SCRIPT_SOUND_GLASS_CRACK:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5243,7 +5153,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_bRequireReflection = true;
break;
case SCRIPT_SOUND_GLASS_LIGHT_BREAK:
- maxDist = 3025.f;
m_sQueueSample.m_fSoundIntensity = 55.0f;
m_sQueueSample.m_nSampleIndex = (m_anRandomTable[4] & 3) + SFX_GLASS_SHARD_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5254,7 +5163,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
emittingVolume = RandomDisplacement(11) + 25;
break;
case SCRIPT_SOUND_BOX_DESTROYED_1:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_WOODEN_BOX_SMASH;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5266,7 +5174,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
emittingVolume = m_anRandomTable[2] % 20 + 80;
break;
case SCRIPT_SOUND_BOX_DESTROYED_2:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_CARDBOARD_BOX_SMASH;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5278,7 +5185,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
emittingVolume = m_anRandomTable[2] % 20 + 80;
break;
case SCRIPT_SOUND_METAL_COLLISION:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = m_anRandomTable[3] % 5 + SFX_COL_CAR_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5291,7 +5197,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
emittingVolume = m_anRandomTable[2] % 30 + 70;
break;
case SCRIPT_SOUND_TIRE_COLLISION:
- maxDist = 3600.f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@@ -5318,14 +5223,13 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2;
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000;
m_sQueueSample.field_16 = 18;
- maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_bIsDistant = false;
emittingVolume = m_anRandomTable[2] % 20 + 30;
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity,
@@ -5349,7 +5253,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1;
m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000;
m_sQueueSample.field_16 = 15;
- maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.field_48 = 0.0f;
@@ -5360,7 +5263,6 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2;
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000;
m_sQueueSample.field_16 = 18;
- maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.field_48 = 0.0f;
@@ -5371,7 +5273,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -5571,7 +5473,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FALL_LAND:
case SOUND_FALL_COLLAPSE:
if(!ped->bIsLooking) {
- maxDist = 900.f;
+ maxDist = SQR(30);
emittingVol = m_anRandomTable[3] % 20 + 80;
if(ped->m_nSurfaceTouched == SURFACE_PUDDLE) {
m_sQueueSample.m_nSampleIndex =
@@ -5609,7 +5511,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5629,7 +5531,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5649,7 +5551,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5669,7 +5571,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5689,7 +5591,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5709,7 +5611,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5729,7 +5631,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5749,7 +5651,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5769,7 +5671,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5789,7 +5691,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5809,7 +5711,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5829,7 +5731,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
@@ -5848,7 +5750,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -5875,7 +5777,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
- maxDist = 2500.f;
+ maxDist = SQR(50);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -5899,7 +5801,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
- maxDist = 6400.f;
+ maxDist = SQR(80);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 15 + 70;
@@ -5943,7 +5845,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
- maxDist = 6400.f;
+ maxDist = SQR(80);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[1] % 15 + 70;
@@ -5963,7 +5865,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
- maxDist = 6400.f;
+ maxDist = SQR(80);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[4] % 15 + 70;
@@ -6066,7 +5968,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6086,7 +5988,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6106,7 +6008,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6127,7 +6029,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6148,7 +6050,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6169,7 +6071,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6190,7 +6092,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 5;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6214,7 +6116,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 3;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
- maxDist = 6400.f;
+ maxDist = SQR(80);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
@@ -6256,7 +6158,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.field_16 = 7;
m_sQueueSample.field_48 = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ maxDist = SQR(30);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[0] % 20 + 90;
@@ -6635,7 +6537,6 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
int32 sampleIndex;
uint8 emittingVol;
float distSquared;
- float maxDist;
cPedParams params;
static uint8 counter = 0;
@@ -6643,18 +6544,16 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
if(time > gCellNextTime) {
switch(sound) {
case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L:
- maxDist = 6400.f;
- m_sQueueSample.m_fSoundIntensity = 80.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
if(m_FrameCounter & 1)
sampleIndex = (m_anRandomTable[1] & 3) + SFX_FIGHT_1;
else
@@ -6682,7 +6581,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
AddSampleToRequestedQueue();
params.m_bDistanceCalculated = 1;
params.m_fDistance = distSquared;
- params.m_pPed = 0;
+ params.m_pPed = nil;
SetupPedComments(&params, SOUND_8A);
}
gCellNextTime = time + 500 + m_anRandomTable[3] % 1500;
@@ -6698,14 +6597,12 @@ cAudioManager::ProcessPornCinema(uint8 sound)
uint32 time;
int32 rand;
float distSquared;
- float maxDist;
switch(sound) {
case SCRIPT_SOUND_PORN_CINEMA_1_S:
case SCRIPT_SOUND_MISTY_SEX_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 400.f;
sample = SFX_PORN_1_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 20.0f;
break;
@@ -6713,43 +6610,38 @@ cAudioManager::ProcessPornCinema(uint8 sound)
case SCRIPT_SOUND_MISTY_SEX_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 6400.f;
sample = SFX_PORN_1_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 80.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_2_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 400.f;
sample = SFX_PORN_2_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 20.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_2_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 6400.f;
sample = SFX_PORN_2_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 80.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_3_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f;
sample = SFX_PORN_3_GROAN_1;
break;
case SCRIPT_SOUND_PORN_CINEMA_3_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- maxDist = 6400.f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
sample = SFX_PORN_3_GROAN_1;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
if(sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) {
m_sQueueSample.m_bVolume =
ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -6804,25 +6696,22 @@ void
cAudioManager::ProcessProjectiles()
{
uint8 emittingVol;
- float maxDist;
for(int32 i = 0; i < NUM_PROJECTILES; i++) {
if(CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
switch(CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
case WEAPONTYPE_ROCKETLAUNCHER:
emittingVol = maxVolume;
- maxDist = 8100.f;
- m_sQueueSample.m_fSoundIntensity = 90.0f;
- m_sQueueSample.m_nSampleIndex = 81;
+ m_sQueueSample.m_fSoundIntensity = rocketLauncherIntensity;
+ m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency =
SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY);
m_sQueueSample.field_16 = 3;
break;
case WEAPONTYPE_MOLOTOV:
- emittingVol = 50;
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ emittingVol = molotovVolume;
+ m_sQueueSample.m_fSoundIntensity = molotovIntensity;
m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency =
@@ -6835,7 +6724,7 @@ cAudioManager::ProcessProjectiles()
m_sQueueSample.field_76 = 3;
m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition();
float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
m_sQueueSample.m_fDistance);
@@ -6864,7 +6753,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
float emittingVol;
CVehicle *veh;
- if(params->m_fDistance < 484.f && CWeather::Rain > 0.01f &&
+ if(params->m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f &&
(!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
++params->m_pVehicle->m_bRainAudioCounter;
veh = params->m_pVehicle;
@@ -6872,13 +6761,13 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
veh->m_bRainAudioCounter = 0;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
emittingVol = 30.f * CWeather::Rain;
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 22.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_bVolume =
+ ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = veh->m_bRainSamplesCounter++;
veh = params->m_pVehicle;
if(veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68;
- m_sQueueSample.m_nSampleIndex =
- (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1;
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIsDistant = false;
m_sQueueSample.field_16 = 9;
@@ -6888,7 +6777,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.field_48 = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 22.0f;
+ m_sQueueSample.m_fSoundIntensity = rainOnVehicleIntensity;
m_sQueueSample.field_56 = 1;
m_sQueueSample.m_bReverbFlag = false;
m_sQueueSample.m_bRequireReflection = false;
@@ -6916,7 +6805,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params)
int32 emittingVol;
float modificator;
- if(params->m_fDistance >= 900.f) return false;
+ if(params->m_fDistance >= SQR(reverseGearIntensity)) return false;
veh = params->m_pVehicle;
if(veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
@@ -6930,7 +6819,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params)
}
modificator = Abs(modificator);
emittingVol = (24.f * modificator);
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
if(params->m_pVehicle->m_fGasPedal >= 0.0f) {
m_sQueueSample.m_counter = 62;
@@ -6949,7 +6838,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params)
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.field_48 = 3.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = reverseGearIntensity;
m_sQueueSample.field_56 = 0;
m_sQueueSample.field_76 = 5;
m_sQueueSample.m_bReverbFlag = true;
@@ -6965,19 +6854,17 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound)
{
uint32 time;
float distSquared;
- float maxDist;
switch(sound) {
case SCRIPT_SOUND_SAWMILL_LOOP_S:
case SCRIPT_SOUND_SAWMILL_LOOP_L:
- maxDist = 900.f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -7043,18 +6930,16 @@ cAudioManager::ProcessShopScriptObject(uint8 sound)
uint32 time;
int32 rand;
float distSquared;
- float maxDist;
switch(sound) {
case SCRIPT_SOUND_SHOP_LOOP_S:
case SCRIPT_SOUND_SHOP_LOOP_L:
- maxDist = 900.f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -7350,64 +7235,36 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params)
if((!automobile->m_bSirenOrAlarm || !UsesSirenSwitching(params->m_nIndex)) &&
automobile->m_modelIndex != MI_MRWHOOP) {
if(automobile->m_nCarHornTimer) {
- if(!params->m_pVehicle->m_status) {
- 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;
- m_sQueueSample.m_nSampleIndex =
- CarSounds[params->m_nIndex].m_nHornSample;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_bIsDistant = false;
- m_sQueueSample.field_16 = 2;
- m_sQueueSample.m_nFrequency =
- CarSounds[params->m_nIndex].m_nHornFrequency;
- 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 = 5.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- m_sQueueSample.field_56 = 0;
- m_sQueueSample.field_76 = 3;
- m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bRequireReflection = false;
- AddSampleToRequestedQueue();
- }
- return;
+ if(params->m_pVehicle->m_status) {
+ if(automobile->m_nCarHornTimer > 44) automobile->m_nCarHornTimer = 44;
+ if(automobile->m_nCarHornTimer == 44)
+ automobile->field_22D =
+ (uint8(m_FrameCounter) + uint8(m_sQueueSample.m_nEntityIndex)) & 7;
}
- if(automobile->m_nCarHornTimer > 44) automobile->m_nCarHornTimer = 44;
- if(automobile->m_nCarHornTimer == 44)
- automobile->field_22D =
- (uint8(m_FrameCounter) + uint8(m_sQueueSample.m_nEntityIndex)) & 7;
- if(hornPatternsArray[automobile->field_22D][44 - automobile->m_nCarHornTimer]) {
- 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;
- m_sQueueSample.m_nSampleIndex =
- CarSounds[params->m_nIndex].m_nHornSample;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_bIsDistant = false;
- m_sQueueSample.field_16 = 2;
- m_sQueueSample.m_nFrequency =
- CarSounds[params->m_nIndex].m_nHornFrequency;
- 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 = 5.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- m_sQueueSample.field_56 = 0;
- m_sQueueSample.field_76 = 3;
- m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bRequireReflection = false;
- AddSampleToRequestedQueue();
- }
+ if(!hornPatternsArray[automobile->field_22D][44 - automobile->m_nCarHornTimer]) return;
+
+ 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;
+ m_sQueueSample.m_nSampleIndex = CarSounds[params->m_nIndex].m_nHornSample;
+ m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_bIsDistant = false;
+ m_sQueueSample.field_16 = 2;
+ m_sQueueSample.m_nFrequency = CarSounds[params->m_nIndex].m_nHornFrequency;
+ 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 = 5.0f;
+ m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.field_56 = 0;
+ m_sQueueSample.field_76 = 3;
+ m_sQueueSample.m_bReverbFlag = true;
+ m_sQueueSample.m_bRequireReflection = false;
+ AddSampleToRequestedQueue();
}
}
}
@@ -7621,7 +7478,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
case SURFACE_HEDGE:
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
emittingVol /= 4;
- m_sQueueSample.m_nFrequency = (signed __int64)(13000.f * skidVal + 35000.f);
+ m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f;
m_sQueueSample.m_bVolume /= 4;
break;
case SURFACE_DIRT:
@@ -7731,7 +7588,7 @@ cAudioManager::ProcessWeather(int32 id)
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
m_sQueueSample.m_nFrequency =
SampleManager.GetSampleBaseFrequency(SFX_RAIN);
- m_sQueueSample.m_bVolume = (uint8)(25.f * CWeather::Rain);
+ m_sQueueSample.m_bVolume = (int32)(25.f * CWeather::Rain);
m_sQueueSample.m_counter = 4;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.field_16 = 0;
@@ -7801,19 +7658,17 @@ void
cAudioManager::ProcessWorkShopScriptObject(uint8 sound)
{
float distSquared;
- float maxDist;
switch(sound) {
case SCRIPT_SOUND_WORK_SHOP_LOOP_S:
case SCRIPT_SOUND_WORK_SHOP_LOOP_L:
- maxDist = 400.f;
m_sQueueSample.m_fSoundIntensity = 20.0f;
break;
default: return;
}
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < maxDist) {
- m_sQueueSample.m_fDistance = sqrt(distSquared);
+ if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_bVolume =
ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
@@ -8214,7 +8069,6 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
{
CPed *ped = params->m_pPed;
uint8 emittingVol;
- float maxDist;
float soundIntensity;
tPedComment pedComment;
@@ -8229,10 +8083,9 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
break;
}
- maxDist = 2500.f;
soundIntensity = 50.f;
- if(params->m_fDistance < maxDist) {
+ if(params->m_fDistance < SQR(soundIntensity)) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
if(sound != SOUND_PAGER) {
switch(sound) {
@@ -8264,14 +8117,12 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
} else {
switch(sound) {
case SOUND_PED_HELI_PLAYER_FOUND:
- maxDist = 160000.f;
soundIntensity = 400.f;
pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 29 +
SFX_POLICE_HELI_1;
break;
case SOUND_PED_BODYCAST_HIT:
if(CTimer::GetTimeInMilliseconds() <= gNextCryTime) return;
- maxDist = 2500.f;
soundIntensity = 50.f;
gNextCryTime = CTimer::GetTimeInMilliseconds() + 500;
pedComment.m_nSampleIndex =
@@ -8279,13 +8130,11 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
break;
case SOUND_INJURED_PED_MALE_OUCH:
case SOUND_8A:
- maxDist = 2500.f;
soundIntensity = 50.f;
pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 15 +
SFX_GENERIC_MALE_GRUNT_1;
break;
case SOUND_INJURED_PED_FEMALE:
- maxDist = 2500.f;
soundIntensity = 50.f;
pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 11 +
SFX_GENERIC_FEMALE_GRUNT_1;
@@ -8293,7 +8142,7 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
default: return;
}
- if(params->m_fDistance < maxDist) {
+ if(params->m_fDistance < SQR(soundIntensity)) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
if(sound != SOUND_PAGER) {
switch(sound) {
@@ -8332,8 +8181,8 @@ cAudioManager::Terminate()
MusicManager.Terminate();
for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) {
- m_asAudioEntities[i].m_bIsUsed = 0;
- m_anAudioEntityIndices[i] = 200;
+ m_asAudioEntities[i].m_bIsUsed = false;
+ m_anAudioEntityIndices[i] = ARRAY_SIZE(m_anAudioEntityIndices);
}
m_nAudioEntitiesTotal = 0;
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index cac3ea65..81e5c89d 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -53,8 +53,8 @@ enum eScriptSounds : int16
SCRIPT_SOUND_CHINATOWN_RESTAURANT_L = 43,
SCRIPT_SOUND_CIPRIANI_RESAURANT_S = 44,
SCRIPT_SOUND_CIPRIANI_RESAURANT_L = 45,
- SCRIPT_SOUND_46 = 46,
- SCRIPT_SOUND_47 = 47,
+ SCRIPT_SOUND_46_S = 46,
+ SCRIPT_SOUND_47_L = 47,
SCRIPT_SOUND_MARCO_BISTRO_S = 48,
SCRIPT_SOUND_MARCO_BISTRO_L = 49,
SCRIPT_SOUND_AIRPORT_LOOP_S = 50,
@@ -224,9 +224,11 @@ static_assert(sizeof(tPedComment) == 28, "tPedComment: error");
class cPedComments
{
public:
- tPedComment m_asPedComments[2][20];
- uint8 indexMap[2][20];
- uint8 nrOfCommentsInBank[2];
+ static constexpr int pedCommentsBanks = 2;
+ static constexpr int pedCommentsSlots = 20;
+ tPedComment m_asPedComments[pedCommentsBanks][pedCommentsSlots];
+ uint8 indexMap[pedCommentsBanks][pedCommentsSlots];
+ uint8 nrOfCommentsInBank[pedCommentsBanks];
uint8 activeBank;
uint8 gap_1163[1];
@@ -607,10 +609,20 @@ public:
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity,
float dist); /// ok
public:
- static const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
- static const int policeChannel = channels + 1;
- static const int allChannels = channels + 2;
- static const int maxVolume = 127;
+ static constexpr int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+ static constexpr int policeChannel = channels + 1;
+ static constexpr int allChannels = channels + 2;
+ static constexpr int maxVolume = 127;
+
+ static constexpr int scriptObjectIntensityS = 30;
+ static constexpr int scriptObjectIntensityL = 80;
+ static constexpr int bridgeIntensity = 400;
+ static constexpr int rocketLauncherIntensity = 90;
+ static constexpr int molotovIntensity = 30;
+ static constexpr int molotovVolume = 50;
+
+ static constexpr int rainOnVehicleIntensity = 22;
+ static constexpr int reverseGearIntensity = 30;
};
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");