summaryrefslogtreecommitdiff
path: root/src/cmd_helper.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-13 17:29:19 +0000
committerfrosch <frosch@openttd.org>2010-04-13 17:29:19 +0000
commitb76f0185d4064a4c44c6030976213dffe4493873 (patch)
tree413acf0fce33ac4b415708b78bb478275601612d /src/cmd_helper.h
parent7ba4f98ce571814d2d1ec647f4175c4ba1df0643 (diff)
downloadopenttd-b76f0185d4064a4c44c6030976213dffe4493873.tar.xz
(svn r19616) -Codechange: Increase transparency of 'Extract' by passing also the number of used bits.
Diffstat (limited to 'src/cmd_helper.h')
-rw-r--r--src/cmd_helper.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd_helper.h b/src/cmd_helper.h
index a034f1217..1530beedb 100644
--- a/src/cmd_helper.h
+++ b/src/cmd_helper.h
@@ -14,12 +14,13 @@
#include "core/enum_type.hpp"
-template<typename T, uint N, typename U> static inline T Extract(U v)
+template<typename T, uint S, uint N, typename U> static inline T Extract(U v)
{
/* Check if there are enough bits in v */
- assert_tcompile(N + EnumPropsT<T>::num_bits <= sizeof(U) * 8);
- assert_tcompile(EnumPropsT<T>::end <= (1 << EnumPropsT<T>::num_bits));
- return (T)GB(v, N, EnumPropsT<T>::num_bits);
+ assert_tcompile(N == EnumPropsT<T>::num_bits);
+ assert_tcompile(S + N <= sizeof(U) * 8);
+ assert_tcompile(EnumPropsT<T>::end <= (1 << N));
+ return (T)GB(v, S, N);
}
#endif