OpenTTD Source  20240917-master-g9ab0a47812
currency.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #ifndef CURRENCY_H
11 #define CURRENCY_H
12 
14 #include "settings_type.h"
15 #include "strings_type.h"
16 
17 static constexpr TimerGameCalendar::Year CF_NOEURO = 0;
18 static constexpr TimerGameCalendar::Year CF_ISEURO = 1;
19 static constexpr TimerGameCalendar::Year MIN_EURO_YEAR = 2000;
20 
26 enum Currencies {
72 };
73 
75 struct CurrencySpec {
76  uint16_t rate;
77  std::string separator;
78  TimerGameCalendar::Year to_euro;
79  std::string prefix;
80  std::string suffix;
81  std::string code;
82 
91  uint8_t symbol_pos;
92  StringID name;
93 
94  CurrencySpec() = default;
95 
96  CurrencySpec(uint16_t rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, uint8_t symbol_pos, StringID name) :
98  {
99  }
100 };
101 
102 extern std::array<CurrencySpec, CURRENCY_END> _currency_specs;
103 
109 {
111 }
112 
117 inline const CurrencySpec &GetCurrency()
118 {
120 }
121 
122 uint64_t GetMaskOfAllowedCurrencies();
123 void ResetCurrencies(bool preserve_custom = true);
124 uint8_t GetNewgrfCurrencyIdConverted(uint8_t grfcurr_id);
125 
126 #endif /* CURRENCY_H */
CURRENCY_RON
@ CURRENCY_RON
Romenian Leu.
Definition: currency.h:47
CURRENCY_DEM
@ CURRENCY_DEM
Deutsche Mark.
Definition: currency.h:35
CURRENCY_HUF
@ CURRENCY_HUF
Hungarian Forint.
Definition: currency.h:41
timer_game_calendar.h
GetCustomCurrency
CurrencySpec & GetCustomCurrency()
Get the custom currency.
Definition: currency.h:108
CURRENCY_ZAR
@ CURRENCY_ZAR
South African Rand.
Definition: currency.h:57
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
CURRENCY_IDR
@ CURRENCY_IDR
Indonesian Rupiah.
Definition: currency.h:67
CURRENCY_RUR
@ CURRENCY_RUR
Russian Rouble.
Definition: currency.h:48
CF_ISEURO
static constexpr TimerGameCalendar::Year CF_ISEURO
Currency is the Euro.
Definition: currency.h:18
CURRENCY_MYR
@ CURRENCY_MYR
Malaysian Ringgit.
Definition: currency.h:68
GetNewgrfCurrencyIdConverted
uint8_t GetNewgrfCurrencyIdConverted(uint8_t grfcurr_id)
Will return the ottd's index correspondence to the ttdpatch's id.
Definition: currency.cpp:116
CURRENCY_PLN
@ CURRENCY_PLN
Polish Zloty.
Definition: currency.h:46
Currencies
Currencies
This enum gives the currencies a unique id which must be maintained for savegame compatibility and in...
Definition: currency.h:26
CURRENCY_BEF
@ CURRENCY_BEF
Belgian Franc.
Definition: currency.h:32
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
CURRENCY_LVL
@ CURRENCY_LVL
Latvian Lats.
Definition: currency.h:69
CURRENCY_SIT
@ CURRENCY_SIT
Slovenian Tolar.
Definition: currency.h:49
strings_type.h
CURRENCY_KRW
@ CURRENCY_KRW
South Korean Won.
Definition: currency.h:56
GetCurrency
const CurrencySpec & GetCurrency()
Get the currently selected currency.
Definition: currency.h:117
CURRENCY_GEL
@ CURRENCY_GEL
Georgian Lari.
Definition: currency.h:59
GetMaskOfAllowedCurrencies
uint64_t GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Definition: currency.cpp:125
MIN_EURO_YEAR
static constexpr TimerGameCalendar::Year MIN_EURO_YEAR
The earliest year custom currencies may switch to the Euro.
Definition: currency.h:19
CURRENCY_SKK
@ CURRENCY_SKK
Slovak Kornuna.
Definition: currency.h:52
CURRENCY_GBP
@ CURRENCY_GBP
British Pound.
Definition: currency.h:27
CurrencySpec::suffix
std::string suffix
Suffix to apply when formatting money in this currency.
Definition: currency.h:80
ResetCurrencies
void ResetCurrencies(bool preserve_custom=true)
Will fill _currency_specs array with default values from origin_currency_specs Called only from newgr...
Definition: currency.cpp:160
CURRENCY_CHF
@ CURRENCY_CHF
Swiss Franc.
Definition: currency.h:33
CURRENCY_MXN
@ CURRENCY_MXN
Mexican Peso.
Definition: currency.h:62
CURRENCY_USD
@ CURRENCY_USD
US Dollar.
Definition: currency.h:28
CURRENCY_NOK
@ CURRENCY_NOK
Norwegian Krone.
Definition: currency.h:45
CurrencySpec::code
std::string code
3 letter untranslated code to identify the currency.
Definition: currency.h:81
CURRENCY_YTL
@ CURRENCY_YTL
Turkish Lira.
Definition: currency.h:51
CURRENCY_DKK
@ CURRENCY_DKK
Danish Krona.
Definition: currency.h:36
CurrencySpec::rate
uint16_t rate
The conversion rate compared to the base currency.
Definition: currency.h:76
settings_type.h
CURRENCY_FIM
@ CURRENCY_FIM
Finish Markka.
Definition: currency.h:38
CurrencySpec
Specification of a currency.
Definition: currency.h:75
CURRENCY_ESP
@ CURRENCY_ESP
Spanish Peseta.
Definition: currency.h:37
CURRENCY_LTL
@ CURRENCY_LTL
Lithuanian Litas.
Definition: currency.h:55
CURRENCY_SEK
@ CURRENCY_SEK
Swedish Krona.
Definition: currency.h:50
CURRENCY_HKD
@ CURRENCY_HKD
Hong Kong Dollar.
Definition: currency.h:65
_currency_specs
std::array< CurrencySpec, CURRENCY_END > _currency_specs
Array of currencies used by the system.
Definition: currency.cpp:77
CURRENCY_END
@ CURRENCY_END
always the last item
Definition: currency.h:71
CURRENCY_GRD
@ CURRENCY_GRD
Greek Drachma.
Definition: currency.h:40
CURRENCY_BRL
@ CURRENCY_BRL
Brazilian Real.
Definition: currency.h:53
CURRENCY_CZK
@ CURRENCY_CZK
Czech Koruna.
Definition: currency.h:34
CURRENCY_CNY
@ CURRENCY_CNY
Chinese Renminbi.
Definition: currency.h:64
CURRENCY_ITL
@ CURRENCY_ITL
Italian Lira.
Definition: currency.h:43
CURRENCY_NLG
@ CURRENCY_NLG
Dutch Gulden.
Definition: currency.h:44
CURRENCY_INR
@ CURRENCY_INR
Indian Rupee.
Definition: currency.h:66
CF_NOEURO
static constexpr TimerGameCalendar::Year CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:17
CurrencySpec::to_euro
TimerGameCalendar::Year to_euro
Year of switching to the Euro. May also be CF_NOEURO or CF_ISEURO.
Definition: currency.h:78
CURRENCY_ISK
@ CURRENCY_ISK
Icelandic Krona.
Definition: currency.h:42
CurrencySpec::separator
std::string separator
The thousands separator for this currency.
Definition: currency.h:77
CURRENCY_JPY
@ CURRENCY_JPY
Japanese Yen.
Definition: currency.h:30
CURRENCY_EEK
@ CURRENCY_EEK
Estonian Krooni.
Definition: currency.h:54
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:606
LocaleSettings::currency
uint8_t currency
currency we currently use
Definition: settings_type.h:268
CURRENCY_IRR
@ CURRENCY_IRR
Iranian Rial.
Definition: currency.h:60
CURRENCY_EUR
@ CURRENCY_EUR
Euro.
Definition: currency.h:29
GetGameSettings
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition: settings_type.h:635
CURRENCY_NTD
@ CURRENCY_NTD
New Taiwan Dollar.
Definition: currency.h:63
CurrencySpec::symbol_pos
uint8_t symbol_pos
The currency symbol is represented by two possible values, prefix and suffix Usage of one or the othe...
Definition: currency.h:91
CURRENCY_FRF
@ CURRENCY_FRF
French Franc.
Definition: currency.h:39
CURRENCY_PTE
@ CURRENCY_PTE
Portuguese Escudo.
Definition: currency.h:70
CurrencySpec::prefix
std::string prefix
Prefix to apply when formatting money in this currency.
Definition: currency.h:79
CURRENCY_RUB
@ CURRENCY_RUB
New Russian Ruble.
Definition: currency.h:61
CURRENCY_CUSTOM
@ CURRENCY_CUSTOM
Custom currency.
Definition: currency.h:58
CURRENCY_ATS
@ CURRENCY_ATS
Austrian Schilling.
Definition: currency.h:31