diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 12:25:42 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 12:25:42 +0200 |
commit | e0be6beb18e55338cda7a613bb9b8df798c81b17 (patch) | |
tree | 22514458646c67c2981ea368b00d474a50b4de86 | |
parent | car ctrl fixes (diff) | |
parent | Remove cMissionAudio, move cAMCrime array outside of cPoliceRadioQueue (R* vision) (diff) | |
download | re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar.gz re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar.bz2 re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar.lz re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar.xz re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.tar.zst re3-e0be6beb18e55338cda7a613bb9b8df798c81b17.zip |
-rw-r--r-- | src/audio/AudioLogic.cpp | 187 | ||||
-rw-r--r-- | src/audio/AudioManager.cpp | 45 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 48 | ||||
-rw-r--r-- | src/audio/PolRadio.cpp | 88 | ||||
-rw-r--r-- | src/audio/PolRadio.h | 49 | ||||
-rw-r--r-- | src/audio/audio_enums.h | 8 | ||||
-rw-r--r-- | src/peds/PedIK.cpp | 10 | ||||
-rw-r--r-- | src/peds/PlayerPed.cpp | 9 |
8 files changed, 233 insertions, 211 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index c7605126..d215724c 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -47,10 +47,6 @@ // TODO: Get rid of *intensity* consts (and get rid of term 'intensity' in general) // Make them defines, not floats because they were not floats on PS2 -#ifndef GTA_PS2 -#define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples -#endif - void cAudioManager::PreInitialiseGameSpecificSetup() { @@ -145,11 +141,7 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1); if (m_nPoliceChannelEntity >= 0) 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); if (m_nEscalatorEntity >= 0) SetEntityStatus(m_nEscalatorEntity, TRUE); @@ -158,25 +150,23 @@ cAudioManager::PostInitialiseGameSpecificSetup() if (m_nExtraSoundsEntity >= 0) 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; - m_sMissionAudio.m_nLoadingStatus[0] = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus[0] = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying[0] = FALSE; - m_sMissionAudio.m_bIsPlayed[0] = FALSE; - m_sMissionAudio.m_bPredefinedProperties[0] = TRUE; - m_sMissionAudio.m_nMissionAudioCounter[0] = 0; - m_sMissionAudio.m_bIsMobile[0] = FALSE; - field_5538 = 127; - m_sMissionAudio.m_nSampleIndex[1] = NO_SAMPLE; - 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; + for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) { + m_nMissionAudioSampleIndex[i] = NO_SAMPLE; + m_nMissionAudioLoadingStatus[i] = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus[i] = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying[i] = FALSE; + m_bIsMissionAudioAllowedToPlay[i] = FALSE; + m_bIsMissionAudio2D[i] = TRUE; + m_nMissionAudioFramesToPlay[i] = 0; + m_bIsMissionAudioPhoneCall[i] = FALSE; + m_nGlobalSfxVolumeMultiplier = 127; + } ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); m_bIsPlayerShutUp = FALSE; @@ -2027,7 +2017,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh bool8 isMoped = FALSE; bool8 processedAccelSampleStopped = FALSE; static uint32 gearSoundStartTime = CTimer::GetTimeInMilliseconds(); - uint8 nChannel = CHANNEL_PLAYER_VEHICLE_ENGINE; // TODO: PS2 channels +#ifdef GTA_PS2 + uint8 nChannel = m_bIsSurround ? CHANNEL_DTS_PLAYER_VEHICLE_ENGINE : CHANNEL_PLAYER_VEHICLE_ENGINE; +#else + uint8 nChannel = CHANNEL_PLAYER_VEHICLE_ENGINE; +#endif if (bPlayerJustEnteredCar) { bAccelSampleStopped = TRUE; bPlayerJustEnteredCar = FALSE; @@ -11532,9 +11526,9 @@ FindMissionAudioSfx(const char *name) const char * 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) { - if (m_sMissionAudio.m_nSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId) + if (m_nMissionAudioSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId) return MissionAudioNameSfxAssoc[i].m_pName; } } @@ -11560,14 +11554,14 @@ cAudioManager::PreloadMissionAudio(uint8 slot, Const char *name) if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { int32 missionAudioSfx = FindMissionAudioSfx(name); if (missionAudioSfx != NO_SAMPLE) { - m_sMissionAudio.m_nSampleIndex[slot] = missionAudioSfx; - m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying[slot] = FALSE; - m_sMissionAudio.m_nMissionAudioCounter[slot] = m_nTimeSpent * SampleManager.GetSampleLength(missionAudioSfx) / SampleManager.GetSampleBaseFrequency(missionAudioSfx); - m_sMissionAudio.m_nMissionAudioCounter[slot] = 11 * m_sMissionAudio.m_nMissionAudioCounter[slot] / 10; - m_sMissionAudio.m_bIsPlayed[slot] = FALSE; - m_sMissionAudio.m_bPredefinedProperties[slot] = TRUE; + m_nMissionAudioSampleIndex[slot] = missionAudioSfx; + m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying[slot] = FALSE; + m_nMissionAudioFramesToPlay[slot] = m_nTimeSpent * SampleManager.GetSampleLength(missionAudioSfx) / SampleManager.GetSampleBaseFrequency(missionAudioSfx); + m_nMissionAudioFramesToPlay[slot] = 11 * m_nMissionAudioFramesToPlay[slot] / 10; + m_bIsMissionAudioAllowedToPlay[slot] = FALSE; + m_bIsMissionAudio2D[slot] = TRUE; g_bMissionAudioLoadFailed[slot] = FALSE; } } @@ -11577,7 +11571,7 @@ uint8 cAudioManager::GetMissionAudioLoadingStatus(uint8 slot) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) - return m_sMissionAudio.m_nLoadingStatus[slot]; + return m_nMissionAudioLoadingStatus[slot]; return LOADING_STATUS_LOADED; } @@ -11586,24 +11580,24 @@ void cAudioManager::SetMissionAudioLocation(uint8 slot, float x, float y, float z) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { - m_sMissionAudio.m_bPredefinedProperties[slot] = FALSE; - m_sMissionAudio.m_vecPos[slot] = CVector(x, y, z); + m_bIsMissionAudio2D[slot] = FALSE; + m_vecMissionAudioPosition[slot] = CVector(x, y, z); } } void 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 && - m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_STOPPED) - m_sMissionAudio.m_bIsPlayed[slot] = TRUE; + if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_nMissionAudioSampleIndex[slot] != NO_SAMPLE && m_nMissionAudioLoadingStatus[slot] == LOADING_STATUS_LOADED && + m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_STOPPED) + m_bIsMissionAudioAllowedToPlay[slot] = TRUE; } bool8 cAudioManager::ShouldDuckMissionAudio(uint8 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; } @@ -11612,7 +11606,7 @@ cAudioManager::IsMissionAudioSamplePlaying(uint8 slot) { if (m_bIsInitialised) { if (slot < MISSION_AUDIO_SLOTS) - return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_PLAYING; + return m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_PLAYING; else return TRUE; } else { @@ -11627,7 +11621,7 @@ cAudioManager::IsMissionAudioSampleFinished(uint8 slot) { if (m_bIsInitialised) { if (slot < MISSION_AUDIO_SLOTS) - return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_FINISHED; + return m_nMissionAudioPlayStatus[slot] == PLAY_STATUS_FINISHED; else return TRUE; } @@ -11641,14 +11635,14 @@ void cAudioManager::ClearMissionAudio(uint8 slot) { if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) { - m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; - m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying[slot] = FALSE; - m_sMissionAudio.m_bIsPlayed[slot] = FALSE; - m_sMissionAudio.m_bPredefinedProperties[slot] = TRUE; - m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; - m_sMissionAudio.m_bIsMobile[slot] = FALSE; + m_nMissionAudioSampleIndex[slot] = NO_SAMPLE; + m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying[slot] = FALSE; + m_bIsMissionAudioAllowedToPlay[slot] = FALSE; + m_bIsMissionAudio2D[slot] = TRUE; + m_nMissionAudioFramesToPlay[slot] = 0; + m_bIsMissionAudioPhoneCall[slot] = FALSE; SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1); } } @@ -11666,18 +11660,18 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) static uint8 nFramesUntilFailedLoad[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: // TODO: LoadMissionAudio - SampleManager.LoadPedComment(m_sMissionAudio.m_nSampleIndex[slot]); - SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_sMissionAudio.m_nSampleIndex[slot])); - m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED; + SampleManager.LoadPedComment(m_nMissionAudioSampleIndex[slot]); + SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot])); + m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED; nFramesUntilFailedLoad[slot] = 0; break; case LOADING_STATUS_LOADED: - if (!m_sMissionAudio.m_bIsPlayed[slot]) + if (!m_bIsMissionAudioAllowedToPlay[slot]) return; if (g_bMissionAudioLoadFailed[slot]) { if (m_bTimerJustReset) { @@ -11689,35 +11683,35 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) nFramesUntilFailedLoad[slot] = 0; } else if (!m_nUserPause) { if (++nFramesForPretendPlaying[slot] < 90) { - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING; } else { - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED; + m_nMissionAudioSampleIndex[slot] = NO_SAMPLE; } } break; } - switch (m_sMissionAudio.m_nPlayStatus[slot]) { + switch (m_nMissionAudioPlayStatus[slot]) { case PLAY_STATUS_STOPPED: - if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) { - SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex[slot]); + if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) { + SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex[slot]); } else { - SampleManager.InitialiseChannel(slot + CHANNEL_MISSION_AUDIO_1, m_sMissionAudio.m_nSampleIndex[slot], SFX_BANK_PED_COMMENTS); + SampleManager.InitialiseChannel(slot + CHANNEL_MISSION_AUDIO_1, m_nMissionAudioSampleIndex[slot], SFX_BANK_PED_COMMENTS); if(m_nUserPause) SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0); else - SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_sMissionAudio.m_nSampleIndex[slot])); - if (m_sMissionAudio.m_bPredefinedProperties[slot]) { + SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot])); + if (m_bIsMissionAudio2D[slot]) { SampleManager.SetChannelVolume(slot + CHANNEL_MISSION_AUDIO_1, 127); SampleManager.SetChannelPan(slot + CHANNEL_MISSION_AUDIO_1, 63); - if (m_sMissionAudio.m_nSampleIndex[slot] == SFX_SFX_CAMERA_LEFT || m_sMissionAudio.m_nSampleIndex[slot] == SFX_SFX_AIRHORN_LEFT) + if (m_nMissionAudioSampleIndex[slot] == SFX_SFX_CAMERA_LEFT || m_nMissionAudioSampleIndex[slot] == SFX_SFX_AIRHORN_LEFT) SampleManager.SetChannelPan(slot + CHANNEL_MISSION_AUDIO_1, 0); - else if (m_sMissionAudio.m_nSampleIndex[slot] == SFX_SFX_CAMERA_RIGHT || m_sMissionAudio.m_nSampleIndex[slot] == SFX_SFX_AIRHORN_RIGHT) + else if (m_nMissionAudioSampleIndex[slot] == SFX_SFX_CAMERA_RIGHT || m_nMissionAudioSampleIndex[slot] == SFX_SFX_AIRHORN_RIGHT) SampleManager.SetChannelPan(slot + CHANNEL_MISSION_AUDIO_1, 127); else SampleManager.SetChannelPan(slot + CHANNEL_MISSION_AUDIO_1, 63); } else { - distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]); + distSquared = GetDistanceSquared(m_vecMissionAudioPosition[slot]); if (distSquared >= SQR(80.0f)) { emittingVol = 0; pan = 63; @@ -11727,7 +11721,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) dist = Sqrt(distSquared); emittingVol = ComputeVolume(127, 80.0f, dist); } - TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec); + TranslateEntity(&m_vecMissionAudioPosition[slot], &vec); pan = ComputePan(80.f, &vec); } SampleManager.SetChannelVolume(slot + CHANNEL_MISSION_AUDIO_1, emittingVol); @@ -11735,7 +11729,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) } SampleManager.StartChannel(slot + CHANNEL_MISSION_AUDIO_1); } - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING; nCheckPlayingDelay[slot] = 30; break; case PLAY_STATUS_PLAYING: @@ -11745,27 +11739,28 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1); break; } - if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) { + if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) { if (!m_nUserPause) { if (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) { debug("FINISHED PLAYINGXXXXXXXXXXXXX"); - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED; + + m_nMissionAudioSampleIndex[slot] = NO_SAMPLE; SampleManager.StopChannel(CHANNEL_POLICE_RADIO); - m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; + m_nMissionAudioFramesToPlay[slot] = 0; } } - } else if (m_sMissionAudio.m_bIsPlaying[slot]) { + } else if (m_bIsMissionAudioPlaying[slot]) { if(SampleManager.GetChannelUsedFlag(slot + CHANNEL_MISSION_AUDIO_1) || m_nUserPause || m_nPreviousUserPause) { if(m_nUserPause) SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0); else { - SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_sMissionAudio.m_nSampleIndex[slot])); - if (!m_sMissionAudio.m_bPredefinedProperties[slot]) { - distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]); + SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot])); + if (!m_bIsMissionAudio2D[slot]) { + distSquared = GetDistanceSquared(m_vecMissionAudioPosition[slot]); if (distSquared >= SQR(80.0f)) { emittingVol = 0; pan = 63; @@ -11775,7 +11770,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) dist = Sqrt(distSquared); emittingVol = ComputeVolume(127, 80.0f, dist); } - TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec); + TranslateEntity(&m_vecMissionAudioPosition[slot], &vec); pan = ComputePan(80.f, &vec); } SampleManager.SetChannelVolume(slot + CHANNEL_MISSION_AUDIO_1, emittingVol); @@ -11783,10 +11778,10 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) } } } else { - m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE; + m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_FINISHED; + m_nMissionAudioSampleIndex[slot] = NO_SAMPLE; SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1); - m_sMissionAudio.m_nMissionAudioCounter[slot] = 0; + m_nMissionAudioFramesToPlay[slot] = 0; } } else { if (m_nUserPause) @@ -11796,7 +11791,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) break; nCheckPlayingDelay[slot] = 0; } - m_sMissionAudio.m_bIsPlaying[slot] = TRUE; + m_bIsMissionAudioPlaying[slot] = TRUE; } break; default: @@ -11808,7 +11803,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot) nFramesForPretendPlaying[slot] = 0; g_bMissionAudioLoadFailed[slot] = TRUE; nFramesUntilFailedLoad[slot] = 0; - m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED; + m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED; } break; default: @@ -11824,12 +11819,12 @@ cAudioManager::ProcessMissionAudio() for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) ProcessMissionAudioSlot(i); - if (m_sMissionAudio.m_bIsMobile[0] || m_sMissionAudio.m_bIsMobile[1]) - field_5538 = 64; - else if (field_5538 < 127) { - field_5538 += 5; - if (field_5538 > 127) - field_5538 = 127; + if (m_bIsMissionAudioPhoneCall[0] || m_bIsMissionAudioPhoneCall[1]) + m_nGlobalSfxVolumeMultiplier = 64; + else if (m_nGlobalSfxVolumeMultiplier < 127) { + m_nGlobalSfxVolumeMultiplier += 5; + if (m_nGlobalSfxVolumeMultiplier > 127) + m_nGlobalSfxVolumeMultiplier = 127; } } #pragma endregion All the mission audio stuff diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 9068b4dd..a2b4a87c 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -495,17 +495,18 @@ cAudioManager::ServiceSoundEffects() #endif m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { - for (int32 i = 0; i < NUM_CHANNELS_GENERIC; i++) + for (uint32 i = 0; i < NUM_CHANNELS_GENERIC; i++) SampleManager.StopChannel(i); - SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, 0); SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_1, 0); SampleManager.SetChannelFrequency(CHANNEL_MISSION_AUDIO_2, 0); - - // ps2 code just stops the sound here for some reason - //SampleManager.StopChannel(CHANNEL_MISSION_AUDIO_1); - //SampleManager.StopChannel(CHANNEL_MISSION_AUDIO_2); - + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); +#if defined(GTA_PS2) || defined(GTA_PSP) + // PSP and PS2 just stop the sound, mobile doesn't. Let's not have it on PC either + uint8 missionAudioChannel = m_bIsSurround ? CHANNEL_DTS_MISSION_AUDIO_1 : CHANNEL_MISSION_AUDIO_1; + SampleManager.StopChannel(missionAudioChannel); + SampleManager.StopChannel(missionAudioChannel+1); +#endif ClearRequestedQueue(); if (m_nActiveSampleQueue) { m_nActiveSampleQueue = 0; @@ -990,7 +991,7 @@ cAudioManager::ProcessActiveQueues() uint8 emittingVol; CVector position; - bool8 missionState; + bool8 isPhoneCall; uint8 channelOffset = 0; for (int32 i = 0; i < m_nActiveSamples; i++) { @@ -1056,18 +1057,18 @@ cAudioManager::ProcessActiveQueues() #endif emittingVol = m_bDoubleVolume ? 2 * Min(63, vol) : vol; - missionState = FALSE; + isPhoneCall = FALSE; for (int32 k = 0; k < MISSION_AUDIO_SLOTS; k++) { - if (m_sMissionAudio.m_bIsMobile[k]) { - missionState = TRUE; + if (m_bIsMissionAudioPhoneCall[k]) { + isPhoneCall = TRUE; break; } } - if (missionState) { - emittingVol = (emittingVol * field_5538) / 127; + if (isPhoneCall) { + emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127; } else { - if (field_5538 < 127) - emittingVol = (emittingVol * field_5538) / 127; + if (m_nGlobalSfxVolumeMultiplier < 127) + emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127; } #ifdef EXTERNAL_3D_SOUND @@ -1145,19 +1146,19 @@ cAudioManager::ProcessActiveQueues() if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { #endif SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); - bool8 isMobile = FALSE; + isPhoneCall = FALSE; for (int32 l = 0; l < MISSION_AUDIO_SLOTS; l++) { - if (m_sMissionAudio.m_bIsMobile[l]) { - isMobile = TRUE; + if (m_bIsMissionAudioPhoneCall[l]) { + isPhoneCall = TRUE; break; } } - if (!isMobile || m_asActiveSamples[k].m_bIs2D) { - if (field_5538 < 127) - emittingVol *= field_5538 / 127; + if (!isPhoneCall || m_asActiveSamples[k].m_bIs2D) { + if (m_nGlobalSfxVolumeMultiplier < 127) + emittingVol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127; vol = emittingVol; } else { - vol = (emittingVol * field_5538 / 127); + vol = (emittingVol * m_nGlobalSfxVolumeMultiplier) / 127; } #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannelEmittingVolume(k, vol); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index eeb2581c..decd438b 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -119,27 +119,8 @@ public: VALIDATE_SIZE(cPedComments, 0x490); -class CEntity; - #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 class cAudioScriptObjectManager { @@ -153,6 +134,7 @@ public: class cTransmission; +class CEntity; class CPlane; class CVehicle; class CPed; @@ -263,7 +245,7 @@ public: bool8 m_bIsPlayerShutUp; uint8 m_nPlayerMood; uint32 m_nPlayerMoodTimer; - uint8 field_rest[4]; + uint32 field_4B38_vc; bool8 m_bGenericSfx; cPedComments m_sPedComments; @@ -271,17 +253,31 @@ public: int32 m_nWaterCannonEntity; int32 m_nPoliceChannelEntity; cPoliceRadioQueue m_sPoliceRadioQueue; + cAMCrime m_aCrimes[10]; int32 m_nFrontEndEntity; int32 m_nCollisionEntity; cAudioCollisionManager m_sCollisionManager; int32 m_nProjectileEntity; + int32 m_nEscalatorEntity; + int32 m_nExtraSoundsEntity; #ifdef GTA_BRIDGE int32 m_nBridgeEntity; #endif - int32 m_nEscalatorEntity; - int32 m_nExtraSoundsEntity; - cMissionAudio m_sMissionAudio; - uint8 field_5538; // something related to phone dialogues + + // Mission audio stuff + // So instead of making an array of struct they've added [MISSION_AUDIO_SLOTS] to every field... + // 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]; uint8 m_nTimeSpent; bool8 m_nUserPause; @@ -641,6 +637,10 @@ public: #define SET_SOUND_REVERB(b) #endif +#ifndef GTA_PS2 +#define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples +#endif + //#if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS) //static_assert(sizeof(cAudioManager) == 0x5558, "cAudioManager: error"); //#endif diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index f741a477..76161d82 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_SFX_CRIME_1 - 1); + m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_SFX_CRIME_1 - 1); #else - m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_SFX_CRIME_1); + m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_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); @@ -646,7 +638,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); @@ -659,24 +651,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; } } @@ -699,7 +691,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); @@ -745,9 +737,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; } } } diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h index d7c928e2..55b2c9f7 100644 --- a/src/audio/PolRadio.h +++ b/src/audio/PolRadio.h @@ -1,6 +1,7 @@ #pragma once #include "Crime.h" +#include "AudioSamples.h" struct cAMCrime { int32 type; @@ -17,30 +18,50 @@ struct cAMCrime { VALIDATE_SIZE(cAMCrime, 20); +#define POLICE_RADIO_QUEUE_MAX_SAMPLES 60 + class cPoliceRadioQueue { public: - int32 crimesSamples[60]; - uint8 policeChannelTimer; - uint8 policeChannelTimerSeconds; - uint8 policeChannelCounterSeconds; - cAMCrime crimes[10]; + uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; + uint8 m_nSamplesInQueue; + uint8 m_nAddOffset; + uint8 m_nRemoveOffset; cPoliceRadioQueue() { - policeChannelTimerSeconds = 0; - policeChannelCounterSeconds = 0; - policeChannelTimer = 0; + Reset(); + } + + void Reset() + { + m_nAddOffset = 0; + m_nRemoveOffset = 0; + m_nSamplesInQueue = 0; } - void Add(uint32 sample) + bool8 Add(uint32 sample) { - if (policeChannelTimer != 60) { - crimesSamples[policeChannelTimerSeconds] = sample; - policeChannelTimer++; - policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; + 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); diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h index 192eafac..a0a4f58c 100644 --- a/src/audio/audio_enums.h +++ b/src/audio/audio_enums.h @@ -146,7 +146,13 @@ enum CHANNEL_MISSION_AUDIO_1, CHANNEL_MISSION_AUDIO_2, CHANNEL_PLAYER_VEHICLE_ENGINE, - NUM_CHANNELS + NUM_CHANNELS, + + NUM_CHANNELS_DTS_GENERIC = 18, + CHANNEL_DTS_POLICE_RADIO = NUM_CHANNELS_DTS_GENERIC, + CHANNEL_DTS_MISSION_AUDIO_1, + CHANNEL_DTS_MISSION_AUDIO_2, + CHANNEL_DTS_PLAYER_VEHICLE_ENGINE, }; #else enum diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index cf2e4ed5..3bc5796b 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -205,9 +205,15 @@ CPedIK::PointGunInDirection(float targetYaw, float targetPitch) else if (status == ANGLES_SET_EXACTLY) m_flags |= GUN_POINTED_SUCCESSFULLY; } - RwMatrix *m = GetBoneMatrix(m_ped, BONE_spine); // BUG: game uses index 2 directly, which happens to be identical to BONE_spine +#ifdef FIX_BUGS + RwMatrix *m = GetBoneMatrix(m_ped, BONE_spine); +#else + RpHAnimHierarchy* hier = GetAnimHierarchyFromSkinClump(m_ped->GetClump()); + RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier); + RwMatrix *m = &mats[2]; +#endif RwV3d axis = { 0.0f, 0.0f, 0.0f }; - float axisangle = -CGeneral::LimitRadianAngle(Atan2(-m->at.y, -m->at.x) - m_ped->m_fRotationCur); + float axisangle = -CGeneral::LimitRadianAngle(Atan2(-m->up.y, -m->up.x) - m_ped->m_fRotationCur); axis.y = -Sin(axisangle); axis.z = Cos(axisangle); diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 3da6c500..3e6509f5 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -777,7 +777,8 @@ spentAmmoCheck: // BUG: m_nSelectedWepSlot and GetWeapon(..) takes slot in VC but they compared them against weapon types in whole condition! jeez #ifdef FIX_BUGS - if (m_nSelectedWepSlot == WEAPONSLOT_MELEE || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != WEAPONSLOT_PROJECTILE) { + if (m_nSelectedWepSlot == WEAPONSLOT_MELEE || + GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && (m_nSelectedWepSlot != WEAPONSLOT_PROJECTILE || GetWeapon(WEAPONSLOT_PROJECTILE).m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE)) { #else if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && GetWeapon(WEAPONTYPE_BASEBALLBAT).m_eWeaponType == WEAPONTYPE_BASEBALLBAT || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 @@ -1057,7 +1058,7 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) // nextTarget = nil; // duplicate float lastCloseness = -10000.0f; // CGeneral::GetATanOfXY(GetForward().x, GetForward().y); // unused - CVector distVec = previousTarget->GetPosition() - GetPosition(); + CVector distVec = previousTarget->GetPosition() - TheCamera.GetPosition(); float referenceBeta = CGeneral::GetATanOfXY(distVec.x, distVec.y); for (int h = CPools::GetPedPool()->GetSize() - 1; h >= 0; h--) { @@ -1069,7 +1070,7 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) && (!pedToCheck->bInVehicle || (pedToCheck->m_pMyVehicle && pedToCheck->m_pMyVehicle->IsBike())) #endif && pedToCheck->m_leader != this && !pedToCheck->bNeverEverTargetThisPed - && OurPedCanSeeThisOne(pedToCheck) && CanIKReachThisTarget(pedToCheck->GetPosition(), GetWeapon(), true)) { + && OurPedCanSeeThisOne(pedToCheck, true) && CanIKReachThisTarget(pedToCheck->GetPosition(), GetWeapon(), true)) { EvaluateNeighbouringTarget(pedToCheck, &nextTarget, &lastCloseness, weaponRange, referenceBeta, lookToLeft, IsThisPedAnAimingPriority(pedToCheck)); @@ -1196,7 +1197,7 @@ CPlayerPed::ProcessAnimGroups(void) GetWeapon()->m_eWeaponType == WEAPONTYPE_MINIGUN) groupToSet = ASSOCGRP_PLAYERCHAINSAW; else if (GetWeapon()->m_eWeaponType != WEAPONTYPE_COLT45 && GetWeapon()->m_eWeaponType != WEAPONTYPE_UZI - // I hope this is a inlined function... + // I hope this is an inlined function... && GetWeapon()->m_eWeaponType != WEAPONTYPE_PYTHON && GetWeapon()->m_eWeaponType != WEAPONTYPE_TEC9 && GetWeapon()->m_eWeaponType != WEAPONTYPE_SILENCED_INGRAM && GetWeapon()->m_eWeaponType != WEAPONTYPE_MP5 && GetWeapon()->m_eWeaponType != WEAPONTYPE_GOLFCLUB && GetWeapon()->m_eWeaponType != WEAPONTYPE_KATANA |