diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Cam.cpp | 18 | ||||
-rw-r--r-- | src/core/Camera.cpp | 10 | ||||
-rw-r--r-- | src/core/FileLoader.cpp | 2 | ||||
-rw-r--r-- | src/core/Frontend.cpp | 28 | ||||
-rw-r--r-- | src/core/Frontend_PS2.cpp | 4 | ||||
-rw-r--r-- | src/core/General.h | 2 | ||||
-rw-r--r-- | src/core/PlayerInfo.cpp | 2 | ||||
-rw-r--r-- | src/core/Ropes.cpp | 2 | ||||
-rw-r--r-- | src/core/World.cpp | 4 | ||||
-rw-r--r-- | src/core/common.h | 4 |
10 files changed, 38 insertions, 38 deletions
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)) |