From d17d437de319ca4c388dc724cffea91702d3a699 Mon Sep 17 00:00:00 2001 From: withmorten Date: Mon, 28 Jun 2021 13:57:05 +0200 Subject: rename clamp macro to Clamp to fix compilation with g++11 (and clamp2 for consistency sake) --- src/audio/AudioLogic.cpp | 22 +++++++++++----------- src/audio/AudioManager.cpp | 8 ++++---- src/audio/oal/stream.cpp | 10 +++++----- src/audio/sampman_miles.cpp | 2 +- src/audio/sampman_oal.cpp | 4 ++-- src/control/CarCtrl.cpp | 4 ++-- src/control/Replay.cpp | 38 +++++++++++++++++++------------------- src/control/Script4.cpp | 4 ++-- src/core/Cam.cpp | 18 +++++++++--------- src/core/Camera.cpp | 10 +++++----- src/core/FileLoader.cpp | 2 +- src/core/Frontend.cpp | 28 ++++++++++++++-------------- src/core/Frontend_PS2.cpp | 4 ++-- src/core/General.h | 2 +- src/core/PlayerInfo.cpp | 2 +- src/core/Ropes.cpp | 2 +- src/core/World.cpp | 4 ++-- src/core/common.h | 4 ++-- src/entities/Physical.cpp | 2 +- src/extras/screendroplets.cpp | 2 +- src/objects/Object.cpp | 6 +++--- src/objects/Stinger.cpp | 2 +- src/peds/PedFight.cpp | 6 +++--- src/peds/PedIK.cpp | 16 ++++++++-------- src/peds/Population.cpp | 2 +- src/render/Coronas.cpp | 2 +- src/render/Fluff.cpp | 2 +- src/render/Glass.cpp | 4 ++-- src/render/Hud.cpp | 2 +- src/render/MBlur.cpp | 18 +++++++++--------- src/render/Particle.cpp | 16 ++++++++-------- src/render/Sprite.cpp | 8 ++++---- src/render/WaterLevel.cpp | 40 ++++++++++++++++++++-------------------- src/render/Weather.cpp | 2 +- src/vehicles/Automobile.cpp | 20 ++++++++++---------- src/vehicles/Bike.cpp | 16 ++++++++-------- src/vehicles/Boat.cpp | 22 +++++++++++----------- src/vehicles/Door.cpp | 4 ++-- src/vehicles/Heli.cpp | 2 +- src/vehicles/Vehicle.cpp | 14 +++++++------- src/weapons/Weapon.cpp | 2 +- 41 files changed, 189 insertions(+), 189 deletions(-) (limited to 'src') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index e4340bdc..3ec40437 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -989,8 +989,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params) freq = 25000; } if (isPlayerVeh) { - volume = clamp2(volume, prevVolume, 7); - freq = clamp2(freq, prevFreq, 800); + volume = Clamp2(volume, prevVolume, 7); + freq = Clamp2(freq, prevFreq, 800); } if (volume > 0) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -1038,8 +1038,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params) freq = Min(22000, (8000 * acceletateState / 255 + 14000) * 3.0f * Abs(params.m_fVelocityChange)); } if (isPlayerVeh && !vehSlowdown) { - volume = clamp2(volume, prevVolume, 7); - freq = clamp2(freq, prevFreq, 800); + volume = Clamp2(volume, prevVolume, 7); + freq = Clamp2(freq, prevFreq, 800); } if (!vehSlowdown) #ifdef THIS_IS_STUPID @@ -1118,7 +1118,7 @@ cAudioManager::ProcessModelHeliVehicle(cVehicleParams& params) } if (acceletateState < brakeState) acceletateState = brakeState; - freq = clamp2(5 * acceletateState + 22050, prevFreq, 30); + freq = Clamp2(5 * acceletateState + 22050, prevFreq, 30); CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(70, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { @@ -1658,8 +1658,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh bHandbrakeOnLastFrame = FALSE; } if (CReplay::IsPlayingBack()) { - accelerateState = (255.0f * clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f)); - brakeState = (255.0f * clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f)); + accelerateState = (255.0f * Clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f)); + brakeState = (255.0f * Clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f)); } else { accelerateState = Pads[0].GetAccelerate(); brakeState = Pads[0].GetBrake(); @@ -1810,7 +1810,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh } } relativeVelocityChange = 2.0f * params.m_fVelocityChange / params.m_pTransmission->fMaxVelocity; - accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); + accelerationMultipler = Clamp(relativeVelocityChange, 0.0f, 1.0f); gasPedalAudio = accelerationMultipler; switch (engineSoundType) { case SFX_BANK_MOPED: @@ -3585,7 +3585,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197); + m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197); freqFrontPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_bIs2D = FALSE; @@ -3641,7 +3641,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params) if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98); + m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98); freqPropellerPrev = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; @@ -3710,7 +3710,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197); + m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197); freqSkimmerPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index aa6a0653..360a2275 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -331,7 +331,7 @@ cAudioManager::Get3DProviderName(uint8 id) const if (!m_bIsInitialised) return nil; #ifdef AUDIO_OAL - id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1); + id = Clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1); #else // We don't want that either since it will crash the game, but skipping for now if (id >= SampleManager.GetNum3DProvidersAvailable()) @@ -531,7 +531,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, if (dist != 0.0f) { float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier; if (m_fSpeedOfSound > Abs(speedOfSource)) { - speedOfSource = clamp2(speedOfSource, 0.0f, 1.5f); + speedOfSource = Clamp2(speedOfSource, 0.0f, 1.5f); newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound); } } @@ -895,11 +895,11 @@ cAudioManager::ProcessActiveQueues() sample.m_fSpeedMultiplier); if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { - m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); + m_asActiveSamples[j].m_nFrequency = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); } if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { - vol = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); + vol = Clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); if (field_4) { emittingVol = 2 * Min(63, vol); diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index ab266681..7fc36acd 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -162,7 +162,7 @@ public: else StepIndex--; - StepIndex = clamp(StepIndex, 0, 88); + StepIndex = Clamp(StepIndex, 0, 88); int delta = step >> 3; if (adpcm & 1) delta += step >> 2; @@ -171,7 +171,7 @@ public: if (adpcm & 8) delta = -delta; int newSample = Sample + delta; - Sample = clamp(newSample, -32768, 32767); + Sample = Clamp(newSample, -32768, 32767); return Sample; } }; @@ -716,7 +716,7 @@ public: static short quantize(double sample) { int a = int(sample + 0.5); - return short(clamp(a, -32768, 32767)); + return short(Clamp(a, -32768, 32767)); } void Decode(void* _inbuf, int16* _outbuf, size_t size) @@ -1448,10 +1448,10 @@ void CStream::SetVolume(uint32 nVol) void CStream::SetPan(uint8 nPan) { - m_nPan = clamp((int8)nPan - 63, 0, 63); + m_nPan = Clamp((int8)nPan - 63, 0, 63); SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); - m_nPan = clamp((int8)nPan + 64, 64, 127); + m_nPan = Clamp((int8)nPan + 64, 64, 127); SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); m_nPan = nPan; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 8191cbf7..e8c28dc4 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1659,7 +1659,7 @@ cSampleManager::UpdateReverb(void) #undef CALCULATE_RATIO #undef MIN_DIST - fRatio = clamp(fRatio, 0.0f, 0.6f); + fRatio = Clamp(fRatio, 0.0f, 0.6f); if ( fRatio == _fPrevEaxRatioDestination ) return FALSE; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 2c7d4cec..fa262c98 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -356,7 +356,7 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) { int savedprovider = curprovider; - nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1); + nProvider = Clamp(nProvider, 0, m_nNumberOfProviders - 1); if ( set_new_provider(nProvider) ) return curprovider; @@ -1449,7 +1449,7 @@ bool8 cSampleManager::UpdateReverb(void) #undef CALCULATE_RATIO #undef MIN_DIST - fRatio = clamp(fRatio, 0.0f, 0.6f); + fRatio = Clamp(fRatio, 0.0f, 0.6f); if ( fRatio == _fPrevEaxRatioDestination ) return FALSE; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 21526d5e..5e4e62ee 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -2575,7 +2575,7 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y); float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y); float steerAngle = LimitRadianAngle(angleToTarget - angleForward); - steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE); + steerAngle = Clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE); #ifdef FIX_BUGS float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed(); #else @@ -2735,7 +2735,7 @@ void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane) { CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition(); float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude(); - fForwardZ = clamp(fForwardZ, -0.3f, 0.3f); + fForwardZ = Clamp(fForwardZ, -0.3f, 0.3f); float angle = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y); while (angle > TWOPI) angle -= TWOPI; diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 7e8bee6b..71b28f7a 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -425,9 +425,9 @@ void CReplay::RecordParticle(tParticleType type, const CVector& vecPos, const CV pp->pos_x = 4.0f * vecPos.x; pp->pos_y = 4.0f * vecPos.y; pp->pos_z = 4.0f * vecPos.z; - pp->dir_x = 120.0f * clamp(vecDir.x, -1.0f, 1.0f); - pp->dir_y = 120.0f * clamp(vecDir.y, -1.0f, 1.0f); - pp->dir_z = 120.0f * clamp(vecDir.z, -1.0f, 1.0f); + pp->dir_x = 120.0f * Clamp(vecDir.x, -1.0f, 1.0f); + pp->dir_y = 120.0f * Clamp(vecDir.y, -1.0f, 1.0f); + pp->dir_z = 120.0f * Clamp(vecDir.z, -1.0f, 1.0f); pp->size = fSize; pp->r = color.red; pp->g = color.green; @@ -463,8 +463,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 * clamp(main->currentTime, 0.0f, 4.0f); - state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f); + state->time = 255.0f / 4.0f * Clamp(main->currentTime, 0.0f, 4.0f); + state->speed = 255.0f / 3.0f * Clamp(main->speed, 0.0f, 3.0f); state->groupId = main->groupId; }else{ state->animId = 3; @@ -474,9 +474,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) } if (second) { state->secAnimId = second->animId; - state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f); - state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f); - state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f); + state->secTime = 255.0f / 4.0f * Clamp(second->currentTime, 0.0f, 4.0f); + state->secSpeed = 255.0f / 3.0f * Clamp(second->speed, 0.0f, 3.0f); + state->blendAmount = 255.0f / 2.0f * Clamp(blend_amount, 0.0f, 2.0f); state->secGroupId = second->groupId; }else{ state->secAnimId = 0; @@ -488,9 +488,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 * clamp(partial->currentTime, 0.0f, 4.0f); - state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f); - state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f); + state->partAnimTime = 255.0f / 4.0f * Clamp(partial->currentTime, 0.0f, 4.0f); + state->partAnimSpeed = 255.0f / 3.0f * Clamp(partial->speed, 0.0f, 3.0f); + state->partBlendAmount = 255.0f / 2.0f * Clamp(partial->blendAmount, 0.0f, 2.0f); state->partGroupId = partial->groupId; }else{ state->partAnimId = 0; @@ -507,10 +507,10 @@ 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 * clamp(assoc->currentTime, 0.0f, 4.0f); - state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f); - state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f); - state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f); + state->aCurTime[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f); + state->aSpeed[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f); + state->aBlendAmount[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f); + state->aBlendDelta[i] = 127.0f / 32.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f); state->aFlags[i] = assoc->flags; state->aGroupId[i] = assoc->groupId; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { @@ -533,10 +533,10 @@ 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 * clamp(assoc->currentTime, 0.0f, 4.0f); - state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f); - state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f); - state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f); + state->aCurTime2[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f); + state->aSpeed2[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f); + state->aBlendAmount2[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f); + state->aBlendDelta2[i] = 127.0f / 16.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f); state->aFlags2[i] = assoc->flags; state->aGroupId2[i] = assoc->groupId; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 2e443110..ac632b15 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -749,7 +749,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 2); CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; script_assert(pPlayerPed); - pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, CWorld::Players[ScriptParams[0]].m_nMaxArmour); + pPlayerPed->m_fArmour = Clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, CWorld::Players[ScriptParams[0]].m_nMaxArmour); return 0; } case COMMAND_ADD_ARMOUR_TO_CHAR: @@ -757,7 +757,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); script_assert(pPed); - pPed->m_fArmour = clamp(pPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f); + pPed->m_fArmour = Clamp(pPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f); return 0; } case COMMAND_OPEN_GARAGE: diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index ad315029..cafbd340 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -1183,7 +1183,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl float ReqSpeed = DeltaBeta * SpeedMultiplier; // this is also added - ReqSpeed = clamp(ReqSpeed, -SpeedLimit, SpeedLimit); + ReqSpeed = Clamp(ReqSpeed, -SpeedLimit, SpeedLimit); // Add or subtract absolute depending on sign, genius! if(ReqSpeed - BetaSpeed > 0.0f) @@ -1678,7 +1678,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa Test.z = TargetCoors.z + 0.2f + Length*Sin(CarAlpha+AlphaOffset) + m_fCloseInCarHeightOffset; if(CWorld::ProcessVerticalLine(Test, CamTargetEntity->GetPosition().z, point, entity, true, false, false, false, false, false, nil)){ float sin = (point.point.z - TargetCoors.z - 0.2f - m_fCloseInCarHeightOffset)/Length; - CarAlpha = Asin(clamp(sin, -1.0f, 1.0f)) - AlphaOffset; + CarAlpha = Asin(Clamp(sin, -1.0f, 1.0f)) - AlphaOffset; if(CarAlpha < 0.0f) AlphaOffset += CarAlpha; } @@ -1828,7 +1828,7 @@ CCam::Process_Cam_On_A_String(const CVector &CameraTarget, float TargetOrientati if(DeltaBeta > PI) DeltaBeta -= TWOPI; else if(DeltaBeta < -PI) DeltaBeta += TWOPI; float dist = (TargetCoors - Source).Magnitude(); - dist = FIRETRUCK_TRACKING_MULT*dist*clamp(DeltaBeta, -0.8f, 0.8f); + dist = FIRETRUCK_TRACKING_MULT*dist*Clamp(DeltaBeta, -0.8f, 0.8f); Source += dist*CrossProduct(Front, CVector(0.0f, 0.0f, 1.0f)); } @@ -2801,7 +2801,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, if(BetaOffset > PI) BetaOffset -= TWOPI; else if(BetaOffset < PI) BetaOffset += TWOPI; - BetaOffset = clamp(BetaOffset, -pedTarget->m_attachRotStep, pedTarget->m_attachRotStep); + BetaOffset = Clamp(BetaOffset, -pedTarget->m_attachRotStep, pedTarget->m_attachRotStep); Beta = NewBeta + BetaOffset; } @@ -3271,7 +3271,7 @@ CCam::Process_BehindBoat(const CVector &CameraTarget, float TargetOrientation, f // useless call //CWaterLevel::GetWaterLevelNoWaves(TargetCoors.x, TargetCoors.y, TargetCoors.z, &Water); Water = (WaterLevel + WATER_Z_ADDITION_MIN - WaterLevelBuffered - WATER_Z_ADDITION)/(BoatDimensions.z/2.0f + MaxHeightUp); - TargetAlpha = Asin(clamp(Water, -1.0f, 1.0f)); + TargetAlpha = Asin(Clamp(Water, -1.0f, 1.0f)); } if(ResetStatics){ @@ -3457,7 +3457,7 @@ FindSplinePathPositionFloat(float *out, float *spline, uint32 time, uint32 &mark } } float a = ((float)time - (float)MS(spline[marker-4])) / (float)MS(spline[marker] - spline[marker-4]); - a = clamp(a, 0.0f, 1.0f); + a = Clamp(a, 0.0f, 1.0f); float b = 1.0f - a; *out = b*b*b * spline[marker-3] + 3.0f*a*b*b * spline[marker-1] + @@ -3495,7 +3495,7 @@ FindSplinePathPositionVector(CVector *out, float *spline, uint32 time, uint32 &m } float a = ((float)time - (float)MS(spline[marker-10])) / (float)MS(spline[marker] - spline[marker-10]); - a = clamp(a, 0.0f, 1.0f); + a = Clamp(a, 0.0f, 1.0f); float b = 1.0f - a; out->x = b*b*b * spline[marker-9] + @@ -4921,7 +4921,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, // 0.98f: CAR_FOV_FADE_MULT FOV = Pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV; - FOV = clamp(FOV, DefaultFOV, DefaultFOV + 30.0f); + FOV = Clamp(FOV, DefaultFOV, DefaultFOV + 30.0f); } // WORKAROUND: I still don't know how looking behind works (m_bCamDirectlyInFront is unused in III, they seem to use m_bUseTransitionBeta) @@ -5040,7 +5040,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, } } - float targetAlpha = Asin(clamp(Front.z, -1.0f, 1.0f)) - zoomModeAlphaOffset; + float targetAlpha = Asin(Clamp(Front.z, -1.0f, 1.0f)) - zoomModeAlphaOffset; if (targetAlpha <= maxAlphaAllowed) { if (targetAlpha < -CARCAM_SET[camSetArrPos][14]) targetAlpha = -CARCAM_SET[camSetArrPos][14]; diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index d94efb03..e7cd65a0 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -347,7 +347,7 @@ CCamera::Process(void) currentTime = m_uiTransitionDuration; float fractionInter = (float) currentTime / m_uiTransitionDuration; float fractionInterTarget = (float) currentTime / m_uiTransitionDurationTargetCoors; - fractionInterTarget = clamp(fractionInterTarget, 0.0f, 1.0f); + fractionInterTarget = Clamp(fractionInterTarget, 0.0f, 1.0f); // Interpolate target separately if(fractionInterTarget <= m_fFractionInterToStopMovingTarget){ @@ -551,7 +551,7 @@ CCamera::Process(void) // Process Shake float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f; - shakeStrength = clamp(shakeStrength, 0.0f, 2.0f); + shakeStrength = Clamp(shakeStrength, 0.0f, 2.0f); int shakeRand = CGeneral::GetRandomNumber(); float shakeOffset = shakeStrength*0.1f; GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7); @@ -1913,7 +1913,7 @@ CCamera::CamShake(float strength, float x, float y, float z) float curForce = mult*(m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - m_uiCamShakeStart)/1000.0f); strength = mult*strength; - if(clamp(curForce, 0.0f, 2.0f) < strength){ + if(Clamp(curForce, 0.0f, 2.0f) < strength){ m_fCamShakeForce = strength; m_uiCamShakeStart = CTimer::GetTimeInMilliseconds(); } @@ -1924,7 +1924,7 @@ void CamShakeNoPos(CCamera *cam, float strength) { float curForce = cam->m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - cam->m_uiCamShakeStart)/1000.0f; - if(clamp(curForce, 0.0f, 2.0f) < strength){ + if(Clamp(curForce, 0.0f, 2.0f) < strength){ cam->m_fCamShakeForce = strength; cam->m_uiCamShakeStart = CTimer::GetTimeInMilliseconds(); } @@ -3985,7 +3985,7 @@ CCamera::Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, float CCamera::Find3rdPersonQuickAimPitch(void) { - float clampedFrontZ = clamp(Cams[ActiveCam].Front.z, -1.0f, 1.0f); + float clampedFrontZ = Clamp(Cams[ActiveCam].Front.z, -1.0f, 1.0f); float rot = Asin(clampedFrontZ); diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 4ad53572..dbf2cad9 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -1074,7 +1074,7 @@ CFileLoader::Load2dEffect(const char *line) &probability); effect->attractor.type = flags; #ifdef FIX_BUGS - effect->attractor.probability = clamp(probability, 0, 255); + effect->attractor.probability = Clamp(probability, 0, 255); #else effect->attractor.probability = probability; #endif diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 7491b7e2..13db6b98 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -697,27 +697,27 @@ CMenuManager::CheckSliderMovement(int value) switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_BRIGHTNESS: m_PrefsBrightness += value * 24.19f; - m_PrefsBrightness = clamp(m_PrefsBrightness, 0, 384); + m_PrefsBrightness = Clamp(m_PrefsBrightness, 0, 384); break; case MENUACTION_DRAWDIST: if(value > 0) m_PrefsLOD += ((1.8f - 0.925f) / 16.0f); else m_PrefsLOD -= ((1.8f - 0.925f) / 16.0f); - m_PrefsLOD = clamp(m_PrefsLOD, 0.925f, 1.8f); + m_PrefsLOD = Clamp(m_PrefsLOD, 0.925f, 1.8f); CRenderer::ms_lodDistScale = m_PrefsLOD; break; case MENUACTION_MUSICVOLUME: if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { m_PrefsMusicVolume += value * (128 / 32); - m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 65); + m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 65); DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); } break; case MENUACTION_SFXVOLUME: if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { m_PrefsSfxVolume += value * (128 / 32); - m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 65); + m_PrefsSfxVolume = Clamp(m_PrefsSfxVolume, 0, 65); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); } break; @@ -725,14 +725,14 @@ CMenuManager::CheckSliderMovement(int value) if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { if (DMAudio.IsMP3RadioChannelAvailable()) { m_PrefsMP3BoostVolume += value * (128 / 32); - m_PrefsMP3BoostVolume = clamp(m_PrefsMP3BoostVolume, 0, 65); + m_PrefsMP3BoostVolume = Clamp(m_PrefsMP3BoostVolume, 0, 65); DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); } } break; case MENUACTION_MOUSESENS: TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ??? - TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f); + TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f); #ifdef FIX_BUGS TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f; #endif @@ -3473,8 +3473,8 @@ CMenuManager::Process(void) break; \ \ m_fMapSize *= z2; \ - m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); \ - m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); \ + m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); \ + m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); \ } while(0) #endif @@ -3512,8 +3512,8 @@ CMenuManager::AdditionalOptionInput(bool &goBack) m_fMapCenterX += (SCREEN_WIDTH/2 - m_fMapCenterX) / ((m_fMapSize - MENU_X(MAP_MIN_SIZE)) * 1/15.f); m_fMapSize = Max(MENU_Y(MAP_MIN_SIZE), m_fMapSize - MENU_Y(15.f)); - m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); - m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); + m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); + m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); } else { m_fMapSize = MENU_Y(MAP_MIN_SIZE); } @@ -3554,8 +3554,8 @@ CMenuManager::AdditionalOptionInput(bool &goBack) if (!justResetPointer) { m_fMapCenterX += m_nMousePosX - m_nMouseOldPosX; m_fMapCenterY += m_nMousePosY - m_nMouseOldPosY; - m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); - m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); + m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); + m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); } justResetPointer = false; @@ -5050,7 +5050,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u case MENUACTION_SPEAKERCONF: if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { m_PrefsSpeakers -= changeAmount; - m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2); + m_PrefsSpeakers = Clamp(m_PrefsSpeakers, 0, 2); DMAudio.SetSpeakerConfig(m_PrefsSpeakers); SaveSettings(); } @@ -5661,7 +5661,7 @@ CMenuManager::DrawQuitGameScreen(void) static int32 exitSignalTimer = 0; #ifdef FIX_BUGS - int alpha = clamp(m_nMenuFadeAlpha, 0, 255); + int alpha = Clamp(m_nMenuFadeAlpha, 0, 255); #else int alpha = m_nMenuFadeAlpha; #endif diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp index c635c21f..fa238031 100644 --- a/src/core/Frontend_PS2.cpp +++ b/src/core/Frontend_PS2.cpp @@ -1375,7 +1375,7 @@ CMenuManager::DrawFrontEndNormal(void) if ((m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) <= 1600) alpha = float(m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 400.0f; - m_someAlpha = 255 - clamp(alpha, 0.0f, 1.0f) * 255.0f; + m_someAlpha = 255 - Clamp(alpha, 0.0f, 1.0f) * 255.0f; switch ( m_nSlidingDir ) { @@ -1392,7 +1392,7 @@ CMenuManager::DrawFrontEndNormal(void) float slide = float(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f; float alpha = float((int32)(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) + -266) / 533.0f; - m_someAlpha = clamp(alpha, 0.0f, 1.0f) * 255.0f; + m_someAlpha = Clamp(alpha, 0.0f, 1.0f) * 255.0f; switch ( m_nSlidingDir ) { diff --git a/src/core/General.h b/src/core/General.h index 2f205c39..c17d916d 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -56,7 +56,7 @@ public: static float LimitRadianAngle(float angle) { - float result = clamp(angle, -25.0f, 25.0f); + float result = Clamp(angle, -25.0f, 25.0f); while (result >= PI) { result -= 2 * PI; diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index a64d4cca..36d05b82 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -299,7 +299,7 @@ CPlayerInfo::Process(void) m_fRoadDensity = ThePaths.CalcRoadDensity(playerPos.x, playerPos.y); } - m_fRoadDensity = clamp(m_fRoadDensity, 0.5f, 1.45f); + m_fRoadDensity = Clamp(m_fRoadDensity, 0.5f, 1.45f); // Because vehicle enter/exit use same key binding. bool enterOrExitVeh; diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp index e390a917..71297eb1 100644 --- a/src/core/Ropes.cpp +++ b/src/core/Ropes.cpp @@ -150,7 +150,7 @@ CRopes::FindCoorsAlongRope(uintptr id, float t, CVector *coors) float f; for(i = 0; i < ARRAY_SIZE(aRopes); i++) if(aRopes[i].m_bActive && aRopes[i].m_id == id){ - t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*clamp(t, 0.0f, 0.999f); + t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*Clamp(t, 0.0f, 0.999f); j = t; f = t - j; *coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1]; diff --git a/src/core/World.cpp b/src/core/World.cpp index 82f03541..841aab40 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -399,8 +399,8 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C CVector point2(point1.x, point1.y, z2); int secX = GetSectorIndexX(point1.x); int secY = GetSectorIndexY(point1.y); - secX = clamp(secX, 0, NUMSECTORS_X-1); - secY = clamp(secY, 0, NUMSECTORS_Y-1); + secX = Clamp(secX, 0, NUMSECTORS_X-1); + secY = Clamp(secY, 0, NUMSECTORS_Y-1); return ProcessVerticalLineSector(*GetSector(secX, secY), CColLine(point1, point2), point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); diff --git a/src/core/common.h b/src/core/common.h index ca29ef5a..6f6acd49 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -289,9 +289,9 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len); extern wchar *AllocUnicode(const char*src); -#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) +#define Clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) -#define clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius)) +#define Clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius)) inline float sq(float x) { return x*x; } #define SQR(x) ((x) * (x)) diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 86ef0669..890e7876 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -553,7 +553,7 @@ CPhysical::ApplyGravity(void) surfaceUp = point.normal; else surfaceUp = CVector(0.0f, 0.0f, 1.0f); - float t = clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f); + float t = Clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f); gravityUp = gravityUp * (1.0f - t) + surfaceUp * t; if (gravityUp.MagnitudeSqr() < 0.1f) gravityUp = CVector(0.0f, 0.0f, 1.0f); diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 1412141e..2485386b 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -423,7 +423,7 @@ ScreenDroplets::ProcessCameraMovement(void) ms_movingEnabled = !isTopDown && !isLookingInDirection; // 0 when looking stright up, 180 when looking up or down - ms_camUpAngle = RADTODEG(Acos(clamp(camUp.z, -1.0f, 1.0f))); + ms_camUpAngle = RADTODEG(Acos(Clamp(camUp.z, -1.0f, 1.0f))); } void diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 575c592c..64c9e256 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -234,9 +234,9 @@ CObject::Render(void) float green = (0.8f * CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj()) * 165.75f; float blue = (0.8f * CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj()) * 165.75f; - red = clamp(red, 0.0f, 255.0f); - green = clamp(green, 0.0f, 255.0f); - blue = clamp(blue, 0.0f, 255.0f); + red = Clamp(red, 0.0f, 255.0f); + green = Clamp(green, 0.0f, 255.0f); + blue = Clamp(blue, 0.0f, 255.0f); int alpha = CGeneral::GetRandomNumberInRange(196, 225); diff --git a/src/objects/Stinger.cpp b/src/objects/Stinger.cpp index 29efea10..d3eee416 100644 --- a/src/objects/Stinger.cpp +++ b/src/objects/Stinger.cpp @@ -220,7 +220,7 @@ CStinger::Process() float degangle = progress * ARRAY_SIZE(m_vPositions); float angle1 = m_fMax_Z + DEGTORAD(degangle); float angle2 = m_fMax_Z - DEGTORAD(degangle); - int pos = clamp(degangle, 0, ARRAY_SIZE(m_vPositions)-1); + int pos = Clamp(degangle, 0, ARRAY_SIZE(m_vPositions)-1); CVector2D pos2d = m_vPositions[pos]; CVector pos3d = m_vPos; diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index 9ea0ae4e..7bcf6b6c 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -3915,7 +3915,7 @@ CPed::DriveVehicle(void) targetLRLean = 0.0f; timeBlend = Pow(0.86f, CTimer::GetTimeStep()); } else { - targetLRLean = clamp(bike->m_fLeanLRAngle / bike->pBikeHandling->fFullAnimLean, -1.0f, 1.0f); + targetLRLean = Clamp(bike->m_fLeanLRAngle / bike->pBikeHandling->fFullAnimLean, -1.0f, 1.0f); timeBlend = Pow(0.86f, CTimer::GetTimeStep()); } @@ -4102,7 +4102,7 @@ CPed::DriveVehicle(void) lDriveAssoc->blendAmount = 0.0f; if (rDriveAssoc) - rDriveAssoc->blendAmount = clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f); + rDriveAssoc->blendAmount = Clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f); else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_RIGHT); else if (m_pMyVehicle->bLowVehicle) @@ -4115,7 +4115,7 @@ CPed::DriveVehicle(void) rDriveAssoc->blendAmount = 0.0f; if (lDriveAssoc) - lDriveAssoc->blendAmount = clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f); + lDriveAssoc->blendAmount = Clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f); else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_LEFT); else if (m_pMyVehicle->bLowVehicle) diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 475e04f1..6730d731 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -79,7 +79,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb } if (limb.yaw > moveInfo.maxYaw || limb.yaw < moveInfo.minYaw) { - limb.yaw = clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw); + limb.yaw = Clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw); result = ANGLES_SET_TO_MAX; } @@ -97,7 +97,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb } if (limb.pitch > moveInfo.maxPitch || limb.pitch < moveInfo.minPitch) { - limb.pitch = clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch); + limb.pitch = Clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch); result = ANGLES_SET_TO_MAX; } return result; @@ -122,14 +122,14 @@ CPedIK::LookInDirection(float targetYaw, float targetPitch) m_headOrient.yaw = Atan2(-m->at.y, -m->at.x); m_headOrient.yaw -= m_ped->m_fRotationCur; m_headOrient.yaw = CGeneral::LimitRadianAngle(m_headOrient.yaw); - float up = clamp(m->up.z, -1.0f, 1.0f); + float up = Clamp(m->up.z, -1.0f, 1.0f); m_headOrient.pitch = Atan2(-up, Sqrt(1.0f - SQR(-up))); } // parent of head is neck RwMatrix *m = GetComponentMatrix(m_ped, PED_NECK); yaw = CGeneral::LimitRadianAngle(Atan2(-m->at.y, -m->at.x)); - float up = clamp(m->up.z, -1.0f, 1.0f); + float up = Clamp(m->up.z, -1.0f, 1.0f); pitch = Atan2(-up, Sqrt(1.0f - SQR(-up))); float headYaw = CGeneral::LimitRadianAngle(targetYaw - (yaw + m_torsoOrient.yaw)); float headPitch = CGeneral::LimitRadianAngle(targetPitch - pitch) * Cos(Min(Abs(headYaw), HALFPI)); @@ -336,11 +336,11 @@ CPedIK::RestoreLookAt(void) void CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch) { - float f = clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f); + float f = Clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f); *yaw = Acos(f); if (mat->up.x > 0.0f) *yaw = -*yaw; - f = clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); + f = Clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); *pitch = Acos(f); if (mat->up.z > 0.0f) *pitch = -*pitch; } @@ -348,11 +348,11 @@ CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch) void CPedIK::ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch) { - float f = clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); + float f = Clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); *yaw = Acos(f); if (mat->at.y > 0.0f) *yaw = -*yaw; - f = clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f); + f = Clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f); *pitch = Acos(f); if (mat->up.x > 0.0f) *pitch = -*pitch; } diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 6a41b0c1..384cef99 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -413,7 +413,7 @@ CPopulation::PedCreationDistMultiplier() return 1.0f; float vehSpeed = veh->m_vecMoveSpeed.Magnitude2D(); - return clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f); + return Clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f); } CPed* diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index 8b137aad..d9bf88d1 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -493,7 +493,7 @@ CCoronas::RenderReflections(void) if(spriteCoors.z < drawDist){ float fadeDistance = drawDist / 2.0f; float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance; - distanceFade = clamp(distanceFade, 0.0f, 1.0f); + distanceFade = Clamp(distanceFade, 0.0f, 1.0f); float recipz = 1.0f/RwCameraGetNearClipPlane(Scene.camera); float heightFade = (20.0f - aCoronas[i].heightAboveRoad)/20.0f; int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads; diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index f2d6d0b3..13dba1a6 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -1155,7 +1155,7 @@ void CScriptPath::Update(void) { return; m_fPosition += m_fSpeed * CTimer::GetTimeStepInSeconds(); - m_fPosition = clamp(m_fPosition, 0.0f, m_fTotalLength); + m_fPosition = Clamp(m_fPosition, 0.0f, m_fTotalLength); if (m_pObjects[0] || m_pObjects[1] || m_pObjects[2] || m_pObjects[3] || m_pObjects[4] || m_pObjects[5]) { diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index 3409a058..b4ec8c7e 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -151,9 +151,9 @@ CFallingGlassPane::Render(void) uint8 alpha = CGlass::CalcAlphaWithNormal(&fwdNorm); #ifdef FIX_BUGS - uint16 time = clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u); + uint16 time = Clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u); #else - uint16 time = clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500); + uint16 time = Clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500); #endif uint8 color = int32( float(alpha) * (float(time) / 500) ); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 91503917..33f33358 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -2070,7 +2070,7 @@ float CHud::DrawFadeState(DRAW_FADE_STATE fadingElement, int forceFadingIn) break; } - return clamp(alpha, 0.0f, 255.0f); + return Clamp(alpha, 0.0f, 255.0f); } void diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 9f5122dc..cc8270ce 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -283,10 +283,10 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect, RwIm2DVertex *verts v1 = y1/height + v1Off; u2 = x2/width + u2Off; v2 = y2/height + v2Off; - u1 = clamp(u1, 0.0f, 1.0f); - v1 = clamp(v1, 0.0f, 1.0f); - u2 = clamp(u2, 0.0f, 1.0f); - v2 = clamp(v2, 0.0f, 1.0f); + u1 = Clamp(u1, 0.0f, 1.0f); + v1 = Clamp(v1, 0.0f, 1.0f); + u2 = Clamp(u2, 0.0f, 1.0f); + v2 = Clamp(v2, 0.0f, 1.0f); } float recipz = 1.0f/z; @@ -517,7 +517,7 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, void CMBlur::SetDrunkBlur(float drunkness) { - Drunkness = clamp(drunkness, 0.0f, 1.0f); + Drunkness = Clamp(drunkness, 0.0f, 1.0f); } void @@ -598,9 +598,9 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf) int red = (0.75f*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed())*0.55f * 255; int green = (0.75f*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen())*0.55f * 255; int blue = (0.75f*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue())*0.55f * 255; - red = clamp(red, 0, 255); - green = clamp(green, 0, 255); - blue = clamp(blue, 0, 255); + red = Clamp(red, 0, 255); + green = Clamp(green, 0, 255); + blue = Clamp(blue, 0, 255); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); @@ -695,7 +695,7 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf) int alpha = FrontEndMenuManager.m_PrefsBrightness > 255 ? FrontEndMenuManager.m_PrefsBrightness - 90 : FrontEndMenuManager.m_PrefsBrightness - 130; - alpha = clamp(alpha, 16, 200)/2; + alpha = Clamp(alpha, 16, 200)/2; CreateImmediateModeData(cam, &fxRect[i], verts, CRGBA(0, 0, 0, alpha), 0.0f, 0.0f, 0.0f, 0.0f, fxZ[i], true); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpHeatHazeRaster); diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index f6d48aef..461a10a6 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -971,15 +971,15 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe int32 ColorVariation = CGeneral::GetRandomNumberInRange(-psystem->m_InitialColorVariation, psystem->m_InitialColorVariation); //float ColorVariation = CGeneral::GetRandomNumberInRange((float)-psystem->m_InitialColorVariation, (float)psystem->m_InitialColorVariation); - pParticle->m_Color.red = clamp(pParticle->m_Color.red + + pParticle->m_Color.red = Clamp(pParticle->m_Color.red + PERCENT(pParticle->m_Color.red, ColorVariation), 0, 255); - pParticle->m_Color.green = clamp(pParticle->m_Color.green + + pParticle->m_Color.green = Clamp(pParticle->m_Color.green + PERCENT(pParticle->m_Color.green, ColorVariation), 0, 255); - pParticle->m_Color.blue = clamp(pParticle->m_Color.blue + + pParticle->m_Color.blue = Clamp(pParticle->m_Color.blue + PERCENT(pParticle->m_Color.blue, ColorVariation), 0, 255); } @@ -1385,15 +1385,15 @@ void CParticle::Update() { float colorMul = 1.0f - float(particle->m_nTimeWhenColorWillBeChanged - CTimer::GetTimeInMilliseconds()) / float(psystem->m_ColorFadeTime); - particle->m_Color.red = clamp( + particle->m_Color.red = Clamp( psystem->m_RenderColouring.red + int32(float(psystem->m_FadeDestinationColor.red - psystem->m_RenderColouring.red) * colorMul), 0, 255); - particle->m_Color.green = clamp( + particle->m_Color.green = Clamp( psystem->m_RenderColouring.green + int32(float(psystem->m_FadeDestinationColor.green - psystem->m_RenderColouring.green) * colorMul), 0, 255); - particle->m_Color.blue = clamp( + particle->m_Color.blue = Clamp( psystem->m_RenderColouring.blue + int32(float(psystem->m_FadeDestinationColor.blue - psystem->m_RenderColouring.blue) * colorMul), 0, 255); } @@ -1703,13 +1703,13 @@ void CParticle::Update() if ( particle->m_nFadeToBlackTimer != 0 ) { - particle->m_nColorIntensity = clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer, + particle->m_nColorIntensity = Clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer, 0, 255); } if ( particle->m_nFadeAlphaTimer != 0 ) { - particle->m_nAlpha = clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer, + particle->m_nAlpha = Clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer, 0, 255); if ( particle->m_nAlpha == 0 ) { diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index ba6ab291..58b29ea9 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -401,13 +401,13 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f // Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2 cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; - cf[0] = clamp(cf[0], 0.0f, 1.0f); + cf[0] = Clamp(cf[0], 0.0f, 1.0f); cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f; - cf[1] = clamp(cf[1], 0.0f, 1.0f); + cf[1] = Clamp(cf[1], 0.0f, 1.0f); cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f; - cf[2] = clamp(cf[2], 0.0f, 1.0f); + cf[2] = Clamp(cf[2], 0.0f, 1.0f); cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f; - cf[3] = clamp(cf[3], 0.0f, 1.0f); + cf[3] = Clamp(cf[3], 0.0f, 1.0f); float screenz = m_f2DNearScreenZ + (z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index 16182137..dee60d66 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -179,10 +179,10 @@ CWaterLevel::Initialise(Const char *pWaterDat) int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top); int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f; - l = clamp(l, 0, MAX_SMALL_SECTORS - 1); - r = clamp(r, 0, MAX_SMALL_SECTORS - 1); - t = clamp(t, 0, MAX_SMALL_SECTORS - 1); - b = clamp(b, 0, MAX_SMALL_SECTORS - 1); + l = Clamp(l, 0, MAX_SMALL_SECTORS - 1); + r = Clamp(r, 0, MAX_SMALL_SECTORS - 1); + t = Clamp(t, 0, MAX_SMALL_SECTORS - 1); + b = Clamp(b, 0, MAX_SMALL_SECTORS - 1); for (int32 x = l; x <= r; x++) { @@ -991,10 +991,10 @@ CWaterLevel::RenderWater() if ( bUseCamEndY ) nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y); - nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1); - nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1); - nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1); - nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1); + nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1); + nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1); + nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1); + nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1); for ( int32 x = nStartX; x <= nEndX; x++ ) { @@ -1259,10 +1259,10 @@ CWaterLevel::RenderTransparentWater(void) if ( bUseCamEndY ) nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y ); - nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1); - nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1); - nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1); - nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1); + nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1); + nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1); + nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1); + nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1); for ( int32 x = nStartX; x <= nEndX; x++ ) @@ -2161,10 +2161,10 @@ CWaterLevel::PreCalcWaterGeometry(void) float signX = CamFwdDir.x * 1.4144272f; float signY = CamFwdDir.y * 1.4144272f; - signX = clamp(signX, -1.0f, 1.0f); + signX = Clamp(signX, -1.0f, 1.0f); fCamX += 0.4f * signX * float(SMALL_SECTOR_SIZE * 2.0f); - signY = clamp(signY, -1.0f, 1.0f); + signY = Clamp(signY, -1.0f, 1.0f); fCamY += 0.4f * signY * float(SMALL_SECTOR_SIZE * 2.0f); int32 nBlock; @@ -2578,7 +2578,7 @@ CWaterLevel::RenderBoatWakes(void) float val = 500.0f - (CBoat::WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[wake]) * 600.0f / CBoat::WAKE_LIFETIME; - fAplhaB = clamp(val, 0.0f, 255.0f); + fAplhaB = Clamp(val, 0.0f, 255.0f); } CVector2D vecDistB = pBoat->m_avec2dWakePoints[wake - 1] - pBoat->m_avec2dWakePoints[wake]; @@ -2888,10 +2888,10 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY) int32 nStartY = WATER_TO_SMALL_SECTOR_Y(fY - fSectorMaxRenderDist) - 1; int32 nEndY = WATER_TO_SMALL_SECTOR_Y(fY + fSectorMaxRenderDist) + 1; - nStartX = clamp(nStartX, 0, MAX_SMALL_SECTORS - 1); - nEndX = clamp(nEndX, 0, MAX_SMALL_SECTORS - 1); - nStartY = clamp(nStartY, 0, MAX_SMALL_SECTORS - 1); - nEndY = clamp(nEndY, 0, MAX_SMALL_SECTORS - 1); + nStartX = Clamp(nStartX, 0, MAX_SMALL_SECTORS - 1); + nEndX = Clamp(nEndX, 0, MAX_SMALL_SECTORS - 1); + nStartY = Clamp(nStartY, 0, MAX_SMALL_SECTORS - 1); + nEndY = Clamp(nEndY, 0, MAX_SMALL_SECTORS - 1); float fDistSqr = 1.0e10f; @@ -2915,7 +2915,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY) } } - return clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist); + return Clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist); } void diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index 4b4c0138..9f925a8c 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -281,7 +281,7 @@ void CWeather::Update(void) if (SunGlare > 0.0f) { SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunDirection().z); - SunGlare = clamp(SunGlare, 0.0f, 1.0f); + SunGlare = Clamp(SunGlare, 0.0f, 1.0f); if (!CSpecialFX::bSnapShotActive) SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f); } diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 14f2909b..8a50ddcf 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -2261,7 +2261,7 @@ CAutomobile::PreRender(void) // 1.0 if directly behind car, -1.0 if in front float behindness = DotProduct(lookVector, GetForward()); - behindness = clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary + behindness = Clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary // 0.0 if behind car, PI if in front // Abs not necessary float angle = Abs(Acos(behindness)); @@ -2619,7 +2619,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_FAT_REARW) @@ -2660,7 +2660,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_FAT_REARW) @@ -2693,7 +2693,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_FAT_REARW) @@ -2727,7 +2727,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_FAT_REARW) @@ -2861,7 +2861,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_NARROW_FRONTW) @@ -2902,7 +2902,7 @@ CAutomobile::PreRender(void) float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale; if(GetModelIndex() == MI_VOODOO) groundOffset *= 0.6f; - mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f))); + mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f))); } } if(pHandling->Flags & HANDLING_NARROW_FRONTW) @@ -3120,7 +3120,7 @@ CAutomobile::ProcessControlInputs(uint8 pad) 0.2f*CTimer::GetTimeStep(); nLastControlInput = 0; } - m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f); + m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f); // Accelerate/Brake float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f; @@ -3239,7 +3239,7 @@ CAutomobile::FireTruckControl(void) m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep(); m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep(); } - m_fCarGunUD = clamp(m_fCarGunUD, 0.05f, 0.3f); + m_fCarGunUD = Clamp(m_fCarGunUD, 0.05f, 0.3f); CVector cannonPos(0.0f, 1.5f, 1.9f); @@ -3664,7 +3664,7 @@ CAutomobile::HydraulicControl(void) float limitDiff = extendedLowerLimit - normalLowerLimit; if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){ float f = (maxDelta + limitDiff)/2.0f/limitDiff; - f = clamp(f, 0.0f, 1.0f); + f = Clamp(f, 0.0f, 1.0f); DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f); if(f < 0.4f || f > 0.6f) setPrevRatio = true; diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index e5bb3622..c42d342e 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -533,7 +533,7 @@ CBike::ProcessControl(void) m_fWheelAngle += DEGTORAD(1.0f)*CTimer::GetTimeStep(); if(bIsStanding){ float f = Pow(0.97f, CTimer::GetTimeStep()); - m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f); + m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(Clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f); m_fLeanLRAngle = m_fLeanLRAngle2; } }else{ @@ -1028,9 +1028,9 @@ CBike::ProcessControl(void) lean = DotProduct(m_vecMoveSpeed-initialMoveSpeed, m_vecAvgSurfaceRight); lean /= GRAVITY*Max(CTimer::GetTimeStep(), 0.01f); if(m_wheelStatus[BIKEWHEEL_FRONT] == WHEEL_STATUS_BURST) - lean = clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean); + lean = Clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean); else - lean = clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean); + lean = Clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean); float f = Pow(pBikeHandling->fDesLean, CTimer::GetTimeStep()); m_fLeanLRAngle2 = (Asin(lean) - idleAngle)*(1.0f-f) + m_fLeanLRAngle2*f; }else{ @@ -1053,11 +1053,11 @@ CBike::ProcessControl(void) if(m_aSuspensionSpringRatio[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatio[BIKESUSP_R2] < 1.0f){ // BUG: this clamp makes no sense and the arguments seem swapped too ApplyTurnForce(contactPoints[BIKESUSP_R1], - m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep()); + m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep()); }else{ // BUG: this clamp makes no sense and the arguments seem swapped too ApplyTurnForce(contactPoints[BIKESUSP_R1], - m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep()); + m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep()); } }else m_fBrakeDestabilization = 0.0f; @@ -1220,7 +1220,7 @@ CBike::ProcessControl(void) // Balance bike if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){ float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal); - onSideness = clamp(onSideness, -1.0f, 1.0f); + onSideness = Clamp(onSideness, -1.0f, 1.0f); CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass); // Keep bike upright if(bBalancedByRider){ @@ -1840,7 +1840,7 @@ CBike::ProcessControlInputs(uint8 pad) 0.2f*CTimer::GetTimeStep(); nLastControlInput = 0; } - m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f); + m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f); // Lean forward/backward float updown; @@ -1850,7 +1850,7 @@ CBike::ProcessControlInputs(uint8 pad) #endif updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f; m_fLeanInput += (updown - m_fLeanInput)*0.2f*CTimer::GetTimeStep(); - m_fLeanInput = clamp(m_fLeanInput, -1.0f, 1.0f); + m_fLeanInput = Clamp(m_fLeanInput, -1.0f, 1.0f); // Accelerate/Brake float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index b768db29..85a41099 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -158,9 +158,9 @@ CBoat::ProcessControl(void) r = 127.5f*(CTimeCycle::GetAmbientRed_Obj() + 0.5f*CTimeCycle::GetDirectionalRed()); g = 127.5f*(CTimeCycle::GetAmbientGreen_Obj() + 0.5f*CTimeCycle::GetDirectionalGreen()); b = 127.5f*(CTimeCycle::GetAmbientBlue_Obj() + 0.5f*CTimeCycle::GetDirectionalBlue()); - r = clamp(r, 0, 255); - g = clamp(g, 0, 255); - b = clamp(b, 0, 255); + r = Clamp(r, 0, 255); + g = Clamp(g, 0, 255); + b = Clamp(b, 0, 255); splashColor.red = r; splashColor.green = g; splashColor.blue = b; @@ -169,9 +169,9 @@ CBoat::ProcessControl(void) r = 229.5f*(CTimeCycle::GetAmbientRed() + 0.85f*CTimeCycle::GetDirectionalRed()); g = 229.5f*(CTimeCycle::GetAmbientGreen() + 0.85f*CTimeCycle::GetDirectionalGreen()); b = 229.5f*(CTimeCycle::GetAmbientBlue() + 0.85f*CTimeCycle::GetDirectionalBlue()); - r = clamp(r, 0, 255); - g = clamp(g, 0, 255); - b = clamp(b, 0, 255); + r = Clamp(r, 0, 255); + g = Clamp(g, 0, 255); + b = Clamp(b, 0, 255); jetColor.red = r; jetColor.green = g; jetColor.blue = b; @@ -387,7 +387,7 @@ CBoat::ProcessControl(void) if(CPad::GetPad(0)->GetHandBrake()) steerLoss *= 0.5f; steerFactor -= steerLoss; - steerFactor = clamp(steerFactor, 0.0f, 1.0f); + steerFactor = Clamp(steerFactor, 0.0f, 1.0f); } CVector boundMin = GetColModel()->boundingBox.min; @@ -771,17 +771,17 @@ CBoat::ProcessControlInputs(uint8 pad) m_nPadID = 3; m_fBrake += (CPad::GetPad(pad)->GetBrake()/255.0f - m_fBrake)*0.1f; - m_fBrake = clamp(m_fBrake, 0.0f, 1.0f); + m_fBrake = Clamp(m_fBrake, 0.0f, 1.0f); if(m_fBrake < 0.05f){ m_fBrake = 0.0f; m_fAccelerate += (CPad::GetPad(pad)->GetAccelerate()/255.0f - m_fAccelerate)*0.1f; - m_fAccelerate = clamp(m_fAccelerate, 0.0f, 1.0f); + m_fAccelerate = Clamp(m_fAccelerate, 0.0f, 1.0f); }else m_fAccelerate = -m_fBrake*0.3f; m_fSteeringLeftRight += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteeringLeftRight)*0.2f; - m_fSteeringLeftRight = clamp(m_fSteeringLeftRight, -1.0f, 1.0f); + m_fSteeringLeftRight = Clamp(m_fSteeringLeftRight, -1.0f, 1.0f); float steeringSq = m_fSteeringLeftRight < 0.0f ? -SQR(m_fSteeringLeftRight) : SQR(m_fSteeringLeftRight); m_fSteerAngle = pHandling->fSteeringLock * DEGTORAD(steeringSq); @@ -1064,7 +1064,7 @@ CBoat::PreRender(void) rot = CGeneral::LimitRadianAngle(rot); if(rot > HALFPI) rot = PI; else if(rot < -HALFPI) rot = -PI; - rot = clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f)); + rot = Clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f)); m_fMovingSpeed += (0.008f * CWeather::Wind + 0.002f) * rot; m_fMovingSpeed *= Pow(0.9985f, CTimer::GetTimeStep())/(500.0f*SQR(m_fMovingSpeed) + 1.0f); diff --git a/src/vehicles/Door.cpp b/src/vehicles/Door.cpp index c80965aa..1b3f9e8f 100644 --- a/src/vehicles/Door.cpp +++ b/src/vehicles/Door.cpp @@ -52,11 +52,11 @@ CDoor::Process(CVehicle *vehicle) fSpeedDiff = vecSpeedDiff.y - vecSpeedDiff.x; break; } - fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f); + fSpeedDiff = Clamp(fSpeedDiff, -0.2f, 0.2f); if(Abs(fSpeedDiff) > 0.002f) m_fAngVel += fSpeedDiff; m_fAngVel *= 0.945f; - m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f); + m_fAngVel = Clamp(m_fAngVel, -0.3f, 0.3f); m_fAngle += m_fAngVel; m_nDoorState = DOORST_SWINGING; diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index bf14416c..f51c8481 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -260,7 +260,7 @@ CHeli::ProcessControl(void) // Move up if too low if(GetPosition().z - 2.0f < groundZ && m_heliStatus != HELI_STATUS_SHOT_DOWN) m_vecMoveSpeed.z += CTimer::GetTimeStep()*0.01f; - m_vecMoveSpeed.z = clamp(m_vecMoveSpeed.z, -0.3f, 0.3f); + m_vecMoveSpeed.z = Clamp(m_vecMoveSpeed.z, -0.3f, 0.3f); } float fTargetDist = vTargetDist.Magnitude(); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 8fbf8224..a41e0fa0 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -479,11 +479,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep()); if (GetUp().z > 0.0f){ - float upRight = clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); + float upRight = Clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseRight * GetUp(), GetRight()); - float upFwd = clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); + float upFwd = Clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseFwd * GetUp(), GetForward()); }else{ @@ -522,8 +522,8 @@ CVehicle::FlyingControl(eFlightModel flightModel) fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f; if (CPad::GetPad(0)->GetHorn()) { fYaw = 0.0f; - fPitch = clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f); - fRoll = clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f); + fPitch = Clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f); + fRoll = Clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f); } ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward()); ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); @@ -2162,9 +2162,9 @@ CVehicle::HeliDustGenerate(CEntity *heli, float radius, float ground, int rnd) float red = (0.3*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*255.0f/4.0f; float green = (0.3*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*255.0f/4.0f; float blue = (0.3*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*255.0f/4.0f; - r = clamp(red, 0.0f, 255.0f); - g = clamp(green, 0.0f, 255.0f); - b = clamp(blue, 0.0f, 255.0f); + r = Clamp(red, 0.0f, 255.0f); + g = Clamp(green, 0.0f, 255.0f); + b = Clamp(blue, 0.0f, 255.0f); RwRGBA col1 = { r, g, b, (RwUInt8)CGeneral::GetRandomNumberInRange(8, 32) }; RwRGBA col2 = { 255, 255, 255, 32 }; diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 9c698269..46ca4cc8 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -252,7 +252,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource) else if ( shooter->IsPed() && ((CPed*)shooter)->m_pSeekTarget != nil ) { float distToTarget = (shooter->GetPosition() - ((CPed*)shooter)->m_pSeekTarget->GetPosition()).Magnitude(); - float power = clamp((distToTarget-10.0f)*0.02f, 0.2f, 1.0f); + float power = Clamp((distToTarget-10.0f)*0.02f, 0.2f, 1.0f); fired = FireProjectile(shooter, source, power); } -- cgit v1.2.3