From 1b3308c2a36b8c3c3ff4ebf5a9ede45165c9fa7c Mon Sep 17 00:00:00 2001 From: FranticDreamer Date: Thu, 5 May 2022 04:49:15 +0300 Subject: [PATCH 1/3] Fix STL Algorithm Header Errors When Included with Platform.h "clamp" macro of Platform.h conflicts with "std::clamp" of the STL algorithm header. So `#include ` forces Platform.h included after itself. This commit fixes the issue. --- dlls/player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 28fd00a5f..f72858a61 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -21,6 +21,7 @@ */ #include +#include #include "extdll.h" #include "util.h" @@ -3904,7 +3905,7 @@ void CBasePlayer::UpdateClientData() if (pev->health != m_iClientHealth) { - int iHealth = clamp(pev->health, 0, std::numeric_limits::max()); // make sure that no negative health values are sent + int iHealth = std::clamp(pev->health, 0.f, (float)(std::numeric_limits::max())); // make sure that no negative health values are sent if (pev->health > 0.0f && pev->health <= 1.0f) iHealth = 1; From 4721651f9535f5de6435609b56335b27fa3d9a4e Mon Sep 17 00:00:00 2001 From: FranticDreamer Date: Thu, 5 May 2022 04:51:36 +0300 Subject: [PATCH 2/3] Add a Note for Deprecation of Clamp Macro --- common/Platform.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/Platform.h b/common/Platform.h index f07654831..386fd3723 100644 --- a/common/Platform.h +++ b/common/Platform.h @@ -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))) From 5a006e6630998172e478597c5077c2014dd3252a Mon Sep 17 00:00:00 2001 From: FranticDreamer Date: Thu, 5 May 2022 05:00:03 +0300 Subject: [PATCH 3/3] Fix Ambiguous Template --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index f72858a61..d6889a77a 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3905,7 +3905,7 @@ void CBasePlayer::UpdateClientData() if (pev->health != m_iClientHealth) { - int iHealth = std::clamp(pev->health, 0.f, (float)(std::numeric_limits::max())); // make sure that no negative health values are sent + int iHealth = std::clamp(pev->health, 0.f, (float)(std::numeric_limits::max())); // make sure that no negative health values are sent if (pev->health > 0.0f && pev->health <= 1.0f) iHealth = 1;