author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 11157 | a0173588b15e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
3 |
/** @file strings_func.h Functions related to OTTD's strings. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6646
diff
changeset
|
4 |
|
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
5 |
#ifndef STRINGS_FUNC_H |
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
6 |
#define STRINGS_FUNC_H |
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
7 |
|
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
8 |
#include "strings_type.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
diff
changeset
|
9 |
|
7762
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
10 |
char *InlineString(char *buf, StringID string); |
7814
fe643468ad64
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
7762
diff
changeset
|
11 |
char *GetString(char *buffr, StringID string, const char *last); |
8941
f93c669d3ca6
(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
parents:
8826
diff
changeset
|
12 |
const char *GetStringPtr(StringID string); |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2056
diff
changeset
|
13 |
|
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
diff
changeset
|
14 |
void InjectDParam(int amount); |
7762
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
15 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
16 |
static inline void SetDParamX(uint64 *s, uint n, uint64 v) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
17 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
18 |
s[n] = v; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
19 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
20 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
21 |
static inline void SetDParam(uint n, uint64 v) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
22 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
23 |
extern uint64 _decode_parameters[20]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
24 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
25 |
assert(n < lengthof(_decode_parameters)); |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
26 |
_decode_parameters[n] = v; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
27 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
28 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
29 |
void SetDParamStr(uint n, const char *str); |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
30 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
31 |
static inline uint64 GetDParamX(const uint64 *s, uint n) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
32 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
33 |
return s[n]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
34 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
35 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
36 |
static inline uint64 GetDParam(uint n) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
37 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
38 |
extern uint64 _decode_parameters[20]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
39 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
40 |
assert(n < lengthof(_decode_parameters)); |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
41 |
return _decode_parameters[n]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
42 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
43 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
44 |
static inline void CopyInDParam(int offs, const uint64 *src, int num) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
45 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
46 |
extern uint64 _decode_parameters[20]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
47 |
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num)); |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
48 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
49 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
50 |
static inline void CopyOutDParam(uint64 *dst, int offs, int num) |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
51 |
{ |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
52 |
extern uint64 _decode_parameters[20]; |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
53 |
memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num)); |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
54 |
} |
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
55 |
|
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7289
diff
changeset
|
56 |
extern DynamicLanguages _dynlang; // defined in strings.cpp |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
diff
changeset
|
57 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6573
diff
changeset
|
58 |
bool ReadLanguagePack(int index); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6573
diff
changeset
|
59 |
void InitializeLanguagePacks(); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6573
diff
changeset
|
60 |
|
7289
d6a004877931
(svn r10032) -Add: sort the strings in server language dropdown
glx
parents:
6916
diff
changeset
|
61 |
int CDECL StringIDSorter(const void *a, const void *b); |
d6a004877931
(svn r10032) -Add: sort the strings in server language dropdown
glx
parents:
6916
diff
changeset
|
62 |
|
8817
9df6e6b40d12
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8610
diff
changeset
|
63 |
/** Key comparison function for std::map */ |
9df6e6b40d12
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8610
diff
changeset
|
64 |
struct StringIDCompare |
9df6e6b40d12
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8610
diff
changeset
|
65 |
{ |
8826
35a3dfe12641
(svn r11896) -Fix (r11886): a missing const broke compilation with MSVC
glx
parents:
8817
diff
changeset
|
66 |
bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; } |
8817
9df6e6b40d12
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8610
diff
changeset
|
67 |
}; |
9df6e6b40d12
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8610
diff
changeset
|
68 |
|
8581
8e4e36a205fe
(svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium
parents:
7814
diff
changeset
|
69 |
void CheckForMissingGlyphsInLoadedLanguagePack(); |
8e4e36a205fe
(svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium
parents:
7814
diff
changeset
|
70 |
|
10250
e64ee7484b43
(svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium
parents:
8941
diff
changeset
|
71 |
StringID RemapOldStringID(StringID s); |
e64ee7484b43
(svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium
parents:
8941
diff
changeset
|
72 |
char *CopyFromOldName(StringID id); |
e64ee7484b43
(svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium
parents:
8941
diff
changeset
|
73 |
|
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8581
diff
changeset
|
74 |
#endif /* STRINGS_TYPE_H */ |