From db76e604df8d367e9d7b631d104544cb1107781c Mon Sep 17 00:00:00 2001 From: Juice Date: Mon, 11 Apr 2022 11:32:00 +0300 Subject: [PATCH] Clamp moving entities' sounds volume (#751) --- regamedll/dlls/plats.cpp | 17 +++++++++++++++++ regamedll/dlls/vehicle.cpp | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/regamedll/dlls/plats.cpp b/regamedll/dlls/plats.cpp index 75c9175a..75a0e96d 100644 --- a/regamedll/dlls/plats.cpp +++ b/regamedll/dlls/plats.cpp @@ -44,6 +44,15 @@ void CBasePlatTrain::KeyValue(KeyValueData *pkvd) else if (FStrEq(pkvd->szKeyName, "volume")) { m_volume = Q_atof(pkvd->szValue); + +#ifdef REGAMEDLL_FIXES + if (m_volume > 1.0) + m_volume = 1.0; + + if (m_volume < 0.0) + m_volume = 0.0; +#endif + pkvd->fHandled = TRUE; } else @@ -928,6 +937,14 @@ void CFuncTrackTrain::KeyValue(KeyValueData *pkvd) m_flVolume = Q_atoi(pkvd->szValue); m_flVolume *= 0.1f; +#ifdef REGAMEDLL_FIXES + if (m_flVolume > 1.0) + m_flVolume = 1.0; + + if (m_flVolume < 0.0) + m_flVolume = 0.0; +#endif + pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "bank")) diff --git a/regamedll/dlls/vehicle.cpp b/regamedll/dlls/vehicle.cpp index 3d887421..55b453ed 100644 --- a/regamedll/dlls/vehicle.cpp +++ b/regamedll/dlls/vehicle.cpp @@ -52,6 +52,14 @@ void CFuncVehicle::KeyValue(KeyValueData *pkvd) m_flVolume = Q_atoi(pkvd->szValue); m_flVolume *= 0.1f; +#ifdef REGAMEDLL_FIXES + if (m_flVolume > 1.0) + m_flVolume = 1.0; + + if (m_flVolume < 0.0) + m_flVolume = 0.0; +#endif + pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "bank"))