summaryrefslogtreecommitdiffstats
path: root/src/audio/PolRadio.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-08-21 12:02:07 +0200
committerSergeanur <s.anureev@yandex.ua>2021-08-21 12:02:07 +0200
commit7c80093efa18bac0598bf6481ccad479c90e47af (patch)
tree90e77d41de1559f95b068cba3b3f56c187f953d3 /src/audio/PolRadio.cpp
parentAudio: bits of PS2 code (diff)
downloadre3-7c80093efa18bac0598bf6481ccad479c90e47af.tar
re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.gz
re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.bz2
re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.lz
re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.xz
re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.zst
re3-7c80093efa18bac0598bf6481ccad479c90e47af.zip
Diffstat (limited to 'src/audio/PolRadio.cpp')
-rw-r--r--src/audio/PolRadio.cpp88
1 files changed, 40 insertions, 48 deletions
diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp
index 2b45b526..da09eeb9 100644
--- a/src/audio/PolRadio.cpp
+++ b/src/audio/PolRadio.cpp
@@ -59,11 +59,9 @@ cAudioManager::InitialisePoliceRadioZones()
void
cAudioManager::InitialisePoliceRadio()
{
- m_sPoliceRadioQueue.policeChannelTimer = 0;
- m_sPoliceRadioQueue.policeChannelTimerSeconds = 0;
- m_sPoliceRadioQueue.policeChannelCounterSeconds = 0;
- for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++)
- m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE;
+ m_sPoliceRadioQueue.Reset();
+ for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++)
+ m_aCrimes[i].type = CRIME_NONE;
#if !defined(GTA_PS2) || defined(AUDIO_REVERB)
SampleManager.SetChannelReverbFlag(CHANNEL_POLICE_RADIO, FALSE);
#endif
@@ -179,7 +177,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
SampleManager.PauseStream(FALSE, 1);
}
- if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE;
+ if (m_sPoliceRadioQueue.m_nSamplesInQueue == 0) bChannelOpen = FALSE;
if (cWait) {
#ifdef FIX_BUGS
cWait -= CTimer::GetLogicalFramesPassed();
@@ -216,14 +214,8 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
}
if (bChannelOpen) DoPoliceRadioCrackle();
if ((g_nMissionAudioSfx == NO_SAMPLE || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) &&
- !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) {
- if (m_sPoliceRadioQueue.policeChannelTimer) {
- sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds];
- m_sPoliceRadioQueue.policeChannelTimer--;
- m_sPoliceRadioQueue.policeChannelCounterSeconds = (m_sPoliceRadioQueue.policeChannelCounterSeconds + 1) % 60;
- } else {
- sample = NO_SAMPLE;
- }
+ !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.m_nSamplesInQueue != 0) {
+ sample = m_sPoliceRadioQueue.Remove();
if (wantedLevel == 0) {
if (gSpecialSuspectLastSeenReport) {
gSpecialSuspectLastSeenReport = FALSE;
@@ -275,18 +267,18 @@ cAudioManager::SetupCrimeReport()
if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE;
- if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) {
+ if (60 - m_sPoliceRadioQueue.m_nSamplesInQueue <= 9) {
AgeCrimes();
return TRUE;
}
- for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) {
- if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE)
+ for (i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
+ if (m_aCrimes[i].type != CRIME_NONE)
break;
}
- if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return FALSE;
- audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position);
+ if (i == ARRAY_SIZE(m_aCrimes)) return FALSE;
+ audioZoneId = CTheZones::FindAudioZone(&m_aCrimes[i].position);
if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) {
zone = CTheZones::GetAudioZone(audioZoneId);
for (int j = 0; j < NUMAUDIOZONES; j++) {
@@ -295,24 +287,24 @@ cAudioManager::SetupCrimeReport()
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_MESSAGE_NOISE_1);
m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT);
m_sPoliceRadioQueue.Add(SFX_A_10);
- switch (m_sPoliceRadioQueue.crimes[i].type) {
+ switch (m_aCrimes[i].type) {
case CRIME_PED_BURNED:
case CRIME_HIT_PED_NASTYWEAPON:
- m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_PED;
+ m_aCrimes[i].type = CRIME_HIT_PED;
break;
case CRIME_COP_BURNED:
case CRIME_HIT_COP_NASTYWEAPON:
- m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_COP;
+ m_aCrimes[i].type = CRIME_HIT_COP;
break;
- case CRIME_VEHICLE_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break;
- case CRIME_DESTROYED_CESSNA: m_sPoliceRadioQueue.crimes[i].type = CRIME_SHOOT_HELI; break;
- case CRIME_EXPLOSION: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; // huh?
+ case CRIME_VEHICLE_BURNED: m_aCrimes[i].type = CRIME_STEAL_CAR; break;
+ case CRIME_DESTROYED_CESSNA: m_aCrimes[i].type = CRIME_SHOOT_HELI; break;
+ case CRIME_EXPLOSION: m_aCrimes[i].type = CRIME_STEAL_CAR; break; // huh?
default: break;
}
#ifdef FIX_BUGS
- m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1 - 1);
+ m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_CRIME_1 - 1);
#else
- m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1);
+ m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_CRIME_1);
#endif
m_sPoliceRadioQueue.Add(SFX_IN);
rangeX = zone->maxx - zone->minx;
@@ -322,17 +314,17 @@ cAudioManager::SetupCrimeReport()
quarterX = 0.25f * rangeX;
quarterY = 0.25f * rangeY;
- if (m_sPoliceRadioQueue.crimes[i].position.y > halfY + quarterY) {
+ if (m_aCrimes[i].position.y > halfY + quarterY) {
m_sPoliceRadioQueue.Add(SFX_NORTH);
processed = TRUE;
- } else if (m_sPoliceRadioQueue.crimes[i].position.y < halfY - quarterY) {
+ } else if (m_aCrimes[i].position.y < halfY - quarterY) {
m_sPoliceRadioQueue.Add(SFX_SOUTH);
processed = TRUE;
}
- if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX)
+ if (m_aCrimes[i].position.x > halfX + quarterX)
m_sPoliceRadioQueue.Add(SFX_EAST);
- else if (m_sPoliceRadioQueue.crimes[i].position.x < halfX - quarterX)
+ else if (m_aCrimes[i].position.x < halfX - quarterX)
m_sPoliceRadioQueue.Add(SFX_WEST);
else if (!processed)
m_sPoliceRadioQueue.Add(SFX_CENTRAL);
@@ -344,7 +336,7 @@ cAudioManager::SetupCrimeReport()
}
}
}
- m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE;
+ m_aCrimes[i].type = CRIME_NONE;
AgeCrimes();
return TRUE;
}
@@ -461,7 +453,7 @@ cAudioManager::SetupSuspectLastSeenReport()
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) {
veh = FindVehicleOfPlayer();
if (veh != nil) {
- if (60 - m_sPoliceRadioQueue.policeChannelTimer > 9) {
+ if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 9) {
color1 = veh->m_currentColour1;
if (color1 >= ARRAY_SIZE(gCarColourTable)) {
debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1);
@@ -647,7 +639,7 @@ cAudioManager::SetupSuspectLastSeenReport()
m_sPoliceRadioQueue.Add(NO_SAMPLE);
}
}
- } else if (60 - m_sPoliceRadioQueue.policeChannelTimer > 4) {
+ } else if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 4) {
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_MESSAGE_NOISE_1);
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT);
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT);
@@ -660,24 +652,24 @@ cAudioManager::SetupSuspectLastSeenReport()
void
cAudioManager::ReportCrime(eCrimeType type, const CVector &pos)
{
- int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes);
+ int32 lastCrime = ARRAY_SIZE(m_aCrimes);
if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 &&
(type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) {
- for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) {
- if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) {
- if (m_sPoliceRadioQueue.crimes[i].type == type) {
- m_sPoliceRadioQueue.crimes[i].position = pos;
- m_sPoliceRadioQueue.crimes[i].timer = 0;
+ for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
+ if (m_aCrimes[i].type != CRIME_NONE) {
+ if (m_aCrimes[i].type == type) {
+ m_aCrimes[i].position = pos;
+ m_aCrimes[i].timer = 0;
return;
}
} else
lastCrime = i;
}
- if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) {
- m_sPoliceRadioQueue.crimes[lastCrime].type = type;
- m_sPoliceRadioQueue.crimes[lastCrime].position = pos;
- m_sPoliceRadioQueue.crimes[lastCrime].timer = 0;
+ if (lastCrime < ARRAY_SIZE(m_aCrimes)) {
+ m_aCrimes[lastCrime].type = type;
+ m_aCrimes[lastCrime].position = pos;
+ m_aCrimes[lastCrime].timer = 0;
gMinTimeToNextReport[type] = m_FrameCounter + 500;
}
}
@@ -700,7 +692,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
if (!m_bIsInitialised) return;
- if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) {
+ if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 9) {
audioZone = CTheZones::FindAudioZone(&vec);
if (audioZone >= 0 && audioZone < NUMAUDIOZONES) {
zone = CTheZones::GetAudioZone(audioZone);
@@ -746,9 +738,9 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
void
cAudioManager::AgeCrimes()
{
- for (uint8 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) {
- if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) {
- if (++m_sPoliceRadioQueue.crimes[i].timer > 1200) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE;
+ for (uint8 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
+ if (m_aCrimes[i].type != CRIME_NONE) {
+ if (++m_aCrimes[i].timer > 1200) m_aCrimes[i].type = CRIME_NONE;
}
}
}