summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-20 14:30:53 +0000
committersmatz <smatz@openttd.org>2008-02-20 14:30:53 +0000
commitca461540689131714dca1cc4cd4e519e8a5d485f (patch)
tree4b4f40c9a8ff641f074121b14dc57e44c13c58cf /src/core
parent0e9e94a94b2b6a1790cab91af3413928e920c982 (diff)
downloadopenttd-ca461540689131714dca1cc4cd4e519e8a5d485f.tar.xz
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
Diffstat (limited to 'src/core')
-rw-r--r--src/core/math_func.hpp12
1 files changed, 12 insertions, 0 deletions
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
@@ -169,6 +169,18 @@ static inline int32 ClampToI32(const int64 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
*
* @param a The first scalar