summaryrefslogtreecommitdiff
path: root/src/strings_func.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-02-26 19:41:30 +0000
committerfrosch <frosch@openttd.org>2017-02-26 19:41:30 +0000
commit2bb80d280cc39684e71be6c4c2db5bf500e10b1c (patch)
tree2e5a9bb6dbd454860fa195da5dc537009a57d572 /src/strings_func.h
parentfc4c4d080c5d95d92354cefac4a05082fc417c83 (diff)
downloadopenttd-2bb80d280cc39684e71be6c4c2db5bf500e10b1c.tar.xz
(svn r27758) -Change: Increase the maximum number of GameScript texts to 64k, and NewGRF texts to 512k.
Diffstat (limited to 'src/strings_func.h')
-rw-r--r--src/strings_func.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/strings_func.h b/src/strings_func.h
index 7ad20eb1f..0da711bc4 100644
--- a/src/strings_func.h
+++ b/src/strings_func.h
@@ -24,7 +24,10 @@
*/
static inline StringTab GetStringTab(StringID str)
{
- return (StringTab)GB(str, TAB_SIZE_BITS, 5);
+ StringTab result = (StringTab)(str >> TAB_SIZE_BITS);
+ if (result >= TEXT_TAB_NEWGRF_START) return TEXT_TAB_NEWGRF_START;
+ if (result >= TEXT_TAB_GAMESCRIPT_START) return TEXT_TAB_GAMESCRIPT_START;
+ return result;
}
/**
@@ -34,7 +37,7 @@ static inline StringTab GetStringTab(StringID str)
*/
static inline uint GetStringIndex(StringID str)
{
- return GB(str, 0, TAB_SIZE_BITS);
+ return str - (GetStringTab(str) << TAB_SIZE_BITS);
}
/**
@@ -45,9 +48,15 @@ static inline uint GetStringIndex(StringID str)
*/
static inline StringID MakeStringID(StringTab tab, uint index)
{
- assert(tab < TEXT_TAB_END);
- assert(index < TAB_SIZE);
- return tab << TAB_SIZE_BITS | index;
+ if (tab == TEXT_TAB_NEWGRF_START) {
+ assert(index < TAB_SIZE_NEWGRF);
+ } else if (tab == TEXT_TAB_GAMESCRIPT_START) {
+ assert(index < TAB_SIZE_GAMESCRIPT);
+ } else {
+ assert(tab < TEXT_TAB_END);
+ assert(index < TAB_SIZE);
+ }
+ return (tab << TAB_SIZE_BITS) + index;
}
class StringParameters {