author | truebrain |
Thu, 12 Jun 2008 21:18:09 +0000 | |
branch | noai |
changeset 10944 | 588393239ac6 |
parent 10294 | 7798ae816af8 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file strings_func.h Functions related to OTTD's strings. */ |
|
4 |
||
5 |
#ifndef STRINGS_FUNC_H |
|
6 |
#define STRINGS_FUNC_H |
|
7 |
||
8 |
#include "strings_type.h" |
|
9 |
||
10 |
char *InlineString(char *buf, StringID string); |
|
11 |
char *GetString(char *buffr, StringID string, const char *last); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
12 |
const char *GetStringPtr(StringID string); |
9723 | 13 |
|
14 |
extern char _userstring[128]; |
|
15 |
||
16 |
void InjectDParam(int amount); |
|
17 |
||
18 |
static inline void SetDParamX(uint64 *s, uint n, uint64 v) |
|
19 |
{ |
|
20 |
s[n] = v; |
|
21 |
} |
|
22 |
||
23 |
static inline void SetDParam(uint n, uint64 v) |
|
24 |
{ |
|
25 |
extern uint64 _decode_parameters[20]; |
|
26 |
||
27 |
assert(n < lengthof(_decode_parameters)); |
|
28 |
_decode_parameters[n] = v; |
|
29 |
} |
|
30 |
||
31 |
/* Used to bind a C string name to a dparam number. |
|
32 |
* NOTE: This has a short lifetime. You can't |
|
33 |
* use this string much later or it will be gone. */ |
|
34 |
void SetDParamStr(uint n, const char *str); |
|
35 |
||
36 |
/** This function takes a C-string and allocates a temporary string ID. |
|
37 |
* The duration of the bound string is valid only until the next call to GetString, |
|
38 |
* so be careful. */ |
|
39 |
StringID BindCString(const char *str); |
|
40 |
||
41 |
static inline uint64 GetDParamX(const uint64 *s, uint n) |
|
42 |
{ |
|
43 |
return s[n]; |
|
44 |
} |
|
45 |
||
46 |
static inline uint64 GetDParam(uint n) |
|
47 |
{ |
|
48 |
extern uint64 _decode_parameters[20]; |
|
49 |
||
50 |
assert(n < lengthof(_decode_parameters)); |
|
51 |
return _decode_parameters[n]; |
|
52 |
} |
|
53 |
||
54 |
static inline void CopyInDParam(int offs, const uint64 *src, int num) |
|
55 |
{ |
|
56 |
extern uint64 _decode_parameters[20]; |
|
57 |
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num)); |
|
58 |
} |
|
59 |
||
60 |
static inline void CopyOutDParam(uint64 *dst, int offs, int num) |
|
61 |
{ |
|
62 |
extern uint64 _decode_parameters[20]; |
|
63 |
memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num)); |
|
64 |
} |
|
65 |
||
66 |
extern DynamicLanguages _dynlang; // defined in strings.cpp |
|
67 |
||
68 |
bool ReadLanguagePack(int index); |
|
69 |
void InitializeLanguagePacks(); |
|
70 |
||
71 |
int CDECL StringIDSorter(const void *a, const void *b); |
|
72 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
73 |
/** Key comparison function for std::map */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
74 |
struct StringIDCompare |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
75 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
76 |
bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; } |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
77 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
78 |
|
9723 | 79 |
void CheckForMissingGlyphsInLoadedLanguagePack(); |
80 |
||
10294 | 81 |
StringID RemapOldStringID(StringID s); |
82 |
char *CopyFromOldName(StringID id); |
|
83 |
||
9723 | 84 |
#endif /* STRINGS_TYPE_H */ |