strings.c
author glx
Mon, 24 Sep 2007 03:08:47 +0000
branch0.5
changeset 5545 f42dc59a45f5
parent 5471 d0fc5d926679
permissions -rw-r--r--
(svn r11153) [0.5] -Fix [FS#1251]: incorrect usage of {G} tag in slovak translation
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1853
diff changeset
     4
#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
     5
#include "currency.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     6
#include "functions.h"
1317
f382f1b439c7 (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents: 1316
diff changeset
     7
#include "string.h"
1309
dab90d4cbf2d (svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents: 1306
diff changeset
     8
#include "strings.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 504
diff changeset
     9
#include "table/strings.h"
1306
40038dfdf3ba (svn r1810) Move town name generation declarations into a header of their own
tron
parents: 1102
diff changeset
    10
#include "namegen.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "town.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "vehicle.h"
6
e9b56d50aa99 (svn r7) -Feature [1003350] Euro introduction news item. (dominik81)
darkvater
parents: 0
diff changeset
    14
#include "news.h"
430
75820dedf4f1 (svn r631) Merge r440, r444, r485, r630 to trunk:
tron
parents: 425
diff changeset
    15
#include "screenshot.h"
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1376
diff changeset
    16
#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
    17
#include "industry.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    18
#include "variables.h"
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
    19
#include "newgrf_text.h"
3616
7ba7353d6561 (svn r4513) Codechange : Assemble a bit the scattered parts of Cargo types.
belugas
parents: 3601
diff changeset
    20
#include "table/landscape_const.h"
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
    21
#include "table/control_codes.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
    22
#include "music.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 4219
diff changeset
    23
#include "date.h"
4942
f990abfa4438 (svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents: 4920
diff changeset
    24
#include "industry.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
4219
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
    26
/* for opendir/readdir/closedir */
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
    27
# include "fios.h"
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
    28
2201
3300b6ce8bce (svn r2717) Move _userstring to strings.[ch]
tron
parents: 2186
diff changeset
    29
char _userstring[128];
3300b6ce8bce (svn r2717) Move _userstring to strings.[ch]
tron
parents: 2186
diff changeset
    30
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
    31
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
    32
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
    33
static char *GetSpecialPlayerNameString(char *buff, int ind, const int32 *argv, const char* last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
    35
static char *FormatString(char *buff, const char *str, const int32 *argv, uint casei, const char* last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
1319
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    37
typedef struct LanguagePack {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	uint32 ident;
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
    39
	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
    40
	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
    41
	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
    42
	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
    43
	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
    44
	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
    45
	byte pad[3];        // pad header to be a multiple of 4
1319
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    46
	char data[VARARRAY_SIZE];
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    47
} LanguagePack;
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    48
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    49
static char **_langpack_offs;
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    50
static LanguagePack *_langpack;
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    51
static uint _langtab_num[32]; // Offset into langpack offs
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
    52
static uint _langtab_start[32]; // Offset into langpack offs
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
    54
static const StringID _cargo_string_list[NUM_LANDSCAPE][NUM_CARGO] = {
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    55
	{ /* LT_NORMAL */
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    56
		STR_PASSENGERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    57
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    58
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    59
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    60
		STR_ITEMS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    61
		STR_CRATES,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    62
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    63
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    64
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    65
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    66
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    67
		STR_RES_OTHER
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    68
	},
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    69
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    70
	{ /* LT_HILLY */
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    71
		STR_PASSENGERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    72
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    73
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    74
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    75
		STR_ITEMS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    76
		STR_CRATES,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    77
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    78
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    79
		STR_RES_OTHER,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    80
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    81
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    82
		STR_TONS
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    83
	},
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    84
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    85
	{ /* LT_DESERT */
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    86
		STR_PASSENGERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    87
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    88
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    89
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    90
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    91
		STR_CRATES,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    92
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    93
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    94
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    95
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    96
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    97
		STR_TONS
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    98
	},
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
    99
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   100
	{ /* LT_CANDY */
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   101
		STR_PASSENGERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   102
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   103
		STR_BAGS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   104
		STR_NOTHING,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   105
		STR_NOTHING,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   106
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   107
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   108
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   109
		STR_TONS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   110
		STR_NOTHING,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   111
		STR_LITERS,
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   112
		STR_NOTHING
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   113
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   117
// Read an int64 from the argv array.
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   118
static inline int64 GetInt64(const int32 **argv)
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   119
{
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   120
	int64 result;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   121
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   122
	assert(argv);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   123
	result = (uint32)(*argv)[0] + ((uint64)(uint32)(*argv)[1] << 32);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   124
	(*argv)+=2;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   125
	return result;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   126
}
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   127
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   128
// Read an int32 from the argv array.
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   129
static inline int32 GetInt32(const int32 **argv)
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   130
{
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   131
	assert(argv);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   132
	return *(*argv)++;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   133
}
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   134
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   135
// Read an array from the argv array.
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   136
static inline const int32 *GetArgvPtr(const int32 **argv, int n)
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   137
{
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   138
	const int32 *result;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   139
	assert(*argv);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   140
	result = *argv;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   141
	(*argv) += n;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   142
	return result;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   143
}
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   144
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   145
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
   146
#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
   147
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
   148
// Array to hold the 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
   149
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
   150
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
   151
// This index is used to implement a "round-robin" allocating of
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
   152
// slots for BindCString. NUM_BOUND_STRINGS slots are reserved.
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
   153
// Which means that after NUM_BOUND_STRINGS calls to BindCString,
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
   154
// the indices will be reused.
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
   155
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
   156
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   157
static const char *GetStringPtr(StringID string)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   162
// The highest 8 bits of string contain the "case index".
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   163
// These 8 bits will only be set when FormatString wants to print
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   164
// the string in a different case. No one else except FormatString
4405
262b9ef8ab8f (svn r6158) -Revert r6139 as that breaks strings with cases. Thanks michi_cc
Darkvater
parents: 4386
diff changeset
   165
// should set those bits, therefore string CANNOT be StringID, but uint32.
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   166
static char *GetStringWithArgs(char *buffr, uint string, const int32 *argv, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
{
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
   168
	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
   169
	uint tab   = GB(string, 11,  5);
4710
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   170
	char buff[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
2635
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2630
diff changeset
   172
	if (GB(string, 0, 16) == 0) error("!invalid string id 0 in GetString");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   174
	switch (tab) {
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   175
		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
   176
			if (index >= 0xC0)
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   177
				return GetSpecialTownNameString(buffr, index - 0xC0, GetInt32(&argv), last);
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   178
			break;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   179
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   180
		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
   181
			if (index >= 0xE4)
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   182
				return GetSpecialPlayerNameString(buffr, index - 0xE4, argv, last);
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   183
			break;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   184
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   185
		// User defined name
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   186
		case 15:
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   187
			return GetName(buffr, index, last);
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   188
4710
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   189
		case 26:
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   190
			/* Include string within newgrf text (format code 81) */
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   191
			if (HASBIT(index, 10)) {
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   192
				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
   193
				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
   194
			}
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   195
			break;
a663b32b9f96 (svn r6622) - Add support for NewGRF text includes. (Based on mart3p's patch)
peter1138
parents: 4602
diff changeset
   196
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   197
		case 28:
4916
4040103f7195 (svn r6890) - Fix (r6884): Supply last position of the correct buffer...
peter1138
parents: 4912
diff changeset
   198
			GetGRFString(buff, index, lastof(buff));
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   199
			return FormatString(buffr, buff, argv, 0, last);
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   200
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   201
		case 29:
4916
4040103f7195 (svn r6890) - Fix (r6884): Supply last position of the correct buffer...
peter1138
parents: 4912
diff changeset
   202
			GetGRFString(buff, index + 0x800, lastof(buff));
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   203
			return FormatString(buffr, buff, argv, 0, last);
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   204
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   205
		case 30:
4916
4040103f7195 (svn r6890) - Fix (r6884): Supply last position of the correct buffer...
peter1138
parents: 4912
diff changeset
   206
			GetGRFString(buff, index + 0x1000, lastof(buff));
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   207
			return FormatString(buffr, buff, argv, 0, last);
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
   208
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   209
		case 31:
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   210
			// dynamic strings. These are NOT to be passed through the formatter,
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   211
			// 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
   212
			if (index < (STR_SPEC_USERSTRING & 0x7FF)) {
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   213
				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
   214
			}
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   215
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   216
			return FormatString(buffr, _userstring, NULL, 0, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   219
	if (index >= _langtab_num[tab]) {
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   220
		error(
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   221
			"!String 0x%X is invalid. "
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   222
			"Probably because an old version of the .lng file.\n", string
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
   223
		);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   224
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   226
	return FormatString(buffr, GetStringPtr(GB(string, 0, 16)), argv, GB(string, 24, 8), last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   229
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
   230
{
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   231
	return GetStringWithArgs(buffr, string, (int32*)_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
   232
}
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   233
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   234
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
   235
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
   236
{
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
   237
	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
   238
	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
   239
	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
   240
}
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
   241
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
   242
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   243
/**
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   244
 * This function takes a C-string and allocates a temporary string ID.
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   245
 * The StringID of the bound string is valid until BindCString is called
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   246
 * another NUM_BOUND_STRINGS times. So be careful when using it.
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   247
 *
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   248
 * @note formatting a DATE_TINY calls BindCString twice, thus reduces the
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   249
 *       amount of 'user' bound strings by 2.
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   250
 * @todo rewrite the BindCString system to make the limit flexible and
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   251
 *       non-round-robin. For example by using smart pointers that free
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   252
 *       the allocated StringID when they go out-of-scope/are freed.
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   253
 */
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
   254
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
   255
{
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
   256
	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
   257
	_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
   258
	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
   259
}
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
   260
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
   261
// This function is used to "bind" a C string to a OpenTTD dparam slot.
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
   262
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
   263
{
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
   264
	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
   265
}
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
   266
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
   267
void InjectDParam(int amount)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
{
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
   269
	memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint32));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
static const uint32 _divisor_table[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	1000000000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
	100000000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	10000000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
	1000000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	100000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	10000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	1000,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	100,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
	1
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   286
// TODO
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   287
static char *FormatCommaNumber(char *buff, int32 number, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	uint32 quot,divisor;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	uint32 tot;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	uint32 num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	if (number < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
		*buff++ = '-';
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
		number = -number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	num = number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	tot = 0;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   302
	for (i = 0; i != 10; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
		divisor = _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
		quot = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
		if (num >= divisor) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
			quot = num / _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
			num = num % _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
		}
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   309
		if (tot |= quot || i == 9) {
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
   310
			*buff++ = '0' + quot;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   311
			if (i == 0 || i == 3 || i == 6) *buff++ = ',';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   315
	*buff = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   320
// TODO
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   321
static char *FormatNoCommaNumber(char *buff, int32 number, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	uint32 quot,divisor;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	uint32 tot;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
	uint32 num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
	if (number < 0) {
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   329
		buff = strecpy(buff, "-", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
		number = -number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	num = number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	tot = 0;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   336
	for (i = 0; i != 10; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
		divisor = _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
		quot = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
		if (num >= divisor) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
			quot = num / _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
			num = num % _divisor_table[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
		}
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   343
		if (tot |= quot || i == 9) {
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
   344
			*buff++ = '0' + quot;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   348
	*buff = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   354
static char *FormatYmdString(char *buff, Date date, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	YearMonthDay ymd;
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   357
	int32 args[3];
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4288
diff changeset
   358
	ConvertDateToYMD(date, &ymd);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   360
	args[0] = ymd.day + STR_01AC_1ST - 1;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   361
	args[1] = STR_0162_JAN + ymd.month;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   362
	args[2] = ymd.year;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   363
	return FormatString(buff, GetStringPtr(STR_DATE_LONG), args, 0, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   366
static char *FormatMonthAndYear(char *buff, Date date, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
	YearMonthDay ymd;
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   369
	int32 args[2];
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4288
diff changeset
   370
	ConvertDateToYMD(date, &ymd);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   372
	args[0] = STR_MONTH_JAN + ymd.month;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   373
	args[1] = ymd.year;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   374
	return FormatString(buff, GetStringPtr(STR_DATE_SHORT), args, 0, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   377
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
   378
{
653c846fb5d9 (svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents: 1093
diff changeset
   379
	YearMonthDay ymd;
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   380
	int32 args[3];
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   381
	char day[3];
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   382
	char month[3];
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4288
diff changeset
   383
	ConvertDateToYMD(date, &ymd);
1097
653c846fb5d9 (svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents: 1093
diff changeset
   384
5471
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   385
	/* We want to zero-pad the days and months */
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   386
	snprintf(day,   lengthof(day),   "%02i", ymd.day);
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   387
	snprintf(month, lengthof(month), "%02i", ymd.month + 1);
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   388
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   389
	args[0] = BindCString(day);
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   390
	args[1] = BindCString(month);
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   391
	args[2] = ymd.year;
d0fc5d926679 (svn r9355) [0.5] -Backport from trunk (r8906):
rubidium
parents: 5444
diff changeset
   392
	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
   393
}
653c846fb5d9 (svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents: 1093
diff changeset
   394
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   395
static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, int64 number, bool compact, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
{
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   397
	const char* multiplier = "";
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   398
	char buf[40];
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   399
	char* p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	int j;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	// multiply by exchange rate
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	number *= spec->rate;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	// convert from negative
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   406
	if (number < 0) {
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   407
		buff = strecpy(buff, "-", last);
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   408
		number = -number;
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   409
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
   410
4602
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4505
diff changeset
   411
	/* 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
   412
	 * 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
   413
	 * 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
   414
	if (spec->symbol_pos != 1) buff = strecpy(buff, spec->prefix, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
	// for huge numbers, compact the number into k or M
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
	if (compact) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
		if (number >= 1000000000) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
			number = (number + 500000) / 1000000;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   420
			multiplier = "M";
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		} else if (number >= 1000000) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
			number = (number + 500) / 1000;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   423
			multiplier = "k";
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
   424
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
   426
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
	// 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
   428
	p = endof(buf);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   429
	*--p = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
	j = 4;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
   431
	do {
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   432
		if (--j == 0) {
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   433
			*--p = spec->separator;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   434
			j = 3;
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   435
		}
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   436
		*--p = '0' + number % 10;
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   437
	} while ((number /= 10) != 0);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   438
	buff = strecpy(buff, p, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   440
	buff = strecpy(buff, multiplier, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
4602
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4505
diff changeset
   442
	/* 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
   443
	 * 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
   444
	 * 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
   445
	if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
2082
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   450
static int DeterminePluralForm(int32 n)
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   451
{
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   452
	// The absolute value determines plurality
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   453
	if (n < 0) n = -n;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   454
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   455
	switch (_langpack->plural_form) {
2082
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   456
	// Two forms, singular used for one only
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   457
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   458
	//   Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   459
	//   Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   460
	case 0:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   461
	default:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   462
		return n != 1;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   463
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   464
	// Only one form
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   465
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   466
	//   Hungarian, Japanese, Korean, Turkish
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   467
	case 1:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   468
		return 0;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   469
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   470
	// Two forms, singular used for zero and one
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   471
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   472
	//   French, Brazilian Portuguese
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   473
	case 2:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   474
		return n > 1;
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
	// Three forms, special case for zero
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   477
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   478
	//   Latvian
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   479
	case 3:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   480
		return n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   481
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   482
	// Three forms, special case for one and two
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   483
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   484
	//   Gaelige (Irish)
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   485
	case 4:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   486
		return n==1 ? 0 : n==2 ? 1 : 2;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   487
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   488
	// Three forms, special case for numbers ending in 1[2-9]
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   489
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   490
	//   Lithuanian
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   491
	case 5:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   492
		return n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   493
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   494
	// Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   495
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   496
	//   Croatian, Czech, Russian, Slovak, Ukrainian
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   497
	case 6:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   498
		return n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   499
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   500
	// Three forms, special case for one and some numbers ending in 2, 3, or 4
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   501
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   502
	//   Polish
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   503
	case 7:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   504
		return n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   505
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   506
	// Four forms, special case for one and all numbers ending in 02, 03, or 04
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   507
	// Used in:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   508
	//   Slovenian
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   509
	case 8:
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   510
		return n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   511
	}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   512
}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   513
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   514
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
   515
{
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   516
	//<NUM> {Length of each string} {each string}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   517
	uint n = (byte)*b++;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   518
	uint pos,i, mylen=0,mypos=0;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   519
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   520
	for (i = pos = 0; i != n; i++) {
2082
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   521
		uint len = (byte)*b++;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   522
		if (i == form) {
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   523
			mypos = pos;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   524
			mylen = len;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   525
		}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   526
		pos += len;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   527
	}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   528
	*dstlen = mylen;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   529
	memcpy(dst, b + mypos, mylen);
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   530
	return b + pos;
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   531
}
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   532
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   533
typedef struct Units {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   534
	int s_m;           ///< Multiplier for velocity
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   535
	int s_s;           ///< Shift for velocity
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   536
	StringID velocity; ///< String for velocity
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   537
	int p_m;           ///< Multiplier for power
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   538
	int p_s;           ///< Shift for power
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   539
	StringID power;    ///< String for velocity
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   540
	int w_m;           ///< Multiplier for weight
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   541
	int w_s;           ///< Shift for weight
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   542
	StringID s_weight; ///< Short string for weight
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   543
	StringID l_weight; ///< Long string for weight
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   544
	int v_m;           ///< Multiplier for volume
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   545
	int v_s;           ///< Shift for volume
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   546
	StringID s_volume; ///< Short string for volume
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   547
	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
   548
	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
   549
	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
   550
	StringID force;    ///< String for force
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   551
} Units;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   552
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   553
/* Unit conversions */
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   554
static const Units units[] = {
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   555
	{ // Imperial (Original, mph, hp, metric ton, litre, metric ton force)
3477
80c3465b38ee (svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents: 3342
diff changeset
   556
		  10,  4, STR_UNITS_VELOCITY_IMPERIAL,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   557
		   1,  0, STR_UNITS_POWER_IMPERIAL,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   558
		   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
   559
		1000,  0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   560
		 835, 13, STR_UNITS_FORCE_METRIC,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   561
	},
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   562
	{ // Metric (km/h, hp, metric ton, litre, metric ton force)
3477
80c3465b38ee (svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents: 3342
diff changeset
   563
		   1,  0, STR_UNITS_VELOCITY_METRIC,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   564
		   1,  0, STR_UNITS_POWER_METRIC,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   565
		   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
   566
		1000,  0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   567
		 835, 13, STR_UNITS_FORCE_METRIC,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   568
	},
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   569
	{ // SI (m/s, kilowatt, kilogram, cubic metres, kilonewton)
3477
80c3465b38ee (svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents: 3342
diff changeset
   570
		 284, 10, STR_UNITS_VELOCITY_SI,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   571
		 764, 10, STR_UNITS_POWER_SI,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   572
		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
   573
		   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
   574
		   1,  0, STR_UNITS_FORCE_SI,
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   575
	},
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   576
};
2082
52fa58482eeb (svn r2592) Feature: [strgen] New way to specify plural forms.
ludde
parents: 2075
diff changeset
   577
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   578
static char* FormatString(char* buff, const char* str, const int32* argv, uint casei, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
{
4840
176bc2a66322 (svn r6766) -Codechange: Move _openttd_revision[] into the functions that use it instead of global
Darkvater
parents: 4710
diff changeset
   580
	extern const char _openttd_revision[];
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
   581
	WChar b;
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   582
	const int32 *argv_orig = argv;
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   583
	uint modifier = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
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
   585
	while ((b = Utf8Consume(&str)) != '\0') {
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   586
		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
   587
			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
   588
				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
   589
					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
   590
					*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
   591
				}
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
				break;
2410
d1fae093e768 (svn r2936) Move string commands to a non-printable range and remove stale comments
tron
parents: 2353
diff changeset
   593
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
   594
			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
   595
				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
   596
					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
   597
					*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
   598
					*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
   599
				}
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
				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
   601
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
			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
   603
				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
   604
				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
   605
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
   606
			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
   607
				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
   608
				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
   609
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
			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
   611
				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
   612
				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
   613
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
   614
			case SCC_VELOCITY: {// {VELOCITY}
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
				int32 args[1];
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
				assert(_opt_ptr->units < lengthof(units));
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
   617
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].s_m >> units[_opt_ptr->units].s_s;
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
   618
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].velocity), args, modifier >> 24, 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
   619
				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
   620
				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
   621
			}
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
   622
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
   623
			case SCC_CURRENCY_COMPACT: /* {CURRCOMPACT} */
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   624
				buff = FormatGenericCurrency(buff, _currency, GetInt32(&argv), true, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
				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
   626
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
   627
			case SCC_REVISION: /* {REV} */
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   628
				buff = strecpy(buff, _openttd_revision, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
				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
   630
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
   631
			case SCC_CARGO_SHORT: { /* {SHORTCARGO} */
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
   632
				// Short description of cargotypes. Layout:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
				// 8-bit = cargo type
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
				// 16-bit = cargo count
3616
7ba7353d6561 (svn r4513) Codechange : Assemble a bit the scattered parts of Cargo types.
belugas
parents: 3601
diff changeset
   635
				StringID cargo_str = _cargo_types_base_values[_opt_ptr->landscape].units_volume[GetInt32(&argv)];
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   636
				switch (cargo_str) {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   637
					case STR_TONS: {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   638
						int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   639
						assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   640
						args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   641
						buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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
   642
						modifier = 0;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   643
						break;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   644
					}
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   645
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   646
					case STR_LITERS: {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   647
						int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   648
						assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   649
						args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   650
						buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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
   651
						modifier = 0;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   652
						break;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   653
					}
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   654
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   655
					default:
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   656
						buff = FormatCommaNumber(buff, GetInt32(&argv), last);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   657
						buff = strecpy(buff, " ", last);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   658
						buff = strecpy(buff, GetStringPtr(cargo_str), last);
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   659
						break;
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   660
				}
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   661
			} 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
   662
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
   663
			case SCC_CURRENCY_COMPACT_64: { /* {CURRCOMPACT64} */
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
   664
				// 64 bit compact currency-unit
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   665
				buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), true, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
				break;
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   667
			}
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
   668
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
   669
			case SCC_STRING1: { /* {STRING1} */
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   670
				// String that consumes ONE argument
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   671
				uint str = modifier + GetInt32(&argv);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   672
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 1), last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   673
				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
   674
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   675
			}
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
   676
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
   677
			case SCC_STRING2: { /* {STRING2} */
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   678
				// String that consumes TWO arguments
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   679
				uint str = modifier + GetInt32(&argv);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   680
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 2), last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   681
				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
   682
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   683
			}
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
   684
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
   685
			case SCC_STRING3: { /* {STRING3} */
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   686
				// String that consumes THREE arguments
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   687
				uint str = modifier + GetInt32(&argv);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   688
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 3), last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   689
				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
   690
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   691
			}
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
   692
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
   693
			case SCC_STRING4: { /* {STRING4} */
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   694
				// String that consumes FOUR arguments
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   695
				uint str = modifier + GetInt32(&argv);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   696
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 4), last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   697
				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
   698
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   699
			}
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
   700
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
   701
			case SCC_STRING5: { /* {STRING5} */
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   702
				// String that consumes FIVE arguments
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   703
				uint str = modifier + GetInt32(&argv);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   704
				buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 5), last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   705
				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
   706
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   707
			}
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   708
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
   709
			case SCC_STATION_FEATURES: { /* {STATIONFEATURES} */
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   710
				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
   711
				break;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2057
diff changeset
   712
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
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
   714
			case SCC_INDUSTRY_NAME: { /* {INDUSTRY} */
3033
e4f7c60a1742 (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 2966
diff changeset
   715
				const Industry* i = GetIndustry(GetInt32(&argv));
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
				int32 args[2];
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
				// industry not valid anymore?
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4321
diff changeset
   719
				if (!IsValidIndustry(i)) 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
   720
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
   721
				// First print the town name and the industry type name
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
   722
				// The string STR_INDUSTRY_PATTERN controls the formatting
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
   723
				args[0] = i->town->index;
4942
f990abfa4438 (svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents: 4920
diff changeset
   724
				args[1] = GetIndustrySpec(i->type)->name;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   725
				buff = FormatString(buff, GetStringPtr(STR_INDUSTRY_FORMAT), args, modifier >> 24, last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   726
				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
   727
				break;
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
   728
			}
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
   729
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
   730
			case SCC_VOLUME: { // {VOLUME}
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   731
				int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   732
				assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   733
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   734
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_volume), args, modifier >> 24, last);
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   735
				modifier = 0;
2084
d67790a49f78 (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents: 2082
diff changeset
   736
				break;
d67790a49f78 (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents: 2082
diff changeset
   737
			}
d67790a49f78 (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents: 2082
diff changeset
   738
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
   739
			case SCC_GENDER_LIST: { // {G 0 Der Die Das}
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
   740
				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
   741
				int len;
d67790a49f78 (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents: 2082
diff changeset
   742
				int gender = 0;
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
   743
				if (s != NULL && Utf8Consume(&s) == SCC_GENDER_INDEX) gender = (byte)s[0];
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
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   751
				break;
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   752
			}
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   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}
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   755
				// Layout now is:
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   756
				//   8bit   - cargo type
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
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);
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
   759
				StringID cargo_str = (cargo == CT_INVALID) ? STR_8838_N_A : _cargoc.names_long[cargo];
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
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   761
				break;
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   762
			}
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   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}
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   765
				int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   766
				assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   767
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].p_m >> units[_opt_ptr->units].p_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   768
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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}
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   774
				int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   775
				assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   776
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   777
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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}
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   783
				int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   784
				assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   785
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   786
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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}
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   792
				int32 args[1];
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   793
				assert(_opt_ptr->units < lengthof(units));
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3329
diff changeset
   794
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   795
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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}
3489
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   801
				int32 args[1];
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   802
				assert(_opt_ptr->units < lengthof(units));
1a4ffb2bc0f4 (svn r4340) Add force {FORCE} to the units system. This is currently unused.
peter1138
parents: 3485
diff changeset
   803
				args[0] = GetInt32(&argv) * units[_opt_ptr->units].f_m >> units[_opt_ptr->units].f_s;
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   804
				buff = FormatString(buff, GetStringPtr(units[_opt_ptr->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
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
   813
			// This sets up the gender for the 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
   814
			// We just ignore this one. It's used in {G 0 Der Die Das} to determine the case.
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
35249d2ded3e (svn r3172) static, const
tron
parents: 2548
diff changeset
   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);
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
   821
				// WARNING. It's prohibited for the included string to consume any arguments.
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
   822
				// For included strings that consume argument, you should use STRING1, STRING2 etc.
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
   823
				// To debug stuff you can set argv to NULL and it will tell you
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
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   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}
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
   830
				buff = FormatCommaNumber(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
   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}
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
   838
				int32 v = argv_orig[(byte)*str++]; // contains the number that determines plural
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}
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
   846
				buff = FormatNoCommaNumber(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
   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}
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
   850
				buff = FormatGenericCurrency(buff, _currency, GetInt32(&argv), false, 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
   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
				int32 temp[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
   855
				Waypoint *wp = GetWaypoint(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
   856
				StringID 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
   857
				if (wp->string != STR_NULL) {
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
   858
					str = wp->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
   859
				} else {
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
					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
   861
					temp[1] = wp->town_cn + 1;
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
					str = wp->town_cn == 0 ? STR_WAYPOINTNAME_CITY : STR_WAYPOINTNAME_CITY_SERIAL;
2087
bedb167de57b (svn r2597) Feature: [string system] Support cases.
ludde
parents: 2084
diff changeset
   863
				}
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
   864
				buff = GetStringWithArgs(buff, str, 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
   865
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
			}
1097
653c846fb5d9 (svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents: 1093
diff changeset
   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
			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
   869
				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
   870
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
				if (!IsValidStation(st)) { // station doesn't exist anymore
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
					buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL, 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
   873
				} else {
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
   874
					int32 temp[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
   875
					temp[0] = st->town->townnametype;
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
   876
					temp[1] = st->town->townnameparts;
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
   877
					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
   878
				}
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
   879
				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
   880
			}
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
   881
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
   882
			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
   883
				const Town* t = GetTown(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
   884
				int32 temp[1];
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
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
				assert(IsValidTown(t));
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
				temp[0] = t->townnameparts;
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
				buff = GetStringWithArgs(buff, t->townnametype, 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
   890
				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
   891
			}
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
   892
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
			case SCC_CURRENCY_64: { // {CURRENCY64}
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
				buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), false, 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
   895
				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
   896
			}
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
   897
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
   898
			case SCC_SETCASE: { // {SETCASE}
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
   899
				// This is a pseudo command, it's outputted when someone does {STRING.ack}
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
   900
				// The modifier is added to all subsequent GetStringWithArgs that accept the modifier.
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
   901
				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
   902
				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
   903
			}
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
   904
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
   905
			case SCC_SWITCH_CASE: { // {Used to implement case switching}
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
   906
				// <0x9E> <NUM CASES> <CASE1> <LEN1> <STRING1> <CASE2> <LEN2> <STRING2> <CASE3> <LEN3> <STRING3> <STRINGDEFAULT>
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
   907
				// Each LEN is printed using 2 bytes in big endian order.
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
   908
				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
   909
				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
   910
					if ((byte)str[0] == casei) {
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
   911
						// Found the case, adjust str pointer and continue
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
						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
   913
						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
   914
					}
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
   915
					// Otherwise skip to the next case
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
   916
					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
   917
					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
   918
				}
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
   919
				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
   920
			}
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
   921
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
   922
			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
   923
				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
   924
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   926
	}
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   927
	*buff = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   928
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   929
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   931
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   932
static char *StationGetSpecialString(char *buff, int x, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
{
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
   934
	if ((x & 0x01) && (buff + Utf8CharLen(SCC_TRAIN) < last)) buff += Utf8Encode(buff, SCC_TRAIN);
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
   935
	if ((x & 0x02) && (buff + Utf8CharLen(SCC_LORRY) < last)) buff += Utf8Encode(buff, SCC_LORRY);
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
   936
	if ((x & 0x04) && (buff + Utf8CharLen(SCC_BUS)   < last)) buff += Utf8Encode(buff, SCC_BUS);
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
   937
	if ((x & 0x08) && (buff + Utf8CharLen(SCC_PLANE) < last)) buff += Utf8Encode(buff, SCC_PLANE);
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
   938
	if ((x & 0x10) && (buff + Utf8CharLen(SCC_SHIP)  < last)) buff += Utf8Encode(buff, SCC_SHIP);
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
   939
	*buff = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   941
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   943
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last)
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
   944
{
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
   945
	char name[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
4920
de739ffd31a4 (svn r6896) - Fix (r6895): Supply last position of the correct buffer *again*
peter1138
parents: 4919
diff changeset
   947
	_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
   948
	return strecpy(buff, name, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   950
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
   951
static const char* const _silly_company_names[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
	"Bloggs Brothers",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
	"Tiny Transport Ltd.",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
	"Express Travel",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   955
	"Comfy-Coach & Co.",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
	"Crush & Bump Ltd.",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
	"Broken & Late Ltd.",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   958
	"Sam Speedy & Son",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   959
	"Supersonic Travel",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   960
	"Mike's Motors",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   961
	"Lightning International",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   962
	"Pannik & Loozit Ltd.",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   963
	"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
   964
	"Getout & Pushit Ltd."
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   965
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   966
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
   967
static const char* const _surname_list[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   968
	"Adams",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   969
	"Allan",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
	"Baker",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
	"Bigwig",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
	"Black",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   973
	"Bloggs",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   974
	"Brown",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   975
	"Campbell",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   976
	"Gordon",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   977
	"Hamilton",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   978
	"Hawthorn",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   979
	"Higgins",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   980
	"Green",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   981
	"Gribble",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   982
	"Jones",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   983
	"McAlpine",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   984
	"MacDonald",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   985
	"McIntosh",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   986
	"Muir",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   987
	"Murphy",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   988
	"Nelson",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   989
	"O'Donnell",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
	"Parker",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
	"Phillips",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   992
	"Pilkington",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
	"Quigley",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   994
	"Sharkey",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   995
	"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
   996
	"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
   997
};
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
   998
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
   999
static const char* const _silly_surname_list[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1000
	"Grumpy",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1001
	"Dozy",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1002
	"Speedy",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1003
	"Nosey",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1004
	"Dribble",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
	"Mushroom",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
	"Cabbage",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1007
	"Sniffle",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
	"Fishy",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1009
	"Swindle",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1010
	"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
  1011
	"Nutkins"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
  1014
static const char _initial_name_letters[] = {
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1015
	'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1016
	'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W',
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1019
static char *GenAndCoName(char *buff, uint32 arg, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
{
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
  1021
	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
  1022
	uint num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1023
1704
2525507adda7 (svn r2208) - Fix: [ 1174237 ] Max loan always in euros, use _opt_ptr instead of _opt (glx)
Darkvater
parents: 1625
diff changeset
  1024
	if (_opt_ptr->landscape == LT_CANDY) {
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
  1025
		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
  1026
		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
  1027
	} 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
  1028
		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
  1029
		num  = lengthof(_surname_list);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1032
	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
  1033
	buff = strecpy(buff, " & Co.", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1036
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1037
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1038
static char *GenPresidentName(char *buff, uint32 x, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1039
{
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1040
	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
  1041
	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
  1042
	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
  1043
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1044
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1045
	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
  1046
	buff = strecpy(buff, initial, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1047
2150
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2140
diff changeset
  1048
	i = (sizeof(_initial_name_letters) + 35) * GB(x, 8, 8) >> 8;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1049
	if (i < sizeof(_initial_name_letters)) {
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1050
		initial[0] = _initial_name_letters[i];
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1051
		buff = strecpy(buff, initial, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
1704
2525507adda7 (svn r2208) - Fix: [ 1174237 ] Max loan always in euros, use _opt_ptr instead of _opt (glx)
Darkvater
parents: 1625
diff changeset
  1054
	if (_opt_ptr->landscape == LT_CANDY) {
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
  1055
		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
  1056
		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
  1057
	} 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
  1058
		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
  1059
		num  = lengthof(_surname_list);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1060
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1061
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1062
	buff = strecpy(buff, base[num * GB(x, 16, 8) >> 8], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1063
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1064
	return buff;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1065
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1066
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1067
static char *GetSpecialPlayerNameString(char *buff, int ind, const int32 *argv, const char* last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1068
{
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1069
	switch (ind) {
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1070
		case 1: // not used
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1071
			return strecpy(buff, _silly_company_names[GetInt32(&argv) & 0xFFFF], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1072
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1073
		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
  1074
			return GenAndCoName(buff, GetInt32(&argv), last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1075
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1076
		case 3: // President name
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1077
			return GenPresidentName(buff, GetInt32(&argv), last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1078
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1079
		case 4: // song names
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1080
			return strecpy(buff, origin_songs_specs[GetInt32(&argv) - 1].song_name, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1083
	// town name?
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1084
	if (IS_INT_INSIDE(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
  1085
		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
  1086
		return strecpy(buff, " Transport", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1088
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
	// language name?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1090
	if (IS_INT_INSIDE(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
		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
  1092
		return strecpy(buff,
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1093
			i == _dynlang.curr ? _langpack->own_name : _dynlang.ent[i].name, last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1094
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1095
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1096
	// resolution size?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1097
	if (IS_INT_INSIDE(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1098
		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
  1099
		buff += snprintf(
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1100
			buff, last - buff + 1, "%dx%d", _resolutions[i][0], _resolutions[i][1]
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1101
		);
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4898
diff changeset
  1102
		return buff;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1104
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1105
	// screenshot format name?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1106
	if (IS_INT_INSIDE(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
		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
  1108
		return strecpy(buff, GetScreenshotFormatDesc(i), last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1109
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1111
	assert(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1112
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1113
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
// remap a string ID from the old format to the new format
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1116
StringID RemapOldStringID(StringID s)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1117
{
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1118
	switch (s) {
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1119
		case 0x0006: return STR_SV_EMPTY;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1120
		case 0x7000: return STR_SV_UNNAMED;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1121
		case 0x70E4: return SPECSTR_PLAYERNAME_ENGLISH;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1122
		case 0x70E9: return SPECSTR_PLAYERNAME_ENGLISH;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1123
		case 0x8864: return STR_SV_TRAIN_NAME;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1124
		case 0x902B: return STR_SV_ROADVEH_NAME;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1125
		case 0x9830: return STR_SV_SHIP_NAME;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1126
		case 0xA02F: return STR_SV_AIRCRAFT_NAME;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1127
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1128
		default:
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2650
diff changeset
  1129
			if (IS_INT_INSIDE(s, 0x300F, 0x3030)) {
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1130
				return s - 0x300F + STR_SV_STNAME;
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2650
diff changeset
  1131
			} else {
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1132
				return s;
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2650
diff changeset
  1133
			}
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1134
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1136
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1137
bool ReadLanguagePack(int lang_index)
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1138
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1139
	int tot_count, i;
1319
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
  1140
	LanguagePack *lang_pack;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1141
	size_t len;
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
  1142
	char **langpack_offs;
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
  1143
	char *s;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1144
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1145
	{
5296
6a4aaa66eed3 (svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents: 5167
diff changeset
  1146
		char *lang = str_fmt("%s%s", _paths.lang_dir, _dynlang.ent[lang_index].file);
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
  1147
		lang_pack = ReadFileToMem(lang, &len, 200000);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1148
		free(lang);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1149
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1150
	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
  1151
	if (len < sizeof(LanguagePack) ||
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
  1152
			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
  1153
			lang_pack->version != TO_LE32(LANGUAGE_PACK_VERSION)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
		free(lang_pack);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1155
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1156
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 64
diff changeset
  1157
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1158
#if defined(TTD_BIG_ENDIAN)
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1159
	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
  1160
		lang_pack->offsets[i] = ReadLE16Aligned(&lang_pack->offsets[i]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1161
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1162
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1163
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
	tot_count = 0;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1165
	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
  1166
		uint num = lang_pack->offsets[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
		_langtab_start[i] = tot_count;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1168
		_langtab_num[i] = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
		tot_count += num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1172
	// Allocate offsets
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
  1173
	langpack_offs = malloc(tot_count * sizeof(*langpack_offs));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1174
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1175
	// Fill offsets
1319
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
  1176
	s = lang_pack->data;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1177
	for (i = 0; i != tot_count; i++) {
1312
8defbb525d09 (svn r1816) Use char instead of byte for string formatting
tron
parents: 1311
diff changeset
  1178
		len = (byte)*s;
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1179
		*s++ = '\0'; // zero terminate the string before.
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1180
		if (len >= 0xC0) len = ((len & 0x3F) << 8) + (byte)*s++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1181
		langpack_offs[i] = s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1182
		s += len;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1185
	free(_langpack);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1186
	_langpack = lang_pack;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1187
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1188
	free(_langpack_offs);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
	_langpack_offs = langpack_offs;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1190
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1191
	ttd_strlcpy(_dynlang.curr_file, _dynlang.ent[lang_index].file, sizeof(_dynlang.curr_file));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1192
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1193
	_dynlang.curr = lang_index;
3601
ac6df06db648 (svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents: 3489
diff changeset
  1194
	SetCurrentGrfLangID(_langpack->isocode);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1195
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1196
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1197
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
  1198
/** 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
  1199
 * 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
  1200
 * and if none exist return the value for $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
  1201
 * @param environment variable to check conditionally if default ones are not
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
  1202
 *        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
  1203
 * @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
  1204
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
  1205
{
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
  1206
	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
  1207
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
  1208
	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
  1209
	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
  1210
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
  1211
	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
  1212
	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
  1213
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
  1214
	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
  1215
		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
  1216
		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
  1217
	}
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
  1218
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
  1219
	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
  1220
}
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
  1221
4219
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1222
static int CDECL LanguageCompareFunc(const void *a, const void *b)
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1223
{
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1224
	return strcmp(*(const char* const *)a, *(const char* const *)b);
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1225
}
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1226
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1227
static int GetLanguageList(char **languages, int max)
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1228
{
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1229
	DIR *dir;
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1230
	struct dirent *dirent;
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1231
	int num = 0;
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1232
5444
3209bb62403e (svn r8872) [0.5] -Backport from trunk (r8784, r8821, r8823, r8824):
Darkvater
parents: 5296
diff changeset
  1233
	dir = ttd_opendir(_paths.lang_dir);
4219
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1234
	if (dir != NULL) {
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1235
		while ((dirent = readdir(dir)) != NULL) {
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5108
diff changeset
  1236
			const char *d_name = FS2OTTD(dirent->d_name);
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5108
diff changeset
  1237
			char *t = 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
  1238
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1239
			if (t != NULL && strcmp(t, ".lng") == 0) {
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5108
diff changeset
  1240
				languages[num++] = strdup(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
  1241
				if (num == max) break;
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1242
			}
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1243
		}
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1244
		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
  1245
	}
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1246
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1247
	qsort(languages, num, sizeof(char*), LanguageCompareFunc);
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1248
	return num;
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1249
}
4211284f29ec (svn r5763) - Cleanup: Move the now unified GetLanguageList and comparator function to strings.c where it belongs.
Darkvater
parents: 4120
diff changeset
  1250
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
// make a list of the available language packs. put the data in _dynlang struct.
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 970
diff changeset
  1252
void InitializeLanguagePacks(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1253
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1254
	DynamicLanguages *dl = &_dynlang;
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1255
	int i;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1256
	int n;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1257
	int m;
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1258
	int def;
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
  1259
	int def2;
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
  1260
	int fallback;
1319
cd302ee91e27 (svn r1823) Get rid of some ugly cast magic concerning language packs
tron
parents: 1318
diff changeset
  1261
	LanguagePack hdr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1262
	FILE *in;
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
  1263
	char *files[MAX_LANG];
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
  1264
	const char* lang;
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
  1265
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
  1266
	lang = GetCurrentLocale("LC_MESSAGES");
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
  1267
	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
  1268
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1269
	n = GetLanguageList(files, lengthof(files));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1270
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
  1271
	def = -1;
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
  1272
	def2 = -1;
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
  1273
	fallback = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1274
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1275
	// go through the language files and make sure that they are valid.
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1276
	for (i = m = 0; i != n; i++) {
4321
b763b7007162 (svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents: 4293
diff changeset
  1277
		size_t j;
1321
938ec22ae6f7 (svn r1825) Further style improvements:
tron
parents: 1319
diff changeset
  1278
5296
6a4aaa66eed3 (svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents: 5167
diff changeset
  1279
		char *s = str_fmt("%s%s", _paths.lang_dir, files[i]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1280
		in = fopen(s, "rb");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1281
		free(s);
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1282
		if (in == NULL ||
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1283
				(j = fread(&hdr, sizeof(hdr), 1, in), fclose(in), j) != 1 ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1284
				hdr.ident != TO_LE32(LANGUAGE_PACK_IDENT) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1285
				hdr.version != TO_LE32(LANGUAGE_PACK_VERSION)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1286
			free(files[i]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1287
			continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1288
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1289
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1290
		dl->ent[m].file = files[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1291
		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
  1292
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
  1293
		if (strcmp(hdr.isocode, "en_GB")  == 0) fallback = m;
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
  1294
		if (strncmp(hdr.isocode, lang, 2) == 0) def2 = m;
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
  1295
		if (strncmp(hdr.isocode, lang, 5) == 0) def = m;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1296
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1297
		m++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1298
	}
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
  1299
	if (def == -1) def = (def2 != -1 ? def2 : fallback);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1300
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1301
	if (m == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1302
		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
  1303
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1304
	dl->num = m;
3033
e4f7c60a1742 (svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents: 2966
diff changeset
  1305
	for (i = 0; i != dl->num; i++) dl->dropdown[i] = SPECSTR_LANGUAGE_START + i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1306
	dl->dropdown[i] = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1307
1316
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1308
	for (i = 0; i != dl->num; i++)
a7352de83a2b (svn r1820) Style cleanup:
tron
parents: 1312
diff changeset
  1309
		if (strcmp(dl->ent[i].file, dl->curr_file) == 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1310
			def = i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1311
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1312
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1313
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1314
	if (!ReadLanguagePack(def))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1315
		error("can't read language pack '%s'", dl->ent[def].file);
2075
7f0ca01392db (svn r2585) - Fix [Makefile]: some small cleanups, remove warnings, and add mersenne to makefile (Luca)
Darkvater
parents: 2070
diff changeset
  1316
}