diff options
author | frosch <frosch@openttd.org> | 2017-02-26 19:39:58 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2017-02-26 19:39:58 +0000 |
commit | 9ad09627ad03030d39bd07e28c74bf91b83a0f24 (patch) | |
tree | 17e9348027ce501410980cdecc1db8ac22b84a9d /src/strings_func.h | |
parent | b264dd2a8d71ac3fd57398e6cc23af4d5ebde046 (diff) | |
download | openttd-9ad09627ad03030d39bd07e28c74bf91b83a0f24.tar.xz |
(svn r27754) -Codechange: Add GetStringTab(), GetStringIndex() and MakeStringID() to access the structure of StringIDs.
Diffstat (limited to 'src/strings_func.h')
-rw-r--r-- | src/strings_func.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/strings_func.h b/src/strings_func.h index 2c7809d02..5d69121e3 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -15,6 +15,38 @@ #include "strings_type.h" #include "string_type.h" #include "gfx_type.h" +#include "core/bitmath_func.hpp" + +/** + * Extract the StringTab from a StringID. + * @param str String identifier + * @return StringTab from \a str + */ +static inline uint GetStringTab(StringID str) +{ + return GB(str, 11, 5); +} + +/** + * Extract the StringIndex from a StringID. + * @param str String identifier + * @return StringIndex from \a str + */ +static inline uint GetStringIndex(StringID str) +{ + return GB(str, 0, 11); +} + +/** + * Create a StringID + * @param tab StringTab + * @param index StringIndex + * @return StringID composed from \a tab and \a index + */ +static inline StringID MakeStringID(uint tab, uint index) +{ + return tab << 11 | index; +} class StringParameters { StringParameters *parent; ///< If not NULL, this instance references data from this parent instance. |