Skip to content

Commit

Permalink
Merge pull request #148 from edgarbarney/master
Browse files Browse the repository at this point in the history
Fix STL Algorithm Header Errors When Included with Platform.h
  • Loading branch information
SamVanheer authored May 5, 2022
2 parents 2c41a96 + 5a006e6 commit 097263f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion common/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ using qboolean = int;
#define V_min(a, b) (((a) < (b)) ? (a) : (b))
#define V_max(a, b) (((a) > (b)) ? (a) : (b))

#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
// Clamp macro is deprecated. Use std::clamp instead.
// #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
3 changes: 2 additions & 1 deletion dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include <limits>
#include <algorithm>

#include "extdll.h"
#include "util.h"
Expand Down Expand Up @@ -3904,7 +3905,7 @@ void CBasePlayer::UpdateClientData()

if (pev->health != m_iClientHealth)
{
int iHealth = clamp(pev->health, 0, std::numeric_limits<short>::max()); // make sure that no negative health values are sent
int iHealth = std::clamp<float>(pev->health, 0.f, (float)(std::numeric_limits<short>::max())); // make sure that no negative health values are sent
if (pev->health > 0.0f && pev->health <= 1.0f)
iHealth = 1;

Expand Down

0 comments on commit 097263f

Please sign in to comment.