author | richk |
Tue, 17 Jun 2008 13:22:13 +0000 | |
branch | NewGRF_ports |
changeset 10994 | cd9968b6f96b |
parent 10991 | d8811e327d12 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
3 |
/** @file strings.cpp Handling of translated strings. */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1853
diff
changeset
|
6 |
#include "openttd.h" |
2291
2b064aa97f91
(svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
2257
diff
changeset
|
7 |
#include "currency.h" |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
8 |
#include "namegen_func.h" |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
9 |
#include "station_base.h" |
0 | 10 |
#include "town.h" |
430 | 11 |
#include "screenshot.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1376
diff
changeset
|
12 |
#include "waypoint.h" |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
13 |
#include "industry.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
14 |
#include "variables.h" |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
15 |
#include "newgrf_text.h" |
4120
90e678fd7d8d
(svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents:
3833
diff
changeset
|
16 |
#include "music.h" |
4942
f990abfa4438
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4920
diff
changeset
|
17 |
#include "industry.h" |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
18 |
#include "fileio.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6414
diff
changeset
|
19 |
#include "cargotype.h" |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
20 |
#include "group.h" |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
21 |
#include "debug.h" |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
22 |
#include "newgrf_townname.h" |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
23 |
#include "signs_base.h" |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
24 |
#include "newgrf_engine.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
25 |
#include "spritecache.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
26 |
#include "fontcache.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
27 |
#include "gui.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
28 |
#include "strings_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
29 |
#include "functions.h" |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
30 |
#include "rev.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
31 |
#include "core/endian_func.hpp" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
32 |
#include "date_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
33 |
#include "vehicle_base.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
34 |
#include "string_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
35 |
#include "player_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
36 |
#include "player_base.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
37 |
#include "fios.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
38 |
#include "settings_type.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
39 |
#include "video/video_driver.hpp" |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
40 |
#include "engine_func.h" |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
41 |
#include "engine_base.h" |
10274
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
42 |
#include "saveload.h" |
0 | 43 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
44 |
#include "table/strings.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
45 |
#include "table/control_codes.h" |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
46 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
47 |
DynamicLanguages _dynlang; |
2201 | 48 |
char _userstring[128]; |
6725
23339968083f
(svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents:
6720
diff
changeset
|
49 |
uint64 _decode_parameters[20]; |
2201 | 50 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
51 |
static char *StationGetSpecialString(char *buff, int x, const char* last); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
52 |
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
53 |
static char *GetSpecialPlayerNameString(char *buff, int ind, const int64 *argv, const char* last); |
0 | 54 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
55 |
static char *FormatString(char *buff, const char *str, const int64 *argv, uint casei, const char* last); |
0 | 56 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
57 |
struct LanguagePack { |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
58 |
uint32 ident; // 32-bits identifier |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
59 |
uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
60 |
char name[32]; // the international name of this language |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
61 |
char own_name[32]; // the localized name of this language |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
62 |
char isocode[16]; // the ISO code for the language (not country code) |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
63 |
uint16 offsets[32]; // the offsets |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
64 |
byte plural_form; // how to compute plural forms |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
65 |
byte pad[3]; // pad header to be a multiple of 4 |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
66 |
char data[VARARRAY_SIZE]; // list of strings |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
67 |
}; |
1319
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
68 |
|
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
69 |
static char **_langpack_offs; |
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
70 |
static LanguagePack *_langpack; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
71 |
static uint _langtab_num[32]; // Offset into langpack offs |
1319
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
72 |
static uint _langtab_start[32]; // Offset into langpack offs |
0 | 73 |
|
74 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
75 |
/** Read an int64 from the argv array. */ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
76 |
static inline int64 GetInt64(const int64 **argv) |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
77 |
{ |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
78 |
assert(argv); |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
79 |
return *(*argv)++; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
80 |
} |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
81 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
82 |
/** Read an int32 from the argv array. */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
83 |
static inline int32 GetInt32(const int64 **argv) |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
84 |
{ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
85 |
return (int32)GetInt64(argv); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
86 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
87 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
88 |
/** Read an array from the argv array. */ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
89 |
static inline const int64 *GetArgvPtr(const int64 **argv, int n) |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
90 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
91 |
const int64 *result; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
92 |
assert(*argv); |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
93 |
result = *argv; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
94 |
(*argv) += n; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
95 |
return result; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
96 |
} |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
97 |
|
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
98 |
|
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
99 |
#define NUM_BOUND_STRINGS 8 |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
100 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
101 |
/* Array to hold the bound strings. */ |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
102 |
static const char *_bound_strings[NUM_BOUND_STRINGS]; |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
103 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
104 |
/* This index is used to implement a "round-robin" allocating of |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
105 |
* slots for BindCString. NUM_BOUND_STRINGS slots are reserved. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
106 |
* Which means that after NUM_BOUND_STRINGS calls to BindCString, |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
107 |
* the indices will be reused. */ |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
108 |
static int _bind_index; |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
109 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
110 |
const char *GetStringPtr(StringID string) |
0 | 111 |
{ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
112 |
switch (GB(string, 11, 5)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
113 |
case 28: return GetGRFStringPtr(GB(string, 0, 11)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
114 |
case 29: return GetGRFStringPtr(GB(string, 0, 11) + 0x0800); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
115 |
case 30: return GetGRFStringPtr(GB(string, 0, 11) + 0x1000); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
116 |
default: return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)]; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
117 |
} |
0 | 118 |
} |
119 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
120 |
/** The highest 8 bits of string contain the "case index". |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
121 |
* These 8 bits will only be set when FormatString wants to print |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
122 |
* the string in a different case. No one else except FormatString |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
123 |
* should set those bits, therefore string CANNOT be StringID, but uint32. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
124 |
* @param buffr |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
125 |
* @param string |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
126 |
* @param argv |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
127 |
* @param last |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
128 |
* @return a formatted string of char |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
129 |
*/ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
130 |
static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, const char* last) |
0 | 131 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
132 |
if (GB(string, 0, 16) == 0) return GetStringWithArgs(buffr, STR_UNDEFINED, argv, last); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
133 |
|
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2131
diff
changeset
|
134 |
uint index = GB(string, 0, 11); |
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2131
diff
changeset
|
135 |
uint tab = GB(string, 11, 5); |
0 | 136 |
|
1321 | 137 |
switch (tab) { |
138 |
case 4: |
|
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
139 |
if (index >= 0xC0) |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
140 |
return GetSpecialTownNameString(buffr, index - 0xC0, GetInt32(&argv), last); |
1321 | 141 |
break; |
142 |
||
143 |
case 14: |
|
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
144 |
if (index >= 0xE4) |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
145 |
return GetSpecialPlayerNameString(buffr, index - 0xE4, argv, last); |
1321 | 146 |
break; |
147 |
||
148 |
case 15: |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
149 |
/* Old table for custom names. This is no longer used */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
150 |
error("Incorrect conversion of custom name string."); |
1321 | 151 |
|
4710
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
152 |
case 26: |
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
153 |
/* Include string within newgrf text (format code 81) */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
154 |
if (HasBit(index, 10)) { |
4710
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
155 |
StringID string = GetGRFStringID(0, 0xD000 + GB(index, 0, 10)); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
156 |
return GetStringWithArgs(buffr, string, argv, last); |
4710
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
157 |
} |
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
158 |
break; |
a663b32b9f96
(svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents:
4602
diff
changeset
|
159 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
160 |
case 28: |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
161 |
return FormatString(buffr, GetGRFStringPtr(index), argv, 0, last); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
162 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
163 |
case 29: |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
164 |
return FormatString(buffr, GetGRFStringPtr(index + 0x0800), argv, 0, last); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
165 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
166 |
case 30: |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
167 |
return FormatString(buffr, GetGRFStringPtr(index + 0x1000), argv, 0, last); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
168 |
|
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
169 |
case 31: |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
170 |
/* dynamic strings. These are NOT to be passed through the formatter, |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
171 |
* but passed through verbatim. */ |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
172 |
if (index < (STR_SPEC_USERSTRING & 0x7FF)) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
173 |
return strecpy(buffr, _bound_strings[index], last); |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
174 |
} |
1321 | 175 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
176 |
return FormatString(buffr, _userstring, NULL, 0, last); |
0 | 177 |
} |
178 |
||
2639 | 179 |
if (index >= _langtab_num[tab]) { |
1321 | 180 |
error( |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
181 |
"String 0x%X is invalid. " |
1321 | 182 |
"Probably because an old version of the .lng file.\n", string |
183 |
); |
|
2639 | 184 |
} |
0 | 185 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
186 |
return FormatString(buffr, GetStringPtr(GB(string, 0, 16)), argv, GB(string, 24, 8), last); |
0 | 187 |
} |
188 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
189 |
char *GetString(char *buffr, StringID string, const char* last) |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
190 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
191 |
return GetStringWithArgs(buffr, string, (int64*)_decode_parameters, last); |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
192 |
} |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
193 |
|
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
194 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
195 |
char *InlineString(char *buf, StringID string) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
196 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
197 |
buf += Utf8Encode(buf, SCC_STRING_ID); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
198 |
buf += Utf8Encode(buf, string); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
199 |
return buf; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
200 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
201 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
202 |
|
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
203 |
/** |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
204 |
* This function takes a C-string and allocates a temporary string ID. |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
205 |
* The StringID of the bound string is valid until BindCString is called |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
206 |
* another NUM_BOUND_STRINGS times. So be careful when using it. |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
207 |
* @param str temp string to add |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
208 |
* @return the id of that temp string |
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
209 |
* @note formatting a DATE_TINY calls BindCString twice, thus reduces the |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
210 |
* amount of 'user' bound strings by 2. |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
211 |
* @todo rewrite the BindCString system to make the limit flexible and |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
212 |
* non-round-robin. For example by using smart pointers that free |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
213 |
* the allocated StringID when they go out-of-scope/are freed. |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
214 |
*/ |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
215 |
StringID BindCString(const char *str) |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
216 |
{ |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
217 |
int idx = (++_bind_index) & (NUM_BOUND_STRINGS - 1); |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
218 |
_bound_strings[idx] = str; |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
219 |
return idx + STR_SPEC_DYNSTRING; |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
220 |
} |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
221 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
222 |
/** This function is used to "bind" a C string to a OpenTTD dparam slot. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
223 |
* @param n slot of the string |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
224 |
* @param str string to bind |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
225 |
*/ |
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
226 |
void SetDParamStr(uint n, const char *str) |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
227 |
{ |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
228 |
SetDParam(n, BindCString(str)); |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
229 |
} |
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2053
diff
changeset
|
230 |
|
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:
1306
diff
changeset
|
231 |
void InjectDParam(int amount) |
0 | 232 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
233 |
memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint64)); |
0 | 234 |
} |
235 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
236 |
// TODO |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
237 |
static char *FormatCommaNumber(char *buff, int64 number, const char *last) |
0 | 238 |
{ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
239 |
uint64 divisor = 10000000000000000000ULL; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
240 |
uint64 quot; |
0 | 241 |
int i; |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
242 |
uint64 tot; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
243 |
uint64 num; |
0 | 244 |
|
245 |
if (number < 0) { |
|
246 |
*buff++ = '-'; |
|
247 |
number = -number; |
|
248 |
} |
|
249 |
||
250 |
num = number; |
|
251 |
||
252 |
tot = 0; |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
253 |
for (i = 0; i < 20; i++) { |
0 | 254 |
quot = 0; |
255 |
if (num >= divisor) { |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
256 |
quot = num / divisor; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
257 |
num = num % divisor; |
0 | 258 |
} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
259 |
if (tot |= quot || i == 19) { |
1312
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
260 |
*buff++ = '0' + quot; |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
261 |
if ((i % 3) == 1 && i != 19) *buff++ = ','; |
0 | 262 |
} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
263 |
|
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
264 |
divisor /= 10; |
0 | 265 |
} |
266 |
||
1316 | 267 |
*buff = '\0'; |
0 | 268 |
|
269 |
return buff; |
|
270 |
} |
|
271 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
272 |
// TODO |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
273 |
static char *FormatNoCommaNumber(char *buff, int64 number, const char *last) |
0 | 274 |
{ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
275 |
uint64 divisor = 10000000000000000000ULL; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
276 |
uint64 quot; |
0 | 277 |
int i; |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
278 |
uint64 tot; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
279 |
uint64 num; |
0 | 280 |
|
281 |
if (number < 0) { |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
282 |
buff = strecpy(buff, "-", last); |
0 | 283 |
number = -number; |
284 |
} |
|
285 |
||
286 |
num = number; |
|
287 |
||
288 |
tot = 0; |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
289 |
for (i = 0; i < 20; i++) { |
0 | 290 |
quot = 0; |
291 |
if (num >= divisor) { |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
292 |
quot = num / divisor; |
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
293 |
num = num % divisor; |
0 | 294 |
} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
295 |
if (tot |= quot || i == 19) { |
1312
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
296 |
*buff++ = '0' + quot; |
0 | 297 |
} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
298 |
|
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
299 |
divisor /= 10; |
0 | 300 |
} |
301 |
||
1316 | 302 |
*buff = '\0'; |
0 | 303 |
|
304 |
return buff; |
|
305 |
} |
|
306 |
||
307 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
308 |
static char *FormatYmdString(char *buff, Date date, const char* last) |
0 | 309 |
{ |
310 |
YearMonthDay ymd; |
|
4289
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4288
diff
changeset
|
311 |
ConvertDateToYMD(date, &ymd); |
0 | 312 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
313 |
int64 args[3] = { ymd.day + STR_01AC_1ST - 1, STR_0162_JAN + ymd.month, ymd.year }; |
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
314 |
return FormatString(buff, GetStringPtr(STR_DATE_LONG), args, 0, last); |
0 | 315 |
} |
316 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
317 |
static char *FormatMonthAndYear(char *buff, Date date, const char* last) |
0 | 318 |
{ |
319 |
YearMonthDay ymd; |
|
4289
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4288
diff
changeset
|
320 |
ConvertDateToYMD(date, &ymd); |
0 | 321 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
322 |
int64 args[2] = { STR_MONTH_JAN + ymd.month, ymd.year }; |
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
323 |
return FormatString(buff, GetStringPtr(STR_DATE_SHORT), args, 0, last); |
0 | 324 |
} |
325 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
326 |
static char *FormatTinyDate(char *buff, Date date, const char* last) |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
327 |
{ |
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
328 |
YearMonthDay ymd; |
4289
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4288
diff
changeset
|
329 |
ConvertDateToYMD(date, &ymd); |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
330 |
|
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
331 |
char day[3]; |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
332 |
char month[3]; |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
333 |
/* We want to zero-pad the days and months */ |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
334 |
snprintf(day, lengthof(day), "%02i", ymd.day); |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
335 |
snprintf(month, lengthof(month), "%02i", ymd.month + 1); |
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
336 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
337 |
int64 args[3] = { BindCString(day), BindCString(month), ymd.year }; |
6484
8258acaa52c8
(svn r8906) -Feature: translation dependant formatting of dates.
rubidium
parents:
6417
diff
changeset
|
338 |
return FormatString(buff, GetStringPtr(STR_DATE_TINY), args, 0, last); |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
339 |
} |
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
340 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
341 |
static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money number, bool compact, const char* last) |
0 | 342 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
343 |
/* We are going to make number absolute for printing, so |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
344 |
* keep this piece of data as we need it later on */ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
345 |
bool negative = number < 0; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
346 |
const char *multiplier = ""; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
347 |
char buf[40]; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
348 |
char *p; |
0 | 349 |
int j; |
350 |
||
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
351 |
number *= spec->rate; |
0 | 352 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
353 |
/* convert from negative */ |
1316 | 354 |
if (number < 0) { |
6800
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
355 |
if (buff + Utf8CharLen(SCC_RED) > last) return buff; |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
356 |
buff += Utf8Encode(buff, SCC_RED); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
357 |
buff = strecpy(buff, "-", last); |
1316 | 358 |
number = -number; |
359 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
360 |
|
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
361 |
/* Add prefix part, folowing symbol_pos specification. |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
362 |
* Here, it can can be either 0 (prefix) or 2 (both prefix anf suffix). |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
363 |
* The only remaining value is 1 (suffix), so everything that is not 1 */ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
364 |
if (spec->symbol_pos != 1) buff = strecpy(buff, spec->prefix, last); |
0 | 365 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
366 |
/* for huge numbers, compact the number into k or M */ |
0 | 367 |
if (compact) { |
368 |
if (number >= 1000000000) { |
|
369 |
number = (number + 500000) / 1000000; |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
370 |
multiplier = "M"; |
0 | 371 |
} else if (number >= 1000000) { |
372 |
number = (number + 500) / 1000; |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
373 |
multiplier = "k"; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
374 |
} |
0 | 375 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
376 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
377 |
/* convert to ascii number and add commas */ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
378 |
p = endof(buf); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
379 |
*--p = '\0'; |
0 | 380 |
j = 4; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
381 |
do { |
1316 | 382 |
if (--j == 0) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
383 |
*--p = spec->separator; |
1316 | 384 |
j = 3; |
385 |
} |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
386 |
*--p = '0' + (char)(number % 10); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
387 |
} while ((number /= 10) != 0); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
388 |
buff = strecpy(buff, p, last); |
0 | 389 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
390 |
buff = strecpy(buff, multiplier, last); |
0 | 391 |
|
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
392 |
/* Add suffix part, folowing symbol_pos specification. |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
393 |
* Here, it can can be either 1 (suffix) or 2 (both prefix anf suffix). |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4505
diff
changeset
|
394 |
* The only remaining value is 1 (prefix), so everything that is not 0 */ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
395 |
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last); |
0 | 396 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
397 |
if (negative) { |
6800
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
398 |
if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff; |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
399 |
buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR); |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
400 |
*buff = '\0'; |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
401 |
} |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
402 |
|
0 | 403 |
return buff; |
404 |
} |
|
405 |
||
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
406 |
static int DeterminePluralForm(int64 count) |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
407 |
{ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
408 |
/* The absolute value determines plurality */ |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
409 |
uint64 n = abs(count); |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
410 |
|
2952 | 411 |
switch (_langpack->plural_form) { |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
412 |
default: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
413 |
NOT_REACHED(); |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
414 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
415 |
/* Two forms, singular used for one only |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
416 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
417 |
* Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish, |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
418 |
* Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
419 |
case 0: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
420 |
return n != 1; |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
421 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
422 |
/* Only one form |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
423 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
424 |
* Hungarian, Japanese, Korean, Turkish */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
425 |
case 1: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
426 |
return 0; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
427 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
428 |
/* Two forms, singular used for zero and one |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
429 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
430 |
* French, Brazilian Portuguese */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
431 |
case 2: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
432 |
return n > 1; |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
433 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
434 |
/* Three forms, special case for zero |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
435 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
436 |
* Latvian */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
437 |
case 3: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
438 |
return n % 10 == 1 && n % 100 != 11 ? 0 : n != 0 ? 1 : 2; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
439 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
440 |
/* Three forms, special case for one and two |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
441 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
442 |
* Gaelige (Irish) */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
443 |
case 4: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
444 |
return n == 1 ? 0 : n == 2 ? 1 : 2; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
445 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
446 |
/* Three forms, special case for numbers ending in 1[2-9] |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
447 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
448 |
* Lithuanian */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
449 |
case 5: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
450 |
return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
451 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
452 |
/* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4] |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
453 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
454 |
* Croatian, Czech, Russian, Slovak, Ukrainian */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
455 |
case 6: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
456 |
return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
457 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
458 |
/* Three forms, special case for one and some numbers ending in 2, 3, or 4 |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
459 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
460 |
* Polish */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
461 |
case 7: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
462 |
return n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
463 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
464 |
/* Four forms, special case for one and all numbers ending in 02, 03, or 04 |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
465 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
466 |
* Slovenian */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
467 |
case 8: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
468 |
return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
469 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
470 |
/* Two forms; singular used for everything ending in 1 but not in 11. |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
471 |
* Used in: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
472 |
* Icelandic */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
473 |
case 9: |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6877
diff
changeset
|
474 |
return n % 10 == 1 && n % 100 != 11 ? 0 : 1; |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
475 |
} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
476 |
} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
477 |
|
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
478 |
static const char *ParseStringChoice(const char *b, uint form, char *dst, int *dstlen) |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
479 |
{ |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
480 |
//<NUM> {Length of each string} {each string} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
481 |
uint n = (byte)*b++; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
482 |
uint pos, i, mylen = 0, mypos = 0; |
2952 | 483 |
|
484 |
for (i = pos = 0; i != n; i++) { |
|
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
485 |
uint len = (byte)*b++; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
486 |
if (i == form) { |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
487 |
mypos = pos; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
488 |
mylen = len; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
489 |
} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
490 |
pos += len; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
491 |
} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
492 |
*dstlen = mylen; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
493 |
memcpy(dst, b + mypos, mylen); |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
494 |
return b + pos; |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
495 |
} |
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
496 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
497 |
struct Units { |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
498 |
int s_m; ///< Multiplier for velocity |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
499 |
int s_s; ///< Shift for velocity |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
500 |
StringID velocity; ///< String for velocity |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
501 |
int p_m; ///< Multiplier for power |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
502 |
int p_s; ///< Shift for power |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
503 |
StringID power; ///< String for velocity |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
504 |
int w_m; ///< Multiplier for weight |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
505 |
int w_s; ///< Shift for weight |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
506 |
StringID s_weight; ///< Short string for weight |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
507 |
StringID l_weight; ///< Long string for weight |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
508 |
int v_m; ///< Multiplier for volume |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
509 |
int v_s; ///< Shift for volume |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
510 |
StringID s_volume; ///< Short string for volume |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
511 |
StringID l_volume; ///< Long string for volume |
3489
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
512 |
int f_m; ///< Multiplier for force |
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
513 |
int f_s; ///< Shift for force |
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
514 |
StringID force; ///< String for force |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
515 |
}; |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
516 |
|
3489
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
517 |
/* Unit conversions */ |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
518 |
static const Units units[] = { |
5653
5d95f08eb4b9
(svn r7596) -Codechange: Always display tractive effort in kN.
peter1138
parents:
5296
diff
changeset
|
519 |
{ // Imperial (Original, mph, hp, metric ton, litre, kN) |
6125
492a1c0440af
(svn r8464) -Revert (r4322): Change back to converting to mph in the GUI code, as 1 mph == 1.6 km/h is too far out for some people.
peter1138
parents:
6065
diff
changeset
|
520 |
1, 0, STR_UNITS_VELOCITY_IMPERIAL, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
521 |
1, 0, STR_UNITS_POWER_IMPERIAL, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
522 |
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
523 |
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, |
5653
5d95f08eb4b9
(svn r7596) -Codechange: Always display tractive effort in kN.
peter1138
parents:
5296
diff
changeset
|
524 |
1, 0, STR_UNITS_FORCE_SI, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
525 |
}, |
5653
5d95f08eb4b9
(svn r7596) -Codechange: Always display tractive effort in kN.
peter1138
parents:
5296
diff
changeset
|
526 |
{ // Metric (km/h, hp, metric ton, litre, kN) |
6125
492a1c0440af
(svn r8464) -Revert (r4322): Change back to converting to mph in the GUI code, as 1 mph == 1.6 km/h is too far out for some people.
peter1138
parents:
6065
diff
changeset
|
527 |
103, 6, STR_UNITS_VELOCITY_METRIC, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
528 |
1, 0, STR_UNITS_POWER_METRIC, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
529 |
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
530 |
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, |
5653
5d95f08eb4b9
(svn r7596) -Codechange: Always display tractive effort in kN.
peter1138
parents:
5296
diff
changeset
|
531 |
1, 0, STR_UNITS_FORCE_SI, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
532 |
}, |
3489
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
533 |
{ // SI (m/s, kilowatt, kilogram, cubic metres, kilonewton) |
6125
492a1c0440af
(svn r8464) -Revert (r4322): Change back to converting to mph in the GUI code, as 1 mph == 1.6 km/h is too far out for some people.
peter1138
parents:
6065
diff
changeset
|
534 |
1831, 12, STR_UNITS_VELOCITY_SI, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
535 |
764, 10, STR_UNITS_POWER_SI, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
536 |
1000, 0, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI, |
3485
a67571100234
(svn r4336) Fix units conversion of volume for SI
peter1138
parents:
3477
diff
changeset
|
537 |
1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, |
3489
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
538 |
1, 0, STR_UNITS_FORCE_SI, |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
539 |
}, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
540 |
}; |
2082
52fa58482eeb
(svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents:
2075
diff
changeset
|
541 |
|
10200
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
542 |
/** |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
543 |
* Convert the given (internal) speed to the display speed. |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
544 |
* @param speed the speed to convert |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
545 |
* @return the converted speed. |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
546 |
*/ |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
547 |
uint ConvertSpeedToDisplaySpeed(uint speed) |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
548 |
{ |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
549 |
return (speed * units[_settings_game.locale.units].s_m) >> units[_settings_game.locale.units].s_s; |
10200
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
550 |
} |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
551 |
|
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
552 |
/** |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
553 |
* Convert the given display speed to the (internal) speed. |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
554 |
* @param speed the speed to convert |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
555 |
* @return the converted speed. |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
556 |
*/ |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
557 |
uint ConvertDisplaySpeedToSpeed(uint speed) |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
558 |
{ |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
559 |
return ((speed << units[_settings_game.locale.units].s_s) + units[_settings_game.locale.units].s_m / 2) / units[_settings_game.locale.units].s_m; |
10200
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
560 |
} |
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
561 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
562 |
static char* FormatString(char* buff, const char* str, const int64* argv, uint casei, const char* last) |
0 | 563 |
{ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
564 |
WChar b; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
565 |
const int64 *argv_orig = argv; |
2087 | 566 |
uint modifier = 0; |
0 | 567 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
568 |
while ((b = Utf8Consume(&str)) != '\0') { |
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
569 |
if (SCC_NEWGRF_FIRST <= b && b <= SCC_NEWGRF_LAST) { |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
570 |
/* We need to pass some stuff as it might be modified; oh boy. */ |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
571 |
b = RemapNewGRFStringControlCode(b, &buff, &str, (int64*)argv); |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
572 |
if (b == 0) continue; |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
573 |
} |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6800
diff
changeset
|
574 |
|
1316 | 575 |
switch (b) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
576 |
case SCC_SETX: // {SETX} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
577 |
if (buff + Utf8CharLen(SCC_SETX) + 1 < last) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
578 |
buff += Utf8Encode(buff, SCC_SETX); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
579 |
*buff++ = *str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
580 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
581 |
break; |
2410
d1fae093e768
(svn r2936) Move string commands to a non-printable range and remove stale comments
tron
parents:
2353
diff
changeset
|
582 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
583 |
case SCC_SETXY: // {SETXY} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
584 |
if (buff + Utf8CharLen(SCC_SETXY) + 2 < last) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
585 |
buff += Utf8Encode(buff, SCC_SETXY); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
586 |
*buff++ = *str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
587 |
*buff++ = *str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
588 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
589 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
590 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
591 |
case SCC_STRING_ID: // {STRINL} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
592 |
buff = GetStringWithArgs(buff, Utf8Consume(&str), argv, last); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
593 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
594 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
595 |
case SCC_DATE_LONG: // {DATE_LONG} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
596 |
buff = FormatYmdString(buff, GetInt32(&argv), last); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
597 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
598 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
599 |
case SCC_DATE_SHORT: // {DATE_SHORT} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
600 |
buff = FormatMonthAndYear(buff, GetInt32(&argv), last); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
601 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
602 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
603 |
case SCC_VELOCITY: {// {VELOCITY} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
604 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
605 |
assert(_settings_game.locale.units < lengthof(units)); |
10200
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
606 |
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv)); |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
607 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].velocity), args, modifier >> 24, last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
608 |
modifier = 0; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
609 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
610 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
611 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
612 |
case SCC_CURRENCY_COMPACT: /* {CURRCOMPACT} */ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
613 |
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), true, last); |
0 | 614 |
break; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
615 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
616 |
case SCC_REVISION: /* {REV} */ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
617 |
buff = strecpy(buff, _openttd_revision, last); |
0 | 618 |
break; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
619 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
620 |
case SCC_CARGO_SHORT: { /* {SHORTCARGO} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
621 |
/* Short description of cargotypes. Layout: |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
622 |
* 8-bit = cargo type |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
623 |
* 16-bit = cargo count */ |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6414
diff
changeset
|
624 |
StringID cargo_str = GetCargo(GetInt32(&argv))->units_volume; |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
625 |
switch (cargo_str) { |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
626 |
case STR_TONS: { |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
627 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
628 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
629 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
630 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_weight), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
631 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
632 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
633 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
634 |
|
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
635 |
case STR_LITERS: { |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
636 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
637 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
638 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
639 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_volume), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
640 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
641 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
642 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
643 |
|
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
644 |
default: |
6685
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
645 |
if (cargo_str >= 0xE000 && cargo_str < 0xF800) { |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
646 |
/* NewGRF strings from Action 4 use a different format here, |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
647 |
* of e.g. "x tonnes of coal", so process accordingly. */ |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
648 |
buff = GetStringWithArgs(buff, cargo_str, argv++, last); |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
649 |
} else { |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
650 |
buff = FormatCommaNumber(buff, GetInt32(&argv), last); |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
651 |
buff = strecpy(buff, " ", last); |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
652 |
buff = strecpy(buff, GetStringPtr(cargo_str), last); |
410bba0abb67
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6683
diff
changeset
|
653 |
} |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
654 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
655 |
} |
1316 | 656 |
} break; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
657 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
658 |
case SCC_STRING1: { /* {STRING1} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
659 |
/* String that consumes ONE argument */ |
2087 | 660 |
uint str = modifier + GetInt32(&argv); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
661 |
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 1), last); |
2087 | 662 |
modifier = 0; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
663 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
664 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
665 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
666 |
case SCC_STRING2: { /* {STRING2} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
667 |
/* String that consumes TWO arguments */ |
2087 | 668 |
uint str = modifier + GetInt32(&argv); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
669 |
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 2), last); |
2087 | 670 |
modifier = 0; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
671 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
672 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
673 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
674 |
case SCC_STRING3: { /* {STRING3} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
675 |
/* String that consumes THREE arguments */ |
2087 | 676 |
uint str = modifier + GetInt32(&argv); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
677 |
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 3), last); |
2087 | 678 |
modifier = 0; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
679 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
680 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
681 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
682 |
case SCC_STRING4: { /* {STRING4} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
683 |
/* String that consumes FOUR arguments */ |
2087 | 684 |
uint str = modifier + GetInt32(&argv); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
685 |
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 4), last); |
2087 | 686 |
modifier = 0; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
687 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
688 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
689 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
690 |
case SCC_STRING5: { /* {STRING5} */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
691 |
/* String that consumes FIVE arguments */ |
2087 | 692 |
uint str = modifier + GetInt32(&argv); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
693 |
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 5), last); |
2087 | 694 |
modifier = 0; |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
695 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
696 |
} |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
697 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
698 |
case SCC_STATION_FEATURES: { /* {STATIONFEATURES} */ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
699 |
buff = StationGetSpecialString(buff, GetInt32(&argv), last); |
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
700 |
break; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2057
diff
changeset
|
701 |
} |
0 | 702 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
703 |
case SCC_INDUSTRY_NAME: { /* {INDUSTRY} */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
2966
diff
changeset
|
704 |
const Industry* i = GetIndustry(GetInt32(&argv)); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
705 |
int64 args[2]; |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
706 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
707 |
/* industry not valid anymore? */ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
708 |
if (!i->IsValid()) break; |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
709 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
710 |
/* First print the town name and the industry type name |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
711 |
* The string STR_INDUSTRY_PATTERN controls the formatting */ |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
712 |
args[0] = i->town->index; |
4942
f990abfa4438
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4920
diff
changeset
|
713 |
args[1] = GetIndustrySpec(i->type)->name; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
714 |
buff = FormatString(buff, GetStringPtr(STR_INDUSTRY_FORMAT), args, modifier >> 24, last); |
2087 | 715 |
modifier = 0; |
2070
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
716 |
break; |
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
717 |
} |
26c657906f25
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2063
diff
changeset
|
718 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
719 |
case SCC_VOLUME: { // {VOLUME} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
720 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
721 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
722 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
723 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_volume), args, modifier >> 24, last); |
2087 | 724 |
modifier = 0; |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
725 |
break; |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
726 |
} |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
727 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
728 |
case SCC_GENDER_LIST: { // {G 0 Der Die Das} |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
729 |
const char *s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender. |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
730 |
int len; |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
731 |
int gender = 0; |
6800
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
732 |
if (s != NULL) { |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
733 |
wchar_t c = Utf8Consume(&s); |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
734 |
/* Switch case is always put before genders, so remove those bits */ |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
735 |
if (c == SCC_SWITCH_CASE) { |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
736 |
/* Skip to the last (i.e. default) case */ |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
737 |
for (uint num = (byte)*s++; num != 0; num--) s += 3 + (s[1] << 8) + s[2]; |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
738 |
|
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
739 |
c = Utf8Consume(&s); |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
740 |
} |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
741 |
/* Does this string have a gender, if so, set it */ |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
742 |
if (c == SCC_GENDER_INDEX) gender = (byte)s[0]; |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
743 |
} |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
744 |
str = ParseStringChoice(str, gender, buff, &len); |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
745 |
buff += len; |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
746 |
break; |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
747 |
} |
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2082
diff
changeset
|
748 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
749 |
case SCC_DATE_TINY: { // {DATE_TINY} |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
750 |
buff = FormatTinyDate(buff, GetInt32(&argv), last); |
2087 | 751 |
break; |
752 |
} |
|
753 |
||
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
754 |
case SCC_CARGO: { // {CARGO} |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
755 |
/* Layout now is: |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
756 |
* 8bit - cargo type |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
757 |
* 16-bit - cargo count */ |
4898
68560c75ec28
(svn r6858) - Fix (r6855): Handle rail vehicles with no capacity (N/A) by setting cargo type to CT_INVALID and handling it later. STR_8838_N_A is not a valid cargo type...
peter1138
parents:
4840
diff
changeset
|
758 |
CargoID cargo = GetInt32(&argv); |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
759 |
StringID cargo_str = (cargo == CT_INVALID) ? STR_8838_N_A : GetCargo(cargo)->quantifier; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
760 |
buff = GetStringWithArgs(buff, cargo_str, argv++, last); |
2087 | 761 |
break; |
762 |
} |
|
763 |
||
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
764 |
case SCC_POWER: { // {POWER} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
765 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
766 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
767 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].p_m >> units[_settings_game.locale.units].p_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
768 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].power), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
769 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
770 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
771 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
772 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
773 |
case SCC_VOLUME_SHORT: { // {VOLUME_S} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
774 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
775 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
776 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].v_m >> units[_settings_game.locale.units].v_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
777 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].s_volume), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
778 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
779 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
780 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
781 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
782 |
case SCC_WEIGHT: { // {WEIGHT} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
783 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
784 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
785 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
786 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_weight), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
787 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
788 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
789 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
790 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
791 |
case SCC_WEIGHT_SHORT: { // {WEIGHT_S} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
792 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
793 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
794 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
795 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].s_weight), args, modifier >> 24, last); |
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
796 |
modifier = 0; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
797 |
break; |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
798 |
} |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3329
diff
changeset
|
799 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
800 |
case SCC_FORCE: { // {FORCE} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
801 |
int64 args[1]; |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
802 |
assert(_settings_game.locale.units < lengthof(units)); |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
803 |
args[0] = GetInt32(&argv) * units[_settings_game.locale.units].f_m >> units[_settings_game.locale.units].f_s; |
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
804 |
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].force), args, modifier >> 24, last); |
3489
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
805 |
modifier = 0; |
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
806 |
break; |
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
807 |
} |
1a4ffb2bc0f4
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents:
3485
diff
changeset
|
808 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
809 |
case SCC_SKIP: // {SKIP} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
810 |
argv++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
811 |
break; |
2410
d1fae093e768
(svn r2936) Move string commands to a non-printable range and remove stale comments
tron
parents:
2353
diff
changeset
|
812 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
813 |
/* This sets up the gender for the string. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
814 |
* We just ignore this one. It's used in {G 0 Der Die Das} to determine the case. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
815 |
case SCC_GENDER_INDEX: // {GENDER 0} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
816 |
str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
817 |
break; |
2630 | 818 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
819 |
case SCC_STRING: {// {STRING} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
820 |
uint str = modifier + GetInt32(&argv); |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
821 |
/* WARNING. It's prohibited for the included string to consume any arguments. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
822 |
* For included strings that consume argument, you should use STRING1, STRING2 etc. |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
823 |
* To debug stuff you can set argv to NULL and it will tell you */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
824 |
buff = GetStringWithArgs(buff, str, argv, last); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
825 |
modifier = 0; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
826 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
827 |
} |
2087 | 828 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
829 |
case SCC_COMMA: // {COMMA} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
830 |
buff = FormatCommaNumber(buff, GetInt64(&argv), last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
831 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
832 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
833 |
case SCC_ARG_INDEX: // Move argument pointer |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
834 |
argv = argv_orig + (byte)*str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
835 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
836 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
837 |
case SCC_PLURAL_LIST: { // {P} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
838 |
int64 v = argv_orig[(byte)*str++]; // contains the number that determines plural |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
839 |
int len; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
840 |
str = ParseStringChoice(str, DeterminePluralForm(v), buff, &len); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
841 |
buff += len; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
842 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
843 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
844 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
845 |
case SCC_NUM: // {NUM} |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
846 |
buff = FormatNoCommaNumber(buff, GetInt64(&argv), last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
847 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
848 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
849 |
case SCC_CURRENCY: // {CURRENCY} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
850 |
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), false, last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
851 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
852 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
853 |
case SCC_WAYPOINT_NAME: { // {WAYPOINT} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
854 |
Waypoint *wp = GetWaypoint(GetInt32(&argv)); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
855 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
856 |
if (!wp->IsValid()) { // waypoint doesn't exist anymore |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
857 |
buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
858 |
} else if (wp->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
859 |
buff = strecpy(buff, wp->name, last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
860 |
} else { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
861 |
int64 temp[2]; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
862 |
temp[0] = wp->town_index; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
863 |
temp[1] = wp->town_cn + 1; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
864 |
StringID str = wp->town_cn == 0 ? STR_WAYPOINTNAME_CITY : STR_WAYPOINTNAME_CITY_SERIAL; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
865 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
866 |
buff = GetStringWithArgs(buff, str, temp, last); |
2087 | 867 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
868 |
break; |
0 | 869 |
} |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1093
diff
changeset
|
870 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
871 |
case SCC_STATION_NAME: { // {STATION} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
872 |
const Station* st = GetStation(GetInt32(&argv)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
873 |
|
6322
3d191e6e89bc
(svn r8707) -Codechange: Turn IsValidStation into a method of Station
celestar
parents:
6125
diff
changeset
|
874 |
if (!st->IsValid()) { // station doesn't exist anymore |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
875 |
buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL, last); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
876 |
} else if (st->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
877 |
buff = strecpy(buff, st->name, last); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
878 |
} else { |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
879 |
int64 temp[3]; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
880 |
temp[0] = STR_TOWN; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
881 |
temp[1] = st->town->index; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
882 |
temp[2] = st->index; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
883 |
buff = GetStringWithArgs(buff, st->string_id, temp, last); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
884 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
885 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
886 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
887 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
888 |
case SCC_TOWN_NAME: { // {TOWN} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
889 |
const Town* t = GetTown(GetInt32(&argv)); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
890 |
int64 temp[1]; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
891 |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
892 |
assert(t->IsValid()); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
893 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
894 |
temp[0] = t->townnameparts; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
895 |
uint32 grfid = t->townnamegrfid; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
896 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
897 |
if (t->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
898 |
buff = strecpy(buff, t->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
899 |
} else if (grfid == 0) { |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
900 |
/* Original town name */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
901 |
buff = GetStringWithArgs(buff, t->townnametype, temp, last); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
902 |
} else { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
903 |
/* Newgrf town name */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
904 |
if (GetGRFTownName(grfid) != NULL) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
905 |
/* The grf is loaded */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
906 |
buff = GRFTownNameGenerate(buff, t->townnamegrfid, t->townnametype, t->townnameparts, last); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
907 |
} else { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
908 |
/* Fallback to english original */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
909 |
buff = GetStringWithArgs(buff, SPECSTR_TOWNNAME_ENGLISH, temp, last); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
910 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
911 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
912 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
913 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
914 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
915 |
case SCC_GROUP_NAME: { // {GROUP} |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
916 |
const Group *g = GetGroup(GetInt32(&argv)); |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
917 |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
918 |
assert(g->IsValid()); |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
919 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
920 |
if (g->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
921 |
buff = strecpy(buff, g->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
922 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
923 |
int64 args[1]; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
924 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
925 |
args[0] = g->index; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
926 |
buff = GetStringWithArgs(buff, STR_GROUP_NAME_FORMAT, args, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
927 |
} |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
928 |
break; |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
929 |
} |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
930 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
931 |
case SCC_ENGINE_NAME: { // {ENGINE} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
932 |
EngineID engine = (EngineID)GetInt32(&argv); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
933 |
const Engine *e = GetEngine(engine); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
934 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
935 |
if (e->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
936 |
buff = strecpy(buff, e->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
937 |
} else { |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
938 |
buff = GetStringWithArgs(buff, e->info.string_id, NULL, last); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
939 |
} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
940 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
941 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
942 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
943 |
case SCC_VEHICLE_NAME: { // {VEHICLE} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
944 |
const Vehicle *v = GetVehicle(GetInt32(&argv)); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
945 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
946 |
if (v->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
947 |
buff = strecpy(buff, v->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
948 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
949 |
int64 args[1]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
950 |
args[0] = v->unitnumber; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
951 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
952 |
StringID str; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
953 |
switch (v->type) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
954 |
default: NOT_REACHED(); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
955 |
case VEH_TRAIN: str = STR_SV_TRAIN_NAME; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
956 |
case VEH_ROAD: str = STR_SV_ROADVEH_NAME; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
957 |
case VEH_SHIP: str = STR_SV_SHIP_NAME; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
958 |
case VEH_AIRCRAFT: str = STR_SV_AIRCRAFT_NAME; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
959 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
960 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
961 |
buff = GetStringWithArgs(buff, str, args, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
962 |
} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
963 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
964 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
965 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
966 |
case SCC_SIGN_NAME: { // {SIGN} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
967 |
const Sign *si = GetSign(GetInt32(&argv)); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
968 |
if (si->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
969 |
buff = strecpy(buff, si->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
970 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
971 |
buff = GetStringWithArgs(buff, STR_280A_SIGN, NULL, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
972 |
} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
973 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
974 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
975 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
976 |
case SCC_COMPANY_NAME: { // {COMPANY} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
977 |
const Player *p = GetPlayer((PlayerID)GetInt32(&argv)); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
978 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
979 |
if (p->name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
980 |
buff = strecpy(buff, p->name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
981 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
982 |
int64 args[1]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
983 |
args[0] = p->name_2; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
984 |
buff = GetStringWithArgs(buff, p->name_1, args, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
985 |
} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
986 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
987 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
988 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
989 |
case SCC_COMPANY_NUM: { // {COMPANYNUM} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
990 |
PlayerID player = (PlayerID)GetInt32(&argv); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
991 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
992 |
/* Nothing is added for AI or inactive players */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
993 |
if (IsHumanPlayer(player) && IsValidPlayer(player)) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
994 |
int64 args[1]; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
995 |
args[0] = player + 1; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
996 |
buff = GetStringWithArgs(buff, STR_7002_PLAYER, args, last); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
997 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
998 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
999 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1000 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1001 |
case SCC_PLAYER_NAME: { // {PLAYERNAME} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1002 |
const Player *p = GetPlayer((PlayerID)GetInt32(&argv)); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1003 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1004 |
if (p->president_name != NULL) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1005 |
buff = strecpy(buff, p->president_name, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1006 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1007 |
int64 args[1]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1008 |
args[0] = p->president_name_2; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1009 |
buff = GetStringWithArgs(buff, p->president_name_1, args, last); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1010 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1011 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1012 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1013 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1014 |
case SCC_SETCASE: { // {SETCASE} |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1015 |
/* This is a pseudo command, it's outputted when someone does {STRING.ack} |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1016 |
* The modifier is added to all subsequent GetStringWithArgs that accept the modifier. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1017 |
modifier = (byte)*str++ << 24; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1018 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1019 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1020 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1021 |
case SCC_SWITCH_CASE: { // {Used to implement case switching} |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1022 |
/* <0x9E> <NUM CASES> <CASE1> <LEN1> <STRING1> <CASE2> <LEN2> <STRING2> <CASE3> <LEN3> <STRING3> <STRINGDEFAULT> |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1023 |
* Each LEN is printed using 2 bytes in big endian order. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1024 |
uint num = (byte)*str++; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1025 |
while (num) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1026 |
if ((byte)str[0] == casei) { |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1027 |
/* Found the case, adjust str pointer and continue */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1028 |
str += 3; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1029 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1030 |
} |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1031 |
/* Otherwise skip to the next case */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1032 |
str += 3 + (str[1] << 8) + str[2]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1033 |
num--; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1034 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1035 |
break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1036 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1037 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1038 |
default: |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1039 |
if (buff + Utf8CharLen(b) < last) buff += Utf8Encode(buff, b); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1040 |
break; |
0 | 1041 |
} |
1042 |
} |
|
1316 | 1043 |
*buff = '\0'; |
0 | 1044 |
return buff; |
1045 |
} |
|
1046 |
||
1047 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1048 |
static char *StationGetSpecialString(char *buff, int x, const char* last) |
0 | 1049 |
{ |
10274
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1050 |
if ((x & FACIL_TRAIN) && (buff + Utf8CharLen(SCC_TRAIN) < last)) buff += Utf8Encode(buff, SCC_TRAIN); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1051 |
if ((x & FACIL_TRUCK_STOP) && (buff + Utf8CharLen(SCC_LORRY) < last)) buff += Utf8Encode(buff, SCC_LORRY); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1052 |
if ((x & FACIL_BUS_STOP) && (buff + Utf8CharLen(SCC_BUS) < last)) buff += Utf8Encode(buff, SCC_BUS); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1053 |
if ((x & FACIL_AIRPORT) && (buff + Utf8CharLen(SCC_PLANE) < last)) buff += Utf8Encode(buff, SCC_PLANE); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1054 |
if ((x & FACIL_DOCK) && (buff + Utf8CharLen(SCC_SHIP) < last)) buff += Utf8Encode(buff, SCC_SHIP); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4942
diff
changeset
|
1055 |
*buff = '\0'; |
0 | 1056 |
return buff; |
1057 |
} |
|
1058 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1059 |
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last) |
1316 | 1060 |
{ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1061 |
char name[512]; |
0 | 1062 |
|
4920
de739ffd31a4
(svn r6896) - Fix (r6895): Supply last position of the correct buffer *again*
peter1138
parents:
4919
diff
changeset
|
1063 |
_town_name_generators[ind](name, seed, lastof(name)); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1064 |
return strecpy(buff, name, last); |
0 | 1065 |
} |
1066 |
||
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1067 |
static const char* const _silly_company_names[] = { |
0 | 1068 |
"Bloggs Brothers", |
1069 |
"Tiny Transport Ltd.", |
|
1070 |
"Express Travel", |
|
1071 |
"Comfy-Coach & Co.", |
|
1072 |
"Crush & Bump Ltd.", |
|
1073 |
"Broken & Late Ltd.", |
|
1074 |
"Sam Speedy & Son", |
|
1075 |
"Supersonic Travel", |
|
1076 |
"Mike's Motors", |
|
1077 |
"Lightning International", |
|
1078 |
"Pannik & Loozit Ltd.", |
|
1079 |
"Inter-City Transport", |
|
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1080 |
"Getout & Pushit Ltd." |
0 | 1081 |
}; |
1082 |
||
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1083 |
static const char* const _surname_list[] = { |
0 | 1084 |
"Adams", |
1085 |
"Allan", |
|
1086 |
"Baker", |
|
1087 |
"Bigwig", |
|
1088 |
"Black", |
|
1089 |
"Bloggs", |
|
1090 |
"Brown", |
|
1091 |
"Campbell", |
|
1092 |
"Gordon", |
|
1093 |
"Hamilton", |
|
1094 |
"Hawthorn", |
|
1095 |
"Higgins", |
|
1096 |
"Green", |
|
1097 |
"Gribble", |
|
1098 |
"Jones", |
|
1099 |
"McAlpine", |
|
1100 |
"MacDonald", |
|
1101 |
"McIntosh", |
|
1102 |
"Muir", |
|
1103 |
"Murphy", |
|
1104 |
"Nelson", |
|
1105 |
"O'Donnell", |
|
1106 |
"Parker", |
|
1107 |
"Phillips", |
|
1108 |
"Pilkington", |
|
1109 |
"Quigley", |
|
1110 |
"Sharkey", |
|
1111 |
"Thomson", |
|
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1112 |
"Watkins" |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1113 |
}; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1114 |
|
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1115 |
static const char* const _silly_surname_list[] = { |
0 | 1116 |
"Grumpy", |
1117 |
"Dozy", |
|
1118 |
"Speedy", |
|
1119 |
"Nosey", |
|
1120 |
"Dribble", |
|
1121 |
"Mushroom", |
|
1122 |
"Cabbage", |
|
1123 |
"Sniffle", |
|
1124 |
"Fishy", |
|
1125 |
"Swindle", |
|
1126 |
"Sneaky", |
|
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1127 |
"Nutkins" |
0 | 1128 |
}; |
1129 |
||
1312
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
1130 |
static const char _initial_name_letters[] = { |
1321 | 1131 |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', |
1132 |
'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', |
|
0 | 1133 |
}; |
1134 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1135 |
static char *GenAndCoName(char *buff, uint32 arg, const char* last) |
0 | 1136 |
{ |
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1137 |
const char* const* base; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1138 |
uint num; |
0 | 1139 |
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
1140 |
if (_settings_game.game_creation.landscape == LT_TOYLAND) { |
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1141 |
base = _silly_surname_list; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1142 |
num = lengthof(_silly_surname_list); |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1143 |
} else { |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1144 |
base = _surname_list; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1145 |
num = lengthof(_surname_list); |
0 | 1146 |
} |
1147 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1148 |
buff = strecpy(buff, base[num * GB(arg, 16, 8) >> 8], last); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1149 |
buff = strecpy(buff, " & Co.", last); |
0 | 1150 |
|
1151 |
return buff; |
|
1152 |
} |
|
1153 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1154 |
static char *GenPresidentName(char *buff, uint32 x, const char* last) |
0 | 1155 |
{ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1156 |
char initial[] = "?. "; |
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1157 |
const char* const* base; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1158 |
uint num; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1159 |
uint i; |
0 | 1160 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1161 |
initial[0] = _initial_name_letters[sizeof(_initial_name_letters) * GB(x, 0, 8) >> 8]; |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1162 |
buff = strecpy(buff, initial, last); |
0 | 1163 |
|
2150
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
1164 |
i = (sizeof(_initial_name_letters) + 35) * GB(x, 8, 8) >> 8; |
0 | 1165 |
if (i < sizeof(_initial_name_letters)) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1166 |
initial[0] = _initial_name_letters[i]; |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1167 |
buff = strecpy(buff, initial, last); |
0 | 1168 |
} |
1169 |
||
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
1170 |
if (_settings_game.game_creation.landscape == LT_TOYLAND) { |
2650
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1171 |
base = _silly_surname_list; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1172 |
num = lengthof(_silly_surname_list); |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1173 |
} else { |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1174 |
base = _surname_list; |
8caa93e39375
(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
tron
parents:
2643
diff
changeset
|
1175 |
num = lengthof(_surname_list); |
0 | 1176 |
} |
1177 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1178 |
buff = strecpy(buff, base[num * GB(x, 16, 8) >> 8], last); |
0 | 1179 |
|
1180 |
return buff; |
|
1181 |
} |
|
1182 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1183 |
static char *GetSpecialPlayerNameString(char *buff, int ind, const int64 *argv, const char* last) |
0 | 1184 |
{ |
1316 | 1185 |
switch (ind) { |
1321 | 1186 |
case 1: // not used |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1187 |
return strecpy(buff, _silly_company_names[GetInt32(&argv) & 0xFFFF], last); |
0 | 1188 |
|
1321 | 1189 |
case 2: // used for Foobar & Co company names |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1190 |
return GenAndCoName(buff, GetInt32(&argv), last); |
0 | 1191 |
|
1321 | 1192 |
case 3: // President name |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1193 |
return GenPresidentName(buff, GetInt32(&argv), last); |
0 | 1194 |
|
1321 | 1195 |
case 4: // song names |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1196 |
return strecpy(buff, origin_songs_specs[GetInt32(&argv) - 1].song_name, last); |
0 | 1197 |
} |
1198 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1199 |
/* town name? */ |
10242
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
10200
diff
changeset
|
1200 |
if (IsInsideMM(ind - 6, 0, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1)) { |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1201 |
buff = GetSpecialTownNameString(buff, ind - 6, GetInt32(&argv), last); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1202 |
return strecpy(buff, " Transport", last); |
0 | 1203 |
} |
1204 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1205 |
/* language name? */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1206 |
if (IsInsideMM(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) { |
0 | 1207 |
int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4); |
1853
2c2f5699e75f
(svn r2359) Use strecpy instead of str_cat (which was rather a cpy than a cat, btw), remove the latter and simplify some constructs
tron
parents:
1704
diff
changeset
|
1208 |
return strecpy(buff, |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1209 |
i == _dynlang.curr ? _langpack->own_name : _dynlang.ent[i].name, last); |
0 | 1210 |
} |
1211 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1212 |
/* resolution size? */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1213 |
if (IsInsideMM(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) { |
0 | 1214 |
int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1215 |
buff += snprintf( |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
1216 |
buff, last - buff + 1, "%dx%d", _resolutions[i].width, _resolutions[i].height |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1217 |
); |
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1218 |
return buff; |
0 | 1219 |
} |
1220 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1221 |
/* screenshot format name? */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1222 |
if (IsInsideMM(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) { |
0 | 1223 |
int i = ind - (SPECSTR_SCREENSHOT_START - 0x70E4); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4898
diff
changeset
|
1224 |
return strecpy(buff, GetScreenshotFormatDesc(i), last); |
0 | 1225 |
} |
1226 |
||
1227 |
assert(0); |
|
1228 |
return NULL; |
|
1229 |
} |
|
1230 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1231 |
#ifdef ENABLE_NETWORK |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1232 |
extern void SortNetworkLanguages(); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1233 |
#else /* ENABLE_NETWORK */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1234 |
static inline void SortNetworkLanguages() {} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1235 |
#endif /* ENABLE_NETWORK */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1236 |
|
1316 | 1237 |
bool ReadLanguagePack(int lang_index) |
1238 |
{ |
|
0 | 1239 |
int tot_count, i; |
1240 |
size_t len; |
|
1312
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
1241 |
char **langpack_offs; |
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
1242 |
char *s; |
0 | 1243 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1244 |
LanguagePack *lang_pack = (LanguagePack*)ReadFileToMem(_dynlang.ent[lang_index].file, &len, 200000); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1245 |
|
0 | 1246 |
if (lang_pack == NULL) return false; |
1319
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
1247 |
if (len < sizeof(LanguagePack) || |
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
1248 |
lang_pack->ident != TO_LE32(LANGUAGE_PACK_IDENT) || |
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
1249 |
lang_pack->version != TO_LE32(LANGUAGE_PACK_VERSION)) { |
0 | 1250 |
free(lang_pack); |
1251 |
return false; |
|
1252 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
1253 |
|
0 | 1254 |
#if defined(TTD_BIG_ENDIAN) |
1316 | 1255 |
for (i = 0; i != 32; i++) { |
2966
7f382cfeb93d
(svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents:
2957
diff
changeset
|
1256 |
lang_pack->offsets[i] = ReadLE16Aligned(&lang_pack->offsets[i]); |
0 | 1257 |
} |
1258 |
#endif |
|
1259 |
||
1260 |
tot_count = 0; |
|
1316 | 1261 |
for (i = 0; i != 32; i++) { |
1319
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
1262 |
uint num = lang_pack->offsets[i]; |
0 | 1263 |
_langtab_start[i] = tot_count; |
1264 |
_langtab_num[i] = num; |
|
1265 |
tot_count += num; |
|
1266 |
} |
|
1267 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1268 |
/* Allocate offsets */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
1269 |
langpack_offs = MallocT<char*>(tot_count); |
0 | 1270 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1271 |
/* Fill offsets */ |
1319
cd302ee91e27
(svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents:
1318
diff
changeset
|
1272 |
s = lang_pack->data; |
1316 | 1273 |
for (i = 0; i != tot_count; i++) { |
1312
8defbb525d09
(svn r1816) Use char instead of byte for string formatting
tron
parents:
1311
diff
changeset
|
1274 |
len = (byte)*s; |
1316 | 1275 |
*s++ = '\0'; // zero terminate the string before. |
1276 |
if (len >= 0xC0) len = ((len & 0x3F) << 8) + (byte)*s++; |
|
0 | 1277 |
langpack_offs[i] = s; |
1278 |
s += len; |
|
1279 |
} |
|
1280 |
||
1321 | 1281 |
free(_langpack); |
0 | 1282 |
_langpack = lang_pack; |
1283 |
||
1321 | 1284 |
free(_langpack_offs); |
0 | 1285 |
_langpack_offs = langpack_offs; |
1286 |
||
6670
86c087999542
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
rubidium
parents:
6646
diff
changeset
|
1287 |
const char *c_file = strrchr(_dynlang.ent[lang_index].file, PATHSEPCHAR) + 1; |
86c087999542
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
rubidium
parents:
6646
diff
changeset
|
1288 |
ttd_strlcpy(_dynlang.curr_file, c_file, lengthof(_dynlang.curr_file)); |
0 | 1289 |
|
1290 |
_dynlang.curr = lang_index; |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3489
diff
changeset
|
1291 |
SetCurrentGrfLangID(_langpack->isocode); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1292 |
SortNetworkLanguages(); |
0 | 1293 |
return true; |
1294 |
} |
|
1295 |
||
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6725
diff
changeset
|
1296 |
/* Win32 implementation in win32.cpp. */ |
6800
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
1297 |
/* OS X implementation in os/macosx/macos.mm. */ |
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
1298 |
#if !(defined(WIN32) || defined(__APPLE__)) |
3329
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1299 |
/** Determine the current charset based on the environment |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1300 |
* First check some default values, after this one we passed ourselves |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1301 |
* and if none exist return the value for $LANG |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6685
diff
changeset
|
1302 |
* @param param environment variable to check conditionally if default ones are not |
3329
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1303 |
* set. Pass NULL if you don't want additional checks. |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1304 |
* @return return string containing current charset, or NULL if not-determinable */ |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1305 |
const char *GetCurrentLocale(const char *param) |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1306 |
{ |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1307 |
const char *env; |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1308 |
|
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1309 |
env = getenv("LANGUAGE"); |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1310 |
if (env != NULL) return env; |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1311 |
|
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1312 |
env = getenv("LC_ALL"); |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1313 |
if (env != NULL) return env; |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1314 |
|
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1315 |
if (param != NULL) { |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1316 |
env = getenv(param); |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1317 |
if (env != NULL) return env; |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1318 |
} |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1319 |
|
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1320 |
return getenv("LANG"); |
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1321 |
} |
10274
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1322 |
#else |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1323 |
const char *GetCurrentLocale(const char *param); |
6800
6c09e1e86fcb
(svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents:
6743
diff
changeset
|
1324 |
#endif /* !(defined(WIN32) || defined(__APPLE__)) */ |
3329
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3033
diff
changeset
|
1325 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1326 |
int CDECL StringIDSorter(const void *a, const void *b) |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1327 |
{ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1328 |
const StringID va = *(const StringID*)a; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1329 |
const StringID vb = *(const StringID*)b; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1330 |
char stra[512]; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1331 |
char strb[512]; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1332 |
GetString(stra, va, lastof(stra)); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1333 |
GetString(strb, vb, lastof(strb)); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1334 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1335 |
return strcmp(stra, strb); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1336 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1337 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1338 |
/** |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1339 |
* Checks whether the given language is already found. |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1340 |
* @param langs languages we've found so fa |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1341 |
* @param max the length of the language list |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1342 |
* @param language name of the language to check |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1343 |
* @return true if and only if a language file with the same name has not been found |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1344 |
*/ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1345 |
static bool UniqueLanguageFile(const Language *langs, uint max, const char *language) |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1346 |
{ |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1347 |
for (uint i = 0; i < max; i++) { |
6670
86c087999542
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
rubidium
parents:
6646
diff
changeset
|
1348 |
const char *f_name = strrchr(langs[i].file, PATHSEPCHAR) + 1; |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1349 |
if (strcmp(f_name, language) == 0) return false; // duplicates |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1350 |
} |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1351 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1352 |
return true; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1353 |
} |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1354 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1355 |
/** |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1356 |
* Reads the language file header and checks compatability. |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1357 |
* @param file the file to read |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1358 |
* @param hdr the place to write the header information to |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1359 |
* @return true if and only if the language file is of a compatible version |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1360 |
*/ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1361 |
static bool GetLanguageFileHeader(const char *file, LanguagePack *hdr) |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1362 |
{ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1363 |
FILE *f = fopen(file, "rb"); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1364 |
if (f == NULL) return false; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1365 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1366 |
size_t read = fread(hdr, sizeof(*hdr), 1, f); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1367 |
fclose(f); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1368 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1369 |
return read == 1 && |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1370 |
hdr->ident == TO_LE32(LANGUAGE_PACK_IDENT) && |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1371 |
hdr->version == TO_LE32(LANGUAGE_PACK_VERSION); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1372 |
} |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1373 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1374 |
/** |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1375 |
* Gets a list of languages from the given directory. |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1376 |
* @param langs the list to write to |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1377 |
* @param start the initial offset in the list |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1378 |
* @param max the length of the language list |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1379 |
* @param path the base directory to search in |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1380 |
* @return the number of added languages |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1381 |
*/ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1382 |
static int GetLanguageList(Language *langs, int start, int max, const char *path) |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1383 |
{ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1384 |
int i = start; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1385 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1386 |
DIR *dir = ttd_opendir(path); |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1387 |
if (dir != NULL) { |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1388 |
struct dirent *dirent; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1389 |
while ((dirent = readdir(dir)) != NULL && i < max) { |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1390 |
const char *d_name = FS2OTTD(dirent->d_name); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1391 |
const char *extension = strrchr(d_name, '.'); |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1392 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1393 |
/* Not a language file */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1394 |
if (extension == NULL || strcmp(extension, ".lng") != 0) continue; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1395 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1396 |
/* Filter any duplicate language-files, first-come first-serve */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1397 |
if (!UniqueLanguageFile(langs, i, d_name)) continue; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1398 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1399 |
langs[i].file = str_fmt("%s%s", path, d_name); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1400 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1401 |
/* Check whether the file is of the correct version */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1402 |
LanguagePack hdr; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1403 |
if (!GetLanguageFileHeader(langs[i].file, &hdr)) { |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1404 |
free(langs[i].file); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1405 |
continue; |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1406 |
} |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1407 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1408 |
i++; |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1409 |
} |
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1410 |
closedir(dir); |
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1411 |
} |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1412 |
return i - start; |
4219
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1413 |
} |
4211284f29ec
(svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents:
4120
diff
changeset
|
1414 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1415 |
/** |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1416 |
* Make a list of the available language packs. put the data in |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1417 |
* _dynlang struct. |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1418 |
*/ |
6573 | 1419 |
void InitializeLanguagePacks() |
0 | 1420 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1421 |
Searchpath sp; |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1422 |
Language files[MAX_LANG]; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1423 |
uint language_count = 0; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1424 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1425 |
FOR_ALL_SEARCHPATHS(sp) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1426 |
char path[MAX_PATH]; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1427 |
FioAppendDirectory(path, lengthof(path), sp, LANG_DIR); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1428 |
language_count += GetLanguageList(files, language_count, lengthof(files), path); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
1429 |
} |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
1430 |
if (language_count == 0) usererror("No available language packs (invalid versions?)"); |
2257
9cf0a4b8eadb
(svn r2777) -Feature: When starting without a config file determine the language on basis of the current locale
tron
parents:
2201
diff
changeset
|
1431 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1432 |
/* Acquire the locale of the current system */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1433 |
const char *lang = GetCurrentLocale("LC_MESSAGES"); |
4505
f87e0c7fdda1
(svn r6290) -Feature: When automatically detecting the language try to first match language+territory (e.g. de_CH), then just language (e.g. de) and fall back to en_GB otherwise
tron
parents:
4503
diff
changeset
|
1434 |
if (lang == NULL) lang = "en_GB"; |
2257
9cf0a4b8eadb
(svn r2777) -Feature: When starting without a config file determine the language on basis of the current locale
tron
parents:
2201
diff
changeset
|
1435 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1436 |
int chosen_language = -1; ///< Matching the language in the configuartion file or the current locale |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1437 |
int language_fallback = -1; ///< Using pt_PT for pt_BR locale when pt_BR is not available |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1438 |
int en_GB_fallback = 0; ///< Fallback when no locale-matching language has been found |
0 | 1439 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1440 |
DynamicLanguages *dl = &_dynlang; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1441 |
dl->num = 0; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1442 |
/* Fill the dynamic languages structures */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1443 |
for (uint i = 0; i < language_count; i++) { |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1444 |
/* File read the language header */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1445 |
LanguagePack hdr; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1446 |
if (!GetLanguageFileHeader(files[i].file, &hdr)) continue; |
1321 | 1447 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1448 |
dl->ent[dl->num].file = files[i].file; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1449 |
dl->ent[dl->num].name = strdup(hdr.name); |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1450 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1451 |
/* We are trying to find a default language. The priority is by |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1452 |
* configuration file, local environment and last, if nothing found, |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1453 |
* english. If def equals -1, we have not picked a default language */ |
6670
86c087999542
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
rubidium
parents:
6646
diff
changeset
|
1454 |
const char *lang_file = strrchr(dl->ent[dl->num].file, PATHSEPCHAR) + 1; |
86c087999542
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
rubidium
parents:
6646
diff
changeset
|
1455 |
if (strcmp(lang_file, dl->curr_file) == 0) chosen_language = dl->num; |
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1456 |
|
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1457 |
if (chosen_language == -1) { |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1458 |
if (strcmp (hdr.isocode, "en_GB") == 0) en_GB_fallback = dl->num; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1459 |
if (strncmp(hdr.isocode, lang, 5) == 0) chosen_language = dl->num; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1460 |
if (strncmp(hdr.isocode, lang, 2) == 0) language_fallback = dl->num; |
0 | 1461 |
} |
1462 |
||
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1463 |
dl->num++; |
0 | 1464 |
} |
1465 |
||
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
1466 |
if (dl->num == 0) usererror("Invalid version of language packs"); |
0 | 1467 |
|
6646
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1468 |
/* We haven't found the language in the config nor the one in the locale. |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1469 |
* Now we set it to one of the fallback languages */ |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1470 |
if (chosen_language == -1) { |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1471 |
chosen_language = (language_fallback != -1) ? language_fallback : en_GB_fallback; |
0e3b3d315288
(svn r9271) -Codechange: make the language pack initialisation a little more clear and extendable (more language paths).
rubidium
parents:
6574
diff
changeset
|
1472 |
} |
0 | 1473 |
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
1474 |
if (!ReadLanguagePack(chosen_language)) usererror("Can't read language pack '%s'", dl->ent[chosen_language].file); |
2075
7f0ca01392db
(svn r2585) - Fix [Makefile]: some small cleanups, remove warnings, and add mersenne to makefile (Luca)
Darkvater
parents:
2070
diff
changeset
|
1475 |
} |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1476 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1477 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1478 |
* Check whether the currently loaded language pack |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1479 |
* uses characters that the currently loaded font |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1480 |
* does not support. If this is the case an error |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1481 |
* message will be shown in English. The error |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1482 |
* message will not be localized because that would |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1483 |
* mean it might use characters that are not in the |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1484 |
* font, which is the whole reason this check has |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1485 |
* been added. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1486 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1487 |
void CheckForMissingGlyphsInLoadedLanguagePack() |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1488 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1489 |
const Sprite *question_mark = GetGlyph(FS_NORMAL, '?'); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1490 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1491 |
for (uint i = 0; i != 32; i++) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1492 |
for (uint j = 0; j < _langtab_num[i]; j++) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1493 |
const char *string = _langpack_offs[_langtab_start[i] + j]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1494 |
WChar c; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1495 |
while ((c = Utf8Consume(&string)) != '\0') { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1496 |
if (c == SCC_SETX) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1497 |
/* |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1498 |
* SetX is, together with SetXY as special character that |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1499 |
* uses the next (two) characters as data points. We have |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1500 |
* to skip those, otherwise the UTF8 reading will go |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1501 |
* haywire. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1502 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1503 |
string++; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1504 |
} else if (c == SCC_SETXY) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1505 |
string += 2; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1506 |
} else if (IsPrintable(c) && c != '?' && GetGlyph(FS_NORMAL, c) == question_mark) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1507 |
/* |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1508 |
* The character is printable, but not in the normal font. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1509 |
* This is the case we were testing for. In this case we |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1510 |
* have to show the error. As we do not want the string to |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1511 |
* be translated by the translators, we 'force' it into the |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1512 |
* binary and 'load' it via a BindCString. To do this |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1513 |
* properly we have to set the color of the string, |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1514 |
* otherwise we end up with a lot of artefacts. The color |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1515 |
* 'character' might change in the future, so for safety |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1516 |
* we just Utf8 Encode it into the string, which takes |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1517 |
* exactly three characters, so it replaces the "XXX" with |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1518 |
* the color marker. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1519 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1520 |
static char *err_str = strdup("XXXThe current font is missing some of the characters used in the texts for this language. Read the readme to see how to solve this."); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1521 |
Utf8Encode(err_str, SCC_YELLOW); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1522 |
StringID err_msg = BindCString(err_str); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1523 |
ShowErrorMessage(INVALID_STRING_ID, err_msg, 0, 0); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1524 |
return; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1525 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1526 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1527 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1528 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1529 |
} |
10274
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1530 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1531 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1532 |
/* --- Handling of saving/loading string IDs from old savegames --- */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1533 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1534 |
/** |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1535 |
* Remap a string ID from the old format to the new format |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1536 |
* @param s StringID that requires remapping |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1537 |
* @return translated ID |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1538 |
*/ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1539 |
StringID RemapOldStringID(StringID s) |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1540 |
{ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1541 |
switch (s) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1542 |
case 0x0006: return STR_SV_EMPTY; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1543 |
case 0x7000: return STR_SV_UNNAMED; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1544 |
case 0x70E4: return SPECSTR_PLAYERNAME_ENGLISH; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1545 |
case 0x70E9: return SPECSTR_PLAYERNAME_ENGLISH; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1546 |
case 0x8864: return STR_SV_TRAIN_NAME; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1547 |
case 0x902B: return STR_SV_ROADVEH_NAME; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1548 |
case 0x9830: return STR_SV_SHIP_NAME; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1549 |
case 0xA02F: return STR_SV_AIRCRAFT_NAME; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1550 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1551 |
default: |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1552 |
if (IsInsideMM(s, 0x300F, 0x3030)) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1553 |
return s - 0x300F + STR_SV_STNAME; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1554 |
} else { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1555 |
return s; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1556 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1557 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1558 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1559 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1560 |
/** Location to load the old names to. */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1561 |
char *_old_name_array = NULL; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1562 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1563 |
/** |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1564 |
* Copy and convert old custom names to UTF-8. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1565 |
* They were all stored in a 512 by 32 long string array and are |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1566 |
* now stored with stations, waypoints and other places with names. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1567 |
* @param id the StringID of the custom name to clone. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1568 |
* @return the clones custom name. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1569 |
*/ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1570 |
char *CopyFromOldName(StringID id) |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1571 |
{ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1572 |
/* Is this name an (old) custom name? */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1573 |
if (GB(id, 11, 5) != 15) return NULL; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1574 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1575 |
if (CheckSavegameVersion(37)) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1576 |
/* Old names were 32 characters long, so 128 characters should be |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1577 |
* plenty to allow for expansion when converted to UTF-8. */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1578 |
char tmp[128]; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1579 |
const char *strfrom = &_old_name_array[32 * GB(id, 0, 9)]; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1580 |
char *strto = tmp; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1581 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1582 |
for (; *strfrom != '\0'; strfrom++) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1583 |
WChar c = (byte)*strfrom; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1584 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1585 |
/* Map from non-ISO8859-15 characters to UTF-8. */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1586 |
switch (c) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1587 |
case 0xA4: c = 0x20AC; break; // Euro |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1588 |
case 0xA6: c = 0x0160; break; // S with caron |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1589 |
case 0xA8: c = 0x0161; break; // s with caron |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1590 |
case 0xB4: c = 0x017D; break; // Z with caron |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1591 |
case 0xB8: c = 0x017E; break; // z with caron |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1592 |
case 0xBC: c = 0x0152; break; // OE ligature |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1593 |
case 0xBD: c = 0x0153; break; // oe ligature |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1594 |
case 0xBE: c = 0x0178; break; // Y with diaresis |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1595 |
default: break; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1596 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1597 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1598 |
/* Check character will fit into our buffer. */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1599 |
if (strto + Utf8CharLen(c) > lastof(tmp)) break; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1600 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1601 |
strto += Utf8Encode(strto, c); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1602 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1603 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1604 |
/* Terminate the new string and copy it back to the name array */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1605 |
*strto = '\0'; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1606 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1607 |
return strdup(tmp); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1608 |
} else { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1609 |
/* Name will already be in UTF-8. */ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1610 |
return strdup(&_old_name_array[32 * GB(id, 0, 9)]); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1611 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1612 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1613 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1614 |
/** |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1615 |
* Free the memory of the old names array. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1616 |
* Should be called once the old names have all been converted. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1617 |
*/ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1618 |
void ResetOldNames() |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1619 |
{ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1620 |
free(_old_name_array); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1621 |
_old_name_array = NULL; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1622 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1623 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1624 |
/** |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1625 |
* Initialize the old names table memory. |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1626 |
*/ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1627 |
void InitializeOldNames() |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1628 |
{ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1629 |
free(_old_name_array); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1630 |
_old_name_array = CallocT<char>(512 * 32); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1631 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1632 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1633 |
static void Load_NAME() |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1634 |
{ |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1635 |
int index; |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1636 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1637 |
while ((index = SlIterateArray()) != -1) { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1638 |
SlArray(&_old_name_array[32 * index], SlGetFieldLength(), SLE_UINT8); |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1639 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1640 |
} |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1641 |
|
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1642 |
extern const ChunkHandler _name_chunk_handlers[] = { |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1643 |
{ 'NAME', NULL, Load_NAME, CH_ARRAY | CH_LAST}, |
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
1644 |
}; |