From ca461540689131714dca1cc4cd4e519e8a5d485f Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 20 Feb 2008 14:30:53 +0000 Subject: (svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value --- src/core/math_func.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/math_func.hpp') diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index e20dc6065..8faa67c11 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -168,6 +168,18 @@ static inline int32 ClampToI32(const int64 a) return (int32)a; } +/** + * Reduce an usigned 64-bit int to an unsigned 16-bit one + * + * @param a The 64-bit value to clamp + * @return The 64-bit value reduced to a 16-bit value + * @see ClampU(uint, uint, uint) + */ +static inline uint16 ClampToU16(const uint64 a) +{ + return min(a, UINT16_MAX); +} + /** * Returns the (absolute) difference between two (scalar) variables * -- cgit v1.2.3-54-g00ecf