author | truelight |
Tue, 14 Dec 2004 20:27:00 +0000 | |
changeset 656 | e3e435079efa |
parent 534 | 306bc86eb23e |
child 659 | a9733f856cd0 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
504
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "station.h" |
5 |
#include "town.h" |
|
6 |
#include "vehicle.h" |
|
6
e9b56d50aa99
(svn r7) -Feature [1003350] Euro introduction news item. (dominik81)
darkvater
parents:
0
diff
changeset
|
7 |
#include "news.h" |
430 | 8 |
#include "screenshot.h" |
0 | 9 |
|
10 |
#define USE_TABLE(x) { assert(index < lengthof(x)); str = x[index]; break; } |
|
11 |
||
12 |
static byte *StationGetSpecialString(byte *buff); |
|
13 |
static byte *GetSpecialTownNameString(byte *buff, int ind); |
|
14 |
static byte *GetSpecialPlayerNameString(byte *buff, int ind); |
|
15 |
||
16 |
static byte *DecodeString(byte *buff, const byte *str); |
|
17 |
||
18 |
static byte **_langpack_offs; |
|
19 |
static byte *_langpack; |
|
20 |
static uint _langtab_num[32]; // Offset into langpack offs |
|
21 |
static uint _langtab_start[32]; // Offset into langpack offs |
|
22 |
||
23 |
typedef byte *PlayerNameGeneratorProc(byte *buffr); |
|
24 |
||
25 |
typedef struct { |
|
26 |
uint32 ident; |
|
27 |
uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h |
|
28 |
char name[32]; // the international name of this language |
|
29 |
char own_name[32]; // the localized name of this language |
|
30 |
uint16 offsets[32]; // the offsets |
|
31 |
} LanguagePackHeader; |
|
32 |
||
33 |
typedef struct { |
|
34 |
uint16 rate; |
|
35 |
char separator; |
|
36 |
byte flags; |
|
37 |
char pre[4]; |
|
38 |
char post[4]; |
|
39 |
} CurrencySpec; |
|
40 |
||
41 |
enum { |
|
42 |
CF_TOEURO_2002 = 1, |
|
43 |
CF_ISEURO = 2, |
|
44 |
}; |
|
45 |
||
46 |
static const CurrencySpec _currency_specs[] = { |
|
47 |
{ 1, ',', 0, "\xA3", "" }, // british pounds |
|
48 |
{ 2, ',', 0, "$", "" }, // us dollars |
|
49 |
{ 10, '.', CF_TOEURO_2002, "FF ", "" }, // french francs |
|
50 |
{ 4, '.', CF_TOEURO_2002, "DM ", "" }, // deutsche mark |
|
51 |
{ 200, ',', 0, "\xA5", "" }, // yen |
|
52 |
{ 200, '.', CF_TOEURO_2002, "Pt", "" }, // spanish pesetas |
|
53 |
{ 376, ',', CF_TOEURO_2002, "", " Ft" }, |
|
54 |
{ 6, ' ', 0, "", " zl" }, |
|
55 |
{ 19, ',', CF_TOEURO_2002, "ATS ", "" }, |
|
56 |
{ 57, ',', CF_TOEURO_2002, "BEF ", "" }, |
|
57 |
{ 10, '.', 0, "", " kr" }, |
|
58 |
{ 8, ',', CF_TOEURO_2002, "FIM ", "" }, |
|
59 |
{ 480, ',', CF_TOEURO_2002, "GRD ", "" }, |
|
60 |
{ 2, ',', 0, "CHF ", "" }, |
|
61 |
{ 3, ',', CF_TOEURO_2002, "NLG ", "" }, |
|
62 |
{ 2730,',', CF_TOEURO_2002, "ITL ", "" }, |
|
63 |
{ 13, '.', 0, "", " kr" }, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
64 |
{ 5, ' ', 0, "", " rur" }, |
0 | 65 |
{ 50, ',', 0, "", " Kc" }, |
66 |
{ 130, '.', 0, "", " kr" }, |
|
67 |
{ 11, '.', 0, "", " kr" }, |
|
504 | 68 |
{ 2, ',', CF_ISEURO, "¤", "" }, |
240 | 69 |
{ 6, '.', 0, "", " Lei" }, |
0 | 70 |
}; |
71 |
||
72 |
const uint16 _currency_string_list[] = { |
|
73 |
STR_CURR_POUNDS, |
|
74 |
STR_CURR_DOLLARS, |
|
75 |
STR_CURR_FF, |
|
76 |
STR_CURR_DM, |
|
77 |
STR_CURR_YEN, |
|
78 |
STR_CURR_PT, |
|
79 |
STR_CURR_FT, |
|
80 |
STR_CURR_ZL, |
|
81 |
STR_CURR_ATS, |
|
82 |
STR_CURR_BEF, |
|
83 |
STR_CURR_DKK, |
|
84 |
STR_CURR_FIM, |
|
85 |
STR_CURR_GRD, |
|
86 |
STR_CURR_CHF, |
|
87 |
STR_CURR_NLG, |
|
88 |
STR_CURR_ITL, |
|
89 |
STR_CURR_SEK, |
|
90 |
STR_CURR_RUR, |
|
91 |
STR_CURR_CZK, |
|
92 |
STR_CURR_ISK, |
|
93 |
STR_CURR_NOK, |
|
261
c4fcd343e906
(svn r267) -Fix: Moved EUR back in its place, savegames should not list Romanian Lei anymore, and 2002 currency is also to EUR again
darkvater
parents:
240
diff
changeset
|
94 |
STR_CURR_EUR, |
233
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
95 |
STR_CURR_ROL, |
0 | 96 |
INVALID_STRING_ID |
97 |
}; |
|
98 |
||
99 |
static const uint16 _cargo_string_list[NUM_LANDSCAPE][NUM_CARGO] = { |
|
100 |
/* LT_NORMAL */ {STR_PASSENGERS, STR_TONS, STR_BAGS, STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, STR_TONS, STR_TONS, STR_TONS, STR_BAGS, STR_RES_OTHER}, |
|
101 |
/* LT_HILLY */ {STR_PASSENGERS, STR_TONS, STR_BAGS, STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, STR_TONS, STR_RES_OTHER, STR_TONS, STR_BAGS, STR_TONS}, |
|
102 |
/* LT_DESERT */ {STR_PASSENGERS, STR_LITERS, STR_BAGS, STR_LITERS, STR_TONS, STR_CRATES, STR_TONS, STR_TONS, STR_TONS, STR_LITERS, STR_BAGS, STR_TONS}, |
|
103 |
/* LT_CANDY */ {STR_PASSENGERS, STR_TONS, STR_BAGS, STR_NOTHING, STR_NOTHING, STR_TONS, STR_TONS, STR_LITERS, STR_TONS, STR_NOTHING, STR_LITERS, STR_NOTHING} |
|
104 |
}; |
|
105 |
||
106 |
// get a mask of the allowed currencies depending on the year |
|
107 |
uint GetMaskOfAllowedCurrencies() |
|
108 |
{ |
|
109 |
int i; |
|
110 |
uint mask = 0; |
|
111 |
for(i=0; i!=lengthof(_currency_specs); i++) { |
|
112 |
byte flags = _currency_specs[i].flags; |
|
113 |
if (_cur_year >= (2002-1920) && (flags & CF_TOEURO_2002)) continue; |
|
114 |
if (_cur_year < (2000-1920) && (flags & CF_ISEURO)) continue; |
|
115 |
mask |= (1 << i); |
|
116 |
} |
|
117 |
return mask; |
|
118 |
} |
|
119 |
||
120 |
void CheckSwitchToEuro() |
|
121 |
{ |
|
122 |
if (_cur_year >= (2002-1920) && _currency_specs[_opt.currency].flags & CF_TOEURO_2002) { |
|
123 |
_opt.currency = 21; // this is the index of euro above. |
|
6
e9b56d50aa99
(svn r7) -Feature [1003350] Euro introduction news item. (dominik81)
darkvater
parents:
0
diff
changeset
|
124 |
AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); |
0 | 125 |
} |
126 |
} |
|
127 |
||
128 |
static byte *str_cat(byte *dst, const byte *src) |
|
129 |
{ |
|
130 |
while ( (*dst++ = *src++) != 0) {} |
|
131 |
return dst - 1; |
|
132 |
} |
|
133 |
||
134 |
static byte *GetStringPtr(uint16 string) |
|
135 |
{ |
|
136 |
return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)]; |
|
137 |
} |
|
138 |
||
139 |
byte *GetString(byte *buffr, uint16 string) |
|
140 |
{ |
|
141 |
uint index = string & 0x7FF; |
|
142 |
uint tab = string >> 11; |
|
143 |
||
144 |
if (string == 0) error("!invalid string id 0 in GetString"); |
|
145 |
||
146 |
if ( tab == 4 && index >= 0xC0) |
|
147 |
return GetSpecialTownNameString(buffr, index - 0xC0); |
|
148 |
||
149 |
if ( tab == 6 && index == 0xD1) |
|
150 |
return StationGetSpecialString(buffr); |
|
151 |
||
152 |
if ( tab == 14 && index >= 0xE4) |
|
153 |
return GetSpecialPlayerNameString(buffr, index - 0xE4); |
|
154 |
||
155 |
if ( tab == 15) |
|
156 |
return GetName(index, buffr); |
|
157 |
||
158 |
// tab 31 is used for special or dynamic strings |
|
159 |
if ( tab == 31) { |
|
160 |
return DecodeString(buffr, index == (STR_SPEC_SCREENSHOT_NAME & 0x7FF) ? _screenshot_name : _userstring); |
|
161 |
} |
|
162 |
||
163 |
if (index >= _langtab_num[tab]) |
|
164 |
error("!String 0x%X is invalid. Probably because an old version of the .lng file.\n", string); |
|
165 |
||
166 |
return DecodeString(buffr, GetStringPtr(string)); |
|
167 |
} |
|
168 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
169 |
void InjectDparam(int amount) |
0 | 170 |
{ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
171 |
memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint32)); |
0 | 172 |
} |
173 |
||
174 |
||
175 |
int32 GetParamInt32() |
|
176 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
177 |
int32 result = GetDParam(0); |
425 | 178 |
memmove(&_decode_parameters[0], &_decode_parameters[1], sizeof(uint32) * (lengthof(_decode_parameters)-1)); |
0 | 179 |
return result; |
180 |
} |
|
181 |
||
410 | 182 |
static int64 GetParamInt64() |
0 | 183 |
{ |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
184 |
int64 result = GetDParam(0) + ((uint64)GetDParam(1) << 32); |
425 | 185 |
memmove(&_decode_parameters[0], &_decode_parameters[2], sizeof(uint32) * (lengthof(_decode_parameters)-2)); |
0 | 186 |
return result; |
187 |
} |
|
188 |
||
189 |
||
190 |
int GetParamInt16() |
|
191 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
192 |
int result = (int16)GetDParam(0); |
425 | 193 |
memmove(&_decode_parameters[0], &_decode_parameters[1], sizeof(uint32) * (lengthof(_decode_parameters)-1)); |
0 | 194 |
return result; |
195 |
} |
|
196 |
||
197 |
int GetParamInt8() |
|
198 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
199 |
int result = (int8)GetDParam(0); |
425 | 200 |
memmove(&_decode_parameters[0], &_decode_parameters[1], sizeof(uint32) * (lengthof(_decode_parameters)-1)); |
0 | 201 |
return result; |
202 |
} |
|
203 |
||
204 |
int GetParamUint16() |
|
205 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
206 |
int result = GetDParam(0); |
425 | 207 |
memmove(&_decode_parameters[0], &_decode_parameters[1], sizeof(uint32) * (lengthof(_decode_parameters)-1)); |
0 | 208 |
return result; |
209 |
} |
|
210 |
||
211 |
static const uint32 _divisor_table[] = { |
|
212 |
1000000000, |
|
213 |
100000000, |
|
214 |
10000000, |
|
215 |
1000000, |
|
216 |
||
217 |
100000, |
|
218 |
10000, |
|
219 |
1000, |
|
220 |
100, |
|
221 |
10, |
|
222 |
1 |
|
223 |
}; |
|
224 |
||
225 |
static byte *FormatCommaNumber(byte *buff, int32 number) |
|
226 |
{ |
|
227 |
uint32 quot,divisor; |
|
228 |
int i; |
|
229 |
uint32 tot; |
|
230 |
uint32 num; |
|
231 |
||
232 |
if (number < 0) { |
|
233 |
*buff++ = '-'; |
|
234 |
number = -number; |
|
235 |
} |
|
236 |
||
237 |
num = number; |
|
238 |
||
239 |
tot = 0; |
|
240 |
for(i=0; i!=10; i++) { |
|
241 |
divisor = _divisor_table[i]; |
|
242 |
quot = 0; |
|
243 |
if (num >= divisor) { |
|
244 |
quot = num / _divisor_table[i]; |
|
245 |
num = num % _divisor_table[i]; |
|
246 |
} |
|
247 |
if (tot|=quot || i==9) { |
|
248 |
*buff++ = (byte)('0' + quot); |
|
249 |
if (i==0 || i==3 || i==6) *buff++ = ','; |
|
250 |
} |
|
251 |
} |
|
252 |
||
253 |
*buff = 0; |
|
254 |
||
255 |
return buff; |
|
256 |
} |
|
257 |
||
258 |
static byte *FormatNoCommaNumber(byte *buff, int32 number) |
|
259 |
{ |
|
260 |
uint32 quot,divisor; |
|
261 |
int i; |
|
262 |
uint32 tot; |
|
263 |
uint32 num; |
|
264 |
||
265 |
if (number < 0) { |
|
266 |
*buff++ = '-'; |
|
267 |
number = -number; |
|
268 |
} |
|
269 |
||
270 |
num = number; |
|
271 |
||
272 |
tot = 0; |
|
273 |
for(i=0; i!=10; i++) { |
|
274 |
divisor = _divisor_table[i]; |
|
275 |
quot = 0; |
|
276 |
if (num >= divisor) { |
|
277 |
quot = num / _divisor_table[i]; |
|
278 |
num = num % _divisor_table[i]; |
|
279 |
} |
|
280 |
if (tot|=quot || i==9) { |
|
281 |
*buff++ = (byte)('0' + quot); |
|
282 |
} |
|
283 |
} |
|
284 |
||
285 |
*buff = 0; |
|
286 |
||
287 |
return buff; |
|
288 |
} |
|
289 |
||
290 |
||
291 |
static byte *FormatYmdString(byte *buff, uint16 number) |
|
292 |
{ |
|
293 |
const byte *src; |
|
294 |
YearMonthDay ymd; |
|
295 |
||
296 |
ConvertDayToYMD(&ymd, number); |
|
297 |
||
298 |
for(src = GetStringPtr(ymd.day+STR_01AC_1ST-1); (*buff++=*src++) != 0;) {} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
299 |
|
0 | 300 |
buff[-1] = ' '; |
301 |
memcpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), 4); |
|
302 |
buff[3] = ' '; |
|
303 |
||
304 |
return FormatNoCommaNumber(buff+4, ymd.year + 1920); |
|
305 |
} |
|
306 |
||
307 |
static byte *FormatMonthAndYear(byte *buff, uint16 number) |
|
308 |
{ |
|
309 |
const char *src; |
|
310 |
YearMonthDay ymd; |
|
311 |
||
312 |
ConvertDayToYMD(&ymd, number); |
|
313 |
||
314 |
for(src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++=*src++) != 0;) {} |
|
315 |
buff[-1] = ' '; |
|
316 |
||
317 |
return FormatNoCommaNumber(buff, ymd.year + 1920); |
|
318 |
} |
|
319 |
||
26 | 320 |
uint GetCurrentCurrencyRate() { |
321 |
return (&_currency_specs[_opt.currency])->rate; |
|
322 |
} |
|
323 |
||
0 | 324 |
static byte *FormatGenericCurrency(byte *buff, const CurrencySpec *spec, int64 number, bool compact) |
325 |
{ |
|
326 |
const char *s; |
|
327 |
char c; |
|
328 |
char buf[40], *p; |
|
329 |
int j; |
|
330 |
||
331 |
// multiply by exchange rate |
|
332 |
number *= spec->rate; |
|
333 |
||
334 |
// convert from negative |
|
335 |
if (number < 0) { *buff++ = '-'; number = -number; } |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
336 |
|
0 | 337 |
// add pre part |
338 |
s = spec->pre; |
|
339 |
while (s != spec->pre + lengthof(spec->pre) && (c=*s++)) *buff++ = c; |
|
340 |
||
341 |
// for huge numbers, compact the number into k or M |
|
342 |
if (compact) { |
|
343 |
compact = 0; |
|
344 |
if (number >= 1000000000) { |
|
345 |
number = (number + 500000) / 1000000; |
|
346 |
compact = 'M'; |
|
347 |
} else if (number >= 1000000) { |
|
348 |
number = (number + 500) / 1000; |
|
349 |
compact = 'k'; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
350 |
} |
0 | 351 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
352 |
|
0 | 353 |
// convert to ascii number and add commas |
354 |
p = buf; |
|
355 |
j = 4; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
356 |
do { |
0 | 357 |
if (--j == 0) { *p++ = spec->separator; j = 3; } |
358 |
*p++ = '0' + number % 10; |
|
359 |
} while (number /= 10); |
|
360 |
do *buff++ = *--p; while (p != buf); |
|
361 |
||
362 |
if (compact) *buff++ = compact; |
|
363 |
||
364 |
// add post part |
|
365 |
s = spec->post; |
|
366 |
while (s != spec->post + lengthof(spec->post) && (c=*s++)) *buff++ = c; |
|
367 |
||
368 |
return buff; |
|
369 |
} |
|
370 |
||
371 |
static byte *DecodeString(byte *buff, const byte *str) |
|
372 |
{ |
|
373 |
byte b; |
|
374 |
||
375 |
while((b = *str++) != 0) { |
|
376 |
switch(b) { |
|
377 |
case 0x1: // {SETX} |
|
378 |
*buff++ = b; |
|
379 |
*buff++ = *str++; |
|
380 |
break; |
|
381 |
case 0x2: // {SETXY} |
|
382 |
*buff++ = b; |
|
383 |
*buff++ = *str++; |
|
384 |
*buff++ = *str++; |
|
385 |
break; |
|
386 |
case 0x7B: // {COMMA32} |
|
387 |
buff = FormatCommaNumber(buff, GetParamInt32()); |
|
388 |
break; |
|
389 |
case 0x7C: // {COMMA16} |
|
390 |
buff = FormatCommaNumber(buff, GetParamInt16()); |
|
391 |
break; |
|
392 |
case 0x7D: // {COMMA8} |
|
393 |
buff = FormatCommaNumber(buff, GetParamInt8()); |
|
394 |
break; |
|
395 |
case 0x7E: // {NUMU16} |
|
396 |
buff = FormatNoCommaNumber(buff, GetParamInt16()); |
|
397 |
break; |
|
398 |
case 0x7F: // {CURRENCY} |
|
399 |
buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt32(), false); |
|
400 |
break; |
|
401 |
// 0x80 is reserved for EURO |
|
402 |
case 0x81: // {STRINL} |
|
403 |
str += 2; |
|
404 |
buff = GetString(buff, READ_LE_UINT16(str-2)); |
|
405 |
break; |
|
406 |
case 0x82: // {DATE_LONG} |
|
407 |
buff = FormatYmdString(buff, GetParamUint16()); |
|
408 |
break; |
|
409 |
case 0x83: // {DATE_SHORT} |
|
410 |
buff = FormatMonthAndYear(buff, GetParamUint16()); |
|
411 |
break; |
|
412 |
case 0x84: {// {VELOCITY} |
|
413 |
int value = GetParamInt16(); |
|
414 |
if (_opt.kilometers) value = value * 1648 >> 10; |
|
415 |
buff = FormatCommaNumber(buff, value); |
|
416 |
if (_opt.kilometers) { |
|
417 |
memcpy(buff, " km/h", 5); |
|
418 |
buff += 5; |
|
419 |
} else { |
|
420 |
memcpy(buff, " mph", 4); |
|
421 |
buff += 4; |
|
422 |
} |
|
423 |
break; |
|
424 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
425 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
426 |
// 0x85 is used as escape character.. |
0 | 427 |
case 0x85: |
428 |
switch(*str++) { |
|
236
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
429 |
case 0: /* {CURRCOMPACT} */ |
0 | 430 |
buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt32(), true); |
431 |
break; |
|
236
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
432 |
case 1: /* {INT32} */ |
0 | 433 |
buff = FormatNoCommaNumber(buff, GetParamInt32()); |
434 |
break; |
|
236
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
435 |
case 2: /* {REV} */ |
0 | 436 |
#ifdef WITH_REV |
437 |
buff = str_cat(buff, (const byte*)_openttd_revision); |
|
438 |
#endif |
|
439 |
break; |
|
236
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
440 |
case 3: { /* {SHORTCARGO} */ |
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
441 |
// Short description of cargotypes. Layout: |
0 | 442 |
// 8-bit = cargo type |
443 |
// 16-bit = cargo count |
|
444 |
char *s; |
|
445 |
uint16 cargo_str = _cargo_string_list[_opt.landscape][(byte)GetParamInt8()]; |
|
446 |
uint16 multiplier = (cargo_str == STR_LITERS) ? 1000 : 1; |
|
447 |
// liquid type of cargo is multiplied by 100 to get correct amount |
|
448 |
buff = FormatCommaNumber(buff, GetParamInt16() * multiplier ); |
|
449 |
s = GetStringPtr(cargo_str); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
450 |
|
0 | 451 |
memcpy(buff++, " ", 1); |
452 |
while (*s) *buff++ = *s++; |
|
236
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
453 |
} break; |
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
454 |
case 4: /* {CURRCOMPACT64} */ |
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
455 |
// 64 bit compact currency-unit |
da0ae9d977e0
(svn r237) -Fix: [1025836] Company value problem (again). Now company value rightly shows the value, including ALL your money.
darkvater
parents:
233
diff
changeset
|
456 |
buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt64(), true); |
0 | 457 |
break; |
458 |
||
459 |
default: |
|
460 |
error("!invalid escape sequence in string"); |
|
461 |
} |
|
462 |
break; |
|
463 |
||
464 |
case 0x86: // {SKIP} |
|
465 |
GetParamInt16(); |
|
466 |
//assert(0); |
|
467 |
break; |
|
468 |
case 0x87: { // {VOLUME} |
|
469 |
char *s; |
|
470 |
buff = FormatCommaNumber(buff, GetParamInt16() * 1000); |
|
471 |
memcpy(buff++, " ", 1); |
|
472 |
s = GetStringPtr(STR_LITERS); |
|
473 |
while (*s) *buff++ = *s++; |
|
474 |
break; |
|
475 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
476 |
|
0 | 477 |
case 0x88: // {STRING} |
478 |
buff = GetString(buff, (uint16)GetParamUint16()); |
|
479 |
break; |
|
480 |
||
481 |
case 0x99: { // {CARGO} |
|
482 |
// Layout now is: |
|
483 |
// 8bit - cargo type |
|
484 |
// 16-bit - cargo count |
|
485 |
int cargo_str = _cargoc.names_long_s[GetParamInt8()]; |
|
486 |
// Now check if the cargo count is 1, if it is, increase string by 32. |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
487 |
if (GetDParam(0) != 1) cargo_str += 32; |
0 | 488 |
buff = GetString(buff, cargo_str); |
489 |
break; |
|
490 |
} |
|
491 |
||
492 |
case 0x9A: { // {STATION} |
|
493 |
Station *st; |
|
494 |
InjectDparam(1); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
495 |
st = DEREF_STATION(GetDParam(1)); |
64
93656f16d50a
(svn r65) -Fix [1009567] problem with transferred cargo crashes game. Invalid st->xy on deleted station.
darkvater
parents:
26
diff
changeset
|
496 |
if (!st->xy) { // station doesn't exist anymore |
93656f16d50a
(svn r65) -Fix [1009567] problem with transferred cargo crashes game. Invalid st->xy on deleted station.
darkvater
parents:
26
diff
changeset
|
497 |
buff = GetString(buff, STR_UNKNOWN_DESTINATION); |
93656f16d50a
(svn r65) -Fix [1009567] problem with transferred cargo crashes game. Invalid st->xy on deleted station.
darkvater
parents:
26
diff
changeset
|
498 |
break; |
93656f16d50a
(svn r65) -Fix [1009567] problem with transferred cargo crashes game. Invalid st->xy on deleted station.
darkvater
parents:
26
diff
changeset
|
499 |
} |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
500 |
SetDParam(0, st->town->townnametype); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
501 |
SetDParam(1, st->town->townnameparts); |
0 | 502 |
buff = GetString(buff, st->string_id); |
503 |
break; |
|
504 |
} |
|
505 |
case 0x9B: { // {TOWN} |
|
506 |
Town *t; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
507 |
t = DEREF_TOWN(GetDParam(0)); |
0 | 508 |
assert(t->xy); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
509 |
SetDParam(0, t->townnameparts); |
0 | 510 |
buff = GetString(buff, t->townnametype); |
511 |
break; |
|
512 |
} |
|
513 |
||
514 |
case 0x9C: { // {CURRENCY64} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
515 |
buff = FormatGenericCurrency(buff, &_currency_specs[_opt.currency], GetParamInt64(), false); |
0 | 516 |
break; |
517 |
} |
|
518 |
||
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
287
diff
changeset
|
519 |
case 0x9D: { // {WAYPOINT} |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
520 |
Waypoint *cp = &_waypoints[GetDParam(0)]; |
0 | 521 |
StringID str; |
522 |
int idx; |
|
523 |
if (~cp->town_or_string & 0xC000) { |
|
524 |
GetParamInt32(); // skip it |
|
525 |
str = cp->town_or_string; |
|
526 |
} else { |
|
527 |
idx = (cp->town_or_string >> 8) & 0x3F; |
|
528 |
if (idx == 0) { |
|
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
287
diff
changeset
|
529 |
str = STR_WAYPOINTNAME_CITY; |
0 | 530 |
} else { |
531 |
InjectDparam(1); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
532 |
SetDParam(1, idx + 1); |
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
287
diff
changeset
|
533 |
str = STR_WAYPOINTNAME_CITY_SERIAL; |
0 | 534 |
} |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
535 |
SetDParam(0, cp->town_or_string & 0xFF); |
0 | 536 |
} |
537 |
||
538 |
buff = GetString(buff, str); |
|
539 |
} break; |
|
540 |
// case 0x88..0x98: // {COLORS} |
|
541 |
// case 0xE: // {TINYFONT} |
|
542 |
// case 0xF: // {BIGFONT} |
|
543 |
// 0x9E is the highest number that is available. |
|
544 |
default: |
|
545 |
*buff++ = b; |
|
546 |
} |
|
547 |
} |
|
548 |
buff[0] = 0; |
|
549 |
return buff; |
|
550 |
} |
|
551 |
||
552 |
||
553 |
static byte *StationGetSpecialString(byte *buff) |
|
554 |
{ |
|
555 |
int x = GetParamInt8(); |
|
556 |
if (x & 1) *buff++ = 0xB4; |
|
557 |
if (x & 2) *buff++ = 0xB5; |
|
558 |
if (x & 4) *buff++ = 0xB6; |
|
559 |
if (x & 8) *buff++ = 0xB7; |
|
560 |
if (x & 16) *buff++ = 0xB8; |
|
561 |
*buff = 0; |
|
562 |
return buff; |
|
563 |
} |
|
564 |
||
565 |
static byte *GetSpecialTownNameString(byte *buff, int ind) { |
|
566 |
uint32 x = GetParamInt32(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
567 |
|
0 | 568 |
_town_name_generators[ind](buff, x); |
569 |
||
570 |
while (*buff != 0) buff++; |
|
571 |
return buff; |
|
572 |
} |
|
573 |
||
574 |
static const char * const _silly_company_names[] = { |
|
575 |
"Bloggs Brothers", |
|
576 |
"Tiny Transport Ltd.", |
|
577 |
"Express Travel", |
|
578 |
"Comfy-Coach & Co.", |
|
579 |
"Crush & Bump Ltd.", |
|
580 |
"Broken & Late Ltd.", |
|
581 |
"Sam Speedy & Son", |
|
582 |
"Supersonic Travel", |
|
583 |
"Mike's Motors", |
|
584 |
"Lightning International", |
|
585 |
"Pannik & Loozit Ltd.", |
|
586 |
"Inter-City Transport", |
|
587 |
"Getout & Pushit Ltd.", |
|
588 |
}; |
|
589 |
||
590 |
static const char * const _surname_list[] = { |
|
591 |
"Adams", |
|
592 |
"Allan", |
|
593 |
"Baker", |
|
594 |
"Bigwig", |
|
595 |
"Black", |
|
596 |
"Bloggs", |
|
597 |
"Brown", |
|
598 |
"Campbell", |
|
599 |
"Gordon", |
|
600 |
"Hamilton", |
|
601 |
"Hawthorn", |
|
602 |
"Higgins", |
|
603 |
"Green", |
|
604 |
"Gribble", |
|
605 |
"Jones", |
|
606 |
"McAlpine", |
|
607 |
"MacDonald", |
|
608 |
"McIntosh", |
|
609 |
"Muir", |
|
610 |
"Murphy", |
|
611 |
"Nelson", |
|
612 |
"O'Donnell", |
|
613 |
"Parker", |
|
614 |
"Phillips", |
|
615 |
"Pilkington", |
|
616 |
"Quigley", |
|
617 |
"Sharkey", |
|
618 |
"Thomson", |
|
619 |
"Watkins", |
|
620 |
"Grumpy", |
|
621 |
"Dozy", |
|
622 |
"Speedy", |
|
623 |
"Nosey", |
|
624 |
"Dribble", |
|
625 |
"Mushroom", |
|
626 |
"Cabbage", |
|
627 |
"Sniffle", |
|
628 |
"Fishy", |
|
629 |
"Swindle", |
|
630 |
"Sneaky", |
|
631 |
"Nutkins", |
|
632 |
}; |
|
633 |
||
634 |
static const byte _initial_name_letters[] = { |
|
635 |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', |
|
636 |
}; |
|
637 |
||
638 |
static byte *GenAndCoName(byte *buff) |
|
639 |
{ |
|
640 |
uint32 x = GetParamInt32(); |
|
641 |
uint base,num; |
|
642 |
||
643 |
base = 0; |
|
644 |
num = 29; |
|
645 |
if (_opt.landscape == LT_CANDY) { |
|
646 |
base = num; |
|
647 |
num = 12; |
|
648 |
} |
|
649 |
||
650 |
buff = str_cat(buff, _surname_list[base + ((num * (byte)(x >> 16)) >> 8)]); |
|
651 |
buff = str_cat(buff, " & Co."); |
|
652 |
||
653 |
return buff; |
|
654 |
} |
|
655 |
||
656 |
static byte *GenPlayerName_4(byte *buff) |
|
657 |
{ |
|
658 |
uint32 x = GetParamInt32(); |
|
659 |
uint i, base, num; |
|
660 |
||
661 |
buff[0] = _initial_name_letters[ (sizeof(_initial_name_letters) * (byte)x) >> 8]; |
|
662 |
buff[1] = '.'; |
|
233
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
663 |
buff[2] = ' '; // Insert a space after initial and period "I. Firstname" instead of "I.Firstname" |
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
664 |
buff += 3; |
0 | 665 |
|
666 |
i = ((sizeof(_initial_name_letters) + 35) * (byte)(x >> 8)) >> 8; |
|
667 |
if (i < sizeof(_initial_name_letters)) { |
|
668 |
buff[0] = _initial_name_letters[i]; |
|
669 |
buff[1] = '.'; |
|
233
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
670 |
buff[2] = ' '; // Insert a space after initial and period "I. J. Firstname" instead of "I.J.Firstname" |
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
671 |
buff += 3; |
0 | 672 |
} |
673 |
||
674 |
base = 0; |
|
675 |
num = 29; |
|
676 |
if (_opt.landscape == LT_CANDY) { |
|
677 |
base = num; |
|
678 |
num = 12; |
|
679 |
} |
|
680 |
||
681 |
buff = str_cat(buff, _surname_list[base + ((num * (byte)(x >> 16)) >> 8)]); |
|
682 |
||
683 |
return buff; |
|
684 |
} |
|
685 |
||
686 |
static const char * const _song_names[] = { |
|
687 |
"Tycoon DELUXE Theme", |
|
688 |
"Easy Driver", |
|
689 |
"Little Red Diesel", |
|
690 |
"Cruise Control", |
|
691 |
"Don't Walk!", |
|
692 |
"Fell Apart On Me", |
|
693 |
"City Groove", |
|
694 |
"Funk Central", |
|
695 |
"Stoke It", |
|
696 |
"Road Hog", |
|
697 |
"Aliens Ate My Railway", |
|
698 |
"Snarl Up", |
|
699 |
"Stroll On", |
|
700 |
"Can't Get There From Here", |
|
701 |
"Sawyer's Tune", |
|
702 |
"Hold That Train!", |
|
703 |
"Movin' On", |
|
704 |
"Goss Groove", |
|
705 |
"Small Town", |
|
706 |
"Broomer's Oil Rag", |
|
707 |
"Jammit", |
|
708 |
"Hard Drivin'" |
|
709 |
}; |
|
710 |
||
711 |
static byte *GetSpecialPlayerNameString(byte *buff, int ind) |
|
712 |
{ |
|
713 |
switch(ind) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
714 |
|
0 | 715 |
// not used |
716 |
case 1: { |
|
717 |
int i = GetParamInt32() & 0xFFFF; |
|
718 |
return str_cat(buff, _silly_company_names[i]); |
|
719 |
} |
|
720 |
||
721 |
case 2: // used for Foobar & Co company names |
|
722 |
return GenAndCoName(buff); |
|
723 |
||
724 |
case 3: // President name |
|
725 |
return GenPlayerName_4(buff); |
|
726 |
||
727 |
// song names |
|
728 |
case 4: { |
|
729 |
const char *song = _song_names[GetParamUint16() - 1]; |
|
730 |
return str_cat(buff, song); |
|
731 |
} |
|
732 |
} |
|
733 |
||
734 |
// town name? |
|
735 |
if (IS_INT_INSIDE(ind-6, 0, SPECSTR_TOWNNAME_LAST-SPECSTR_TOWNNAME_START+1)) { |
|
736 |
buff = GetSpecialTownNameString(buff, ind - 6); |
|
737 |
return str_cat(buff, " Transport"); |
|
738 |
} |
|
739 |
||
740 |
// language name? |
|
741 |
if (IS_INT_INSIDE(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) { |
|
742 |
int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4); |
|
743 |
return str_cat(buff, i == _dynlang.curr ? ((LanguagePackHeader*)_langpack)->own_name : _dynlang.ent[i].name); |
|
744 |
} |
|
745 |
||
746 |
// resolution size? |
|
747 |
if (IS_INT_INSIDE(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) { |
|
748 |
int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4); |
|
749 |
return buff + sprintf(buff, "%dx%d", _resolutions[i][0], _resolutions[i][1]); |
|
750 |
} |
|
751 |
||
752 |
// screenshot format name? |
|
753 |
if (IS_INT_INSIDE(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) { |
|
754 |
int i = ind - (SPECSTR_SCREENSHOT_START - 0x70E4); |
|
755 |
return str_cat(buff, GetScreenshotFormatDesc(i)); |
|
756 |
} |
|
757 |
||
758 |
||
759 |
assert(0); |
|
760 |
return NULL; |
|
761 |
} |
|
762 |
||
763 |
// remap a string ID from the old format to the new format |
|
764 |
StringID RemapOldStringID(StringID s) |
|
765 |
{ |
|
766 |
if (s == 0x7000) s = STR_SV_UNNAMED; |
|
767 |
else if (s == 0x0006) s = STR_SV_EMPTY; |
|
768 |
else if (s == 0x8864) s = STR_SV_TRAIN_NAME; |
|
769 |
else if (s == 0x902B) s = STR_SV_ROADVEH_NAME; |
|
770 |
else if (s == 0x9830) s = STR_SV_SHIP_NAME; |
|
771 |
else if (s == 0xA02F) s = STR_SV_AIRCRAFT_NAME; |
|
772 |
else if (IS_INT_INSIDE(s, 0x300F, 0x3030)) s = s - 0x300F + STR_SV_STNAME; |
|
773 |
else if (s == 0x70E4 || s == 0x70E9) s = SPECSTR_PLAYERNAME_ENGLISH; |
|
774 |
return s; |
|
775 |
} |
|
776 |
||
777 |
bool ReadLanguagePack(int lang_index) { |
|
778 |
int tot_count, i; |
|
779 |
byte *lang_pack; |
|
780 |
size_t len; |
|
781 |
byte **langpack_offs; |
|
782 |
byte *s; |
|
783 |
||
784 |
#define HDR ((LanguagePackHeader*)lang_pack) |
|
785 |
{ |
|
786 |
char *lang = str_fmt("%s%s", _path.lang_dir, _dynlang.ent[lang_index].file); |
|
787 |
lang_pack = ReadFileToMem(lang, &len, 100000); |
|
788 |
free(lang); |
|
789 |
} |
|
790 |
if (lang_pack == NULL) return false; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
791 |
if (len < sizeof(LanguagePackHeader) || |
0 | 792 |
HDR->ident != TO_LE32(LANGUAGE_PACK_IDENT) || |
793 |
HDR->version != TO_LE32(LANGUAGE_PACK_VERSION)) { |
|
794 |
free(lang_pack); |
|
795 |
return false; |
|
796 |
} |
|
797 |
#undef HDR |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
798 |
|
0 | 799 |
#if defined(TTD_BIG_ENDIAN) |
800 |
for(i=0; i!=32; i++) { |
|
801 |
((LanguagePackHeader*)lang_pack)->offsets[i] = READ_LE_UINT16(&((LanguagePackHeader*)lang_pack)->offsets[i]); |
|
802 |
} |
|
803 |
#endif |
|
804 |
||
805 |
tot_count = 0; |
|
806 |
for(i=0; i!=32; i++) { |
|
807 |
uint num = ((LanguagePackHeader*)lang_pack)->offsets[i]; |
|
808 |
_langtab_start[i] = tot_count; |
|
809 |
_langtab_num[i] = num; |
|
810 |
tot_count += num; |
|
811 |
} |
|
812 |
||
813 |
// Allocate offsets |
|
814 |
langpack_offs = (byte**)malloc(tot_count * sizeof(byte*)); |
|
815 |
||
816 |
// Fill offsets |
|
817 |
s = lang_pack + sizeof(LanguagePackHeader); |
|
818 |
for(i=0; i!=tot_count; i++) { |
|
819 |
len = *s; |
|
820 |
*s++ = 0; // zero terminate the string before. |
|
821 |
if (len >= 0xC0) { len = ((len & 0x3F) << 8) + *s++; } |
|
822 |
langpack_offs[i] = s; |
|
823 |
s += len; |
|
824 |
} |
|
825 |
||
826 |
if (_langpack) free(_langpack); |
|
827 |
_langpack = lang_pack; |
|
828 |
||
829 |
if (_langpack_offs) free(_langpack_offs); |
|
830 |
_langpack_offs = langpack_offs; |
|
831 |
||
832 |
ttd_strlcpy(_dynlang.curr_file, _dynlang.ent[lang_index].file, sizeof(_dynlang.curr_file)); |
|
833 |
||
834 |
||
835 |
_dynlang.curr = lang_index; |
|
836 |
return true; |
|
837 |
} |
|
838 |
||
839 |
// make a list of the available language packs. put the data in _dynlang struct. |
|
840 |
void InitializeLanguagePacks() |
|
841 |
{ |
|
842 |
DynamicLanguages *dl = &_dynlang; |
|
843 |
int i, j, n, m,def; |
|
844 |
LanguagePackHeader hdr; |
|
845 |
FILE *in; |
|
846 |
char *files[32]; |
|
847 |
||
848 |
n = GetLanguageList(files, lengthof(files)); |
|
849 |
||
850 |
def = 0; // default language file |
|
851 |
||
852 |
// go through the language files and make sure that they are valid. |
|
853 |
for(i=m=0; i!=n; i++) { |
|
854 |
char *s = str_fmt("%s%s", _path.lang_dir, files[i]); |
|
855 |
in = fopen(s, "rb"); |
|
856 |
free(s); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
857 |
if (!in || |
0 | 858 |
(j = fread(&hdr, sizeof(hdr), 1, in), fclose(in), j) != 1 || |
859 |
hdr.ident != TO_LE32(LANGUAGE_PACK_IDENT) || |
|
860 |
hdr.version != TO_LE32(LANGUAGE_PACK_VERSION)) { |
|
861 |
free(files[i]); |
|
862 |
continue; |
|
863 |
} |
|
864 |
||
865 |
dl->ent[m].file = files[i]; |
|
866 |
dl->ent[m].name = strdup(hdr.name); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
867 |
|
0 | 868 |
if (!strcmp(hdr.name, "English")) def = m; |
869 |
||
870 |
m++; |
|
871 |
} |
|
872 |
||
873 |
if (m == 0) |
|
874 |
error(n == 0 ? "No available language packs" : "Invalid version of language packs"); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
64
diff
changeset
|
875 |
|
0 | 876 |
dl->num = m; |
877 |
for(i=0; i!=dl->num; i++) |
|
878 |
dl->dropdown[i] = SPECSTR_LANGUAGE_START + i; |
|
879 |
dl->dropdown[i] = INVALID_STRING_ID; |
|
880 |
||
881 |
for(i=0; i!=dl->num; i++) |
|
882 |
if (!strcmp(dl->ent[i].file, dl->curr_file)) { |
|
883 |
def = i; |
|
884 |
break; |
|
885 |
} |
|
886 |
||
887 |
if (!ReadLanguagePack(def)) |
|
888 |
error("can't read language pack '%s'", dl->ent[def].file); |
|
889 |
} |