Remove cMissionAudio, move cAMCrime array outside of cPoliceRadioQueue (R* vision)

This commit is contained in:
Sergeanur 2021-08-21 13:02:07 +03:00
parent fe51abd534
commit 7c80093efa
5 changed files with 200 additions and 197 deletions

View file

@ -144,11 +144,7 @@ cAudioManager::PostInitialiseGameSpecificSetup()
m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1); m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1);
if (m_nPoliceChannelEntity >= 0) if (m_nPoliceChannelEntity >= 0)
SetEntityStatus(m_nPoliceChannelEntity, TRUE); SetEntityStatus(m_nPoliceChannelEntity, TRUE);
#ifdef GTA_BRIDGE
m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void*)1);
if (m_nBridgeEntity >= 0)
SetEntityStatus(m_nBridgeEntity, TRUE);
#endif // GTA_BRIDGE
m_nEscalatorEntity = CreateEntity(AUDIOTYPE_ESCALATOR, (void*)1); m_nEscalatorEntity = CreateEntity(AUDIOTYPE_ESCALATOR, (void*)1);
if (m_nEscalatorEntity >= 0) if (m_nEscalatorEntity >= 0)
SetEntityStatus(m_nEscalatorEntity, TRUE); SetEntityStatus(m_nEscalatorEntity, TRUE);
@ -157,25 +153,23 @@ cAudioManager::PostInitialiseGameSpecificSetup()
if (m_nExtraSoundsEntity >= 0) if (m_nExtraSoundsEntity >= 0)
SetEntityStatus(m_nExtraSoundsEntity, TRUE); SetEntityStatus(m_nExtraSoundsEntity, TRUE);
#ifdef GTA_BRIDGE
m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void*)1);
if (m_nBridgeEntity >= 0)
SetEntityStatus(m_nBridgeEntity, TRUE);
#endif // GTA_BRIDGE
m_sMissionAudio.m_nSampleIndex[0] = NO_SAMPLE; for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) {
m_sMissionAudio.m_nLoadingStatus[0] = LOADING_STATUS_NOT_LOADED; m_nMissionAudioSampleIndex[i] = NO_SAMPLE;
m_sMissionAudio.m_nPlayStatus[0] = PLAY_STATUS_STOPPED; m_nMissionAudioLoadingStatus[i] = LOADING_STATUS_NOT_LOADED;
m_sMissionAudio.m_bIsPlaying[0] = FALSE; m_nMissionAudioPlayStatus[i] = PLAY_STATUS_STOPPED;
m_sMissionAudio.m_bIsPlayed[0] = FALSE; m_bIsMissionAudioPlaying[i] = FALSE;
m_sMissionAudio.m_bPredefinedProperties[0] = TRUE; m_bIsMissionAudioAllowedToPlay[i] = FALSE;
m_sMissionAudio.m_nMissionAudioCounter[0] = 0; m_bIsMissionAudio2D[i] = TRUE;
m_sMissionAudio.m_bIsMobile[0] = FALSE; m_nMissionAudioFramesToPlay[i] = 0;
field_5538 = 127; m_bIsMissionAudioPhoneCall[i] = FALSE;
m_sMissionAudio.m_nSampleIndex[1] = NO_SAMPLE; m_nGlobalSfxVolumeMultiplier = 127;
m_sMissionAudio.m_nLoadingStatus[1] = LOADING_STATUS_NOT_LOADED; }
m_sMissionAudio.m_nPlayStatus[1] = PLAY_STATUS_STOPPED;
m_sMissionAudio.m_bIsPlaying[1] = FALSE;
m_sMissionAudio.m_bIsPlayed[1] = FALSE;
m_sMissionAudio.m_bPredefinedProperties[1] = TRUE;
m_sMissionAudio.m_nMissionAudioCounter[1] = 0;
m_sMissionAudio.m_bIsMobile[1] = FALSE;
field_5538 = 127;
ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds());
m_bIsPlayerShutUp = FALSE; m_bIsPlayerShutUp = FALSE;
@ -9812,9 +9806,9 @@ FindMissionAudioSfx(const char *name)
const char * const char *
cAudioManager::GetMissionAudioLoadedLabel(uint8 slot) cAudioManager::GetMissionAudioLoadedLabel(uint8 slot)
{ {
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_sMissionAudio.m_nSampleIndex[slot] != NO_SAMPLE) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_nMissionAudioSampleIndex[slot] != NO_SAMPLE) {
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) { for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) {
if (m_sMissionAudio.m_nSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId) if (m_nMissionAudioSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId)
return MissionAudioNameSfxAssoc[i].m_pName; return MissionAudioNameSfxAssoc[i].m_pName;
} }
} }
@ -9838,14 +9832,14 @@ cAudioManager::PreloadMissionAudio(uint8 slot, Const char *name)
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
int32 missionAudioSfx = FindMissionAudioSfx(name); int32 missionAudioSfx = FindMissionAudioSfx(name);
if (missionAudioSfx != NO_SAMPLE) { if (missionAudioSfx != NO_SAMPLE) {
m_sMissionAudio.m_nSampleIndex[slot] = missionAudioSfx; m_nMissionAudioSampleIndex[slot] = missionAudioSfx;
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED;
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_STOPPED;
m_sMissionAudio.m_bIsPlaying[slot] = FALSE; m_bIsMissionAudioPlaying[slot] = FALSE;
m_sMissionAudio.m_nMissionAudioCounter[slot] = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; m_nMissionAudioFramesToPlay[slot] = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000;
m_sMissionAudio.m_nMissionAudioCounter[slot] *= 4; m_nMissionAudioFramesToPlay[slot] *= 4;
m_sMissionAudio.m_bIsPlayed[slot] = FALSE; m_bIsMissionAudioAllowedToPlay[slot] = FALSE;
m_sMissionAudio.m_bPredefinedProperties[slot] = TRUE; m_bIsMissionAudio2D[slot] = TRUE;
g_bMissionAudioLoadFailed[slot] = FALSE; g_bMissionAudioLoadFailed[slot] = FALSE;
} }
} }
@ -9855,7 +9849,7 @@ uint8
cAudioManager::GetMissionAudioLoadingStatus(uint8 slot) cAudioManager::GetMissionAudioLoadingStatus(uint8 slot)
{ {
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS)
return m_sMissionAudio.m_nLoadingStatus[slot]; return m_nMissionAudioLoadingStatus[slot];
return LOADING_STATUS_LOADED; return LOADING_STATUS_LOADED;
} }
@ -9864,24 +9858,24 @@ void
cAudioManager::SetMissionAudioLocation(uint8 slot, float x, float y, float z) cAudioManager::SetMissionAudioLocation(uint8 slot, float x, float y, float z)
{ {
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
m_sMissionAudio.m_bPredefinedProperties[slot] = FALSE; m_bIsMissionAudio2D[slot] = FALSE;
m_sMissionAudio.m_vecPos[slot] = CVector(x, y, z); m_vecMissionAudioPosition[slot] = CVector(x, y, z);
} }
} }
void void
cAudioManager::PlayLoadedMissionAudio(uint8 slot) cAudioManager::PlayLoadedMissionAudio(uint8 slot)
{ {
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_sMissionAudio.m_nSampleIndex[slot] != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus[slot] == LOADING_STATUS_LOADED && if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_nMissionAudioSampleIndex[slot] != NO_SAMPLE && m_nMissionAudioLoadingStatus[slot] == LOADING_STATUS_LOADED &&
m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_STOPPED) m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_STOPPED)
m_sMissionAudio.m_bIsPlayed[slot] = TRUE; m_bIsMissionAudioAllowedToPlay[slot] = TRUE;
} }
bool8 bool8
cAudioManager::ShouldDuckMissionAudio(uint8 slot) cAudioManager::ShouldDuckMissionAudio(uint8 slot)
{ {
if (IsMissionAudioSamplePlaying(slot)) if (IsMissionAudioSamplePlaying(slot))
return m_sMissionAudio.m_nSampleIndex[slot] != STREAMED_SOUND_MISSION_ROK2_01; return m_nMissionAudioSampleIndex[slot] != STREAMED_SOUND_MISSION_ROK2_01;
return FALSE; return FALSE;
} }
@ -9890,7 +9884,7 @@ cAudioManager::IsMissionAudioSamplePlaying(uint8 slot)
{ {
if (m_bIsInitialised) { if (m_bIsInitialised) {
if (slot < MISSION_AUDIO_SLOTS) if (slot < MISSION_AUDIO_SLOTS)
return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_PLAYING; return m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_PLAYING;
else else
return TRUE; return TRUE;
} else { } else {
@ -9905,7 +9899,7 @@ cAudioManager::IsMissionAudioSampleFinished(uint8 slot)
{ {
if (m_bIsInitialised) { if (m_bIsInitialised) {
if (slot < MISSION_AUDIO_SLOTS) if (slot < MISSION_AUDIO_SLOTS)
return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_FINISHED; return m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_FINISHED;
else else
return TRUE; return TRUE;
} }
@ -9919,14 +9913,14 @@ void
cAudioManager::ClearMissionAudio(uint8 slot) cAudioManager::ClearMissionAudio(uint8 slot)
{ {
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; m_nMissionAudioSampleIndex[slot] = NO_SAMPLE;
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED;
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_STOPPED;
m_sMissionAudio.m_bIsPlaying[slot] = FALSE; m_bIsMissionAudioPlaying[slot] = FALSE;
m_sMissionAudio.m_bIsPlayed[slot] = FALSE; m_bIsMissionAudioAllowedToPlay[slot] = FALSE;
m_sMissionAudio.m_bPredefinedProperties[slot] = TRUE; m_bIsMissionAudio2D[slot] = TRUE;
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; m_nMissionAudioFramesToPlay[slot] = 0;
m_sMissionAudio.m_bIsMobile[slot] = FALSE; m_bIsMissionAudioPhoneCall[slot] = FALSE;
SampleManager.StopStreamedFile(slot + 1); SampleManager.StopStreamedFile(slot + 1);
} }
} }
@ -9944,16 +9938,16 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
static uint8 nFramesUntilFailedLoad[MISSION_AUDIO_SLOTS] = { 0, 0 }; static uint8 nFramesUntilFailedLoad[MISSION_AUDIO_SLOTS] = { 0, 0 };
static uint8 nFramesForPretendPlaying[MISSION_AUDIO_SLOTS] = { 0, 0 }; static uint8 nFramesForPretendPlaying[MISSION_AUDIO_SLOTS] = { 0, 0 };
if (m_sMissionAudio.m_nSampleIndex[slot] == NO_SAMPLE) return; if (m_nMissionAudioSampleIndex[slot] == NO_SAMPLE) return;
switch (m_sMissionAudio.m_nLoadingStatus[slot]) { switch (m_nMissionAudioLoadingStatus[slot]) {
case LOADING_STATUS_NOT_LOADED: case LOADING_STATUS_NOT_LOADED:
SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex[slot], slot + 1); SampleManager.PreloadStreamedFile(m_nMissionAudioSampleIndex[slot], slot + 1);
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED; m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED;
nFramesUntilFailedLoad[slot] = 0; nFramesUntilFailedLoad[slot] = 0;
break; break;
case LOADING_STATUS_LOADED: case LOADING_STATUS_LOADED:
if (!m_sMissionAudio.m_bIsPlayed[slot]) if (!m_bIsMissionAudioAllowedToPlay[slot])
return; return;
if (g_bMissionAudioLoadFailed[slot]) { if (g_bMissionAudioLoadFailed[slot]) {
if (m_bTimerJustReset) { if (m_bTimerJustReset) {
@ -9964,30 +9958,30 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
nFramesUntilFailedLoad[slot] = 0; nFramesUntilFailedLoad[slot] = 0;
} else if (!m_nUserPause) { } else if (!m_nUserPause) {
if (++nFramesForPretendPlaying[slot] < 90) { if (++nFramesForPretendPlaying[slot] < 90) {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING;
} else { } else {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED;
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; m_nMissionAudioSampleIndex[slot] = NO_SAMPLE;
} }
} }
break; break;
} }
switch (m_sMissionAudio.m_nPlayStatus[slot]) { switch (m_nMissionAudioPlayStatus[slot]) {
case PLAY_STATUS_STOPPED: case PLAY_STATUS_STOPPED:
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) { if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex[slot]); SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex[slot]);
} else { } else {
if (m_nUserPause) if (m_nUserPause)
SampleManager.PauseStream(TRUE, slot + 1); SampleManager.PauseStream(TRUE, slot + 1);
if (m_sMissionAudio.m_bPredefinedProperties[slot]) { if (m_bIsMissionAudio2D[slot]) {
if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAL) if (m_nMissionAudioSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAL)
SampleManager.SetStreamedVolumeAndPan(80, 0, TRUE, slot + 1); SampleManager.SetStreamedVolumeAndPan(80, 0, TRUE, slot + 1);
else if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAR) else if (m_nMissionAudioSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAR)
SampleManager.SetStreamedVolumeAndPan(80, 127, TRUE, slot + 1); SampleManager.SetStreamedVolumeAndPan(80, 127, TRUE, slot + 1);
else else
SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, slot + 1); SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, slot + 1);
} else { } else {
distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]); distSquared = GetDistanceSquared(m_vecMissionAudioPosition[slot]);
if (distSquared >= SQR(80.0f)) { if (distSquared >= SQR(80.0f)) {
emittingVol = 0; emittingVol = 0;
pan = 63; pan = 63;
@ -9997,17 +9991,17 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
dist = Sqrt(distSquared); dist = Sqrt(distSquared);
emittingVol = ComputeVolume(80, 80.0f, dist); emittingVol = ComputeVolume(80, 80.0f, dist);
} }
TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec); TranslateEntity(&m_vecMissionAudioPosition[slot], &vec);
pan = ComputePan(80.f, &vec); pan = ComputePan(80.f, &vec);
} }
SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, slot + 1); SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, slot + 1);
} }
SampleManager.StartPreloadedStreamedFile(slot + 1); SampleManager.StartPreloadedStreamedFile(slot + 1);
} }
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING;
nCheckPlayingDelay[slot] = 30; nCheckPlayingDelay[slot] = 30;
if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A) if (m_nMissionAudioSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_nMissionAudioSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
m_sMissionAudio.m_bIsMobile[slot] = TRUE; m_bIsMissionAudioPhoneCall[slot] = TRUE;
break; break;
case PLAY_STATUS_PLAYING: case PLAY_STATUS_PLAYING:
if (m_bTimerJustReset) { if (m_bTimerJustReset) {
@ -10015,28 +10009,28 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
SampleManager.StopStreamedFile(slot + 1); SampleManager.StopStreamedFile(slot + 1);
break; break;
} }
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) { if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
if (!m_nUserPause) { if (!m_nUserPause) {
if (nCheckPlayingDelay[slot]) { if (nCheckPlayingDelay[slot]) {
--nCheckPlayingDelay[slot]; --nCheckPlayingDelay[slot];
} else if ((g_bMissionAudioLoadFailed[slot] && m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) { } else if ((g_bMissionAudioLoadFailed[slot] && m_nMissionAudioFramesToPlay[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED;
if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A) if (m_nMissionAudioSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_nMissionAudioSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
m_sMissionAudio.m_bIsMobile[slot] = FALSE; m_bIsMissionAudioPhoneCall[slot] = FALSE;
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; m_nMissionAudioSampleIndex[slot] = NO_SAMPLE;
SampleManager.StopStreamedFile(slot + 1); SampleManager.StopStreamedFile(slot + 1);
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; m_nMissionAudioFramesToPlay[slot] = 0;
} }
} }
} else if (m_sMissionAudio.m_bIsPlaying[slot]) { } else if (m_bIsMissionAudioPlaying[slot]) {
if (SampleManager.IsStreamPlaying(slot + 1) || m_nUserPause || m_nPreviousUserPause) { if (SampleManager.IsStreamPlaying(slot + 1) || m_nUserPause || m_nPreviousUserPause) {
if (m_nUserPause) if (m_nUserPause)
SampleManager.PauseStream(TRUE, slot + 1); SampleManager.PauseStream(TRUE, slot + 1);
else else
{ {
SampleManager.PauseStream(FALSE, slot + 1); SampleManager.PauseStream(FALSE, slot + 1);
if (!m_sMissionAudio.m_bPredefinedProperties[slot]) { if (!m_bIsMissionAudio2D[slot]) {
distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]); distSquared = GetDistanceSquared(m_vecMissionAudioPosition[slot]);
if (distSquared >= SQR(80.0f)) { if (distSquared >= SQR(80.0f)) {
emittingVol = 0; emittingVol = 0;
pan = 63; pan = 63;
@ -10046,21 +10040,21 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
dist = Sqrt(distSquared); dist = Sqrt(distSquared);
emittingVol = ComputeVolume(127, 80.0f, dist); emittingVol = ComputeVolume(127, 80.0f, dist);
} }
TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec); TranslateEntity(&m_vecMissionAudioPosition[slot], &vec);
pan = ComputePan(80.f, &vec); pan = ComputePan(80.f, &vec);
} }
SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, slot + 1); SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, slot + 1);
} }
} }
} else if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_ROK2_01) { } else if (m_nMissionAudioSampleIndex[slot] == STREAMED_SOUND_MISSION_ROK2_01) {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_STOPPED;
} else { } else {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED;
if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A) if (m_nMissionAudioSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_nMissionAudioSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
m_sMissionAudio.m_bIsMobile[slot] = FALSE; m_bIsMissionAudioPhoneCall[slot] = FALSE;
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; m_nMissionAudioSampleIndex[slot] = NO_SAMPLE;
SampleManager.StopStreamedFile(slot + 1); SampleManager.StopStreamedFile(slot + 1);
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; m_nMissionAudioFramesToPlay[slot] = 0;
} }
} else { } else {
if (m_nUserPause) if (m_nUserPause)
@ -10070,7 +10064,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
break; break;
nCheckPlayingDelay[slot] = 0; nCheckPlayingDelay[slot] = 0;
} }
m_sMissionAudio.m_bIsPlaying[slot] = TRUE; m_bIsMissionAudioPlaying[slot] = TRUE;
} }
break; break;
default: default:
@ -10082,7 +10076,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
nFramesForPretendPlaying[slot] = 0; nFramesForPretendPlaying[slot] = 0;
g_bMissionAudioLoadFailed[slot] = TRUE; g_bMissionAudioLoadFailed[slot] = TRUE;
nFramesUntilFailedLoad[slot] = 0; nFramesUntilFailedLoad[slot] = 0;
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED; m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED;
} }
break; break;
default: default:
@ -10098,12 +10092,12 @@ cAudioManager::ProcessMissionAudio()
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
ProcessMissionAudioSlot(i); ProcessMissionAudioSlot(i);
if (m_sMissionAudio.m_bIsMobile[0] || m_sMissionAudio.m_bIsMobile[1]) if (m_bIsMissionAudioPhoneCall[0] || m_bIsMissionAudioPhoneCall[1])
field_5538 = 64; m_nGlobalSfxVolumeMultiplier = 64;
else if (field_5538 < 127) { else if (m_nGlobalSfxVolumeMultiplier < 127) {
field_5538 += 5; m_nGlobalSfxVolumeMultiplier += 5;
if (field_5538 > 127) if (m_nGlobalSfxVolumeMultiplier > 127)
field_5538 = 127; m_nGlobalSfxVolumeMultiplier = 127;
} }
} }
#pragma endregion All the mission audio stuff #pragma endregion All the mission audio stuff

