diff options
Diffstat (limited to '')
35 files changed, 1553 insertions, 1085 deletions
diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp index d2214057..ec42191b 100644 --- a/src/animation/AnimBlendAssociation.cpp +++ b/src/animation/AnimBlendAssociation.cpp @@ -185,7 +185,7 @@ CAnimBlendAssociation::UpdateBlend(float timeDelta) if(blendAmount <= 0.0f && blendDelta < 0.0f){ // We're faded out and are not fading in blendAmount = 0.0f; - blendDelta = Max(0.0f, blendDelta); + blendDelta = max(0.0f, blendDelta); if(flags & ASSOC_DELETEFADEDOUT){ if(callbackType == CB_FINISH || callbackType == CB_DELETE) callback(this, callbackArg); @@ -197,7 +197,7 @@ CAnimBlendAssociation::UpdateBlend(float timeDelta) if(blendAmount > 1.0f){ // Maximally faded in, clamp values blendAmount = 1.0f; - blendDelta = Min(0.0f, blendDelta); + blendDelta = min(0.0f, blendDelta); } return true; diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp index e594e5d8..e4bcdc69 100644 --- a/src/animation/AnimBlendHierarchy.cpp +++ b/src/animation/AnimBlendHierarchy.cpp @@ -36,7 +36,7 @@ CAnimBlendHierarchy::CalcTotalTime(void) float seqTime = 0.0f; for(j = 0; j < sequences[i].numFrames; j++) seqTime += sequences[i].GetKeyFrame(j)->deltaTime; - totalTime = Max(totalTime, seqTime); + totalTime = max(totalTime, seqTime); } totalLength = totalTime; } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e1860698..1e4b9c3b 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -31,12 +31,18 @@ #include "sampman.h" cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; +uint32 *audioLogicTimers = (uint32 *)0x6508A0; +uint8 &jumboVolOffset = *(uint8 *)0x6508ED; +uint8 &gJumboVolOffsetPercentage = *(uint8 *)0x6508ED; +char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; +int32 *BankStartOffset = (int32 *)0x6FAB70; //[2] +int32 &g_nMissionAudioSfx = *(int32 *)0x60ED84; +bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; +bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; constexpr int totalAudioEntitiesSlots = 200; constexpr int maxVolume = 127; -uint32 *audioLogicTimers = (uint32 *)0x6508A0; - // TODO: where is this used? Is this the right file? enum eVehicleModel { LANDSTAL, @@ -251,8 +257,6 @@ cAudioScriptObject::operator delete(void *p, int handle) CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); } -char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; - void cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) { @@ -311,8 +315,7 @@ cAudioManager::AddReflectionsToRequestedQueue() { float reflectionDistance; int32 noise; - uint8 emittingVolume = emittingVolume = - (m_sQueueSample.m_bVolume >> 1) + (m_sQueueSample.m_bVolume >> 3); + uint8 emittingVolume = (m_sQueueSample.m_bVolume >> 1) + (m_sQueueSample.m_bVolume >> 3); for(uint32 i = 0; i < 5u; i++) { reflectionDistance = m_afReflectionsDistances[i]; @@ -452,9 +455,9 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float speedOfSource = (dist / field_19195) * speedMultiplier; if(speedOfSound > Abs(speedOfSource)) { if(speedOfSource < 0.0f) { - speedOfSource = Max(speedOfSource, -1.5f); + speedOfSource = max(speedOfSource, -1.5f); } else { - speedOfSource = Min(speedOfSource, 1.5f); + speedOfSource = min(speedOfSource, 1.5f); } newFreq = (oldFreq * speedOfSound) / (speedOfSource + speedOfSound); } @@ -485,7 +488,7 @@ cAudioManager::ComputeVolume(int emittingVolume, float soundIntensity, float dis } int32 -cAudioManager::CreateEntity(int32 type, void *entity) +cAudioManager::CreateEntity(int32 type, CPhysical *entity) { if(!m_bIsInitialised) return -4; if(!entity) return -2; @@ -495,7 +498,7 @@ cAudioManager::CreateEntity(int32 type, void *entity) m_asAudioEntities[i].m_bIsUsed = true; m_asAudioEntities[i].m_bStatus = 0; m_asAudioEntities[i].m_nType = (eAudioType)type; - m_asAudioEntities[i].m_pEntity = entity; + m_asAudioEntities[i].m_pEntity = (void*)entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[1] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_TOTAL_PED_SOUNDS; @@ -558,6 +561,13 @@ cAudioManager::DestroyEntity(int32 id) } void +cAudioManager::DoJumboVolOffset() const +{ + if(!(m_FrameCounter % (m_anRandomTable[0] % 6u + 3))) + jumboVolOffset = m_anRandomTable[1] % 60u; +} + +void cAudioManager::DoPoliceRadioCrackle() { m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; @@ -581,573 +591,6 @@ cAudioManager::DoPoliceRadioCrackle() AddSampleToRequestedQueue(); } -void -cAudioManager::GenerateIntegerRandomNumberTable() -{ - for(int32 i = 0; i < 5; i++) { m_anRandomTable[i] = rand(); } -} - -void -cAudioManager::TranslateEntity(CVector *v1, CVector *v2) const -{ - const RwMatrix &cM = TheCamera.GetMatrix().m_matrix; - const CVector &cV = TheCamera.GetPosition(); - - float a = v1->z - cV.z; - float b = v1->y - cV.y; - float c = v1->x - cV.x; - - v2->x = cM.right.y * b + cM.right.x * c + cM.right.z * a; - v2->y = cM.up.y * b + cM.up.x * c + cM.up.z * a; - v2->z = cM.at.y * b + cM.at.x * c + cM.at.z * a; -} - -void -cAudioManager::ResetAudioLogicTimers(int32 timer) -{ - audioLogicTimers[0] = timer; - audioLogicTimers[8] = timer; - audioLogicTimers[1] = timer; - audioLogicTimers[7] = timer; - audioLogicTimers[2] = timer; - audioLogicTimers[6] = timer; - audioLogicTimers[3] = timer; - audioLogicTimers[5] = timer; - audioLogicTimers[4] = timer; - for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { - if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { - CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; - if(ped->IsPed()) { - ped->m_lastSoundStart = timer; - ped->m_soundStart = timer + m_anRandomTable[0] % 3000u; - } - } - } -<<<<<<< HEAD -} - -void -cAudioManager::PostInitialiseGameSpecificSetup() -{ - m_nFireAudioEntity = - CreateEntity(AUDIOTYPE_FIRE, - (CPhysical *)0x8F31D0); // last is addr of firemanager @todo change - if(m_nFireAudioEntity >= 0) SetEntityStatus(m_nFireAudioEntity, 1); - - m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (CPhysical *)1); - if(m_nCollisionEntity >= 0) SetEntityStatus(m_nCollisionEntity, 1); - - m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (CPhysical *)1); - if(m_nFrontEndEntity >= 0) SetEntityStatus(m_nFrontEndEntity, 1); - - m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); - if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); - - m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (CPhysical *)1); - if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); - - m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (CPhysical *)1); - if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); - - m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); - if(m_nBridgeEntity >= 0) SetEntityStatus(m_nBridgeEntity, 1); - - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; - m_sMissionAudio.m_bLoadingStatus = 0; - m_sMissionAudio.m_bPlayStatus = 0; - m_sMissionAudio.field_22 = 0; - m_sMissionAudio.m_bIsPlayed = 0; - m_sMissionAudio.field_12 = 1; - m_sMissionAudio.field_24 = 0; - ResetAudioLogicTimers((int32)CTimer::GetTimeInMilliseconds); -} - -WRAPPER -void -cAudioManager::InitialisePoliceRadioZones() -{ - EAXJMP(0x57EAC0); -} - -WRAPPER -void -cAudioManager::ResetAudioLogicTimers(int32 timer) -{ - EAXJMP(0x569650); -======= - ClearMissionAudio(); - SampleManager.StopChannel(28); ->>>>>>> More more more audio -} - -void -cAudioManager::Terminate() -{ - if(m_bIsInitialised) { - MusicManager.Terminate(); - - for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) { - m_asAudioEntities[i].m_bIsUsed = 0; - m_anAudioEntityIndices[i] = 200; - } - - m_nAudioEntitiesTotal = 0; - m_nScriptObjectEntityTotal = 0; - PreTerminateGameSpecificShutdown(); - - for(uint32 i = 0; i < 2; i++) { - if(SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); - } - - SampleManager.Terminate(); - - m_bIsInitialised = 0; - PostTerminateGameSpecificShutdown(); - } -} - -uint8 -cAudioManager::GetNum3DProvidersAvailable() const -{ - if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); - return 0; -} - -bool -cAudioManager::IsMP3RadioChannelAvailable() const -{ - if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); - - return 0; -} - -uint8 -cAudioManager::GetCDAudioDriveLetter() const -{ - if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); - - return 0; -} - -void -cAudioManager::SetEffectsMasterVolume(uint8 volume) const -{ - SampleManager.SetEffectsMasterVolume(volume); -} - -void -cAudioManager::SetMusicMasterVolume(uint8 volume) const -{ - SampleManager.SetMusicMasterVolume(volume); -} - -void -cAudioManager::SetEffectsFadeVolume(uint8 volume) const -{ - SampleManager.SetEffectsFadeVolume(volume); -} - -void -cAudioManager::SetMusicFadeVolume(uint8 volume) const -{ - SampleManager.SetMusicFadeVolume(volume); -} - -void -cAudioManager::SetSpeakerConfig(int32 conf) const -{ - SampleManager.SetSpeakerConfig(conf); -} - -WRAPPER -bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); } - -int32 *BankStartOffset = (int32 *)0x6FAB70; //[2] - -void -cAudioManager::PreInitialiseGameSpecificSetup() const -{ - BankStartOffset[0] = AUDIO_SAMPLE_VEHICLE_HORN_0; - BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; -} - -int32 &g_nMissionAudioSfx = *(int32 *)0x60ED84; - -void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const -{ - if(m_bIsInitialised) { - if(g_nMissionAudioPlayingStatus != 1) { - g_nMissionAudioPlayingStatus = 0; - g_nMissionAudioSfx = sfx; - } - } -} - -bool -cAudioManager::UsesSiren(int32 model) const -{ - switch(model) { - case FIRETRUK: - case AMBULAN: - case FBICAR: - case POLICE: - case ENFORCER: - case PREDATOR: return true; - default: return false; - } -} - -bool -cAudioManager::UsesSirenSwitching(int32 model) const -{ - switch(model) { - case AMBULAN: - case POLICE: - case ENFORCER: - case PREDATOR: return true; - default: return false; - } -} - -char * -cAudioManager::Get3DProviderName(uint8 id) const -{ - if(!m_bIsInitialised) return 0; - if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; - return SampleManager.Get3DProviderName(id); -} - -bool -cAudioManager::SetupJumboFlySound(uint8 emittingVol) -{ - int32 vol; - - if(m_sQueueSample.m_fDistance >= 440.0f) return 0; - - vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance); - m_sQueueSample.m_bVolume = vol; - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; - m_sQueueSample.m_counter = 0; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_FLY_SOUND); - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSoundIntensity = 440.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.field_76 = 5; - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - AddSampleToRequestedQueue(); - } - return 1; -} - -bool -cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) -{ - if(m_sQueueSample.m_fDistance >= 240.f) return 0; - - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 5; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 1; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 240.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 12; - m_sQueueSample.m_bOffset = 0; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - m_sQueueSample.m_counter = 6; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; - m_sQueueSample.m_nFrequency += 200; - m_sQueueSample.m_bOffset = maxVolume; - AddSampleToRequestedQueue(); - } - return 1; -} - -uint8 &gJumboVolOffsetPercentage = *(uint8 *)0x6508ED; - -bool -cAudioManager::SetupJumboTaxiSound(uint8 vol) -{ - uint8 emittingVol; - - if(m_sQueueSample.m_fDistance >= 180.f) return 0; - - emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance * 0.0055556f); - - if(m_sQueueSample.m_fDistance * 0.0055556f < 0.7f) - emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 180.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 4; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - return 1; -} - -bool -cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) -{ - if(m_sQueueSample.m_fDistance >= 170.f) return 0; - - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_WHINE_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = freq; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 170.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 4; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - return 1; -} - -void -cAudioManager::SetMissionAudioLocation(float x, float y, float z) -{ - if(m_bIsInitialised) { - m_sMissionAudio.field_12 = 0; - m_sMissionAudio.m_vecPos.x = x; - m_sMissionAudio.m_vecPos.y = y; - m_sMissionAudio.m_vecPos.z = z; - } -} - -void -cAudioManager::ResetPoliceRadio() -{ - if(m_bIsInitialised) { - if(SampleManager.GetChannelUsedFlag(28)) SampleManager.StopChannel(28); - InitialisePoliceRadio(); - } -} - -bool -cAudioManager::UsesReverseWarning(int32 model) const -{ - return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || - model == COACH; -} - -int32 -cAudioManager::RandomDisplacement(uint32 seed) const -{ - int32 value; - - static bool bIsEven = true; - static uint32 base = 0; - - if(!seed) return 0; - - value = m_anRandomTable[(base + seed) % 5] % seed; - base += value; - - if(value % 2) { bIsEven = !bIsEven; } - if(!bIsEven) value = -value; - return value; -} - -void -cAudioManager::ReleaseDigitalHandle() const -{ - if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } -} - -void -cAudioManager::ReacquireDigitalHandle() const -{ - if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); } -} - -void -cAudioManager::SetDynamicAcousticModelingStatus(bool status) -{ - m_bDynamicAcousticModelingStatus = status; -} - -bool -cAudioManager::IsAudioInitialised() const -{ - return m_bIsInitialised; -} - -void -cAudioManager::SetEntityStatus(int32 id, bool status) -{ - if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) { - if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; } - } -} - -void -cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const -{ - *phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; - - // check if the same sfx like last time, if yes, then try use next one, - // if exceeded range, then choose first available sample - if(*phrase == *prevPhrase && ++*phrase >= sample + maxOffset) *phrase = sample; - *prevPhrase = *phrase; -} - -uint8 &jumboVolOffset = *(uint8 *)0x6508ED; - -void -cAudioManager::DoJumboVolOffset() const -{ - if(!(m_FrameCounter % (m_anRandomTable[0] % 6u + 3))) - jumboVolOffset = m_anRandomTable[1] % 60u; -} - -int32 -cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) -{ - if(ped->IsPlayer()) return GetPlayerTalkSfx(sound); - - switch(ped->m_modelIndex) { - case MI_COP: return GetCopTalkSfx(sound); - case MI_SWAT: return GetSwatTalkSfx(sound); - case MI_FBI: return GetFBITalkSfx(sound); - case MI_ARMY: return GetArmyTalkSfx(sound); - case MI_MEDIC: return GetMedicTalkSfx(sound); - case MI_FIREMAN: return GetFiremanTalkSfx(sound); - case MI_MALE01: return GetNormalMaleTalkSfx(sound); - case MI_TAXI_D: return GetTaxiDriverTalkSfx(sound); - case MI_PIMP: return GetPimpTalkSfx(sound); - case MI_GANG01: - case MI_GANG02: return GetMafiaTalkSfx(sound); - case MI_GANG03: - case MI_GANG04: return GetTriadTalkSfx(sound); - case MI_GANG05: - case MI_GANG06: return GetDiabloTalkSfx(sound); - case MI_GANG07: - case MI_GANG08: return GetYakuzaTalkSfx(sound); - case MI_GANG09: - case MI_GANG10: return GetYardieTalkSfx(sound); - case MI_GANG11: - case MI_GANG12: return GetColumbianTalkSfx(sound); - case MI_GANG13: - case MI_GANG14: return GetHoodTalkSfx(sound); - case MI_CRIMINAL01: return GetBlackCriminalTalkSfx(sound); - case MI_CRIMINAL02: return GetWhiteCriminalTalkSfx(sound); - case MI_SPECIAL01: - case MI_SPECIAL02: - case MI_SPECIAL03: - case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->m_modelIndex, sound); - case MI_MALE02: return GetMaleNo2TalkSfx(sound); - case MI_MALE03: - case MI_P_MAN1: - case MI_P_MAN2: return GetBlackProjectMaleTalkSfx(sound, ped->m_modelIndex); - case MI_FATMALE01: return GetWhiteFatMaleTalkSfx(sound); - case MI_FATMALE02: return GetBlackFatMaleTalkSfx(sound); - case MI_FEMALE01: return GetBlackCasualFemaleTalkSfx(sound); - case MI_FEMALE02: - case MI_CAS_WOM: return GetWhiteCasualFemaleTalkSfx(sound); - case MI_FEMALE03: return GetFemaleNo3TalkSfx(sound); - case MI_FATFEMALE01: return GetBlackFatFemaleTalkSfx(sound); - case MI_FATFEMALE02: return GetWhiteFatFemaleTalkSfx(sound); - case MI_PROSTITUTE: return GetBlackFemaleProstituteTalkSfx(sound); - case MI_PROSTITUTE2: return GetWhiteFemaleProstituteTalkSfx(sound); - case MI_P_WOM1: return GetBlackProjectFemaleOldTalkSfx(sound); - case MI_P_WOM2: return GetBlackProjectFemaleYoungTalkSfx(sound); - case MI_CT_MAN1: return GetChinatownMaleOldTalkSfx(sound); - case MI_CT_MAN2: return GetChinatownMaleYoungTalkSfx(sound); - case MI_CT_WOM1: return GetChinatownFemaleOldTalkSfx(sound); - case MI_CT_WOM2: return GetChinatownFemaleYoungTalkSfx(sound); - case MI_LI_MAN1: - case MI_LI_MAN2: return GetLittleItalyMaleTalkSfx(sound); - case MI_LI_WOM1: return GetLittleItalyFemaleOldTalkSfx(sound); - case MI_LI_WOM2: return GetLittleItalyFemaleYoungTalkSfx(sound); - case MI_DOCKER1: return GetWhiteDockerMaleTalkSfx(sound); - case MI_DOCKER2: return GetBlackDockerMaleTalkSfx(sound); - case MI_SCUM_MAN: return GetScumMaleTalkSfx(sound); - case MI_SCUM_WOM: return GetScumFemaleTalkSfx(sound); - case MI_WORKER1: return GetWhiteWorkerMaleTalkSfx(sound); - case MI_WORKER2: return GetBlackWorkerMaleTalkSfx(sound); - case MI_B_MAN1: - case MI_B_MAN3: return GetBusinessMaleYoungTalkSfx(sound, ped->m_modelIndex); - case MI_B_MAN2: return GetBusinessMaleOldTalkSfx(sound); - case MI_B_WOM1: - case MI_B_WOM2: return GetWhiteBusinessFemaleTalkSfx(sound, ped->m_modelIndex); - case MI_B_WOM3: return GetBlackBusinessFemaleTalkSfx(sound); - case MI_MOD_MAN: return GetSupermodelMaleTalkSfx(sound); - case MI_MOD_WOM: return GetSupermodelFemaleTalkSfx(sound); - case MI_ST_MAN: return GetStewardMaleTalkSfx(sound); - case MI_ST_WOM: return GetStewardFemaleTalkSfx(sound); - case MI_FAN_MAN1: - case MI_FAN_MAN2: return GetFanMaleTalkSfx(sound, ped->m_modelIndex); - case MI_FAN_WOM: return GetFanFemaleTalkSfx(sound); - case MI_HOS_MAN: return GetHospitalMaleTalkSfx(sound); - case MI_HOS_WOM: return GetHospitalFemaleTalkSfx(sound); - case MI_CONST1: return GetWhiteConstructionWorkerTalkSfx(sound); - case MI_CONST2: return GetBlackConstructionWorkerTalkSfx(sound); - case MI_SHOPPER1: - case MI_SHOPPER2: - case MI_SHOPPER3: return GetShopperFemaleTalkSfx(sound, ped->m_modelIndex); - case MI_STUD_MAN: return GetStudentMaleTalkSfx(sound); - case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound); - case MI_CAS_MAN: return GetCasualMaleOldTalkSfx(sound); - default: return GetGenericMaleTalkSfx(sound); - } -} - uint32 cAudioManager::GetPlayerTalkSfx(int16 sound) { @@ -3256,6 +2699,28 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) return sfx; } +void +cAudioManager::GenerateIntegerRandomNumberTable() +{ + for(int32 i = 0; i < 5; i++) { m_anRandomTable[i] = rand(); } +} + +char * +cAudioManager::Get3DProviderName(uint8 id) const +{ + if(!m_bIsInitialised) return 0; + if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; + return SampleManager.Get3DProviderName(id); +} + +uint8 +cAudioManager::GetCDAudioDriveLetter() const +{ + if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); + + return 0; +} + int8 cAudioManager::GetCurrent3DProviderIndex() const { @@ -3351,6 +2816,117 @@ cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const return g_nMissionAudioPlayingStatus; } +uint8 +cAudioManager::GetNum3DProvidersAvailable() const +{ + if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); + return 0; +} + + +int32 +cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) +{ + if(ped->IsPlayer()) return GetPlayerTalkSfx(sound); + + switch(ped->m_modelIndex) { + case MI_COP: return GetCopTalkSfx(sound); + case MI_SWAT: return GetSwatTalkSfx(sound); + case MI_FBI: return GetFBITalkSfx(sound); + case MI_ARMY: return GetArmyTalkSfx(sound); + case MI_MEDIC: return GetMedicTalkSfx(sound); + case MI_FIREMAN: return GetFiremanTalkSfx(sound); + case MI_MALE01: return GetNormalMaleTalkSfx(sound); + case MI_TAXI_D: return GetTaxiDriverTalkSfx(sound); + case MI_PIMP: return GetPimpTalkSfx(sound); + case MI_GANG01: + case MI_GANG02: return GetMafiaTalkSfx(sound); + case MI_GANG03: + case MI_GANG04: return GetTriadTalkSfx(sound); + case MI_GANG05: + case MI_GANG06: return GetDiabloTalkSfx(sound); + case MI_GANG07: + case MI_GANG08: return GetYakuzaTalkSfx(sound); + case MI_GANG09: + case MI_GANG10: return GetYardieTalkSfx(sound); + case MI_GANG11: + case MI_GANG12: return GetColumbianTalkSfx(sound); + case MI_GANG13: + case MI_GANG14: return GetHoodTalkSfx(sound); + case MI_CRIMINAL01: return GetBlackCriminalTalkSfx(sound); + case MI_CRIMINAL02: return GetWhiteCriminalTalkSfx(sound); + case MI_SPECIAL01: + case MI_SPECIAL02: + case MI_SPECIAL03: + case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->m_modelIndex, sound); + case MI_MALE02: return GetMaleNo2TalkSfx(sound); + case MI_MALE03: + case MI_P_MAN1: + case MI_P_MAN2: return GetBlackProjectMaleTalkSfx(sound, ped->m_modelIndex); + case MI_FATMALE01: return GetWhiteFatMaleTalkSfx(sound); + case MI_FATMALE02: return GetBlackFatMaleTalkSfx(sound); + case MI_FEMALE01: return GetBlackCasualFemaleTalkSfx(sound); + case MI_FEMALE02: + case MI_CAS_WOM: return GetWhiteCasualFemaleTalkSfx(sound); + case MI_FEMALE03: return GetFemaleNo3TalkSfx(sound); + case MI_FATFEMALE01: return GetBlackFatFemaleTalkSfx(sound); + case MI_FATFEMALE02: return GetWhiteFatFemaleTalkSfx(sound); + case MI_PROSTITUTE: return GetBlackFemaleProstituteTalkSfx(sound); + case MI_PROSTITUTE2: return GetWhiteFemaleProstituteTalkSfx(sound); + case MI_P_WOM1: return GetBlackProjectFemaleOldTalkSfx(sound); + case MI_P_WOM2: return GetBlackProjectFemaleYoungTalkSfx(sound); + case MI_CT_MAN1: return GetChinatownMaleOldTalkSfx(sound); + case MI_CT_MAN2: return GetChinatownMaleYoungTalkSfx(sound); + case MI_CT_WOM1: return GetChinatownFemaleOldTalkSfx(sound); + case MI_CT_WOM2: return GetChinatownFemaleYoungTalkSfx(sound); + case MI_LI_MAN1: + case MI_LI_MAN2: return GetLittleItalyMaleTalkSfx(sound); + case MI_LI_WOM1: return GetLittleItalyFemaleOldTalkSfx(sound); + case MI_LI_WOM2: return GetLittleItalyFemaleYoungTalkSfx(sound); + case MI_DOCKER1: return GetWhiteDockerMaleTalkSfx(sound); + case MI_DOCKER2: return GetBlackDockerMaleTalkSfx(sound); + case MI_SCUM_MAN: return GetScumMaleTalkSfx(sound); + case MI_SCUM_WOM: return GetScumFemaleTalkSfx(sound); + case MI_WORKER1: return GetWhiteWorkerMaleTalkSfx(sound); + case MI_WORKER2: return GetBlackWorkerMaleTalkSfx(sound); + case MI_B_MAN1: + case MI_B_MAN3: return GetBusinessMaleYoungTalkSfx(sound, ped->m_modelIndex); + case MI_B_MAN2: return GetBusinessMaleOldTalkSfx(sound); + case MI_B_WOM1: + case MI_B_WOM2: return GetWhiteBusinessFemaleTalkSfx(sound, ped->m_modelIndex); + case MI_B_WOM3: return GetBlackBusinessFemaleTalkSfx(sound); + case MI_MOD_MAN: return GetSupermodelMaleTalkSfx(sound); + case MI_MOD_WOM: return GetSupermodelFemaleTalkSfx(sound); + case MI_ST_MAN: return GetStewardMaleTalkSfx(sound); + case MI_ST_WOM: return GetStewardFemaleTalkSfx(sound); + case MI_FAN_MAN1: + case MI_FAN_MAN2: return GetFanMaleTalkSfx(sound, ped->m_modelIndex); + case MI_FAN_WOM: return GetFanFemaleTalkSfx(sound); + case MI_HOS_MAN: return GetHospitalMaleTalkSfx(sound); + case MI_HOS_WOM: return GetHospitalFemaleTalkSfx(sound); + case MI_CONST1: return GetWhiteConstructionWorkerTalkSfx(sound); + case MI_CONST2: return GetBlackConstructionWorkerTalkSfx(sound); + case MI_SHOPPER1: + case MI_SHOPPER2: + case MI_SHOPPER3: return GetShopperFemaleTalkSfx(sound, ped->m_modelIndex); + case MI_STUD_MAN: return GetStudentMaleTalkSfx(sound); + case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound); + case MI_CAS_MAN: return GetCasualMaleOldTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); + } +} + +void +cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const +{ + *phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; + + // check if the same sfx like last time, if yes, then try use next one, + // if exceeded range, then choose first available sample + if(*phrase == *prevPhrase && ++*phrase >= sample + maxOffset) *phrase = sample; + *prevPhrase = *phrase; +} + bool cAudioManager::HasAirBrakes(int32 model) const { @@ -3403,6 +2979,12 @@ cAudioManager::InterrogateAudioEntities() } bool +cAudioManager::IsAudioInitialised() const +{ + return m_bIsInitialised; +} + +bool cAudioManager::IsMissionAudioSampleFinished() { if(m_bIsInitialised) return m_sMissionAudio.m_bPlayStatus == 2; @@ -3413,6 +2995,14 @@ cAudioManager::IsMissionAudioSampleFinished() } bool +cAudioManager::IsMP3RadioChannelAvailable() const +{ + if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); + + return 0; +} + +bool cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const { switch(soundMission) { @@ -3448,8 +3038,6 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) EAXJMP(0x57A500); } -bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; - void cAudioManager::PlayerJustGotInCar() const { @@ -3479,10 +3067,10 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); - m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATER_CANNON, (CPhysical *)1); + m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (CPhysical *)1); if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); - m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_D, (CPhysical *)1); + m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (CPhysical *)1); if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); @@ -3504,6 +3092,14 @@ cAudioManager::PostTerminateGameSpecificShutdown() ; } + +void +cAudioManager::PreInitialiseGameSpecificSetup() const +{ + BankStartOffset[0] = AUDIO_SAMPLE_VEHICLE_HORN_0; + BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; +} + void cAudioManager::PreTerminateGameSpecificShutdown() { @@ -3818,7 +3414,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) velocityChange = Abs(params->m_fVelocityChange); if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return 1; - velocityChange = Min(0.75f, velocityChange); + velocityChange = min(0.75f, velocityChange); multiplier = (velocityChange - 0.0005f) * 1.3342f; CalculateDistance((bool *)params, params->m_fDistance); vol = (30.f * multiplier); @@ -5556,8 +5152,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } } -bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; - void cAudioManager::ProcessMissionAudio() { @@ -5571,9 +5165,9 @@ cAudioManager::ProcessMissionAudio() static uint8 nFramesUntilFailedLoad = 0; static uint8 nFramesForPretendPlaying = 0; - if(this->m_bIsInitialised) { + if(m_bIsInitialised) { if(m_sMissionAudio.m_nSampleIndex != 3033) { - switch(this->m_sMissionAudio.m_bLoadingStatus) { + switch(m_sMissionAudio.m_bLoadingStatus) { case 0: SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, 1u); @@ -5581,9 +5175,9 @@ cAudioManager::ProcessMissionAudio() nFramesUntilFailedLoad = 0; return; case 1: - if(!this->m_sMissionAudio.m_bIsPlayed) return; + if(!m_sMissionAudio.m_bIsPlayed) return; if(g_bMissionAudioLoadFailed) { - if(this->m_bTimerJustReset) { + if(m_bTimerJustReset) { ClearMissionAudio(); SampleManager.StopStreamedFile(1u); nFramesForPretendPlaying = 0; @@ -5591,16 +5185,16 @@ cAudioManager::ProcessMissionAudio() nFramesUntilFailedLoad = 0; } else if(!m_bUserPause) { if(++nFramesForPretendPlaying < 120u) { - this->m_sMissionAudio.m_bPlayStatus = 1; + m_sMissionAudio.m_bPlayStatus = 1; } else { - this->m_sMissionAudio.m_bPlayStatus = 2; - this->m_sMissionAudio.m_nSampleIndex = 3033; + m_sMissionAudio.m_bPlayStatus = 2; + m_sMissionAudio.m_nSampleIndex = 3033; } } } else { if(m_sMissionAudio.m_bPlayStatus) { if(m_sMissionAudio.m_bPlayStatus != 1) return; - if(this->m_bTimerJustReset) { + if(m_bTimerJustReset) { ClearMissionAudio(); SampleManager.StopStreamedFile(1u); return; @@ -5696,7 +5290,7 @@ cAudioManager::ProcessMissionAudio() nFramesForPretendPlaying = 0; g_bMissionAudioLoadFailed = 1; nFramesUntilFailedLoad = 0; - this->m_sMissionAudio.m_bLoadingStatus = 1; + m_sMissionAudio.m_bLoadingStatus = 1; } return; default: return; @@ -6072,7 +5666,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) if(params->m_fDistance < 49.f) { ped = params->m_pPed; - if(!(ped->m_ped_flagA20) || ped->m_bodyPartBleeding != 2) { + if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != 2) { CalculateDistance((bool *)params, params->m_fDistance); if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) { emittingVol = 10; @@ -7121,7 +6715,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * CurrentPretendGear = 1; } if(CReplay::IsPlayingBack()) { - accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal)); + accelerateState = 255.f * max(0.0f, min(1.0f, automobile->m_fGasPedal)); } else { accelerateState = Pads->GetAccelerate(); } @@ -7156,9 +6750,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * if(0.0f != velocityChange) { time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; if(time <= 0.0f) { - freqModifier = Max(-0.2f, time) * -15000.f; + freqModifier = max(-0.2f, time) * -15000.f; } else { - freqModifier = -(Min(0.2f, time) * 15000.f); + freqModifier = -(min(0.2f, time) * 15000.f); } if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; } else { @@ -7177,10 +6771,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * gasPedalAudio = automobile->m_fGasPedalAudio; } else { gasPedalAudio = - Min(1.0f, params->m_fVelocityChange / + min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); } - gasPedalAudio = Max(0.0f, gasPedalAudio); + gasPedalAudio = max(0.0f, gasPedalAudio); automobile->m_fGasPedalAudio = gasPedalAudio; } else if(LastAccel > 0) { if(channelUsed) { @@ -7210,7 +6804,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * (engineSoundType + AUDIO_SAMPLE_VEHICLE_ENGINE_IDLE_NONE), 0, 52u, 1); - CurrentPretendGear = Max(1, currentGear); + CurrentPretendGear = max(1, currentGear); LastAccel = accelerateState; bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; @@ -7665,11 +7259,11 @@ cAudioManager::ProcessScriptObject(int32 id) { cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; if(entity) { - m_sQueueSample.m_vecPos = entity->m_vecPos; + m_sQueueSample.m_vecPos = entity->Posn; if(m_asAudioEntities[id].m_Loops == 1) ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); else - ProcessLoopingScriptObject(entity->m_wSound); + ProcessLoopingScriptObject(entity->AudioId); } } @@ -7778,7 +7372,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if(params->m_fVelocityChange <= 0.0f) { CalculateDistance((bool *)params, params->m_fDistance); train = (CTrain *)params->m_pVehicle; - speedMultipler = Min(1.0f, train->m_fSpeed * 250.f / 51.f); + speedMultipler = min(1.0f, train->m_fSpeed * 250.f / 51.f); emittingVol = (75.f * speedMultipler); if(train->m_fWagonPosition == 0.0f) { m_sQueueSample.m_bVolume = @@ -7871,7 +7465,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if(automobile->Damage.GetDoorStatus(i) == 2) { doorState = automobile->Doors[i].m_nDoorState; if(doorState == 1 || doorState == 2) { - velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); + velocity = min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); if(velocity > 0.0035f) { emittingVol = (100.f * velocity * 10.f / 3.f); m_sQueueSample.m_bVolume = ComputeVolume( @@ -7961,7 +7555,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) CalculateDistance((bool *)params, params->m_fDistance); emittingVol = 30.f * - Min(1.f, + min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); @@ -8011,11 +7605,63 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) WRAPPER void cAudioManager::ProcessWaterCannon(int32) { EAXJMP(0x575F30); } -WRAPPER void cAudioManager::ProcessWeather(int32 id) { - EAXJMP(0x578370); + uint8 vol; + static uint8 counter = 0; + + if(m_asAudioEntities[id].m_Loops && + m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { + if(m_asAudioEntities[id].m_afVolume[0] >= 10.f) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_EXPLOSION_CAR; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 4000; + vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; + } else { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_GRENADE_EXPLOSION; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 4000; + vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; + } + m_sQueueSample.m_bVolume = vol; + if(TheCamera.SoundDistUp < 20.f) m_sQueueSample.m_bVolume >>= 1; + if(counter == 4) counter = 0; + m_sQueueSample.m_counter = counter++; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bOffset = (m_anRandomTable[2] & 15) + 55; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bRequireReflection = 0; + cAudioManager::AddSampleToRequestedQueue(); + } + if(CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_LOOPING_GRASS; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_COLLISION_LOOPING_GRASS); + m_sQueueSample.m_bVolume = (uint8)(25.f * CWeather::Rain); + m_sQueueSample.m_counter = 4; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bOffset = 63; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 30; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bRequireReflection = 0; + cAudioManager::AddSampleToRequestedQueue(); + } } bool @@ -8034,7 +7680,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) if(velChange > 0.f) { CalculateDistance((bool *)params, params->m_fDistance); relativeVelocity = - Min(1.0f, + min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; m_sQueueSample.m_bVolume = @@ -8114,6 +7760,286 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) } } +int32 +cAudioManager::RandomDisplacement(uint32 seed) const +{ + int32 value; + + static bool bIsEven = true; + static uint32 base = 0; + + if(!seed) return 0; + + value = m_anRandomTable[(base + seed) % 5] % seed; + base += value; + + if(value % 2) { bIsEven = !bIsEven; } + if(!bIsEven) value = -value; + return value; +} + +void +cAudioManager::ReacquireDigitalHandle() const +{ + if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); } +} + +void +cAudioManager::ReleaseDigitalHandle() const +{ + if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } +} + +void +cAudioManager::ResetAudioLogicTimers(int32 timer) +{ + audioLogicTimers[0] = timer; + audioLogicTimers[8] = timer; + audioLogicTimers[1] = timer; + audioLogicTimers[7] = timer; + audioLogicTimers[2] = timer; + audioLogicTimers[6] = timer; + audioLogicTimers[3] = timer; + audioLogicTimers[5] = timer; + audioLogicTimers[4] = timer; + for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { + if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { + CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; + if(ped->IsPed()) { + ped->m_lastSoundStart = timer; + ped->m_soundStart = timer + m_anRandomTable[0] % 3000u; + } + } + } + ClearMissionAudio(); + SampleManager.StopChannel(28); +} + +void +cAudioManager::ResetPoliceRadio() +{ + if(m_bIsInitialised) { + if(SampleManager.GetChannelUsedFlag(28)) SampleManager.StopChannel(28); + InitialisePoliceRadio(); + } +} + +WRAPPER void +cAudioManager::Service() +{ + EAXJMP(0x57A2A0); +} + + +void +cAudioManager::SetDynamicAcousticModelingStatus(bool status) +{ + m_bDynamicAcousticModelingStatus = status; +} + +void +cAudioManager::SetEffectsFadeVolume(uint8 volume) const +{ + SampleManager.SetEffectsFadeVolume(volume); +} + +void +cAudioManager::SetEffectsMasterVolume(uint8 volume) const +{ + SampleManager.SetEffectsMasterVolume(volume); +} + +void +cAudioManager::SetEntityStatus(int32 id, bool status) +{ + if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) { + if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; } + } +} + +void +cAudioManager::SetMissionAudioLocation(float x, float y, float z) +{ + if(m_bIsInitialised) { + m_sMissionAudio.field_12 = 0; + m_sMissionAudio.m_vecPos.x = x; + m_sMissionAudio.m_vecPos.y = y; + m_sMissionAudio.m_vecPos.z = z; + } +} + +void +cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const +{ + if(m_bIsInitialised) { + if(g_nMissionAudioPlayingStatus != 1) { + g_nMissionAudioPlayingStatus = 0; + g_nMissionAudioSfx = sfx; + } + } +} + +void +cAudioManager::SetMusicFadeVolume(uint8 volume) const +{ + SampleManager.SetMusicFadeVolume(volume); +} + +void +cAudioManager::SetMusicMasterVolume(uint8 volume) const +{ + SampleManager.SetMusicMasterVolume(volume); +} + + +void +cAudioManager::SetSpeakerConfig(int32 conf) const +{ + SampleManager.SetSpeakerConfig(conf); +} + +WRAPPER +bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); } + +bool +cAudioManager::SetupJumboFlySound(uint8 emittingVol) +{ + int32 vol; + + if(m_sQueueSample.m_fDistance >= 440.0f) return 0; + + vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_bVolume = vol; + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; + m_sQueueSample.m_counter = 0; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_FLY_SOUND); + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSoundIntensity = 440.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.field_76 = 5; + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + AddSampleToRequestedQueue(); + } + return 1; +} + +bool +cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) +{ + if(m_sQueueSample.m_fDistance >= 240.f) return 0; + + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 5; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 240.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 12; + m_sQueueSample.m_bOffset = 0; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + m_sQueueSample.m_counter = 6; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; + m_sQueueSample.m_nFrequency += 200; + m_sQueueSample.m_bOffset = maxVolume; + AddSampleToRequestedQueue(); + } + return 1; +} + +bool +cAudioManager::SetupJumboTaxiSound(uint8 vol) +{ + uint8 emittingVol; + + if(m_sQueueSample.m_fDistance >= 180.f) return 0; + + emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance * 0.0055556f); + + if(m_sQueueSample.m_fDistance * 0.0055556f < 0.7f) + emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 180.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + return 1; +} + +bool +cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) +{ + if(m_sQueueSample.m_fDistance >= 170.f) return 0; + + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_WHINE_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 170.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + return 1; +} + void cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) { @@ -8240,69 +8166,105 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) } } -WRAPPER void -cAudioManager::Service() +void +cAudioManager::Terminate() { - EAXJMP(0x57A2A0); -} + if(m_bIsInitialised) { + MusicManager.Terminate(); -WRAPPER void cAudioManager::PlayOneShot(int, unsigned short, float) -{ - EAXJMP(0x57A500); -} + for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) { + m_asAudioEntities[i].m_bIsUsed = 0; + m_anAudioEntityIndices[i] = 200; + } -WRAPPER void cAudioManager::SetEffectsFadeVol(unsigned char) -{ - EAXJMP(0x57A770); -} + m_nAudioEntitiesTotal = 0; + m_nScriptObjectEntityTotal = 0; + PreTerminateGameSpecificShutdown(); -WRAPPER void cAudioManager::SetMusicFadeVol(unsigned char) -{ - EAXJMP(0x57A790); -} + for(uint32 i = 0; i < 2; i++) { + if(SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); + } -WRAPPER int8 cAudioManager::SetCurrent3DProvider(unsigned char) -{ - EAXJMP(0x57A910); + SampleManager.Terminate(); + + m_bIsInitialised = 0; + PostTerminateGameSpecificShutdown(); + } } -WRAPPER void cAudioManager::ReportCrime(eCrimeType, CVector const &) +void +cAudioManager::TranslateEntity(CVector *v1, CVector *v2) const { - EAXJMP(0x5803D0); + const RwMatrix &cM = TheCamera.GetMatrix().m_matrix; + const CVector &cV = TheCamera.GetPosition(); + + float a = v1->z - cV.z; + float b = v1->y - cV.y; + float c = v1->x - cV.x; + + v2->x = cM.right.y * b + cM.right.x * c + cM.right.z * a; + v2->y = cM.up.y * b + cM.up.x * c + cM.up.z * a; + v2->z = cM.at.y * b + cM.at.x * c + cM.at.z * a; } -WRAPPER void cAudioManager::PlaySuspectLastSeen(float, float, float) +void +cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) { - EAXJMP(0x580500); + float newGasPedalAudio; + + float gasPedal = Abs(automobile->m_fGasPedal); + float gasPedalAudio = automobile->m_fGasPedalAudio; + + if(gasPedalAudio < gasPedal) { + newGasPedalAudio = gasPedalAudio + 0.09f; + if(gasPedal <= newGasPedalAudio) newGasPedalAudio = gasPedal; + } else { + newGasPedalAudio = gasPedalAudio - 0.07f; + if(gasPedal >= newGasPedalAudio) newGasPedalAudio = gasPedal; + } + automobile->m_fGasPedalAudio = newGasPedalAudio; } -WRAPPER void cAudioManager::ReportCollision(CEntity *, CEntity *, unsigned char, unsigned char, float, float) +bool +cAudioManager::UsesReverseWarning(int32 model) const { - EAXJMP(0x568410); + return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || + model == COACH; } -WRAPPER void cAudioManager::ResetTimers(unsigned int) +bool +cAudioManager::UsesSiren(int32 model) const { - EAXJMP(0x57A7B0); + switch(model) { + case FIRETRUK: + case AMBULAN: + case FBICAR: + case POLICE: + case ENFORCER: + case PREDATOR: return true; + default: return false; + } } -WRAPPER void cAudioManager::PreloadMissionAudio(char *) +bool +cAudioManager::UsesSirenSwitching(int32 model) const { - EAXJMP(0x579550); + switch(model) { + case AMBULAN: + case POLICE: + case ENFORCER: + case PREDATOR: return true; + default: return false; + } } STARTPATCHES -InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); -InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); - InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP); InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP); InjectHook(0x57B300, &cAudioManager::AddReflectionsToRequestedQueue, PATCH_JUMP); // InjectHook(0x57B8D0, &cAudioManager::AddReleasingSounds, PATCH_JUMP); InjectHook(0x57B070, &cAudioManager::AddSampleToRequestedQueue, PATCH_JUMP); -InjectHook(0x57A8F0, &cAudioManager::GetCurrent3DProviderIndex, PATCH_JUMP); // InjectHook(0x580AF0, &cAudioManager::AgeCrimes, PATCH_JUMP); - InjectHook(0x5697A0, &cAudioManager::CalculateDistance, PATCH_JUMP); InjectHook(0x57AA10, &cAudioManager::CheckForAnAudioFileOnCD, PATCH_JUMP); InjectHook(0x5796A0, &cAudioManager::ClearMissionAudio, PATCH_JUMP); @@ -8310,162 +8272,111 @@ InjectHook(0x57C120, &cAudioManager::ClearRequestedQueue, PATCH_JUMP); InjectHook(0x57AE00, &cAudioManager::ComputeDopplerEffectedFrequency, PATCH_JUMP); InjectHook(0x57ABB0, &cAudioManager::ComputeVolume, PATCH_JUMP); InjectHook(0x57A310, &cAudioManager::CreateEntity, PATCH_JUMP); - InjectHook(0x57A830, &cAudioManager::DestroyAllGameCreatedEntities, PATCH_JUMP); InjectHook(0x57A400, &cAudioManager::DestroyEntity, PATCH_JUMP); InjectHook(0x57F060, &cAudioManager::DoPoliceRadioCrackle, PATCH_JUMP); - InjectHook(0x57C290, &cAudioManager::GenerateIntegerRandomNumberTable, PATCH_JUMP); -InjectHook(0x569750, &cAudioManager::GetDistanceSquared, PATCH_JUMP); -InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP); - -InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); -InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); -// InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); -InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); -InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); - -InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); -InjectHook(0x5795D0, &cAudioManager::GetMissionAudioLoadingStatus, PATCH_JUMP); - -InjectHook(0x57A8A0, &cAudioManager::GetNum3DProvidersAvailable, PATCH_JUMP); -InjectHook(0x57A9C0, &cAudioManager::IsMP3RadioChannelAvailable, PATCH_JUMP); -InjectHook(0x57AA30, &cAudioManager::GetCDAudioDriveLetter, PATCH_JUMP); - -InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP); -InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP); -InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP); -InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP); - -InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, PATCH_JUMP); - -InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP); - -InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP); - -InjectHook(0x56C3C0, &cAudioManager::UsesSiren, PATCH_JUMP); -InjectHook(0x56C3F0, &cAudioManager::UsesSirenSwitching, PATCH_JUMP); - -InjectHook(0x579520, &cAudioManager::MissionScriptAudioUsesPoliceChannel, PATCH_JUMP); - InjectHook(0x57A8C0, &cAudioManager::Get3DProviderName, PATCH_JUMP); -InjectHook(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP); -InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP); -InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, PATCH_JUMP); -InjectHook(0x56F070, &cAudioManager::SetupJumboWhineSound, PATCH_JUMP); - -InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP); - -InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP); - -InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP); - -InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP); - -InjectHook(0x56C600, &cAudioManager::UsesReverseWarning, PATCH_JUMP); -InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP); - -InjectHook(0x56F410, &cAudioManager::GetJumboTaxiFreq, PATCH_JUMP); - -InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP); -InjectHook(0x57AF90, &cAudioManager::RandomDisplacement, PATCH_JUMP); - -InjectHook(0x57A9E0, &cAudioManager::ReleaseDigitalHandle, PATCH_JUMP); -InjectHook(0x57A9F0, &cAudioManager::ReacquireDigitalHandle, PATCH_JUMP); -InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP); - -InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP); - -InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP); - -InjectHook(0x569570, &cAudioManager::PreTerminateGameSpecificShutdown, PATCH_JUMP); -InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP); - -InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP); -InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP); -InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP); - -// Get ped sfx stuff -InjectHook(0x570960, &cAudioManager::GetPedCommentSfx, PATCH_JUMP); - -InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP); -InjectHook(0x570EA0, &cAudioManager::GetCopTalkSfx, PATCH_JUMP); -InjectHook(0x570F80, &cAudioManager::GetSwatTalkSfx, PATCH_JUMP); -InjectHook(0x571040, &cAudioManager::GetFBITalkSfx, PATCH_JUMP); InjectHook(0x571110, &cAudioManager::GetArmyTalkSfx, PATCH_JUMP); -InjectHook(0x5711C0, &cAudioManager::GetMedicTalkSfx, PATCH_JUMP); -InjectHook(0x5712B0, &cAudioManager::GetFiremanTalkSfx, PATCH_JUMP); -InjectHook(0x575340, &cAudioManager::GetNormalMaleTalkSfx, PATCH_JUMP); -InjectHook(0x575190, &cAudioManager::GetTaxiDriverTalkSfx, PATCH_JUMP); -InjectHook(0x575240, &cAudioManager::GetPimpTalkSfx, PATCH_JUMP); -InjectHook(0x571510, &cAudioManager::GetMafiaTalkSfx, PATCH_JUMP); -InjectHook(0x571650, &cAudioManager::GetTriadTalkSfx, PATCH_JUMP); -InjectHook(0x571770, &cAudioManager::GetDiabloTalkSfx, PATCH_JUMP); -InjectHook(0x5718D0, &cAudioManager::GetYakuzaTalkSfx, PATCH_JUMP); -InjectHook(0x5719E0, &cAudioManager::GetYardieTalkSfx, PATCH_JUMP); -InjectHook(0x571B00, &cAudioManager::GetColumbianTalkSfx, PATCH_JUMP); -InjectHook(0x571C30, &cAudioManager::GetHoodTalkSfx, PATCH_JUMP); -InjectHook(0x571D80, &cAudioManager::GetBlackCriminalTalkSfx, PATCH_JUMP); -InjectHook(0x571E60, &cAudioManager::GetWhiteCriminalTalkSfx, PATCH_JUMP); -InjectHook(0x571F40, &cAudioManager::GetMaleNo2TalkSfx, PATCH_JUMP); -InjectHook(0x572AF0, &cAudioManager::GetBlackProjectMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5725D0, &cAudioManager::GetWhiteFatMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5726C0, &cAudioManager::GetBlackFatMaleTalkSfx, PATCH_JUMP); +InjectHook(0x573AB0, &cAudioManager::GetBlackBusinessFemaleTalkSfx, PATCH_JUMP); InjectHook(0x572050, &cAudioManager::GetBlackCasualFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x572170, &cAudioManager::GetWhiteCasualFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x572280, &cAudioManager::GetFemaleNo3TalkSfx, PATCH_JUMP); +InjectHook(0x574380, &cAudioManager::GetBlackConstructionWorkerTalkSfx, PATCH_JUMP); +InjectHook(0x571D80, &cAudioManager::GetBlackCriminalTalkSfx, PATCH_JUMP); +InjectHook(0x5735E0, &cAudioManager::GetBlackDockerMaleTalkSfx, PATCH_JUMP); InjectHook(0x5724D0, &cAudioManager::GetBlackFatFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x5727B0, &cAudioManager::GetWhiteFatFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5726C0, &cAudioManager::GetBlackFatMaleTalkSfx, PATCH_JUMP); InjectHook(0x5728B0, &cAudioManager::GetBlackFemaleProstituteTalkSfx, PATCH_JUMP); -InjectHook(0x5729D0, &cAudioManager::GetWhiteFemaleProstituteTalkSfx, PATCH_JUMP); InjectHook(0x572C20, &cAudioManager::GetBlackProjectFemaleOldTalkSfx, PATCH_JUMP); InjectHook(0x572D20, &cAudioManager::GetBlackProjectFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x572E10, &cAudioManager::GetChinatownMaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x572F10, &cAudioManager::GetChinatownMaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x573010, &cAudioManager::GetChinatownFemaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x5730F0, &cAudioManager::GetChinatownFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x5731E0, &cAudioManager::GetLittleItalyMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573310, &cAudioManager::GetLittleItalyFemaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x573400, &cAudioManager::GetLittleItalyFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x5734F0, &cAudioManager::GetWhiteDockerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5735E0, &cAudioManager::GetBlackDockerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5736D0, &cAudioManager::GetScumMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5737E0, &cAudioManager::GetScumFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x5738D0, &cAudioManager::GetWhiteWorkerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x572AF0, &cAudioManager::GetBlackProjectMaleTalkSfx, PATCH_JUMP); InjectHook(0x5739C0, &cAudioManager::GetBlackWorkerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5713E0, &cAudioManager::GetBusinessMaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x574FF0, &cAudioManager::GetBomberTalkSfx, PATCH_JUMP); InjectHook(0x5712C0, &cAudioManager::GetBusinessMaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x5723A0, &cAudioManager::GetWhiteBusinessFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573AB0, &cAudioManager::GetBlackBusinessFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573BD0, &cAudioManager::GetSupermodelMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573CD0, &cAudioManager::GetSupermodelFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573DC0, &cAudioManager::GetStewardMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573E90, &cAudioManager::GetStewardFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573F60, &cAudioManager::GetFanMaleTalkSfx, PATCH_JUMP); -InjectHook(0x574040, &cAudioManager::GetFanFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574120, &cAudioManager::GetHospitalMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5741F0, &cAudioManager::GetHospitalFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574290, &cAudioManager::GetWhiteConstructionWorkerTalkSfx, PATCH_JUMP); -InjectHook(0x574380, &cAudioManager::GetBlackConstructionWorkerTalkSfx, PATCH_JUMP); -InjectHook(0x574480, &cAudioManager::GetShopperFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574590, &cAudioManager::GetStudentMaleTalkSfx, PATCH_JUMP); -InjectHook(0x574690, &cAudioManager::GetStudentFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5713E0, &cAudioManager::GetBusinessMaleYoungTalkSfx, PATCH_JUMP); InjectHook(0x572040, &cAudioManager::GetCasualMaleOldTalkSfx, PATCH_JUMP); - -InjectHook(0x574790, &cAudioManager::GetSpecialCharacterTalkSfx, PATCH_JUMP); +InjectHook(0x574FE0, &cAudioManager::GetCatatalinaTalkSfx, PATCH_JUMP); +InjectHook(0x57AA30, &cAudioManager::GetCDAudioDriveLetter, PATCH_JUMP); +InjectHook(0x573010, &cAudioManager::GetChinatownFemaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x5730F0, &cAudioManager::GetChinatownFemaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x572E10, &cAudioManager::GetChinatownMaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x572F10, &cAudioManager::GetChinatownMaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x575120, &cAudioManager::GetChunkyTalkSfx, PATCH_JUMP); +InjectHook(0x571B00, &cAudioManager::GetColumbianTalkSfx, PATCH_JUMP); +InjectHook(0x570EA0, &cAudioManager::GetCopTalkSfx, PATCH_JUMP); +InjectHook(0x57A8F0, &cAudioManager::GetCurrent3DProviderIndex, PATCH_JUMP); +InjectHook(0x569060, &cAudioManager::GetCollisionOneShotRatio, PATCH_JUMP); +InjectHook(0x5693B0, &cAudioManager::GetCollisionRatio, PATCH_JUMP); +InjectHook(0x571770, &cAudioManager::GetDiabloTalkSfx, PATCH_JUMP); +InjectHook(0x569750, &cAudioManager::GetDistanceSquared, PATCH_JUMP); InjectHook(0x574DA0, &cAudioManager::GetEightTalkSfx, PATCH_JUMP); +InjectHook(0x574040, &cAudioManager::GetFanFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573F60, &cAudioManager::GetFanMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571040, &cAudioManager::GetFBITalkSfx, PATCH_JUMP); +InjectHook(0x572280, &cAudioManager::GetFemaleNo3TalkSfx, PATCH_JUMP); +InjectHook(0x5712B0, &cAudioManager::GetFiremanTalkSfx, PATCH_JUMP); InjectHook(0x574E50, &cAudioManager::GetFrankieTalkSfx, PATCH_JUMP); +InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571C30, &cAudioManager::GetHoodTalkSfx, PATCH_JUMP); +InjectHook(0x5741F0, &cAudioManager::GetHospitalFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574120, &cAudioManager::GetHospitalMaleTalkSfx, PATCH_JUMP); +InjectHook(0x56F410, &cAudioManager::GetJumboTaxiFreq, PATCH_JUMP); +InjectHook(0x573310, &cAudioManager::GetLittleItalyFemaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x573400, &cAudioManager::GetLittleItalyFemaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x5731E0, &cAudioManager::GetLittleItalyMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571510, &cAudioManager::GetMafiaTalkSfx, PATCH_JUMP); +InjectHook(0x571F40, &cAudioManager::GetMaleNo2TalkSfx, PATCH_JUMP); +InjectHook(0x5711C0, &cAudioManager::GetMedicTalkSfx, PATCH_JUMP); +InjectHook(0x5795D0, &cAudioManager::GetMissionAudioLoadingStatus, PATCH_JUMP); +InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); InjectHook(0x574F00, &cAudioManager::GetMistyTalkSfx, PATCH_JUMP); +InjectHook(0x575340, &cAudioManager::GetNormalMaleTalkSfx, PATCH_JUMP); +InjectHook(0x57A8A0, &cAudioManager::GetNum3DProvidersAvailable, PATCH_JUMP); InjectHook(0x574FD0, &cAudioManager::GetOJGTalkSfx, PATCH_JUMP); -InjectHook(0x574FE0, &cAudioManager::GetCatatalinaTalkSfx, PATCH_JUMP); -InjectHook(0x574FF0, &cAudioManager::GetBomberTalkSfx, PATCH_JUMP); +InjectHook(0x570960, &cAudioManager::GetPedCommentSfx, PATCH_JUMP); +InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP); +InjectHook(0x575240, &cAudioManager::GetPimpTalkSfx, PATCH_JUMP); +InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP); +InjectHook(0x5737E0, &cAudioManager::GetScumFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5736D0, &cAudioManager::GetScumMaleTalkSfx, PATCH_JUMP); InjectHook(0x575060, &cAudioManager::GetSecurityGuardTalkSfx, PATCH_JUMP); -InjectHook(0x575120, &cAudioManager::GetChunkyTalkSfx, PATCH_JUMP); - -InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP); -InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); - -// Process stuff +InjectHook(0x574480, &cAudioManager::GetShopperFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574790, &cAudioManager::GetSpecialCharacterTalkSfx, PATCH_JUMP); +InjectHook(0x573E90, &cAudioManager::GetStewardFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573DC0, &cAudioManager::GetStewardMaleTalkSfx, PATCH_JUMP); +InjectHook(0x574690, &cAudioManager::GetStudentFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574590, &cAudioManager::GetStudentMaleTalkSfx, PATCH_JUMP); +InjectHook(0x573CD0, &cAudioManager::GetSupermodelFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573BD0, &cAudioManager::GetSupermodelMaleTalkSfx, PATCH_JUMP); +InjectHook(0x570F80, &cAudioManager::GetSwatTalkSfx, PATCH_JUMP); +InjectHook(0x575190, &cAudioManager::GetTaxiDriverTalkSfx, PATCH_JUMP); +InjectHook(0x571650, &cAudioManager::GetTriadTalkSfx, PATCH_JUMP); +InjectHook(0x5723A0, &cAudioManager::GetWhiteBusinessFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x572170, &cAudioManager::GetWhiteCasualFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574290, &cAudioManager::GetWhiteConstructionWorkerTalkSfx, PATCH_JUMP); +InjectHook(0x571E60, &cAudioManager::GetWhiteCriminalTalkSfx, PATCH_JUMP); +InjectHook(0x5734F0, &cAudioManager::GetWhiteDockerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5727B0, &cAudioManager::GetWhiteFatFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5725D0, &cAudioManager::GetWhiteFatMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5729D0, &cAudioManager::GetWhiteFemaleProstituteTalkSfx, PATCH_JUMP); +InjectHook(0x5738D0, &cAudioManager::GetWhiteWorkerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5718D0, &cAudioManager::GetYakuzaTalkSfx, PATCH_JUMP); +InjectHook(0x5719E0, &cAudioManager::GetYardieTalkSfx, PATCH_JUMP); +InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP); +InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); +// InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); +InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP); +InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP); +InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP); +InjectHook(0x57A9C0, &cAudioManager::IsMP3RadioChannelAvailable, PATCH_JUMP); +InjectHook(0x579520, &cAudioManager::MissionScriptAudioUsesPoliceChannel, PATCH_JUMP); +InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP); +InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP); +InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP); +InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); +InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP); +InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP); +InjectHook(0x569570, &cAudioManager::PreTerminateGameSpecificShutdown, PATCH_JUMP); // InjectHook(0x57BA60, &cAudioManager::ProcessActiveQueues, PATCH_JUMP); InjectHook(0x56C940, &cAudioManager::ProcessAirBrakes, PATCH_JUMP); InjectHook(0x577B30, &cAudioManager::ProcessAirportScriptObject, PATCH_JUMP); @@ -8515,6 +8426,34 @@ InjectHook(0x56DBF0, &cAudioManager::ProcessTrainNoise, PATCH_JUMP); InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP); InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP); InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP); +InjectHook(0x578370, &cAudioManager::ProcessWeather, PATCH_JUMP); +InjectHook(0x56A440, &cAudioManager::ProcessWetRoadNoise, PATCH_JUMP); InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP); +InjectHook(0x57AF90, &cAudioManager::RandomDisplacement, PATCH_JUMP); +InjectHook(0x57A9F0, &cAudioManager::ReacquireDigitalHandle, PATCH_JUMP); +InjectHook(0x57A9E0, &cAudioManager::ReleaseDigitalHandle, PATCH_JUMP); +InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); +InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP); +InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP); +InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP); +InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP); +InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP); +InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP); +InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP); +InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP); +InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP); +InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, PATCH_JUMP); +InjectHook(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP); +InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP); +InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, PATCH_JUMP); +InjectHook(0x56F070, &cAudioManager::SetupJumboWhineSound, PATCH_JUMP); InjectHook(0x570690, &cAudioManager::SetupPedComments, PATCH_JUMP); +InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); +InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP); +InjectHook(0x56AC80, &cAudioManager::UpdateGasPedalAudio, PATCH_JUMP); +InjectHook(0x56C600, &cAudioManager::UsesReverseWarning, PATCH_JUMP); +InjectHook(0x56C3C0, &cAudioManager::UsesSiren, PATCH_JUMP); +InjectHook(0x56C3F0, &cAudioManager::UsesSirenSwitching, PATCH_JUMP); +InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); +InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); ENDPATCHES diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 5ad14050..c765bfd4 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -49,8 +49,8 @@ public: uint8 field_89; uint8 field_90; uint8 field_91; - - // no methods + + // no methods }; static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); @@ -88,8 +88,8 @@ public: float m_afVolume[4]; uint8 m_Loops; uint8 field_25[3]; - - // no methods + + // no methods }; static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); @@ -104,8 +104,8 @@ public: uint8 m_bVolume; int8 field_25; // allocated time? uint8 gap_26[2]; - - // no methods + + // no methods }; static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); @@ -119,7 +119,7 @@ public: uint8 activeBank; uint8 gap_1163[1]; - // reversed all methods + // reversed all methods void Add(tPedComment *com); /// ok void Process(); /// ok }; @@ -142,8 +142,8 @@ public: CVector m_vecPosition; float m_fDistance; int32 m_nBaseVolume; - - // no methods + + // no methods }; static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); @@ -157,6 +157,8 @@ public: uint8 m_bCollisionsInQueue; uint8 gap_811; cAudioCollision m_sQueue; + + void AddCollisionToRequestedQueue(); // todo }; static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); @@ -177,6 +179,7 @@ public: uint8 field_29; uint8 field_30; uint8 field_31; + // no methods }; static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); @@ -188,7 +191,8 @@ class CPed; class cPedParams; class cTransmission; -class cAudioScriptObject { +class cAudioScriptObject +{ public: int16 AudioId; char _pad0[2]; @@ -220,22 +224,14 @@ enum { MAX_REFLECTIONS, }; -<<<<<<< HEAD -enum AudioEntityHandle -{ - AEHANDLE_NONE = -5, - AEHANDLE_ERROR_NOAUDIOSYS = -4, - AEHANDLE_ERROR_NOFREESLOT = -3, - AEHANDLE_ERROR_NOENTITY = -2, +enum AudioEntityHandle { + AEHANDLE_NONE = -5, + AEHANDLE_ERROR_NOAUDIOSYS = -4, + AEHANDLE_ERROR_NOFREESLOT = -3, + AEHANDLE_ERROR_NOENTITY = -2, AEHANDLE_ERROR_BADAUDIOTYPE = -1, }; -#define AEHANDLE_IS_FAILED(h) ((h)<0) -#define AEHANDLE_IS_OK(h) ((h)>=0) - - -======= ->>>>>>> Cleanup class cAudioManager { public: @@ -285,22 +281,10 @@ public: uint8 field_19195; // time? uint32 m_FrameCounter; -<<<<<<< HEAD - inline uint32 GetFrameCounter(void) { return m_FrameCounter; } - float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; } -<<<<<<< HEAD - int32 GetRandomNumber(int32 idx) { return m_anRandomTable[idx]; } -======= - int32 GetRandomTabe(int32 idx) { return m_anRandomTable[idx]; } - ->>>>>>> Cleanup - // -======= // getters uint32 GetFrameCounter() const { return m_FrameCounter; } float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } - int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } ->>>>>>> More more more audio + int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); /// ok @@ -312,80 +296,22 @@ public: void AgeCrimes(); // todo void CalculateDistance(bool *ptr, float dist); /// ok - bool CheckForAnAudioFileOnCD() const; /// ok + bool CheckForAnAudioFileOnCD() const; /// ok void ClearMissionAudio(); /// ok void ClearRequestedQueue(); /// ok int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; /// ok - int32 ComputePan(float, CVector *); // todo -<<<<<<< HEAD - uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok - int32 CreateEntity(int32 type, void *entity); /// ok -======= + float speedMultiplier) const; /// ok + int32 ComputePan(float, CVector *); // todo uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok - int32 CreateEntity(int32 type, CPhysical *entity); /// ok ->>>>>>> More more more audio + int32 CreateEntity(int32 type, CPhysical *entity); /// ok void DestroyAllGameCreatedEntities(); /// ok void DestroyEntity(int32 id); /// ok + void DoJumboVolOffset() const; /// ok void DoPoliceRadioCrackle(); /// ok - void GenerateIntegerRandomNumberTable(); /// ok - - void TranslateEntity(CVector *v1, CVector *v2) const ; /// ok - - void ResetAudioLogicTimers(int32 timer); /// ok - - void Terminate(); - uint8 GetNum3DProvidersAvailable() const; - bool IsMP3RadioChannelAvailable() const; - uint8 GetCDAudioDriveLetter() const; - - void SetEffectsMasterVolume(uint8 volume) const; - void SetMusicMasterVolume(uint8 volume) const; - void SetEffectsFadeVolume(uint8 volume) const; - void SetMusicFadeVolume(uint8 volume) const; - - void SetSpeakerConfig(int32 conf) const; - - bool SetupJumboEngineSound(uint8, int32); // todo - void PreInitialiseGameSpecificSetup() const; - void SetMissionScriptPoliceAudio(int32 sfx) const; - - bool UsesSiren(int32 model) const; - bool UsesSirenSwitching(int32 model) const; - - char *Get3DProviderName(uint8 id) const; - - bool SetupJumboFlySound(uint8 emittingVol); /// ok - bool SetupJumboRumbleSound(uint8 emittingVol); /// ok - bool SetupJumboTaxiSound(uint8 vol); /// ok - bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok - - void SetMissionAudioLocation(float x, float y, float z); - - void ResetPoliceRadio(); - - bool UsesReverseWarning(int32 model) const; - - int32 RandomDisplacement(uint32 seed) const; - - void ReleaseDigitalHandle() const; - void ReacquireDigitalHandle() const; - void SetDynamicAcousticModelingStatus(bool status); - - bool IsAudioInitialised() const; - - void SetEntityStatus(int32 id, bool status); - - void Service(); - void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; - - void DoJumboVolOffset() const; - - int32 GetPedCommentSfx(CPed *ped, int32 sound); - - // order from GetPedCommentSfx + // functions returning talk sfx, + // order from GetPedCommentSfx uint32 GetPlayerTalkSfx(int16 sound); uint32 GetCopTalkSfx(int16 sound); uint32 GetSwatTalkSfx(int16 sound); @@ -462,15 +388,22 @@ public: uint32 GetGenericMaleTalkSfx(int16 sound); uint32 GetGenericFemaleTalkSfx(int16 sound); + // end of functions returning talk sfx + void GenerateIntegerRandomNumberTable(); /// ok + char *Get3DProviderName(uint8 id) const; + uint8 GetCDAudioDriveLetter() const; int8 GetCurrent3DProviderIndex() const; /// ok - float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // todo hook - float GetCollisionOneShotRatio(uint32 a, float b) const; // todo hook - float GetCollisionRatio(float a, float b, float c, float d) const; // todo hook + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used + float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok + float GetCollisionRatio(float a, float b, float c, float d) const; /// ok float GetDistanceSquared(CVector *v) const; /// ok int32 GetJumboTaxiFreq() const; /// ok bool GetMissionAudioLoadingStatus() const; /// ok char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok + uint8 GetNum3DProvidersAvailable() const; + int32 GetPedCommentSfx(CPed *ped, int32 sound); + void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, float a4); // todo int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo @@ -481,19 +414,22 @@ public: void InitialisePoliceRadio(); // todo void InitialisePoliceRadioZones(); // todo void InterrogateAudioEntities(); /// ok + bool IsAudioInitialised() const; /// ok bool IsMissionAudioSampleFinished(); /// ok + bool IsMP3RadioChannelAvailable() const; bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok void PlayLoadedMissionAudio(); /// ok void PlayOneShot(int32 index, int16 sound, float vol); // todo - uint32 PlaySuspectLastSeen(float x, float y, float z); // todo - void PlayerJustGotInCar() const; /// ok - void PlayerJustLeftCar() const; /// ok + uint32 PlaySuspectLastSeen(float x, float y, float z); // todo + void PlayerJustGotInCar() const; /// ok + void PlayerJustLeftCar() const; /// ok void PostInitialiseGameSpecificSetup(); /// ok void PostTerminateGameSpecificShutdown(); /// ok - void PreTerminateGameSpecificShutdown(); /// ok - void PreloadMissionAudio(char *); // todo + void PreInitialiseGameSpecificSetup() const; + void PreloadMissionAudio(char *); // todo + void PreTerminateGameSpecificShutdown(); /// ok /// processX - main logic of adding new sounds void ProcessActiveQueues(); // todo bool ProcessAirBrakes(cVehicleParams *params); /// ok @@ -541,7 +477,7 @@ public: void ProcessPornCinema(uint8 sound); /// ok void ProcessProjectiles(); // todo requires CProjectileInfo void ProcessRainOnVehicle(cVehicleParams *params); /// ok - void ProcessReverb() const; /// ok + void ProcessReverb() const; /// ok bool ProcessReverseGear(cVehicleParams *a2); /// ok void ProcessSawMillScriptObject(uint8 sound); /// ok void ProcessScriptObject(int32 id); /// ok @@ -558,11 +494,55 @@ public: // void ProcessVehicleSirenOrAlarm(void *); // void ProcessVehicleSkidding(void *); void ProcessWaterCannon(int32); // todo - void ProcessWeather(int32 id); // todo - bool ProcessWetRoadNoise(cVehicleParams *params); // todo hook + void ProcessWeather(int32 id); /// ok + bool ProcessWetRoadNoise(cVehicleParams *params); /// ok void ProcessWorkShopScriptObject(uint8 sound); /// ok - void SetupPedComments(cPedParams *params, uint32 sound); /// ok + int32 RandomDisplacement(uint32 seed) const; + void ReacquireDigitalHandle() const; + void ReleaseDigitalHandle() const; + int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, + float a7); // todo + int32 ReportCrime(int a2, int *a3); // todo + void ResetAudioLogicTimers(int32 timer); /// ok + void ResetPoliceRadio(); + void ResetTimers(unsigned int a2); // todo + + void Service(); // todo + void ServiceCollisions(); // todo + void ServicePoliceRadio(); // todo + void ServicePoliceRadioChannel(int a2); // todo + void ServiceSoundEffects(); // todo + void SetCurrent3DProvider(uint8); + void SetDynamicAcousticModelingStatus(bool status); + void SetEffectsFadeVolume(uint8 volume) const; + void SetEffectsMasterVolume(uint8 volume) const; + void SetEntityStatus(int32 id, bool status); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo + void SetMissionAudioLocation(float x, float y, float z); + void SetMissionScriptPoliceAudio(int32 sfx) const; + void SetMonoMode(uint8); // todo + void SetMusicFadeVolume(uint8 volume) const; + void SetMusicMasterVolume(uint8 volume) const; + void SetSpeakerConfig(int32 conf) const; + void SetUpLoopingCollisionSound(int a2, int a3); // todo + void SetUpOneShotCollisionSound(int a2); // todo + void SetupCrimeReport(); // todo + bool SetupJumboEngineSound(uint8, int32); // todo + bool SetupJumboFlySound(uint8 emittingVol); /// ok + bool SetupJumboRumbleSound(uint8 emittingVol); /// ok + bool SetupJumboTaxiSound(uint8 vol); /// ok + bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok + void SetupPedComments(cPedParams *params, uint32 sound); /// ok + void SetupSuspectLastSeenReport(); // todo + + void Terminate(); + void TranslateEntity(CVector *v1, CVector *v2) const; /// ok + + void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook + bool UsesReverseWarning(int32 model) const; + bool UsesSiren(int32 model) const; + bool UsesSirenSwitching(int32 model) const; }; static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); diff --git a/src/audio/AudioManager.h.autosave b/src/audio/AudioManager.h.autosave new file mode 100644 index 00000000..2ea78476 --- /dev/null +++ b/src/audio/AudioManager.h.autosave @@ -0,0 +1,549 @@ +#pragma once + +#include "AudioSamples.h" +#include "DMAudio.h" +#include "common.h" + +class tActiveSample +{ +public: + int32 m_nEntityIndex; + int32 m_counter; + int32 m_nSampleIndex; + uint8 m_bBankIndex; + uint8 m_bIsDistant; + uint8 field_14; + uint8 field_15; + int32 field_16; + int32 m_nFrequency; + uint8 m_bVolume; + uint8 field_25; + uint8 field_26; + uint8 field_27; + float m_fDistance; + int32 m_nLoopCount; + int32 m_nLoopStart; + int32 m_nLoopEnd; + uint8 m_bEmittingVolume; + uint8 field_45; + uint8 field_46; + uint8 field_47; + float field_48; + float m_fSoundIntensity; + uint8 field_56; + uint8 field_57; + uint8 field_58; + uint8 field_59; + CVector m_vecPos; + uint8 m_bReverbFlag; + uint8 m_bLoopsRemaining; + uint8 m_bRequireReflection; + uint8 m_bOffset; + int32 field_76; + uint8 m_bIsProcessed; + uint8 m_bLoopEnded; + uint8 field_82; + uint8 field_83; + int32 calculatedVolume; + uint8 field_88; + uint8 field_89; + uint8 field_90; + uint8 field_91; + + // no methods +}; + +static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); + +enum eAudioType : int32 { + AUDIOTYPE_PHYSICAL = 0, + AUDIOTYPE_EXPLOSION = 1, + AUDIOTYPE_FIRE = 2, + AUDIOTYPE_WEATHER = 3, + AUDIOTYPE_CRANE = 4, + AUDIOTYPE_SCRIPTOBJECT = 5, + AUDIOTYPE_BRIDGE = 6, + AUDIOTYPE_COLLISION = 7, + AUDIOTYPE_FRONTEND = 8, + AUDIOTYPE_PROJECTILE = 9, + AUDIOTYPE_GARAGE = 10, + AUDIOTYPE_FIREHYDRANT = 11, + AUDIOTYPE_WATERCANNON = 12, + AUDIOTYPE_POLICERADIO = 13, + TOTAL_AUDIO_TYPES = 14, +}; + +class CPhysical; +class CAutomobile; + +class tAudioEntity +{ +public: + eAudioType m_nType; + void *m_pEntity; + bool m_bIsUsed; + uint8 m_bStatus; + int16 m_awAudioEvent[4]; + uint8 gap_18[2]; + float m_afVolume[4]; + uint8 m_Loops; + uint8 field_25[3]; + + // no methods +}; + +static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); + +class tPedComment +{ +public: + int32 m_nSampleIndex; + int32 m_entityIndex; + CVector m_vecPos; + float m_fDistance; + uint8 m_bVolume; + int8 field_25; // allocated time? + uint8 gap_26[2]; + + // no methods +}; + +static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); + +class cPedComments +{ +public: + tPedComment m_asPedComments[2][20]; + uint8 indexMap[2][20]; + uint8 nrOfCommentsInBank[2]; + uint8 activeBank; + uint8 gap_1163[1]; + + // reversed all methods + void Add(tPedComment *com); /// ok + void Process(); /// ok +}; + +static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); + +class CEntity; + +class cAudioCollision +{ +public: + CEntity *m_pEntity1; + CEntity *m_pEntity2; + uint8 m_bSurface1; + uint8 m_bSurface2; + uint8 field_10; + uint8 field_11; + float m_fIntensity1; + float m_fIntensity2; + CVector m_vecPosition; + float m_fDistance; + int32 m_nBaseVolume; + + // no methods +}; + +static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); + +class cAudioCollisionManager +{ +public: + cAudioCollision m_asCollisions1[10]; + cAudioCollision m_asCollisions2[10]; + uint8 m_bIndicesTable[10]; + uint8 m_bCollisionsInQueue; + uint8 gap_811; + cAudioCollision m_sQueue; + + void AddCollisionToRequestedQueue(); // todo +}; + +static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); + +class cMissionAudio +{ +public: + CVector m_vecPos; + uint8 field_12; + uint8 gap_13[3]; + int m_nSampleIndex; + uint8 m_bLoadingStatus; + uint8 m_bPlayStatus; + uint8 field_22; + uint8 field_23; + int field_24; + bool m_bIsPlayed; + uint8 field_29; + uint8 field_30; + uint8 field_31; + // no methods +}; + +static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); + +class cVehicleParams; +class CPlane; +class CVehicle; +class CPed; +class cPedParams; +class cTransmission; + +class cAudioScriptObject { +public: + int16 AudioId; + char _pad0[2]; + CVector Posn; + int32 AudioEntity; + + static void *operator new(size_t); + static void *operator new(size_t, int); + static void operator delete(void *, size_t); + static void operator delete(void *, int); +}; + +static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error"); + +enum { + /* + REFLECTION_YMAX = 0, top + REFLECTION_YMIN = 1, bottom + REFLECTION_XMIN = 2, left + REFLECTION_XMAX = 3, right + REFLECTION_ZMAX = 4, + */ + + REFLECTION_TOP = 0, + REFLECTION_BOTTOM, + REFLECTION_LEFT, + REFLECTION_RIGHT, + REFLECTION_UP, + MAX_REFLECTIONS, +}; + +enum AudioEntityHandle +{ + AEHANDLE_NONE = -5, + AEHANDLE_ERROR_NOAUDIOSYS = -4, + AEHANDLE_ERROR_NOFREESLOT = -3, + AEHANDLE_ERROR_NOENTITY = -2, + AEHANDLE_ERROR_BADAUDIOTYPE = -1, +}; + +class cAudioManager +{ +public: + bool m_bIsInitialised; + uint8 field_1; + uint8 field_2; + uint8 m_bActiveSamples; + uint8 field_4; + bool m_bDynamicAcousticModelingStatus; + uint8 field_6; + uint8 field_7; + float speedOfSound; + bool m_bTimerJustReset; + uint8 field_13; + uint8 field_14; + uint8 field_15; + int32 m_nTimer; + tActiveSample m_sQueueSample; + uint8 m_bActiveSampleQueue; + uint8 gap_109[3]; + tActiveSample m_asSamples[2][27]; + uint8 m_abSampleQueueIndexTable[2][27]; + uint8 m_bSampleRequestQueuesStatus[2]; + tActiveSample m_asActiveSamples[27]; + tAudioEntity m_asAudioEntities[200]; + int32 m_anAudioEntityIndices[200]; + int32 m_nAudioEntitiesTotal; + CVector m_avecReflectionsPos[5]; + float m_afReflectionsDistances[5]; + int32 m_anScriptObjectEntityIndices[40]; + int32 m_nScriptObjectEntityTotal; + cPedComments m_sPedComments; + int32 m_nFireAudioEntity; + int32 m_nWaterCannonEntity; + int32 m_nPoliceChannelEntity; + uint8 gap45B8[444]; + int32 m_nFrontEndEntity; + int32 m_nCollisionEntity; + cAudioCollisionManager m_sCollisionManager; + int32 m_nProjectileEntity; + int32 m_nBridgeEntity; + cMissionAudio m_sMissionAudio; + int32 m_anRandomTable[5]; + uint8 field_19192; + uint8 m_bUserPause; + uint8 m_bPreviousUserPause; + uint8 field_19195; // time? + uint32 m_FrameCounter; + + // getters + uint32 GetFrameCounter() const { return m_FrameCounter; } + float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } + int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } + + // "Should" be in alphabetic order, except "getXTalkSfx" + void AddDetailsToRequestedOrderList(uint8 sample); /// ok + void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, + uint8 counter, bool notLooping); /// ok + void AddReflectionsToRequestedQueue(); /// ok (check value) + void AddReleasingSounds(); // todo (difficult) + void AddSampleToRequestedQueue(); /// ok + void AgeCrimes(); // todo + + void CalculateDistance(bool *ptr, float dist); /// ok + bool CheckForAnAudioFileOnCD() const; /// ok + void ClearMissionAudio(); /// ok + void ClearRequestedQueue(); /// ok + int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, + float speedMultiplier) const; /// ok + int32 ComputePan(float, CVector *); // todo + uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok + int32 CreateEntity(int32 type, CPhysical *entity); /// ok + + void DestroyAllGameCreatedEntities(); /// ok + void DestroyEntity(int32 id); /// ok + void DoJumboVolOffset() const; /// ok + void DoPoliceRadioCrackle(); /// ok + + // functions returning talk sfx, + // order from GetPedCommentSfx + uint32 GetPlayerTalkSfx(int16 sound); + uint32 GetCopTalkSfx(int16 sound); + uint32 GetSwatTalkSfx(int16 sound); + uint32 GetFBITalkSfx(int16 sound); + uint32 GetArmyTalkSfx(int16 sound); + uint32 GetMedicTalkSfx(int16 sound); + uint32 GetFiremanTalkSfx(int16 sound); + uint32 GetNormalMaleTalkSfx(int16 sound); + uint32 GetTaxiDriverTalkSfx(int16 sound); + uint32 GetPimpTalkSfx(int16 sound); + uint32 GetMafiaTalkSfx(int16 sound); + uint32 GetTriadTalkSfx(int16 sound); + uint32 GetDiabloTalkSfx(int16 sound); + uint32 GetYakuzaTalkSfx(int16 sound); + uint32 GetYardieTalkSfx(int16 sound); + uint32 GetColumbianTalkSfx(int16 sound); + uint32 GetHoodTalkSfx(int16 sound); + uint32 GetBlackCriminalTalkSfx(int16 sound); + uint32 GetWhiteCriminalTalkSfx(int16 sound); + uint32 GetMaleNo2TalkSfx(int16 sound); + uint32 GetBlackProjectMaleTalkSfx(int16 sound, int32 model); + uint32 GetWhiteFatMaleTalkSfx(int16 sound); + uint32 GetBlackFatMaleTalkSfx(int16 sound); + uint32 GetBlackCasualFemaleTalkSfx(int16 sound); + uint32 GetWhiteCasualFemaleTalkSfx(int16 sound); + uint32 GetFemaleNo3TalkSfx(int16 sound); + uint32 GetBlackFatFemaleTalkSfx(int16 sound); + uint32 GetWhiteFatFemaleTalkSfx(int16 sound); + uint32 GetBlackFemaleProstituteTalkSfx(int16 sound); + uint32 GetWhiteFemaleProstituteTalkSfx(int16 sound); + uint32 GetBlackProjectFemaleOldTalkSfx(int16 sound); + uint32 GetBlackProjectFemaleYoungTalkSfx(int16 sound); + uint32 GetChinatownMaleOldTalkSfx(int16 sound); + uint32 GetChinatownMaleYoungTalkSfx(int16 sound); + uint32 GetChinatownFemaleOldTalkSfx(int16 sound); + uint32 GetChinatownFemaleYoungTalkSfx(int16 sound); + uint32 GetLittleItalyMaleTalkSfx(int16 sound); + uint32 GetLittleItalyFemaleOldTalkSfx(int16 sound); + uint32 GetLittleItalyFemaleYoungTalkSfx(int16 sound); + uint32 GetWhiteDockerMaleTalkSfx(int16 sound); + uint32 GetBlackDockerMaleTalkSfx(int16 sound); + uint32 GetScumMaleTalkSfx(int16 sound); + uint32 GetScumFemaleTalkSfx(int16 sound); + uint32 GetWhiteWorkerMaleTalkSfx(int16 sound); + uint32 GetBlackWorkerMaleTalkSfx(int16 sound); + uint32 GetBusinessMaleYoungTalkSfx(int16 sound, int32 model); + uint32 GetBusinessMaleOldTalkSfx(int16 sound); + uint32 GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model); + uint32 GetBlackBusinessFemaleTalkSfx(int16 sound); + uint32 GetSupermodelMaleTalkSfx(int16 sound); + uint32 GetSupermodelFemaleTalkSfx(int16 sound); + uint32 GetStewardMaleTalkSfx(int16 sound); + uint32 GetStewardFemaleTalkSfx(int16 sound); + uint32 GetFanMaleTalkSfx(int16 sound, int32 model); + uint32 GetFanFemaleTalkSfx(int16 sound); + uint32 GetHospitalMaleTalkSfx(int16 sound); + uint32 GetHospitalFemaleTalkSfx(int16 sound); + uint32 GetWhiteConstructionWorkerTalkSfx(int16 sound); + uint32 GetBlackConstructionWorkerTalkSfx(int16 sound); + uint32 GetShopperFemaleTalkSfx(int16 sound, int32 model); + uint32 GetStudentMaleTalkSfx(int16 sound); + uint32 GetStudentFemaleTalkSfx(int16 sound); + uint32 GetCasualMaleOldTalkSfx(int16 sound); + + uint32 GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound); + uint32 GetEightTalkSfx(int16 sound); + uint32 GetFrankieTalkSfx(int16 sound); + uint32 GetMistyTalkSfx(int16 sound); + uint32 GetOJGTalkSfx(int16 sound); + uint32 GetCatatalinaTalkSfx(int16 sound); + uint32 GetBomberTalkSfx(int16 sound); + uint32 GetSecurityGuardTalkSfx(int16 sound); + uint32 GetChunkyTalkSfx(int16 sound); + + uint32 GetGenericMaleTalkSfx(int16 sound); + uint32 GetGenericFemaleTalkSfx(int16 sound); + // end of functions returning talk sfx + + void GenerateIntegerRandomNumberTable(); /// ok + char *Get3DProviderName(uint8 id) const; + uint8 GetCDAudioDriveLetter() const; + int8 GetCurrent3DProviderIndex() const; /// ok + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used + float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok + float GetCollisionRatio(float a, float b, float c, float d) const; /// ok + float GetDistanceSquared(CVector *v) const; /// ok + int32 GetJumboTaxiFreq() const; /// ok + bool GetMissionAudioLoadingStatus() const; /// ok + char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok + uint8 GetNum3DProvidersAvailable() const; + int32 GetPedCommentSfx(CPed *ped, int32 sound); + void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; + float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, + float a4); // todo + int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo + + bool HasAirBrakes(int32 model) const; /// ok + + void Initialise(); /// ok + void InitialisePoliceRadio(); // todo + void InitialisePoliceRadioZones(); // todo + void InterrogateAudioEntities(); /// ok + bool IsAudioInitialised() const; /// ok + bool IsMissionAudioSampleFinished(); /// ok + bool IsMP3RadioChannelAvailable() const; + + bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok + + void PlayLoadedMissionAudio(); /// ok + void PlayOneShot(int32 index, int16 sound, float vol); // todo + uint32 PlaySuspectLastSeen(float x, float y, float z); // todo + void PlayerJustGotInCar() const; /// ok + void PlayerJustLeftCar() const; /// ok + void PostInitialiseGameSpecificSetup(); /// ok + void PostTerminateGameSpecificShutdown(); /// ok + void PreInitialiseGameSpecificSetup() const; + void PreloadMissionAudio(char *); // todo + void PreTerminateGameSpecificShutdown(); /// ok + /// processX - main logic of adding new sounds + void ProcessActiveQueues(); // todo + bool ProcessAirBrakes(cVehicleParams *params); /// ok + void ProcessAirportScriptObject(uint8 sound); /// ok + bool ProcessBoatEngine(cVehicleParams *params); /// ok + bool ProcessBoatMovingOverWater(cVehicleParams *params); /// ok + void ProcessBridge(); /// ok + void ProcessBridgeMotor(); /// ok + void ProcessBridgeOneShots(); /// ok + void ProcessBridgeWarning(); /// ok + bool ProcessCarBombTick(cVehicleParams *params); /// ok + void ProcessCesna(void *); // todo requires CPlane + void ProcessCinemaScriptObject(uint8 sound); /// ok + void ProcessCrane(); // todo requires CCrane + void ProcessDocksScriptObject(uint8 sound); /// ok + bool ProcessEngineDamage(cVehicleParams *params); /// ok + void ProcessEntity(int32 sound); /// ok + void ProcessExplosions(int32 explosion); /// ok + void ProcessFireHydrant(); /// ok + void ProcessFires(int32 entity); // todo requires gFireManager + void ProcessFrontEnd(); /// ok + void ProcessGarages(); // todo requires CGarages::aGarages + bool ProcessHelicopter(cVehicleParams *params); /// ok + void ProcessHomeScriptObject(uint8 sound); /// ok + void ProcessJumbo(cVehicleParams *); /// ok + void ProcessJumboAccel(CPlane *plane); /// ok + void ProcessJumboDecel(CPlane *plane); /// ok + void ProcessJumboFlying(); /// ok + void ProcessJumboLanding(CPlane *plane); /// ok + void ProcessJumboTakeOff(CPlane *plane); /// ok + void ProcessJumboTaxi(); /// ok + void ProcessLaunderetteScriptObject(uint8 sound); /// ok + void ProcessLoopingScriptObject(uint8 sound); /// ok + void ProcessMissionAudio(); /// ok + void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons) + void ProcessOneShotScriptObject(uint8 sound); /// ok + void ProcessPed(CPhysical *ped); /// ok + void ProcessPedHeadphones(cPedParams *params); /// ok + void ProcessPedOneShots(cPedParams *params); // todo later (weird) + void ProcessPhysical(int32 id); /// ok + void ProcessPlane(cVehicleParams *params); /// ok + void ProcessPlayersVehicleEngine(cVehicleParams *params, + CAutomobile *automobile); /// ok (check float comparisons) + void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo + void ProcessPornCinema(uint8 sound); /// ok + void ProcessProjectiles(); // todo requires CProjectileInfo + void ProcessRainOnVehicle(cVehicleParams *params); /// ok + void ProcessReverb() const; /// ok + bool ProcessReverseGear(cVehicleParams *a2); /// ok + void ProcessSawMillScriptObject(uint8 sound); /// ok + void ProcessScriptObject(int32 id); /// ok + void ProcessShopScriptObject(uint8 sound); /// ok + void ProcessSpecial(); /// ok + bool ProcessTrainNoise(cVehicleParams *params); /// ok + void ProcessVehicle(CVehicle *); // todo + bool ProcessVehicleDoors(cVehicleParams *params); /// ok + // bool ProcessVehicleEngine(void *); + // void ProcessVehicleHorn(cVehicleParams *params); + // void ProcessVehicleOneShots(void *); + bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok + bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok + // void ProcessVehicleSirenOrAlarm(void *); + // void ProcessVehicleSkidding(void *); + void ProcessWaterCannon(int32); // todo + void ProcessWeather(int32 id); /// ok + bool ProcessWetRoadNoise(cVehicleParams *params); /// ok + void ProcessWorkShopScriptObject(uint8 sound); /// ok + + int32 RandomDisplacement(uint32 seed) const; + void ReacquireDigitalHandle() const; + void ReleaseDigitalHandle() const; + int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, + float a7); // todo + int32 ReportCrime(int a2, int *a3); // todo + void ResetAudioLogicTimers(int32 timer); /// ok + void ResetPoliceRadio(); + void ResetTimers(unsigned int a2); // todo + + void Service(); // todo + void ServiceCollisions(); // todo + void ServicePoliceRadio(); // todo + void ServicePoliceRadioChannel(int a2); // todo + void ServiceSoundEffects(); // todo + void SetDynamicAcousticModelingStatus(bool status); + void SetEffectsFadeVolume(uint8 volume) const; + void SetEffectsMasterVolume(uint8 volume) const; + void SetEntityStatus(int32 id, bool status); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo + void SetMissionAudioLocation(float x, float y, float z); + void SetMissionScriptPoliceAudio(int32 sfx) const; + void SetMonoMode(uint8); // todo + void SetMusicFadeVolume(uint8 volume) const; + void SetMusicMasterVolume(uint8 volume) const; + void SetSpeakerConfig(int32 conf) const; + void SetUpLoopingCollisionSound(int a2, int a3); // todo + void SetUpOneShotCollisionSound(int a2); // todo + void SetupCrimeReport(); // todo + bool SetupJumboEngineSound(uint8, int32); // todo + bool SetupJumboFlySound(uint8 emittingVol); /// ok + bool SetupJumboRumbleSound(uint8 emittingVol); /// ok + bool SetupJumboTaxiSound(uint8 vol); /// ok + bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok + void SetupPedComments(cPedParams *params, uint32 sound); /// ok + void SetupSuspectLastSeenReport(); // todo + + void Terminate(); + void TranslateEntity(CVector *v1, CVector *v2) const; /// ok + + void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook + bool UsesReverseWarning(int32 model) const; + bool UsesSiren(int32 model) const; + bool UsesSirenSwitching(int32 model) const; +}; + +static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); + +extern cAudioManager &AudioManager; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 076c1178..08ec3bc5 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -31,7 +31,7 @@ cDMAudio::Service(void) int32 cDMAudio::CreateEntity(eAudioType type, void *UID) { - return AudioManager.CreateEntity(type, UID); + return AudioManager.CreateEntity(type, (CPhysical *)UID); } void @@ -82,7 +82,7 @@ cDMAudio::SetEffectsFadeVol(uint8 volume) uint8 vol = volume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - AudioManager.SetEffectsFadeVol(vol); + AudioManager.SetEffectsFadeVolume(vol); } void @@ -91,7 +91,7 @@ cDMAudio::SetMusicFadeVol(uint8 volume) uint8 vol = volume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - AudioManager.SetMusicFadeVol(vol); + AudioManager.SetMusicFadeVolume(vol); } uint8 @@ -169,13 +169,13 @@ cDMAudio::IsAudioInitialised(void) void cDMAudio::ReportCrime(eCrimeType crime, CVector const &pos) { - AudioManager.ReportCrime(crime, pos); + AudioManager.ReportCrime(crime, &pos); } int32 cDMAudio::CreateLoopingScriptObject(cAudioScriptObject *scriptObject) { - int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject); + int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, (CPhysical *)scriptObject); if ( AEHANDLE_IS_OK(audioEntity) ) AudioManager.SetEntityStatus(audioEntity, true); @@ -192,7 +192,7 @@ cDMAudio::DestroyLoopingScriptObject(int32 audioEntity) void cDMAudio::CreateOneShotScriptObject(cAudioScriptObject *scriptObject) { - int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject); + int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, (CPhysical *)scriptObject); if ( AEHANDLE_IS_OK(audioEntity) ) { diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 677436a6..bcf94479 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -340,7 +340,7 @@ CCarCtrl::GenerateOneRandomCar() if (distanceBetweenNodes / 2 < carLength) positionBetweenNodes = 0.5f; else - positionBetweenNodes = Min(1.0f - carLength / distanceBetweenNodes, Max(carLength / distanceBetweenNodes, positionBetweenNodes)); + positionBetweenNodes = min(1.0f - carLength / distanceBetweenNodes, max(carLength / distanceBetweenNodes, positionBetweenNodes)); pCar->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1; if (pCurNode->numLinks == 1){ /* Do not create vehicle if there is nowhere to go. */ @@ -793,10 +793,10 @@ CCarCtrl::FindMaximumSpeedForThisCarInTraffic(CVehicle* pVehicle) float right = pVehicle->GetPosition().x + DISTANCE_TO_SCAN_FOR_DANGER; float top = pVehicle->GetPosition().y - DISTANCE_TO_SCAN_FOR_DANGER; float bottom = pVehicle->GetPosition().y + DISTANCE_TO_SCAN_FOR_DANGER; - int xstart = Max(0, CWorld::GetSectorIndexX(left)); - int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right)); - int ystart = Max(0, CWorld::GetSectorIndexY(top)); - int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom)); + int xstart = max(0, CWorld::GetSectorIndexX(left)); + int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right)); + int ystart = max(0, CWorld::GetSectorIndexY(top)); + int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom)); assert(xstart <= xend); assert(ystart <= yend); @@ -827,10 +827,10 @@ CCarCtrl::ScanForPedDanger(CVehicle* pVehicle) float right = pVehicle->GetPosition().x + DISTANCE_TO_SCAN_FOR_DANGER; float top = pVehicle->GetPosition().y - DISTANCE_TO_SCAN_FOR_DANGER; float bottom = pVehicle->GetPosition().y + DISTANCE_TO_SCAN_FOR_DANGER; - int xstart = Max(0, CWorld::GetSectorIndexX(left)); - int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right)); - int ystart = Max(0, CWorld::GetSectorIndexY(top)); - int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom)); + int xstart = max(0, CWorld::GetSectorIndexX(left)); + int xend = min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(right)); + int ystart = max(0, CWorld::GetSectorIndexY(top)); + int yend = min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(bottom)); assert(xstart <= xend); assert(ystart <= yend); @@ -862,12 +862,12 @@ CCarCtrl::SlowCarOnRailsDownForTrafficAndLights(CVehicle* pVehicle) float curSpeed = pVehicle->AutoPilot.m_fMaxTrafficSpeed; if (maxSpeed >= curSpeed){ if (maxSpeed > curSpeed) - pVehicle->AutoPilot.ModifySpeed(Min(maxSpeed, curSpeed + 0.05f * CTimer::GetTimeStep())); + pVehicle->AutoPilot.ModifySpeed(min(maxSpeed, curSpeed + 0.05f * CTimer::GetTimeStep())); }else{ if (curSpeed == 0.0f) return; if (curSpeed >= 0.1f) - pVehicle->AutoPilot.ModifySpeed(Max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep())); + pVehicle->AutoPilot.ModifySpeed(max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep())); else if (curSpeed != 0.0f) /* no need to check */ pVehicle->AutoPilot.ModifySpeed(0.0f); } diff --git a/src/control/CarGen.cpp b/src/control/CarGen.cpp index f2b35547..65a23c8c 100644 --- a/src/control/CarGen.cpp +++ b/src/control/CarGen.cpp @@ -157,7 +157,7 @@ void CCarGenerator::Setup(float x, float y, float z, float angle, int32 mi, int1 m_bIsBlocking = false; m_vecInf = CModelInfo::GetModelInfo(m_nModelIndex)->GetColModel()->boundingBox.min; m_vecSup = CModelInfo::GetModelInfo(m_nModelIndex)->GetColModel()->boundingBox.max; - m_fSize = Max(m_vecInf.Magnitude(), m_vecSup.Magnitude()); + m_fSize = max(m_vecInf.Magnitude(), m_vecSup.Magnitude()); } bool CCarGenerator::CheckForBlockage() diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 025db0c9..eb63b0b0 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -207,8 +207,8 @@ CPathFind::PreparePathData(void) numExtern++; if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes) numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes; - maxX = Max(maxX, Abs(InfoForTileCars[k].x)); - maxY = Max(maxY, Abs(InfoForTileCars[k].y)); + maxX = max(maxX, Abs(InfoForTileCars[k].x)); + maxY = max(maxY, Abs(InfoForTileCars[k].y)); }else if(InfoForTileCars[k].type == NodeTypeIntern) numIntern++; } @@ -392,7 +392,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor if(Abs(dx) < nearestDist){ dy = tempnodes[k].pos.y - CoorsXFormed.y; if(Abs(dy) < nearestDist){ - nearestDist = Max(Abs(dx), Abs(dy)); + nearestDist = max(Abs(dx), Abs(dy)); nearestId = k; } } @@ -501,13 +501,13 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor // Find i inside path segment iseg = 0; - for(j = Max(oldNumPathNodes, i-12); j < i; j++) + for(j = max(oldNumPathNodes, i-12); j < i; j++) if(m_pathNodes[j].objectIndex == m_pathNodes[i].objectIndex) iseg++; istart = 12*m_mapObjects[m_pathNodes[i].objectIndex]->m_modelIndex; // Add links to other internal nodes - for(j = Max(oldNumPathNodes, i-12); j < Min(m_numPathNodes, i+12); j++){ + for(j = max(oldNumPathNodes, i-12); j < min(m_numPathNodes, i+12); j++){ if(m_pathNodes[i].objectIndex != m_pathNodes[j].objectIndex || i == j) continue; // N.B.: in every path segment, the externals have to be at the end diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 03104307..be87eb2a 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -366,8 +366,8 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount); if (main){ state->animId = main->animId; - state->time = 255.0f / 4.0f * Max(0.0f, Min(4.0f, main->currentTime)); - state->speed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, main->speed)); + state->time = 255.0f / 4.0f * max(0.0f, min(4.0f, main->currentTime)); + state->speed = 255.0f / 3.0f * max(0.0f, min(3.0f, main->speed)); }else{ state->animId = 3; state->time = 0; @@ -375,9 +375,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) } if (second) { state->secAnimId = second->animId; - state->secTime = 255.0f / 4.0f * Max(0.0f, Min(4.0f, second->currentTime)); - state->secSpeed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, second->speed)); - state->blendAmount = 255.0f / 2.0f * Max(0.0f, Min(2.0f, blend_amount)); + state->secTime = 255.0f / 4.0f * max(0.0f, min(4.0f, second->currentTime)); + state->secSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, second->speed)); + state->blendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, blend_amount)); }else{ state->secAnimId = 0; state->secTime = 0; @@ -387,9 +387,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject); if (partial) { state->partAnimId = partial->animId; - state->partAnimTime = 255.0f / 4.0f * Max(0.0f, Min(4.0f, partial->currentTime)); - state->partAnimSpeed = 255.0f / 3.0f * Max(0.0f, Min(3.0f, partial->speed)); - state->partBlendAmount = 255.0f / 2.0f * Max(0.0f, Min(2.0f, partial->blendAmount)); + state->partAnimTime = 255.0f / 4.0f * max(0.0f, min(4.0f, partial->currentTime)); + state->partAnimSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, partial->speed)); + state->partBlendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, partial->blendAmount)); }else{ state->partAnimId = 0; state->partAnimTime = 0; @@ -408,9 +408,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i); if (assoc){ state->aAnimId[i] = assoc->animId; - state->aCurTime[i] = 255.0f / 4.0f * Max(0.0f, Min(4.0f, assoc->currentTime)); - state->aSpeed[i] = 255.0f / 3.0f * Max(0.0f, Min(3.0f, assoc->speed)); - state->aBlendAmount[i] = 255.0f / 2.0f * Max(0.0f, Min(2.0f, assoc->blendAmount)); + state->aCurTime[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime)); + state->aSpeed[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed)); + state->aBlendAmount[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount)); state->aFlags[i] = assoc->flags; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback); @@ -431,9 +431,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i); if (assoc) { state->aAnimId2[i] = assoc->animId; - state->aCurTime2[i] = 255.0f / 4.0f * Max(0.0f, Min(4.0f, assoc->currentTime)); - state->aSpeed2[i] = 255.0f / 3.0f * Max(0.0f, Min(3.0f, assoc->speed)); - state->aBlendAmount2[i] = 255.0f / 2.0f * Max(0.0f, Min(2.0f, assoc->blendAmount)); + state->aCurTime2[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime)); + state->aSpeed2[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed)); + state->aBlendAmount2[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount)); state->aFlags2[i] = assoc->flags; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback); @@ -625,9 +625,9 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ vp->acceleration = vehicle->m_fGasPedal * 100.0f; vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0; - vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */ - vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y)); - vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z)); + vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */ + vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().y)); + vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().z)); vp->mi = vehicle->GetModelIndex(); vp->primary_color = vehicle->m_currentColour1; vp->secondary_color = vehicle->m_currentColour2; @@ -1501,9 +1501,9 @@ void CReplay::ProcessLookAroundCam(void) --FramesActiveLookAroundCam; fBetaAngleLookAroundCam += x_moved; if (CPad::NewMouseControllerState.LMB && CPad::NewMouseControllerState.RMB) - fDistanceLookAroundCam = Max(3.0f, Min(15.0f, fDistanceLookAroundCam + 2.0f * y_moved)); + fDistanceLookAroundCam = max(3.0f, min(15.0f, fDistanceLookAroundCam + 2.0f * y_moved)); else - fAlphaAngleLookAroundCam = Max(0.1f, Min(1.5f, fAlphaAngleLookAroundCam + y_moved)); + fAlphaAngleLookAroundCam = max(0.1f, min(1.5f, fAlphaAngleLookAroundCam + y_moved)); CVector camera_pt( fDistanceLookAroundCam * Sin(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam), fDistanceLookAroundCam * Cos(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam), diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 7e87fc6e..c81cd050 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1987,7 +1987,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS; car->m_status = STATUS_PHYSICS; car->bEngineOn = true; - car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6); + car->AutoPilot.m_nCruiseSpeed = max(car->AutoPilot.m_nCruiseSpeed, 6); car->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); return 0; } @@ -1999,7 +1999,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) CCarCtrl::JoinCarWithRoadSystem(car); car->AutoPilot.m_nCarMission = MISSION_CRUISE; car->bEngineOn = true; - car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6); + car->AutoPilot.m_nCruiseSpeed = max(car->AutoPilot.m_nCruiseSpeed, 6); car->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); return 0; } @@ -2083,7 +2083,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) CollectParameters(&m_nIp, 2); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); assert(car); - car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); + car->AutoPilot.m_nCruiseSpeed = min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); return 0; } case COMMAND_SET_CAR_DRIVING_STYLE: diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index f15232f3..cb16c3ad 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -209,7 +209,7 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp else if(TargetSpeed > 0.0f && *CurrentSpeed > TargetSpeed) *CurrentSpeed = TargetSpeed; - *CurrentValue += *CurrentSpeed * Min(10.0f, CTimer::GetTimeStep()); + *CurrentValue += *CurrentSpeed * min(10.0f, CTimer::GetTimeStep()); } void @@ -697,7 +697,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl // Process height offset to avoid peds and cars float TargetZOffSet = m_fUnknownZOffSet + m_fDimensionOfHighestNearCar; - TargetZOffSet = Max(TargetZOffSet, m_fPedBetweenCameraHeightOffset); + TargetZOffSet = max(TargetZOffSet, m_fPedBetweenCameraHeightOffset); float TargetHeight = CameraTarget.z + TargetZOffSet - Source.z; if(TargetHeight > m_fCamBufferedHeight){ @@ -753,7 +753,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl } } - TargetCoors.z += Min(1.0f, m_fCamBufferedHeight/2.0f); + TargetCoors.z += min(1.0f, m_fCamBufferedHeight/2.0f); m_cvecTargetCoorsForFudgeInter = TargetCoors; Front = TargetCoors - Source; @@ -991,7 +991,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa } if(FoundCamRoof){ // Camera is under something - float roof = FoundRoofCenter ? Min(CamRoof, CarRoof) : CamRoof; + float roof = FoundRoofCenter ? min(CamRoof, CarRoof) : CamRoof; // Same weirdness again? TargetAlpha = CGeneral::GetATanOfXY(CA_MAX_DISTANCE, roof - CamTargetZ - 1.5f); CamClear = false; @@ -1249,7 +1249,7 @@ void CCam::Cam_On_A_String_Unobscured(const CVector &TargetCoors, float BaseDist) { CA_MAX_DISTANCE = BaseDist + 0.1f + TheCamera.CarZoomValueSmooth; - CA_MIN_DISTANCE = Min(BaseDist*0.6f, 3.5f); + CA_MIN_DISTANCE = min(BaseDist*0.6f, 3.5f); CVector Dist = Source - TargetCoors; diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 538bcae6..66b29d9f 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -153,10 +153,10 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) // on water we expect to be between levels multipleLevels = true; }else{ - xmin = Max(sx - 1, 0); - xmax = Min(sx + 1, NUMSECTORS_X-1); - ymin = Max(sy - 1, 0); - ymax = Min(sy + 1, NUMSECTORS_Y-1); + xmin = max(sx - 1, 0); + xmax = min(sx + 1, NUMSECTORS_X-1); + ymin = max(sy - 1, 0); + ymax = min(sy + 1, NUMSECTORS_Y-1); for(x = xmin; x <= xmax; x++) for(y = ymin; y <= ymax; y++){ diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index f4545f7b..effcb0b4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1030,7 +1030,7 @@ int CMenuManager::FadeIn(int alpha) m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS || m_nCurrScreen == MENUPAGE_DELETING) return alpha; - return Min(m_nMenuFadeAlpha, alpha); + return min(m_nMenuFadeAlpha, alpha); } #endif diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 46dceff3..08b30876 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -17,10 +17,10 @@ void CIniFile::LoadIniFile() if (f){ CFileMgr::ReadLine(f, gString, 200); sscanf(gString, "%f", &PedNumberMultiplier); - PedNumberMultiplier = Min(3.0f, Max(0.5f, PedNumberMultiplier)); + PedNumberMultiplier = min(3.0f, max(0.5f, PedNumberMultiplier)); CFileMgr::ReadLine(f, gString, 200); sscanf(gString, "%f", &CarNumberMultiplier); - CarNumberMultiplier = Min(3.0f, Max(0.5f, CarNumberMultiplier)); + CarNumberMultiplier = min(3.0f, max(0.5f, CarNumberMultiplier)); CFileMgr::CloseFile(f); } CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier; diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index b5086d64..f334a255 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -299,10 +299,10 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat { if ( State1.button || State2.button ) ReconState.button = 255; } #define _RECONCILE_AXIS_POSITIVE(axis) \ - { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = Max(State1.axis, State2.axis); } + { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = max(State1.axis, State2.axis); } #define _RECONCILE_AXIS_NEGATIVE(axis) \ - { if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = Min(State1.axis, State2.axis); } + { if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = min(State1.axis, State2.axis); } #define _RECONCILE_AXIS(axis) \ { _RECONCILE_AXIS_POSITIVE(axis); _RECONCILE_AXIS_NEGATIVE(axis); } diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 8158cd1d..a7bde91e 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1940,7 +1940,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){ lodDistSq = sq(mi->GetLargestLodDistance()); - lodDistSq = Min(lodDistSq, sq(STREAM_DIST)); + lodDistSq = min(lodDistSq, sq(STREAM_DIST)); pos = CVector2D(e->GetPosition()); if(xmin < pos.x && pos.x < xmax && ymin < pos.y && pos.y < ymax && @@ -2160,20 +2160,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){ // looking west/east - ymin = Max(iy - 10, 0); - ymax = Min(iy + 10, NUMSECTORS_Y); + ymin = max(iy - 10, 0); + ymax = min(iy + 10, NUMSECTORS_Y); assert(ymin <= ymax); // Delete a block of sectors that we know is behind the camera if(TheCamera.GetForward().x > 0){ // looking east - xmax = Max(ix - 2, 0); - xmin = Max(ix - 10, 0); + xmax = max(ix - 2, 0); + xmin = max(ix - 10, 0); inc = 1; }else{ // looking west - xmax = Min(ix + 2, NUMSECTORS_X); - xmin = Min(ix + 10, NUMSECTORS_X); + xmax = min(ix + 2, NUMSECTORS_X); + xmin = min(ix + 10, NUMSECTORS_X); inc = -1; } for(y = ymin; y <= ymax; y++){ @@ -2189,13 +2189,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) // Now a block that intersects with the camera's frustum if(TheCamera.GetForward().x > 0){ // looking east - xmax = Max(ix + 10, 0); - xmin = Max(ix - 2, 0); + xmax = max(ix + 10, 0); + xmin = max(ix - 2, 0); inc = 1; }else{ // looking west - xmax = Min(ix - 10, NUMSECTORS_X); - xmin = Min(ix + 2, NUMSECTORS_X); + xmax = min(ix - 10, NUMSECTORS_X); + xmin = min(ix + 2, NUMSECTORS_X); inc = -1; } for(y = ymin; y <= ymax; y++){ @@ -2224,20 +2224,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) }else{ // looking north/south - xmin = Max(ix - 10, 0); - xmax = Min(ix + 10, NUMSECTORS_X); + xmin = max(ix - 10, 0); + xmax = min(ix + 10, NUMSECTORS_X); assert(xmin <= xmax); // Delete a block of sectors that we know is behind the camera if(TheCamera.GetForward().y > 0){ // looking north - ymax = Max(iy - 2, 0); - ymin = Max(iy - 10, 0); + ymax = max(iy - 2, 0); + ymin = max(iy - 10, 0); inc = 1; }else{ // looking south - ymax = Min(iy + 2, NUMSECTORS_Y); - ymin = Min(iy + 10, NUMSECTORS_Y); + ymax = min(iy + 2, NUMSECTORS_Y); + ymin = min(iy + 10, NUMSECTORS_Y); inc = -1; } for(x = xmin; x <= xmax; x++){ @@ -2253,13 +2253,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) // Now a block that intersects with the camera's frustum if(TheCamera.GetForward().y > 0){ // looking north - ymax = Max(iy + 10, 0); - ymin = Max(iy - 2, 0); + ymax = max(iy + 10, 0); + ymin = max(iy - 2, 0); inc = 1; }else{ // looking south - ymax = Min(iy - 10, NUMSECTORS_Y); - ymin = Min(iy + 2, NUMSECTORS_Y); + ymax = min(iy - 10, NUMSECTORS_Y); + ymin = min(iy + 2, NUMSECTORS_Y); inc = -1; } for(x = xmin; x <= xmax; x++){ diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index daed9155..26b115e3 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -209,7 +209,7 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt else sensitivity = m_fCrimeSensitivity; - wantedLevelDrop = Min(CCullZones::GetWantedLevelDrop(), 100); + wantedLevelDrop = min(CCullZones::GetWantedLevelDrop(), 100); chaos = (1.0f - wantedLevelDrop/100.0f) * sensitivity; if (policeDoesntCare) diff --git a/src/core/common.h b/src/core/common.h index d1f71720..b3a271c6 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -195,8 +195,8 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) #define BIT(num) (1<<(num)) -#define Max(a, b) (((a) > (b)) ? (a) : (b)) -#define Min(a, b) (((a) < (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) #define ABS(a) (((a) < 0) ? (-(a)) : (a)) #define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min))))) diff --git a/src/core/main.cpp b/src/core/main.cpp index a82a2ab8..50494ef3 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -453,7 +453,7 @@ DoFade(void) CRGBA fadeColor; CRect rect; int fadeValue = CDraw::FadeValue; - float brightness = Min(CMenuManager::m_PrefsBrightness, 256); + float brightness = min(CMenuManager::m_PrefsBrightness, 256); if(brightness <= 50) brightness = 50; if(FrontEndMenuManager.m_bMenuActive) diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index d59e6c59..fbd1322d 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -457,7 +457,7 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector & { float compression = 1.0f - springRatio; if(compression > 0.0f){ - float step = Min(CTimer::GetTimeStep(), 3.0f); + float step = min(CTimer::GetTimeStep(), 3.0f); float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f; ApplyMoveForce(springDir*impulse); ApplyTurnForce(springDir*impulse, point); @@ -471,12 +471,12 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin { float speedA = DotProduct(speed, springDir); float speedB = DotProduct(GetSpeed(point), springDir); - float step = Min(CTimer::GetTimeStep(), 3.0f); + float step = min(CTimer::GetTimeStep(), 3.0f); float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f; // what is this? float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass); - a = Min(a, 1.0f); + a = min(a, 1.0f); float b = Abs(impulse / (speedB * m_fMass)); if(a < b) impulse *= a/b; @@ -646,7 +646,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl // positive if B is moving towards A // not interested in how much B moves into A apparently? // only interested in cases where A collided into B - speedB = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal)); + speedB = max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal)); // A has moved into B if(speedA < speedB){ if(!A->bHasHitWall) @@ -1147,18 +1147,18 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) CVector dir = A->GetPosition() - B->GetPosition(); dir.Normalise(); if(dir.z < 0.0f && dir.z < A->GetForward().z && dir.z < A->GetRight().z) - dir.z = Min(0.0f, Min(A->GetForward().z, A->GetRight().z)); + dir.z = min(0.0f, min(A->GetForward().z, A->GetRight().z)); shift += dir * colpoints[mostColliding].depth * 0.5f; }else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){ CVector dir = colpoints[mostColliding].normal; - float f = Min(Abs(dir.z), 0.9f); + float f = min(Abs(dir.z), 0.9f); dir.z = 0.0f; dir.Normalise(); shift += dir * colpoints[mostColliding].depth / (1.0f - f); boat = B; }else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){ CVector dir = colpoints[mostColliding].normal * -1.0f; - float f = Min(Abs(dir.z), 0.9f); + float f = min(Abs(dir.z), 0.9f); dir.z = 0.0f; dir.Normalise(); B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f); @@ -1246,7 +1246,7 @@ collision: float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); } }else if(A->bHasContacted){ CVector savedMoveFriction = A->m_vecMoveFriction; @@ -1268,7 +1268,7 @@ collision: float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1301,7 +1301,7 @@ collision: float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1328,7 +1328,7 @@ collision: float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1506,7 +1506,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr(); float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff)); } }else{ for(i = 0; i < numCollisions; i++){ @@ -1527,7 +1527,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr(); float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff)); float adhesion = CSurfaceTable::GetAdhesiveLimit(aColPoints[i]) / numCollisions; @@ -1545,7 +1545,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) else if(A->GetUp().z > 0.3f) adhesion = 0.0f; else - adhesion *= Min(5.0f, 0.03f*impulseA + 1.0f); + adhesion *= min(5.0f, 0.03f*impulseA + 1.0f); } if(A->ApplyFriction(adhesion, aColPoints[i])) @@ -1594,7 +1594,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); } }else if(A->bHasContacted){ CVector savedMoveFriction = A->m_vecMoveFriction; @@ -1619,7 +1619,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1655,7 +1655,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1685,7 +1685,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); - DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff)); + DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ A->bHasContacted = true; @@ -1831,7 +1831,7 @@ CPhysical::ProcessCollision(void) if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){ if(ped->IsPlayer()) - n = Max(NUMSTEPS(0.2f), 2.0); + n = max(NUMSTEPS(0.2f), 2.0); else n = NUMSTEPS(0.3f); step = savedTimeStep / n; @@ -1852,7 +1852,7 @@ CPhysical::ProcessCollision(void) speedDown = Multiply3x3(GetMatrix(), speedDown); speedUp = GetSpeed(speedUp); speedDown = GetSpeed(speedDown); - distSq = Max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep()); + distSq = max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep()); if(distSq >= sq(0.3f)){ n = NUMSTEPS(0.3f); step = savedTimeStep / n; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 65bd696d..a590c1ed 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -1792,7 +1792,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) neededPos.z = autoZPos.z; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); } else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep); @@ -1807,12 +1807,12 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (m_pVehicleAnim && (vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS || vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ; } else if (m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK) { - neededPos.z = Max(currentZ, autoZPos.z); + neededPos.z = max(currentZ, autoZPos.z); } } } @@ -4771,12 +4771,12 @@ CPed::FightStrike(CVector &touchedNodePos) float moveMult; if (m_lastFightMove == FIGHTMOVE_GROUNDKICK) { - moveMult = Min(damageMult * 0.6f, 4.0f); + moveMult = min(damageMult * 0.6f, 4.0f); } else { if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) { moveMult = damageMult; } else { - moveMult = Min(damageMult * 2.0f, 14.0f); + moveMult = min(damageMult * 2.0f, 14.0f); } } @@ -5434,7 +5434,7 @@ CPed::CreateDeadPedWeaponPickups(void) pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f; } if (found) - CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon])); + CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, min(weaponAmmo, AmmoForWeapon_OnStreet[weapon])); } ClearWeapons(); } @@ -5443,7 +5443,7 @@ void CPed::SetAttackTimer(uint32 time) { if (CTimer::GetTimeInMilliseconds() > m_attackTimer) - m_attackTimer = Max(m_lastHitTime, CTimer::GetTimeInMilliseconds()) + time; + m_attackTimer = max(m_lastHitTime, CTimer::GetTimeInMilliseconds()) + time; } void diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp index d7b7ec75..8a40e56f 100644 --- a/src/peds/PedPlacement.cpp +++ b/src/peds/PedPlacement.cpp @@ -29,7 +29,7 @@ CPedPlacement::FindZCoorForPed(CVector* pos) if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil)) foundColZ2 = foundCol.point.z; - zForPed = Max(foundColZ, foundColZ2); + zForPed = max(foundColZ, foundColZ2); if (zForPed > -99.0f) pos->z = 1.04f + zForPed; diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index a461301c..2884894c 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -388,7 +388,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, ms_colourBottom.b = topblue; ms_colourBottom.a = alpha; - botpos = Min(SCREEN_HEIGHT, topedge); + botpos = min(SCREEN_HEIGHT, topedge); CSprite2d::DrawRect(CRect(0, 0, SCREEN_WIDTH, botpos), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); } @@ -415,18 +415,18 @@ CClouds::RenderHorizon(void) if(ms_horizonZ > SCREEN_HEIGHT) return; - float z1 = Min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT); + float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT); CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREEN_WIDTH, z1), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); // This is just weird float a = SCREEN_HEIGHT/400.0f * HORIZSTRIPHEIGHT + - SCREEN_HEIGHT/300.0f * Max(TheCamera.GetPosition().z, 0.0f); + SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f); float b = TheCamera.GetUp().z < 0.0f ? SCREEN_HEIGHT : SCREEN_HEIGHT * Abs(TheCamera.GetRight().z); float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier; - z2 = Min(z2, SCREEN_HEIGHT); + z2 = min(z2, SCREEN_HEIGHT); CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2), ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); } diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 9881e764..1a6cfea3 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -109,7 +109,7 @@ CCoronas::Update(void) int i; static int LastCamLook = 0; - LightsMult = Min(LightsMult + 0.03f * CTimer::GetTimeStep(), 1.0f); + LightsMult = min(LightsMult + 0.03f * CTimer::GetTimeStep(), 1.0f); int CamLook = 0; if(TheCamera.Cams[TheCamera.ActiveCam].LookingLeft) CamLook |= 1; @@ -121,7 +121,7 @@ CCoronas::Update(void) if(LastCamLook != CamLook) bChangeBrightnessImmediately = 3; else - bChangeBrightnessImmediately = Max(bChangeBrightnessImmediately-1, 0); + bChangeBrightnessImmediately = max(bChangeBrightnessImmediately-1, 0); LastCamLook = CamLook; for(i = 0; i < NUMCORONAS; i++) @@ -309,7 +309,7 @@ CCoronas::Render(void) // render corona itself if(aCoronas[i].texture){ - float fogscale = CWeather::Foggyness*Min(spriteCoors.z, 40.0f)/40.0f + 1.0f; + float fogscale = CWeather::Foggyness*min(spriteCoors.z, 40.0f)/40.0f + 1.0f; if(CCoronas::aCoronas[i].id == SUN_CORE) spriteCoors.z = 0.95f * RwCameraGetFarClipPlane(Scene.camera); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(aCoronas[i].texture)); @@ -320,7 +320,7 @@ CCoronas::Render(void) float f = 1.0f - aCoronas[i].someAngle*2.0f/PI; float wscale = 6.0f*sq(sq(sq(f))) + 0.5f; float hscale = 0.35f - (wscale - 0.5f) * 0.06f; - hscale = Max(hscale, 0.15f); + hscale = max(hscale, 0.15f); CSprite::RenderOneXLUSprite(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * aCoronas[i].size * wscale, @@ -467,7 +467,7 @@ CCoronas::RenderReflections(void) float spritew, spriteh; if(CSprite::CalcScreenCoors(coors, spriteCoors, &spritew, &spriteh, true)){ float drawDist = 0.75f * aCoronas[i].drawDist; - drawDist = Min(drawDist, 50.0f); + drawDist = min(drawDist, 50.0f); if(spriteCoors.z < drawDist){ float fadeDistance = drawDist / 2.0f; float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance; @@ -546,25 +546,25 @@ CRegisteredCorona::Update(void) (CCoronas::SunBlockedByClouds && id == CCoronas::SUN_CORONA || !CWorld::GetIsLineOfSightClear(coors, TheCamera.GetPosition(), true, false, false, false, false, false))){ // Corona is blocked, fade out - fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f); + fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f); }else if(offScreen){ // Same when off screen - fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f); + fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), 0.0f); }else{ // Visible if(alpha > fadeAlpha){ // fade in - fadeAlpha = Min(fadeAlpha + 15.0f*CTimer::GetTimeStep(), alpha); + fadeAlpha = min(fadeAlpha + 15.0f*CTimer::GetTimeStep(), alpha); if(CCoronas::bChangeBrightnessImmediately) fadeAlpha = alpha; }else if(alpha < fadeAlpha){ // too visible, decrease alpha but not below alpha - fadeAlpha = Max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), alpha); + fadeAlpha = max(fadeAlpha - 15.0f*CTimer::GetTimeStep(), alpha); } // darken scene when the sun is visible if(id == CCoronas::SUN_CORONA) - CCoronas::LightsMult = Max(CCoronas::LightsMult - CTimer::GetTimeStep()*0.06f, 0.6f); + CCoronas::LightsMult = max(CCoronas::LightsMult - CTimer::GetTimeStep()*0.06f, 0.6f); } // remove if invisible diff --git a/src/render/Lights.cpp b/src/render/Lights.cpp index 85d7ba13..cd83a898 100644 --- a/src/render/Lights.cpp +++ b/src/render/Lights.cpp @@ -37,9 +37,9 @@ SetLightsWithTimeOfDayColour(RpWorld *) AmbientLightColourForFrame.green = 1.0f; AmbientLightColourForFrame.blue = 1.0f; } - AmbientLightColourForFrame_PedsCarsAndObjects.red = Min(1.0f, AmbientLightColourForFrame.red*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.green = Min(1.0f, AmbientLightColourForFrame.green*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.blue = Min(1.0f, AmbientLightColourForFrame.blue*1.3f); + AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame.red*1.3f); + AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame.green*1.3f); + AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame.blue*1.3f); RpLightSetColor(pAmbient, &AmbientLightColourForFrame); } @@ -70,16 +70,16 @@ SetLightsWithTimeOfDayColour(RpWorld *) float f1 = 2.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; float f2 = 3.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; - AmbientLightColourForFrame.red = Min(1.0f, AmbientLightColourForFrame.red * f2); - AmbientLightColourForFrame.green = Min(1.0f, AmbientLightColourForFrame.green * f2); - AmbientLightColourForFrame.blue = Min(1.0f, AmbientLightColourForFrame.blue * f2); - AmbientLightColourForFrame_PedsCarsAndObjects.red = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1); - AmbientLightColourForFrame_PedsCarsAndObjects.green = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1); - AmbientLightColourForFrame_PedsCarsAndObjects.blue = Min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1); + AmbientLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f2); + AmbientLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f2); + AmbientLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f2); + AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1); + AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1); + AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1); #ifdef FIX_BUGS - DirectionalLightColourForFrame.red = Min(1.0f, DirectionalLightColourForFrame.red * f1); - DirectionalLightColourForFrame.green = Min(1.0f, DirectionalLightColourForFrame.green * f1); - DirectionalLightColourForFrame.blue = Min(1.0f, DirectionalLightColourForFrame.blue * f1); + DirectionalLightColourForFrame.red = min(1.0f, DirectionalLightColourForFrame.red * f1); + DirectionalLightColourForFrame.green = min(1.0f, DirectionalLightColourForFrame.green * f1); + DirectionalLightColourForFrame.blue = min(1.0f, DirectionalLightColourForFrame.blue * f1); #else DirectionalLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f1); DirectionalLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f1); @@ -193,7 +193,7 @@ AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, f RwRGBAReal color; RwV3d *dir; - strength = Max(Max(red, green), blue); + strength = max(max(red, green), blue); n = -1; if(NumExtraDirLightsInWorld < NUMEXTRADIRECTIONALS) n = NumExtraDirLightsInWorld; @@ -221,7 +221,7 @@ AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, f RwFrameUpdateObjects(RpLightGetFrame(pExtraDirectionals[n])); RpLightSetFlags(pExtraDirectionals[n], rpLIGHTLIGHTATOMICS); LightStrengths[n] = strength; - NumExtraDirLightsInWorld = Min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS); + NumExtraDirLightsInWorld = min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS); } void diff --git a/src/render/ParticleMgr.cpp b/src/render/ParticleMgr.cpp index 9381787c..7a1804de 100644 --- a/src/render/ParticleMgr.cpp +++ b/src/render/ParticleMgr.cpp @@ -91,7 +91,7 @@ void cParticleSystemMgr::LoadParticleData() break; case CFG_PARAM_INITIAL_COLOR_VARIATION: - entry->m_InitialColorVariation = Min(atoi(value), 100); + entry->m_InitialColorVariation = min(atoi(value), 100); break; case CFG_PARAM_FADE_DESTINATION_COLOR_R: diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index 8e942ce6..a015ec54 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -98,7 +98,7 @@ CPointLights::GenerateLightsAffectingObject(CVector *objCoors) if(aLights[i].type == LIGHT_DIRECTIONAL){ float dot = -DotProduct(dir, aLights[i].dir); - intensity *= Max((dot-0.5f)*2.0f, 0.0f); + intensity *= max((dot-0.5f)*2.0f, 0.0f); } if(intensity > 0.0f) diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index b5147f02..4d2e4605 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -727,10 +727,10 @@ CShadows::RenderStoredShadows(void) float fStartY = shadowPos.y - fHeight; float fEndY = shadowPos.y + fHeight; - int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); - int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); - int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1); - int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1); + int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); + int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); + int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1); + int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1); CWorld::AdvanceCurrentScanCode(); @@ -873,10 +873,10 @@ CShadows::GeneratePolysForStaticShadow(int16 nStaticShadowID) float fStartY = shadowPos.y - fHeight; float fEndY = shadowPos.y + fHeight; - int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); - int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); - int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1); - int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1); + int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); + int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); + int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X-1); + int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y-1); CWorld::AdvanceCurrentScanCode(); @@ -1016,11 +1016,11 @@ CShadows::CastShadowEntity(CEntity *pEntity, float fStartX, float fStartY, floa Points[3].x = (fLengthRight - fFrontRight) - fSideRight; Points[3].y = (fLengthForward - fFrontForward) - fSideForward; - float MinX = Min(Min(Points[0].x, Points[1].x), Min(Points[2].x, Points[3].x)); - float MaxX = Max(Max(Points[0].x, Points[1].x), Max(Points[2].x, Points[3].x)); + float MinX = min(min(Points[0].x, Points[1].x), min(Points[2].x, Points[3].x)); + float MaxX = max(max(Points[0].x, Points[1].x), max(Points[2].x, Points[3].x)); - float MinY = Min(Min(Points[0].y, Points[1].y), Min(Points[2].y, Points[3].y)); - float MaxY = Max(Max(Points[0].y, Points[1].y), Max(Points[2].y, Points[3].y)); + float MinY = min(min(Points[0].y, Points[1].y), min(Points[2].y, Points[3].y)); + float MaxY = max(max(Points[0].y, Points[1].y), max(Points[2].y, Points[3].y)); float MaxZ = pPosn->z - pEntity->GetPosition().z; float MinZ = MaxZ - fZDistance; @@ -1767,7 +1767,7 @@ CShadows::RenderIndicatorShadow(uint32 nID, uint8 ShadowType, RwTexture *pTextur { ASSERT(pPosn != NULL); - C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, Max(fFrontX, -fSideY), + C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, max(fFrontX, -fSideY), 0, 128, 255, 128, 2048, 0.2f, 0); } diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index 0113c001..7ab3e91e 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -290,7 +290,7 @@ CTimeCycle::Update(void) TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, m_fCurrentBlurAlpha, MBLUR_NORMAL); if(m_FogReduction != 0) - m_fCurrentFarClip = Max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f); + m_fCurrentFarClip = max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f); m_nCurrentFogColourRed = (m_nCurrentSkyTopRed + 2*m_nCurrentSkyBottomRed) / 3; m_nCurrentFogColourGreen = (m_nCurrentSkyTopGreen + 2*m_nCurrentSkyBottomGreen) / 3; m_nCurrentFogColourBlue = (m_nCurrentSkyTopBlue + 2*m_nCurrentSkyBottomBlue) / 3; @@ -311,9 +311,9 @@ CTimeCycle::Update(void) if(TheCamera.GetForward().z < -0.9f || !CWeather::bScriptsForceRain && (CCullZones::PlayerNoRain() || CCullZones::CamNoRain() || CCutsceneMgr::IsRunning())) - m_FogReduction = Min(m_FogReduction+1, 64); + m_FogReduction = min(m_FogReduction+1, 64); else - m_FogReduction = Max(m_FogReduction-1, 0); + m_FogReduction = max(m_FogReduction-1, 0); } STARTPATCHES diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index c711c8c8..a1c2af93 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -979,7 +979,7 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col SMALL_SECTOR_SIZE / 2, apBoatList) ) { - float fWakeColor = fAdd1 - Max(255.0f - float(color.blue + color.red + color.green) / 3, fAdd2); + float fWakeColor = fAdd1 - max(255.0f - float(color.blue + color.red + color.green) / 3, fAdd2); RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic); RpGeometry *geom = apGeomArray[nGeomUsed++]; @@ -1035,9 +1035,9 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col RwRGBAAssign(&wakeColor, &color); - wakeColor.red = Min(color.red + int32(fWakeColor * fRedMult * fDistMult), 255); - wakeColor.green = Min(color.green + int32(fWakeColor * fGreenMult * fDistMult), 255); - wakeColor.blue = Min(color.blue + int32(fWakeColor * fBlueMult * fDistMult), 255); + wakeColor.red = min(color.red + int32(fWakeColor * fRedMult * fDistMult), 255); + wakeColor.green = min(color.green + int32(fWakeColor * fGreenMult * fDistMult), 255); + wakeColor.blue = min(color.blue + int32(fWakeColor * fBlueMult * fDistMult), 255); RwRGBAAssign(&geomPreLights[9*i+j], &wakeColor); @@ -1114,7 +1114,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY) fSectorY + SMALL_SECTOR_SIZE - fY ); - fDistSqr = Min(vecDist.MagnitudeSqr(), fDistSqr); + fDistSqr = min(vecDist.MagnitudeSqr(), fDistSqr); } } } diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 99354d70..5a788945 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -691,7 +691,7 @@ CAutomobile::ProcessControl(void) if(m_aSuspensionSpringRatio[i] < 1.0f) m_aWheelTimer[i] = 4.0f; else - m_aWheelTimer[i] = Max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f); + m_aWheelTimer[i] = max(m_aWheelTimer[i]-CTimer::GetTimeStep(), 0.0f); if(m_aWheelTimer[i] > 0.0f){ m_nWheelsOnGround++; @@ -1009,7 +1009,7 @@ CAutomobile::ProcessControl(void) if(m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE && m_status != STATUS_PHYSICS){ if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW) - m_aWheelSpeed[0] = Max(m_aWheelSpeed[0]-0.0005f, 0.0f); + m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.0005f, 0.0f); }else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) && m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){ FlyingControl(FLIGHT_MODEL_DODO); @@ -1017,7 +1017,7 @@ CAutomobile::ProcessControl(void) FlyingControl(FLIGHT_MODEL_HELI); }else if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW || bAllCarCheat){ if(CPad::GetPad(0)->GetCircleJustDown()) - m_aWheelSpeed[0] = Max(m_aWheelSpeed[0]-0.03f, 0.0f); + m_aWheelSpeed[0] = max(m_aWheelSpeed[0]-0.03f, 0.0f); if(m_aWheelSpeed[0] < 0.22f) m_aWheelSpeed[0] += 0.0001f; if(m_aWheelSpeed[0] > 0.15f) @@ -1129,10 +1129,10 @@ CAutomobile::ProcessControl(void) if(speed > sq(0.1f)){ speed = Sqrt(speed); if(suspShake > 0.0f){ - uint8 freq = Min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f); + uint8 freq = min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f); CPad::GetPad(0)->StartShake(20000.0f*CTimer::GetTimeStep()/freq, freq); }else{ - uint8 freq = Min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 145.0f); + uint8 freq = min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 145.0f); CPad::GetPad(0)->StartShake(5000.0f*CTimer::GetTimeStep()/freq, freq); } } @@ -2588,7 +2588,7 @@ CAutomobile::HydraulicControl(void) float minz = pos.z + extendedLowerLimit - wheelRadius; if(minz < specialColModel->boundingBox.min.z) specialColModel->boundingBox.min.z = minz; - float radius = Max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude()); + float radius = max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude()); if(specialColModel->boundingSphere.radius < radius) specialColModel->boundingSphere.radius = radius; @@ -2687,10 +2687,10 @@ CAutomobile::HydraulicControl(void) float front = -rear; float right = CPad::GetPad(0)->GetCarGunLeftRight()/128.0f; float left = -right; - suspChange[CARWHEEL_FRONT_LEFT] = Max(front+left, 0.0f); - suspChange[CARWHEEL_REAR_LEFT] = Max(rear+left, 0.0f); - suspChange[CARWHEEL_FRONT_RIGHT] = Max(front+right, 0.0f); - suspChange[CARWHEEL_REAR_RIGHT] = Max(rear+right, 0.0f); + suspChange[CARWHEEL_FRONT_LEFT] = max(front+left, 0.0f); + suspChange[CARWHEEL_REAR_LEFT] = max(rear+left, 0.0f); + suspChange[CARWHEEL_FRONT_RIGHT] = max(front+right, 0.0f); + suspChange[CARWHEEL_REAR_RIGHT] = max(rear+right, 0.0f); if(m_hydraulicState < 100){ // Lowered, move wheels up @@ -2806,7 +2806,7 @@ CAutomobile::ProcessBuoyancy(void) ApplyTurnForce(impulse, point); CVector initialSpeed = m_vecMoveSpeed; - float timeStep = Max(CTimer::GetTimeStep(), 0.01f); + float timeStep = max(CTimer::GetTimeStep(), 0.01f); float impulseRatio = impulse.z / (GRAVITY * m_fMass * timeStep); float waterResistance = Pow(1.0f - 0.05f*impulseRatio, CTimer::GetTimeStep()); m_vecMoveSpeed *= waterResistance; @@ -2899,7 +2899,7 @@ CAutomobile::ProcessBuoyancy(void) float fSpeed = vSpeed.MagnitudeSqr(); if(fSpeed > sq(0.05f)){ fSpeed = Sqrt(fSpeed); - float size = Min((fSpeed < 0.15f ? 0.25f : 0.75f)*fSpeed, 0.6f); + float size = min((fSpeed < 0.15f ? 0.25f : 0.75f)*fSpeed, 0.6f); CVector right = 0.2f*fSpeed*GetRight() + 0.2f*vSpeed; CParticle::AddParticle(PARTICLE_PED_SPLASH, @@ -2981,11 +2981,11 @@ CAutomobile::DoDriveByShootings(void) // TODO: what is this? if(!lookingLeft && m_weaponDoorTimerLeft > 0.0f){ - m_weaponDoorTimerLeft = Max(m_weaponDoorTimerLeft - CTimer::GetTimeStep()*0.1f, 0.0f); + m_weaponDoorTimerLeft = max(m_weaponDoorTimerLeft - CTimer::GetTimeStep()*0.1f, 0.0f); ProcessOpenDoor(CAR_DOOR_LF, NUM_ANIMS, m_weaponDoorTimerLeft); } if(!lookingRight && m_weaponDoorTimerRight > 0.0f){ - m_weaponDoorTimerRight = Max(m_weaponDoorTimerRight - CTimer::GetTimeStep()*0.1f, 0.0f); + m_weaponDoorTimerRight = max(m_weaponDoorTimerRight - CTimer::GetTimeStep()*0.1f, 0.0f); ProcessOpenDoor(CAR_DOOR_RF, NUM_ANIMS, m_weaponDoorTimerRight); } } @@ -3133,7 +3133,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece) FindPlayerPed()->SetWantedLevelNoDrop(1); if(m_status == STATUS_PLAYER && impulse > 50.0f){ - uint8 freq = Min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f); + uint8 freq = min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f); CPad::GetPad(0)->StartShake(40000/freq, freq); } @@ -3286,7 +3286,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece) if(m_pDamageEntity && m_pDamageEntity == FindPlayerVehicle() && impulse > 10.0f){ int money = (doubleMoney ? 2 : 1) * impulse*pHandling->nMonetaryValue/1000000.0f; - money = Min(money, 40); + money = min(money, 40); if(money > 2){ sprintf(gString, "$%d", money); CWorld::Players[CWorld::PlayerInFocus].m_nMoney += money; @@ -3989,7 +3989,7 @@ CAutomobile::SetupSuspensionLines(void) // adjust col model to include suspension lines if(colModel->boundingBox.min.z > colModel->lines[0].p1.z) colModel->boundingBox.min.z = colModel->lines[0].p1.z; - float radius = Max(colModel->boundingBox.min.Magnitude(), colModel->boundingBox.max.Magnitude()); + float radius = max(colModel->boundingBox.min.Magnitude(), colModel->boundingBox.max.Magnitude()); if(colModel->boundingSphere.radius < radius) colModel->boundingSphere.radius = radius; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 2b5ff567..f614b78f 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -61,7 +61,7 @@ float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat) float fDist = vecDist.MagnitudeSqr(); if ( fDist < SQR(fMaxDist) ) - return 1.0f - Min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f); + return 1.0f - min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f); } return 0.0f; diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 39fc7ec4..aab9dd0d 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -223,19 +223,19 @@ CHeli::ProcessControl(void) switch(m_heliStatus){ case HELI_STATUS_HOVER: groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil); - m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f; + m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f; break; case HELI_STATUS_SHOT_DOWN: groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil); - m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset; + m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset; break; case HELI_STATUS_HOVER2: groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil); - m_fTargetZ = Max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset; + m_fTargetZ = max(groundZ, m_fTargetZ) + 8.0f + m_fTargetOffset; break; default: groundZ = CWorld::FindGroundZFor3DCoord(GetPosition().x, GetPosition().y, 1000.0f, nil); - m_fTargetZ = Max(groundZ, m_fTargetZ) + 12.0f; + m_fTargetZ = max(groundZ, m_fTargetZ) + 12.0f; break; } @@ -994,7 +994,7 @@ CHeli::TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, i float distToHeli = (pHelis[i]->GetPosition() - *line0).Magnitude(); CVector line = (*line1 - *line0); float lineLength = line.Magnitude(); - *bulletPos = *line0 + line*Max(1.0f, distToHeli-5.0f); + *bulletPos = *line0 + line*max(1.0f, distToHeli-5.0f); pHelis[i]->m_nBulletDamage += damage; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 0355cba1..4795a29f 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -273,7 +273,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon right = -contactSpeedRight/wheelsOnGround; if(wheelStatus == WHEEL_STATUS_BURST){ - float fwdspeed = Min(contactSpeedFwd, 0.3f); + float fwdspeed = min(contactSpeedFwd, 0.3f); right += fwdspeed * CGeneral::GetRandomNumberInRange(-0.1f, 0.1f); } } @@ -363,7 +363,7 @@ CVehicle::ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVec void CVehicle::ExtinguishCarFire(void) { - m_fHealth = Max(m_fHealth, 300.0f); + m_fHealth = max(m_fHealth, 300.0f); if(m_pCarFire) m_pCarFire->Extinguish(); if(IsCar()){ @@ -638,13 +638,13 @@ CVehicle::SetDriver(CPed *driver) if(bFreebies && driver == FindPlayerPed()){ if(GetModelIndex() == MI_AMBULAN) - FindPlayerPed()->m_fHealth = Min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f); + FindPlayerPed()->m_fHealth = min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f); else if(GetModelIndex() == MI_TAXI) CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25; else if(GetModelIndex() == MI_POLICE) driver->GiveWeapon(WEAPONTYPE_SHOTGUN, 5); else if(GetModelIndex() == MI_ENFORCER) - driver->m_fArmour = Max(driver->m_fArmour, 100.0f); + driver->m_fArmour = max(driver->m_fArmour, 100.0f); else if(GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE) CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25; bFreebies = false; |