Skip to content

Commit

Permalink
Clamp moving entities' sounds volume (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
etojuice committed Apr 11, 2022
1 parent f050be7 commit db76e60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions regamedll/dlls/plats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
8 changes: 8 additions & 0 deletions regamedll/dlls/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit db76e60

Please sign in to comment.