Skip to content

Commit 097263f

Browse files
authored
Merge pull request #148 from edgarbarney/master
Fix STL Algorithm Header Errors When Included with Platform.h
2 parents 2c41a96 + 5a006e6 commit 097263f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

common/Platform.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ using qboolean = int;
7777
#define V_min(a, b) (((a) < (b)) ? (a) : (b))
7878
#define V_max(a, b) (((a) > (b)) ? (a) : (b))
7979

80-
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
80+
// Clamp macro is deprecated. Use std::clamp instead.
81+
// #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))

dlls/player.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include <limits>
24+
#include <algorithm>
2425

2526
#include "extdll.h"
2627
#include "util.h"
@@ -3904,7 +3905,7 @@ void CBasePlayer::UpdateClientData()
39043905

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

0 commit comments

Comments
 (0)