summaryrefslogtreecommitdiff
path: root/src/cmd_helper.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-11-14 16:39:17 +0100
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commit6fe445e6c0fa3163aba48b1ec6d810b6594777bd (patch)
tree320cd8d2d76b38ee06f9fde07ea349adeb3f228a /src/cmd_helper.h
parent21675ec7e22bfe53f20300cc27b4d50c84aeb4dc (diff)
downloadopenttd-6fe445e6c0fa3163aba48b1ec6d810b6594777bd.tar.xz
Codechange: Un-bitstuff station/depot/waypoint commands.
Diffstat (limited to 'src/cmd_helper.h')
-rw-r--r--src/cmd_helper.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cmd_helper.h b/src/cmd_helper.h
index ceb4d4bd9..03b6e8ea7 100644
--- a/src/cmd_helper.h
+++ b/src/cmd_helper.h
@@ -31,4 +31,15 @@ template<typename T, uint S, uint N, typename U> static inline T Extract(U v)
return IsInsideMM(masked, EnumPropsT<T>::begin, EnumPropsT<T>::end) ? (T)masked : EnumPropsT<T>::invalid;
}
+/**
+ * Check if an enum value is inside it's valid values.
+ * @tparam T Type of enum.
+ * @param v The value to validate
+ * @return True if enum is valid.
+ */
+template <typename T> static constexpr inline bool IsEnumValid(T v) noexcept
+{
+ return IsInsideMM(v, EnumPropsT<T>::begin, EnumPropsT<T>::end);
+}
+
#endif /* CMD_HELPER_H */