View file

@ -999,7 +999,7 @@ cAudioManager::ProcessActiveQueues()
uint8 emittingVol; uint8 emittingVol;
CVector position; CVector position;
bool8 missionState; bool8 isPhoneCall;
uint8 channelOffset = 0; uint8 channelOffset = 0;
for (int32 i = 0; i < m_nActiveSamples; i++) { for (int32 i = 0; i < m_nActiveSamples; i++) {
@ -1065,18 +1065,18 @@ cAudioManager::ProcessActiveQueues()
#endif #endif
emittingVol = m_bDoubleVolume ? 2 * Min(63, vol) : vol; emittingVol = m_bDoubleVolume ? 2 * Min(63, vol) : vol;
missionState = FALSE; isPhoneCall = FALSE;
for (int32 k = 0; k < MISSION_AUDIO_SLOTS; k++) { for (int32 k = 0; k < MISSION_AUDIO_SLOTS; k++) {
if (m_sMissionAudio.m_bIsMobile[k]) { if (m_bIsMissionAudioPhoneCall[k]) {
missionState = TRUE; isPhoneCall = TRUE;
break; break;
} }
} }
if (missionState) { if (isPhoneCall) {
emittingVol = (emittingVol * field_5538) / 127; emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127;
} else { } else {
if (field_5538 < 127) if (m_nGlobalSfxVolumeMultiplier < 127)
emittingVol = (emittingVol * field_5538) / 127; emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127;
} }
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
@ -1154,19 +1154,19 @@ cAudioManager::ProcessActiveQueues()
if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) {
#endif #endif
SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency);
bool8 isMobile = FALSE; isPhoneCall = FALSE;
for (int32 l = 0; l < MISSION_AUDIO_SLOTS; l++) { for (int32 l = 0; l < MISSION_AUDIO_SLOTS; l++) {
if (m_sMissionAudio.m_bIsMobile[l]) { if (m_bIsMissionAudioPhoneCall[l]) {
isMobile = TRUE; isPhoneCall = TRUE;
break; break;
} }
} }
if (!isMobile || m_asActiveSamples[k].m_bIs2D) { if (!isPhoneCall || m_asActiveSamples[k].m_bIs2D) {
if (field_5538 < 127) if (m_nGlobalSfxVolumeMultiplier < 127)
emittingVol *= field_5538 / 127; emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127;
vol = emittingVol; vol = emittingVol;
} else { } else {
vol = (emittingVol * field_5538 / 127); vol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127;
} }
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
SampleManager.SetChannelEmittingVolume(k, vol); SampleManager.SetChannelEmittingVolume(k, vol);

View file

@ -119,27 +119,8 @@ public:
VALIDATE_SIZE(cPedComments, 0x490); VALIDATE_SIZE(cPedComments, 0x490);
class CEntity;
#define MISSION_AUDIO_SLOTS (2) #define MISSION_AUDIO_SLOTS (2)
// So instead of doing cMissionAudio [2] they've added [2] to every field of the struct...
// Only someone with a VERY EXTRAORDINARY mind could have come up with that
class cMissionAudio
{
public:
CVector m_vecPos[MISSION_AUDIO_SLOTS];
bool8 m_bPredefinedProperties[MISSION_AUDIO_SLOTS];
uint32 m_nSampleIndex[MISSION_AUDIO_SLOTS];
uint8 m_nLoadingStatus[MISSION_AUDIO_SLOTS];
uint8 m_nPlayStatus[MISSION_AUDIO_SLOTS];
bool8 m_bIsPlaying[MISSION_AUDIO_SLOTS];
int32 m_nMissionAudioCounter[MISSION_AUDIO_SLOTS];
bool8 m_bIsPlayed[MISSION_AUDIO_SLOTS];
bool8 m_bIsMobile[MISSION_AUDIO_SLOTS];
};
VALIDATE_SIZE(cMissionAudio, 0x38);
// name made up // name made up
class cAudioScriptObjectManager class cAudioScriptObjectManager
{ {
@ -153,6 +134,7 @@ public:
class cTransmission; class cTransmission;
class CEntity;
class CPlane; class CPlane;
class CVehicle; class CVehicle;
class CPed; class CPed;
@ -263,7 +245,7 @@ public:
bool8 m_bIsPlayerShutUp; bool8 m_bIsPlayerShutUp;
uint8 m_nPlayerMood; uint8 m_nPlayerMood;
uint32 m_nPlayerMoodTimer; uint32 m_nPlayerMoodTimer;
uint8 field_rest[4]; uint32 field_4B38_vc;
bool8 m_bGenericSfx; bool8 m_bGenericSfx;
cPedComments m_sPedComments; cPedComments m_sPedComments;
@ -271,17 +253,31 @@ public:
int32 m_nWaterCannonEntity; int32 m_nWaterCannonEntity;
int32 m_nPoliceChannelEntity; int32 m_nPoliceChannelEntity;
cPoliceRadioQueue m_sPoliceRadioQueue; cPoliceRadioQueue m_sPoliceRadioQueue;
cAMCrime m_aCrimes[10];
int32 m_nFrontEndEntity; int32 m_nFrontEndEntity;
int32 m_nCollisionEntity; int32 m_nCollisionEntity;
cAudioCollisionManager m_sCollisionManager; cAudioCollisionManager m_sCollisionManager;
int32 m_nProjectileEntity; int32 m_nProjectileEntity;
int32 m_nEscalatorEntity;
int32 m_nExtraSoundsEntity;
#ifdef GTA_BRIDGE #ifdef GTA_BRIDGE
int32 m_nBridgeEntity; int32 m_nBridgeEntity;
#endif #endif
int32 m_nEscalatorEntity;
int32 m_nExtraSoundsEntity; // Mission audio stuff
cMissionAudio m_sMissionAudio; // So instead of making an array of struct they've added [MISSION_AUDIO_SLOTS] to every field...
uint8 field_5538; // something related to phone dialogues // Only someone with a VERY EXTRAORDINARY mind could have come up with that
CVector m_vecMissionAudioPosition[MISSION_AUDIO_SLOTS];
bool8 m_bIsMissionAudio2D[MISSION_AUDIO_SLOTS];
uint32 m_nMissionAudioSampleIndex[MISSION_AUDIO_SLOTS];
uint8 m_nMissionAudioLoadingStatus[MISSION_AUDIO_SLOTS];
uint8 m_nMissionAudioPlayStatus[MISSION_AUDIO_SLOTS];
bool8 m_bIsMissionAudioPlaying[MISSION_AUDIO_SLOTS];
int32 m_nMissionAudioFramesToPlay[MISSION_AUDIO_SLOTS];
bool8 m_bIsMissionAudioAllowedToPlay[MISSION_AUDIO_SLOTS];
bool8 m_bIsMissionAudioPhoneCall[MISSION_AUDIO_SLOTS];
uint8 m_nGlobalSfxVolumeMultiplier; // used to lower sfx volume during phone calls
int32 m_anRandomTable[5]; int32 m_anRandomTable[5];
uint8 m_nTimeSpent; uint8 m_nTimeSpent;
bool8 m_nUserPause; bool8 m_nUserPause;

View file

@ -59,11 +59,9 @@ cAudioManager::InitialisePoliceRadioZones()
void void
cAudioManager::InitialisePoliceRadio() cAudioManager::InitialisePoliceRadio()
{ {
m_sPoliceRadioQueue.policeChannelTimer = 0; m_sPoliceRadioQueue.Reset();
m_sPoliceRadioQueue.policeChannelTimerSeconds = 0; for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++)
m_sPoliceRadioQueue.policeChannelCounterSeconds = 0; m_aCrimes[i].type = CRIME_NONE;
for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++)
m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE;
#if !defined(GTA_PS2) || defined(AUDIO_REVERB) #if !defined(GTA_PS2) || defined(AUDIO_REVERB)
SampleManager.SetChannelReverbFlag(CHANNEL_POLICE_RADIO, FALSE); SampleManager.SetChannelReverbFlag(CHANNEL_POLICE_RADIO, FALSE);
#endif #endif
@ -179,7 +177,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) { bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
SampleManager.PauseStream(FALSE, 1); SampleManager.PauseStream(FALSE, 1);
} }
if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; if (m_sPoliceRadioQueue.m_nSamplesInQueue == 0) bChannelOpen = FALSE;
if (cWait) { if (cWait) {
#ifdef FIX_BUGS #ifdef FIX_BUGS
cWait -= CTimer::GetLogicalFramesPassed(); cWait -= CTimer::GetLogicalFramesPassed();
@ -216,14 +214,8 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
} }
if (bChannelOpen) DoPoliceRadioCrackle(); if (bChannelOpen) DoPoliceRadioCrackle();
if ((g_nMissionAudioSfx == NO_SAMPLE || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) && if ((g_nMissionAudioSfx == NO_SAMPLE || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) &&
!SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) { !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.m_nSamplesInQueue != 0) {
if (m_sPoliceRadioQueue.policeChannelTimer) { sample = m_sPoliceRadioQueue.Remove();
sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds];
m_sPoliceRadioQueue.policeChannelTimer--;
m_sPoliceRadioQueue.policeChannelCounterSeconds = (m_sPoliceRadioQueue.policeChannelCounterSeconds + 1) % 60;
} else {
sample = NO_SAMPLE;
}
if (wantedLevel == 0) { if (wantedLevel == 0) {
if (gSpecialSuspectLastSeenReport) { if (gSpecialSuspectLastSeenReport) {
gSpecialSuspectLastSeenReport = FALSE; gSpecialSuspectLastSeenReport = FALSE;
@ -275,18 +267,18 @@ cAudioManager::SetupCrimeReport()
if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE; if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE;
if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) { if (60 - m_sPoliceRadioQueue.m_nSamplesInQueue <= 9) {
AgeCrimes(); AgeCrimes();
return TRUE; return TRUE;
} }
for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { for (i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) if (m_aCrimes[i].type != CRIME_NONE)
break; break;
} }
if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return FALSE; if (i == ARRAY_SIZE(m_aCrimes)) return FALSE;
audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position); audioZoneId = CTheZones::FindAudioZone(&m_aCrimes[i].position);
if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) { if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) {
zone = CTheZones::GetAudioZone(audioZoneId); zone = CTheZones::GetAudioZone(audioZoneId);
for (int j = 0; j < NUMAUDIOZONES; j++) { 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(SFX_POLICE_RADIO_MESSAGE_NOISE_1);
m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT); m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT);
m_sPoliceRadioQueue.Add(SFX_A_10); m_sPoliceRadioQueue.Add(SFX_A_10);
switch (m_sPoliceRadioQueue.crimes[i].type) { switch (m_aCrimes[i].type) {
case CRIME_PED_BURNED: case CRIME_PED_BURNED:
case CRIME_HIT_PED_NASTYWEAPON: case CRIME_HIT_PED_NASTYWEAPON:
m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_PED; m_aCrimes[i].type = CRIME_HIT_PED;
break; break;
case CRIME_COP_BURNED: case CRIME_COP_BURNED:
case CRIME_HIT_COP_NASTYWEAPON: case CRIME_HIT_COP_NASTYWEAPON:
m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_COP; m_aCrimes[i].type = CRIME_HIT_COP;
break; break;
case CRIME_VEHICLE_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; case CRIME_VEHICLE_BURNED: m_aCrimes[i].type = CRIME_STEAL_CAR; break;
case CRIME_DESTROYED_CESSNA: m_sPoliceRadioQueue.crimes[i].type = CRIME_SHOOT_HELI; break; case CRIME_DESTROYED_CESSNA: m_aCrimes[i].type = CRIME_SHOOT_HELI; break;
case CRIME_EXPLOSION: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; // huh? case CRIME_EXPLOSION: m_aCrimes[i].type = CRIME_STEAL_CAR; break; // huh?
default: break; default: break;
} }
#ifdef FIX_BUGS #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 #else
m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1); m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_CRIME_1);
#endif #endif
m_sPoliceRadioQueue.Add(SFX_IN); m_sPoliceRadioQueue.Add(SFX_IN);
rangeX = zone->maxx - zone->minx; rangeX = zone->maxx - zone->minx;
@ -322,17 +314,17 @@ cAudioManager::SetupCrimeReport()
quarterX = 0.25f * rangeX; quarterX = 0.25f * rangeX;
quarterY = 0.25f * rangeY; 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); m_sPoliceRadioQueue.Add(SFX_NORTH);
processed = TRUE; 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); m_sPoliceRadioQueue.Add(SFX_SOUTH);
processed = TRUE; processed = TRUE;
} }
if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX) if (m_aCrimes[i].position.x > halfX + quarterX)
m_sPoliceRadioQueue.Add(SFX_EAST); 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); m_sPoliceRadioQueue.Add(SFX_WEST);
else if (!processed) else if (!processed)
m_sPoliceRadioQueue.Add(SFX_CENTRAL); 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(); AgeCrimes();
return TRUE; return TRUE;
} }
@ -461,7 +453,7 @@ cAudioManager::SetupSuspectLastSeenReport()
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) {
veh = FindVehicleOfPlayer(); veh = FindVehicleOfPlayer();
if (veh != nil) { if (veh != nil) {
if (60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 9) {
color1 = veh->m_currentColour1; color1 = veh->m_currentColour1;
if (color1 >= ARRAY_SIZE(gCarColourTable)) { if (color1 >= ARRAY_SIZE(gCarColourTable)) {
debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1); debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1);
@ -647,7 +639,7 @@ cAudioManager::SetupSuspectLastSeenReport()
m_sPoliceRadioQueue.Add(NO_SAMPLE); 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_MESSAGE_NOISE_1);
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT);
m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT); m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT);
@ -660,24 +652,24 @@ cAudioManager::SetupSuspectLastSeenReport()
void void
cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) 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 && if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 &&
(type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) {
for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { if (m_aCrimes[i].type != CRIME_NONE) {
if (m_sPoliceRadioQueue.crimes[i].type == type) { if (m_aCrimes[i].type == type) {
m_sPoliceRadioQueue.crimes[i].position = pos; m_aCrimes[i].position = pos;
m_sPoliceRadioQueue.crimes[i].timer = 0; m_aCrimes[i].timer = 0;
return; return;
} }
} else } else
lastCrime = i; lastCrime = i;
} }
if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) { if (lastCrime < ARRAY_SIZE(m_aCrimes)) {
m_sPoliceRadioQueue.crimes[lastCrime].type = type; m_aCrimes[lastCrime].type = type;
m_sPoliceRadioQueue.crimes[lastCrime].position = pos; m_aCrimes[lastCrime].position = pos;
m_sPoliceRadioQueue.crimes[lastCrime].timer = 0; m_aCrimes[lastCrime].timer = 0;
gMinTimeToNextReport[type] = m_FrameCounter + 500; gMinTimeToNextReport[type] = m_FrameCounter + 500;
} }
} }
@ -700,7 +692,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
if (!m_bIsInitialised) return; 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); audioZone = CTheZones::FindAudioZone(&vec);
if (audioZone >= 0 && audioZone < NUMAUDIOZONES) { if (audioZone >= 0 && audioZone < NUMAUDIOZONES) {
zone = CTheZones::GetAudioZone(audioZone); zone = CTheZones::GetAudioZone(audioZone);
@ -746,9 +738,9 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
void void
cAudioManager::AgeCrimes() cAudioManager::AgeCrimes()
{ {
for (uint8 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { for (uint8 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { if (m_aCrimes[i].type != CRIME_NONE) {
if (++m_sPoliceRadioQueue.crimes[i].timer > 1200) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; if (++m_aCrimes[i].timer > 1200) m_aCrimes[i].type = CRIME_NONE;
} }
} }
} }

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Crime.h" #include "Crime.h"
#include "AudioSamples.h"
struct cAMCrime { struct cAMCrime {
int32 type; int32 type;
@ -17,30 +18,50 @@ struct cAMCrime {
VALIDATE_SIZE(cAMCrime, 20); VALIDATE_SIZE(cAMCrime, 20);
#define POLICE_RADIO_QUEUE_MAX_SAMPLES 60
class cPoliceRadioQueue class cPoliceRadioQueue
{ {
public: public:
int32 crimesSamples[60]; uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES];
uint8 policeChannelTimer; uint8 m_nSamplesInQueue;
uint8 policeChannelTimerSeconds; uint8 m_nAddOffset;
uint8 policeChannelCounterSeconds; uint8 m_nRemoveOffset;
cAMCrime crimes[10];
cPoliceRadioQueue() cPoliceRadioQueue()
{ {
policeChannelTimerSeconds = 0; Reset();
policeChannelCounterSeconds = 0;
policeChannelTimer = 0;
} }
void Add(uint32 sample) void Reset()
{ {
if (policeChannelTimer != 60) { m_nAddOffset = 0;
crimesSamples[policeChannelTimerSeconds] = sample; m_nRemoveOffset = 0;
policeChannelTimer++; m_nSamplesInQueue = 0;
policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60;
}
} }
bool8 Add(uint32 sample)
{
if (m_nSamplesInQueue != POLICE_RADIO_QUEUE_MAX_SAMPLES) {
m_aSamples[m_nAddOffset] = sample;
m_nSamplesInQueue++;
m_nAddOffset = (m_nAddOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES;
return TRUE;
}
return FALSE;
}
uint32 Remove()
{
if (m_nSamplesInQueue != 0) {
uint32 sample = m_aSamples[m_nRemoveOffset];
m_nSamplesInQueue--;
m_nRemoveOffset = (m_nRemoveOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES;
return sample;
}
return NO_SAMPLE;
}
}; };
VALIDATE_SIZE(cPoliceRadioQueue, 0x1BC); VALIDATE_SIZE(cPoliceRadioQueue, 244);