author | rubidium |
Sun, 25 May 2008 19:17:03 +0000 | |
changeset 9354 | 845e07db4549 |
parent 8987 | 80d22b9c2a0c |
child 9648 | c79160082c0f |
permissions | -rw-r--r-- |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
2 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
3 |
/** @file strings_func.h Functions related to OTTD's strings. */ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
4 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
5 |
#ifndef STRINGS_FUNC_H |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
6 |
#define STRINGS_FUNC_H |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
7 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
8 |
#include "strings_type.h" |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
9 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
10 |
char *InlineString(char *buf, StringID string); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
11 |
char *GetString(char *buffr, StringID string, const char *last); |
8445
54a5d84d1d7d
(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:
8330
diff
changeset
|
12 |
const char *GetStringPtr(StringID string); |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
13 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
14 |
extern char _userstring[128]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
15 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
16 |
void InjectDParam(int amount); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
17 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
18 |
static inline void SetDParamX(uint64 *s, uint n, uint64 v) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
19 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
20 |
s[n] = v; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
21 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
22 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
23 |
static inline void SetDParam(uint n, uint64 v) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
24 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
25 |
extern uint64 _decode_parameters[20]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
26 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
27 |
assert(n < lengthof(_decode_parameters)); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
28 |
_decode_parameters[n] = v; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
29 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
30 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
31 |
/* Used to bind a C string name to a dparam number. |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
32 |
* NOTE: This has a short lifetime. You can't |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
33 |
* use this string much later or it will be gone. */ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
34 |
void SetDParamStr(uint n, const char *str); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
35 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
36 |
/** This function takes a C-string and allocates a temporary string ID. |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
37 |
* The duration of the bound string is valid only until the next call to GetString, |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
38 |
* so be careful. */ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
39 |
StringID BindCString(const char *str); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
40 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
41 |
static inline uint64 GetDParamX(const uint64 *s, uint n) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
42 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
43 |
return s[n]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
44 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
45 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
46 |
static inline uint64 GetDParam(uint n) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
47 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
48 |
extern uint64 _decode_parameters[20]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
49 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
50 |
assert(n < lengthof(_decode_parameters)); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
51 |
return _decode_parameters[n]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
52 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
53 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
54 |
static inline void CopyInDParam(int offs, const uint64 *src, int num) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
55 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
56 |
extern uint64 _decode_parameters[20]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
57 |
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num)); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
58 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
59 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
60 |
static inline void CopyOutDParam(uint64 *dst, int offs, int num) |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
61 |
{ |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
62 |
extern uint64 _decode_parameters[20]; |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
63 |
memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num)); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
64 |
} |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
65 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
66 |
extern DynamicLanguages _dynlang; // defined in strings.cpp |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
67 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
68 |
bool ReadLanguagePack(int index); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
69 |
void InitializeLanguagePacks(); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
70 |
|
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
71 |
int CDECL StringIDSorter(const void *a, const void *b); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
72 |
|
8321
96c331ee5ac3
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8114
diff
changeset
|
73 |
/** Key comparison function for std::map */ |
96c331ee5ac3
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8114
diff
changeset
|
74 |
struct StringIDCompare |
96c331ee5ac3
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8114
diff
changeset
|
75 |
{ |
8330
55c297af752e
(svn r11896) -Fix (r11886): a missing const broke compilation with MSVC
glx
parents:
8321
diff
changeset
|
76 |
bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; } |
8321
96c331ee5ac3
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8114
diff
changeset
|
77 |
}; |
96c331ee5ac3
(svn r11886) -Add: sort the strings in languages dropdown
glx
parents:
8114
diff
changeset
|
78 |
|
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
79 |
void CheckForMissingGlyphsInLoadedLanguagePack(); |
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
80 |
|
8987
80d22b9c2a0c
(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:
8445
diff
changeset
|
81 |
StringID RemapOldStringID(StringID s); |
80d22b9c2a0c
(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:
8445
diff
changeset
|
82 |
char *CopyFromOldName(StringID id); |
80d22b9c2a0c
(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:
8445
diff
changeset
|
83 |
|
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
diff
changeset
|
84 |
#endif /* STRINGS_TYPE_H */ |