annotate src/strings_func.h @ 10831:31f766ee053b draft

(svn r15166) -Codechange: reduce number of includes in afterload.cpp
author smatz <smatz@openttd.org>
date Tue, 20 Jan 2009 13:56:35 +0000
parents b6779abf2e96
children 2df072b251df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
3 /** @file strings_func.h Functions related to OTTD's strings. */
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
4
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
5 #ifndef STRINGS_FUNC_H
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
6 #define STRINGS_FUNC_H
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
7
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
8 #include "strings_type.h"
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
9
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
10 char *InlineString(char *buf, StringID string);
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
11 char *GetString(char *buffr, StringID string, const char *last);
8445
cfc312cfe346 (svn r12015) -Fix [FS#1716] (Revert r11422): Patch in FS#1430 avoided instead of fixed the problem. GetStringWithArgs() discards information that SCC_GENDER_LIST needs to work. Now use pointers to retrieve GRF strings, so that GetStringPtr() will work correctly. This is advantageous as now no buffer copy is made when using all GRF strings.
peter1138 <peter1138@openttd.org>
parents: 8330
diff changeset
12 const char *GetStringPtr(StringID string);
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
13
10197
9af4677fdb90 (svn r14410) -Codechange: one can't inject a negative number of parameters, so enforce this by using a uint.
rubidium <rubidium@openttd.org>
parents: 9648
diff changeset
14 void InjectDParam(uint amount);
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
15
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
16 static inline void SetDParamX(uint64 *s, uint n, uint64 v)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
18 s[n] = v;
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
19 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
20
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
21 static inline void SetDParam(uint n, uint64 v)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
22 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
23 extern uint64 _decode_parameters[20];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
24
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
25 assert(n < lengthof(_decode_parameters));
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
26 _decode_parameters[n] = v;
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
27 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
28
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
29 void SetDParamStr(uint n, const char *str);
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
30
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
31 static inline uint64 GetDParamX(const uint64 *s, uint n)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
32 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
33 return s[n];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
34 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
35
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
36 static inline uint64 GetDParam(uint n)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
37 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
38 extern uint64 _decode_parameters[20];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
39
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
40 assert(n < lengthof(_decode_parameters));
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
41 return _decode_parameters[n];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
42 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
43
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
44 static inline void CopyInDParam(int offs, const uint64 *src, int num)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
45 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
46 extern uint64 _decode_parameters[20];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
47 memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
48 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
49
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
50 static inline void CopyOutDParam(uint64 *dst, int offs, int num)
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
51 {
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
52 extern uint64 _decode_parameters[20];
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
53 memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num));
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
54 }
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
55
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
56 extern DynamicLanguages _dynlang; // defined in strings.cpp
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
57
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
58 bool ReadLanguagePack(int index);
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
59 void InitializeLanguagePacks();
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
60
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
61 int CDECL StringIDSorter(const void *a, const void *b);
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
62
8321
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8114
diff changeset
63 /** Key comparison function for std::map */
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8114
diff changeset
64 struct StringIDCompare
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8114
diff changeset
65 {
8330
43831761bc77 (svn r11896) -Fix (r11886): a missing const broke compilation with MSVC
glx <glx@openttd.org>
parents: 8321
diff changeset
66 bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; }
8321
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8114
diff changeset
67 };
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8114
diff changeset
68
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
69 void CheckForMissingGlyphsInLoadedLanguagePack();
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
70
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
diff changeset
71 #endif /* STRINGS_TYPE_H */