From 6a305748ffae710f4dea2672d9ed114bf053a85a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Aug 2020 21:25:03 +0200 Subject: [PATCH] - removed some C cruft from compat.h. --- source/build/include/compat.h | 18 ------------------ source/build/src/mdsprite.cpp | 2 +- source/core/gamecontrol.cpp | 2 +- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 04c166f99..4fc10e2ae 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -833,28 +833,10 @@ static FORCE_INLINE CONSTEXPR uint64_t B_UNBUF64(void const * const buf) { retur #define ABSTRACT_DECL static FORCE_INLINE WARN_UNUSED_RESULT CONSTEXPR -#ifdef __cplusplus template ABSTRACT_DECL T clamp(T in, X min, Y max) { return in <= (T) min ? (T) min : (in >= (T) max ? (T) max : in); } template ABSTRACT_DECL T clamp2(T in, X min, Y max) { return in >= (T) max ? (T) max : (in <= (T) min ? (T) min : in); } using std::min; using std::max; -# define fclamp clamp -# define fclamp2 clamp2 -#else -// Clamp to [..]. The case in <= min is handled first. -ABSTRACT_DECL int32_t clamp(int32_t in, int32_t min, int32_t max) { return in <= min ? min : (in >= max ? max : in); } -ABSTRACT_DECL double fclamp(double in, double min, double max) { return in <= min ? min : (in >= max ? max : in); } -// Clamp to [..]. The case in >= max is handled first. -ABSTRACT_DECL int32_t clamp2(int32_t in, int32_t min, int32_t max) { return in >= max ? max : (in <= min ? min : in); } -ABSTRACT_DECL double fclamp2(double in, double min, double max) { return in >= max ? max : (in <= min ? min : in); } - -#ifndef min -# define min(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max -# define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif -#endif ////////// Mathematical operations ////////// diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 685d6dd85..b019bc129 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1515,7 +1515,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) m->head.nam, m->cframe, m->nframe, m->numframes, m->interpol); #endif - m->interpol = fclamp(m->interpol, 0.f, 1.f); + m->interpol = clamp(m->interpol, 0.f, 1.f); m->cframe = clamp(m->cframe, 0, m->numframes-1); m->nframe = clamp(m->nframe, 0, m->numframes-1); } diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 56e6220cb..fdc074569 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1074,7 +1074,7 @@ double CalcSmoothRatio(ClockTicks totalclk, ClockTicks ototalclk, int realgameti ratio = (0.5 + (totalclk - ototalclk)) / (120 / realgameticspersec); } - result = fclamp2(ratio * MaxSmoothRatio, 0., MaxSmoothRatio); + result = clamp2(ratio * MaxSmoothRatio, 0., MaxSmoothRatio); if (cl_debugintrpl) {