summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio/AudioLogic.cpp12
-rw-r--r--src/core/common.h2
-rw-r--r--src/render/Fluff.h4
3 files changed, 10 insertions, 8 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 28fa9343..9154e6a6 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -3210,7 +3210,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 = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197);
+ m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197);
freqFrontPrev = m_sQueueSample.m_nFrequency;
m_sQueueSample.m_bIs2D = false;
@@ -3268,7 +3268,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params)
if (propellerSpeed < 1.0f)
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2);
- m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPropellerPrev - 98, 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;
@@ -3339,7 +3339,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params)
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
if (propellerSpeed < 1.0)
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f);
- m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, 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;
@@ -3441,8 +3441,8 @@ cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params)
return;
}
modifier = Min(1.0f, Abs(params->m_fVelocityChange) / (0.3f * params->m_pTransmission->fMaxVelocity));
- if (modifier > 0.01) { //mb can be replaced by (emittingVol > 1)
- emittingVol = (100.0 * modifier);
+ if (modifier > 0.01f) { //mb can be replaced by (emittingVol > 1)
+ emittingVol = (100.0f * modifier);
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume) {
@@ -4968,7 +4968,7 @@ cAudioManager::ProcessExtraSounds()
m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i];
distance = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distance < SQR(SOUND_INTENSITY)) {
- if (distance > 0.0)
+ if (distance > 0.0f)
m_sQueueSample.m_fDistance = Sqrt(distance);
else
m_sQueueSample.m_fDistance = 0.0f;
diff --git a/src/core/common.h b/src/core/common.h
index ba1d24ef..0a2a236e 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -219,6 +219,8 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len);
#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))
+
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
diff --git a/src/render/Fluff.h b/src/render/Fluff.h
index d600def7..a6a28cb7 100644
--- a/src/render/Fluff.h
+++ b/src/render/Fluff.h
@@ -103,7 +103,7 @@ public:
void Update(void);
void SwitchOff(void);
void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown);
- bool IsActive() { return m_bIsActive; };
+ bool IsActive() const { return m_bIsActive; };
const CVector& GetPosition() const { return m_midPoint; };
};
@@ -116,7 +116,7 @@ public:
static void Update(void);
static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown);
static void Shutdown(void);
- static CEscalator& GetEscalator(int ind) { return aEscalators[ind]; };
+ static const CEscalator& GetEscalator(int ind) { return aEscalators[ind]; };
};
class CMovingThing