src/currency.h
author rubidium
Wed, 07 Mar 2007 12:11:48 +0000
changeset 6248 e4a2ed7e5613
parent 6247 7d81e3a5d803
child 6379 e3cb84b60342
permissions -rw-r--r--
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
2292
0b9d6e4ea0e6 (svn r2816) Forgot an Id tag and an #include
tron
parents: 2291
diff changeset
     1
/* $Id$ */
0b9d6e4ea0e6 (svn r2816) Forgot an Id tag and an #include
tron
parents: 2291
diff changeset
     2
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5475
diff changeset
     3
/** @file currency.h */
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5475
diff changeset
     4
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     5
#ifndef CURRENCY_H
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     6
#define CURRENCY_H
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     7
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     8
enum {
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     9
	CF_NOEURO = 0,
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    10
	CF_ISEURO = 1,
5091
a7dfbe278c05 (svn r7160) -Feature [SF 1243657, 1171147]: Slovak/Brazil currency patch (gpsoft, klanticus)
Darkvater
parents: 4625
diff changeset
    11
	NUM_CURRENCY = 28,
4380
71243f206e6b (svn r6122) Fix an off-by-two error in r6108: it should be the index for the last element in the array
tron
parents: 4377
diff changeset
    12
	CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    13
};
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    14
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    15
struct CurrencySpec {
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    16
	uint16 rate;
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    17
	char separator;
4297
d0311b62255c (svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents: 3596
diff changeset
    18
	Year to_euro;
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    19
	char prefix[16];
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    20
	char suffix[16];
4377
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    21
	/**
4602
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    22
	 * The currency symbol is represented by two possible values, prefix and suffix
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    23
	 * Usage of one or the other is determined by symbol_pos.
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    24
	 * 0 = prefix
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    25
	 * 1 = suffix
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    26
	 * 2 = both : Special case only for custom currency.
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    27
	 *            It is not a spec from Newgrf,
43c44f7df615 (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    28
	 *            rather a way to let users do what they want with custom curency
4377
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    29
	 */
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    30
	byte symbol_pos;
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    31
	StringID name;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    32
};
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    33
4377
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    34
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    35
extern CurrencySpec _currency_specs[NUM_CURRENCY];
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    36
2306
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2292
diff changeset
    37
// XXX small hack, but makes the rest of the code a bit nicer to read
3596
6654541a3958 (svn r4487) - Codechange: replace the custom currency magic number 23 with a define
peter1138
parents: 2468
diff changeset
    38
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID])
2468
9ea52370a093 (svn r2994) Another small hack regarding currencies: add a #define to emulate a variable, that holds the current currency; again this should increase readability
tron
parents: 2436
diff changeset
    39
#define _currency ((const CurrencySpec*)&_currency_specs[_opt_ptr->currency])
2306
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2292
diff changeset
    40
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    41
uint GetMaskOfAllowedCurrencies();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    42
void CheckSwitchToEuro();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    43
void ResetCurrencies();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6123
diff changeset
    44
StringID* BuildCurrencyDropdown();
4625
f365b341a330 (svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents: 4602
diff changeset
    45
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    46
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2306
diff changeset
    47
#endif /* CURRENCY_H */