annotate src/currency.h @ 20729:ea20edff1862 draft default tip master

(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author planetmaker <planetmaker@openttd.org>
date Wed, 31 Jul 2013 18:50:01 +0000
parents 26a38928cb16
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11754
diff changeset
9
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
10 /** @file currency.h Functions to handle different currencies. */
6123
595dc16a6fd8 (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 5475
diff changeset
11
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 #ifndef CURRENCY_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 #define CURRENCY_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
14
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 6379
diff changeset
15 #include "date_type.h"
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8140
diff changeset
16 #include "strings_type.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 6379
diff changeset
17
18855
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
18 static const int CF_NOEURO = 0; ///< Currency never switches to the Euro (as far as known).
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
19 static const int CF_ISEURO = 1; ///< Currency _is_ the Euro.
20128
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
20
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
21 /**
20129
c7853270c635 (svn r25073) -Doc: Improve Currencies enum description
planetmaker <planetmaker@openttd.org>
parents: 20128
diff changeset
22 * This enum gives the currencies a unique id which must be maintained for
c7853270c635 (svn r25073) -Doc: Improve Currencies enum description
planetmaker <planetmaker@openttd.org>
parents: 20128
diff changeset
23 * savegame compatibility and in order to refer to them quickly, especially
c7853270c635 (svn r25073) -Doc: Improve Currencies enum description
planetmaker <planetmaker@openttd.org>
parents: 20128
diff changeset
24 * for referencing the custom one.
20128
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
25 */
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
26 enum Currencies {
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
27 CURRENCY_GBP, ///< British Pound
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
28 CURRENCY_USD, ///< US Dollar
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
29 CURRENCY_EUR, ///< Euro
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
30 CURRENCY_JPY, ///< Japanese Yen
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
31 CURRENCY_ATS, ///< Austrian Schilling
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
32 CURRENCY_BEF, ///< Belgian Franc
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
33 CURRENCY_CHF, ///< Swiss Franc
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
34 CURRENCY_CZK, ///< Czech Koruna
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
35 CURRENCY_DEM, ///< Deutsche Mark
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
36 CURRENCY_DKK, ///< Danish Krona
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
37 CURRENCY_ESP, ///< Spanish Peseta
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
38 CURRENCY_FIM, ///< Finish Markka
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
39 CURRENCY_FRF, ///< French Franc
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
40 CURRENCY_GRD, ///< Greek Drachma
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
41 CURRENCY_HUF, ///< Hungarian Forint
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
42 CURRENCY_ISK, ///< Icelandic Krona
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
43 CURRENCY_ITL, ///< Italian Lira
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
44 CURRENCY_NLG, ///< Dutch Gulden
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
45 CURRENCY_NOK, ///< Norwegian Krone
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
46 CURRENCY_PLN, ///< Polish Zloty
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
47 CURRENCY_RON, ///< Romenian Leu
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
48 CURRENCY_RUR, ///< Russian Rouble
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
49 CURRENCY_SIT, ///< Slovenian Tolar
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
50 CURRENCY_SEK, ///< Swedish Krona
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
51 CURRENCY_YTL, ///< Turkish Lira
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
52 CURRENCY_SKK, ///< Slovak Kornuna
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
53 CURRENCY_BRL, ///< Brazilian Real
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
54 CURRENCY_EEK, ///< Estonian Krooni
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
55 CURRENCY_LTL, ///< Lithuanian Litas
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
56 CURRENCY_KRW, ///< South Korean Won
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
57 CURRENCY_ZAR, ///< South African Rand
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
58 CURRENCY_CUSTOM, ///< Custom currency
20132
26a38928cb16 (svn r25076) -Add [FS#5212]: Georgian Lari and Iranian Rial as currencies
planetmaker <planetmaker@openttd.org>
parents: 20131
diff changeset
59 CURRENCY_GEL, ///< Georgian Lari
26a38928cb16 (svn r25076) -Add [FS#5212]: Georgian Lari and Iranian Rial as currencies
planetmaker <planetmaker@openttd.org>
parents: 20131
diff changeset
60 CURRENCY_IRR, ///< Iranian Rial
20128
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
61 CURRENCY_END, ///< always the last item
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
62 };
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
63
18855
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
64 /** Specification of a currency. */
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
65 struct CurrencySpec {
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
66 uint16 rate;
11754
1b84d3b57f8b (svn r16144) -Fix (r16129): setting the custom digit grouping separator required to restart OpenTTD to take effect. Now also support non 1 ASCII character custom grouping separators.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
67 char separator[8];
18855
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
68 Year to_euro; ///< %Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO.
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
69 char prefix[16];
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
70 char suffix[16];
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
71 /**
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
72 * The currency symbol is represented by two possible values, prefix and suffix
18855
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
73 * Usage of one or the other is determined by #symbol_pos.
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
74 * 0 = prefix
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
75 * 1 = suffix
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
76 * 2 = both : Special case only for custom currency.
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
77 * It is not a spec from Newgrf,
18855
a0d7e20ebafe (svn r23704) -Doc: Doxygen comment fixes and additions.
alberth <alberth@openttd.org>
parents: 16959
diff changeset
78 * rather a way to let users do what they want with custom currency
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
79 */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
80 byte symbol_pos;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
81 StringID name;
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
82 };
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
83
20128
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
84 extern CurrencySpec _currency_specs[CURRENCY_END];
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
85
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 10647
diff changeset
86 /* XXX small hack, but makes the rest of the code a bit nicer to read */
20128
e33dfe401e65 (svn r25072) -Codechange: Don't require the custom currency to be the last defined one
planetmaker <planetmaker@openttd.org>
parents: 19259
diff changeset
87 #define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
16959
55b2bec60c52 (svn r21695) -Codechange: add helper function to get the currently applicable GameSettings object
yexo <yexo@openttd.org>
parents: 15183
diff changeset
88 #define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
89
20131
daecbe4af833 (svn r25075) -Codechange: Allow for more than 32 currencies
planetmaker <planetmaker@openttd.org>
parents: 20129
diff changeset
90 uint64 GetMaskOfAllowedCurrencies();
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6123
diff changeset
91 void CheckSwitchToEuro();
6379
318fb976dca6 (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 <belugas@openttd.org>
parents: 6248
diff changeset
92 void ResetCurrencies(bool preserve_custom = true);
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10344
diff changeset
93 StringID *BuildCurrencyDropdown();
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
94 byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
95
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
96 #endif /* CURRENCY_H */