src/currency.h
author peter1138
Tue, 29 Jan 2008 17:09:00 +0000
changeset 8941 f93c669d3ca6
parent 8760 ce0891c412ce
child 10429 1b99254f9607
permissions -rw-r--r--
(svn r12015) -Fix [FS#1716] (Revert r11422): Patch in FS#1430 avoided instead of fixed the problem. GetStringWithArgs() discards information that SCC_GENDER_LIST needs to work. Now use pointers to retrieve GRF strings, so that GetStringPtr() will work correctly. This is advantageous as now no buffer copy is made when using all GRF strings.
2292
c5a944e9bcae (svn r2816) Forgot an Id tag and an #include
tron
parents: 2291
diff changeset
     1
/* $Id$ */
c5a944e9bcae (svn r2816) Forgot an Id tag and an #include
tron
parents: 2291
diff changeset
     2
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5726
diff changeset
     3
/** @file currency.h */
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5726
diff changeset
     4
2291
2b064aa97f91 (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
2b064aa97f91 (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
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
     7
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 6705
diff changeset
     8
#include "date_type.h"
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8636
diff changeset
     9
#include "strings_type.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 6705
diff changeset
    10
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    11
enum {
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    12
	CF_NOEURO = 0,
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    13
	CF_ISEURO = 1,
5091
fe51b6c9ed6c (svn r7160) -Feature [SF 1243657, 1171147]: Slovak/Brazil currency patch (gpsoft, klanticus)
Darkvater
parents: 4625
diff changeset
    14
	NUM_CURRENCY = 28,
4380
f9e0e17c4d17 (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
    15
	CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    16
};
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    17
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    18
struct CurrencySpec {
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    19
	uint16 rate;
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    20
	char separator;
4297
47ce9665b4af (svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents: 3596
diff changeset
    21
	Year to_euro;
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    22
	char prefix[16];
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    23
	char suffix[16];
4377
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    24
	/**
4602
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    25
	 * The currency symbol is represented by two possible values, prefix and suffix
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    26
	 * Usage of one or the other is determined by symbol_pos.
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    27
	 * 0 = prefix
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    28
	 * 1 = suffix
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    29
	 * 2 = both : Special case only for custom currency.
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    30
	 *            It is not a spec from Newgrf,
36e779efee9a (svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents: 4601
diff changeset
    31
	 *            rather a way to let users do what they want with custom curency
4377
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    32
	 */
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    33
	byte symbol_pos;
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    34
	StringID name;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    35
};
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    36
4377
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    37
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4311
diff changeset
    38
extern CurrencySpec _currency_specs[NUM_CURRENCY];
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    39
2306
3d4efe849dd9 (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2292
diff changeset
    40
// XXX small hack, but makes the rest of the code a bit nicer to read
3596
443a7377c67e (svn r4487) - Codechange: replace the custom currency magic number 23 with a define
peter1138
parents: 2468
diff changeset
    41
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID])
2468
15753a8438ba (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
    42
#define _currency ((const CurrencySpec*)&_currency_specs[_opt_ptr->currency])
2306
3d4efe849dd9 (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2292
diff changeset
    43
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
    44
uint GetMaskOfAllowedCurrencies();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
    45
void CheckSwitchToEuro();
6705
d3fb7785c0a4 (svn r9467) -Fix(FS#703,6108): When resetting the array of currencies, the custom currency was reset too, thus loosing the setting a user could have used for it.(glx)
belugas
parents: 6574
diff changeset
    46
void ResetCurrencies(bool preserve_custom = true);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
    47
StringID* BuildCurrencyDropdown();
4625
3e45c59b5d64 (svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents: 4602
diff changeset
    48
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
diff changeset
    49
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2306
diff changeset
    50
#endif /* CURRENCY_H */