OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Enumerations | Functions | Variables
currency.h File Reference

Functions to handle different currencies. More...

`#include "date_type.h"`
`#include "strings_type.h"`

Go to the source code of this file.

## Data Structures
struct | CurrencySpec
| Specification of a currency. More...

## Macros
#define | _custom_currency (_currency_specs[CURRENCY_CUSTOM])
#define | _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])

## Enumerations
enum | Currencies { CURRENCY_GBP, CURRENCY_USD, CURRENCY_EUR, CURRENCY_JPY, CURRENCY_ATS, CURRENCY_BEF, CURRENCY_CHF, CURRENCY_CZK, CURRENCY_DEM, CURRENCY_DKK, CURRENCY_ESP, CURRENCY_FIM, CURRENCY_FRF, CURRENCY_GRD, CURRENCY_HUF, CURRENCY_ISK, CURRENCY_ITL, CURRENCY_NLG, CURRENCY_NOK, CURRENCY_PLN, CURRENCY_RON, CURRENCY_RUR, CURRENCY_SIT, CURRENCY_SEK, CURRENCY_YTL, CURRENCY_SKK, CURRENCY_BRL, CURRENCY_EEK, CURRENCY_LTL, CURRENCY_KRW, CURRENCY_ZAR, CURRENCY_CUSTOM, CURRENCY_GEL, CURRENCY_IRR, CURRENCY_END }
| This enum gives the currencies a unique id which must be maintained for savegame compatibility and in order to refer to them quickly, especially for referencing the custom one. More...

## Functions
uint64 | GetMaskOfAllowedCurrencies ()
| get a mask of the allowed currencies depending on the year
void | CheckSwitchToEuro ()
| Verify if the currency chosen by the user is about to be converted to Euro.
void | ResetCurrencies (bool preserve_custom=true)
| Will fill _currency_specs array with default values from origin_currency_specs Called only from newgrf.cpp and settings.cpp.
StringID * | BuildCurrencyDropdown ()
| Build a list of currency names StringIDs to use in a dropdown list.
byte | GetNewgrfCurrencyIdConverted (byte grfcurr_id)
| Will return the ottd's index correspondence to the ttdpatch's id.

## Variables
static const int | CF_NOEURO = 0
| Currency never switches to the Euro (as far as known).
static const int | CF_ISEURO = 1
| Currency is the Euro.
CurrencySpec | _currency_specs [CURRENCY_END]
| Array of currencies used by the system.

## Detailed Description

Functions to handle different currencies.

Definition in file currency.h.

## Enumeration Type Documentation

enum Currencies

This enum gives the currencies a unique id which must be maintained for savegame compatibility and in order to refer to them quickly, especially for referencing the custom one.

Enumerator:

  CURRENCY_GBP | British Pound.
  CURRENCY_USD | US Dollar.
  CURRENCY_EUR | Euro.
  CURRENCY_JPY | Japanese Yen.
  CURRENCY_ATS | Austrian Schilling.
  CURRENCY_BEF | Belgian Franc.
  CURRENCY_CHF | Swiss Franc.
  CURRENCY_CZK | Czech Koruna.
  CURRENCY_DEM | Deutsche Mark.
  CURRENCY_DKK | Danish Krona.
  CURRENCY_ESP | Spanish Peseta.
  CURRENCY_FIM | Finish Markka.
  CURRENCY_FRF | French Franc.
  CURRENCY_GRD | Greek Drachma.
  CURRENCY_HUF | Hungarian Forint.
  CURRENCY_ISK | Icelandic Krona.
  CURRENCY_ITL | Italian Lira.
  CURRENCY_NLG | Dutch Gulden.
  CURRENCY_NOK | Norwegian Krone.
  CURRENCY_PLN | Polish Zloty.
  CURRENCY_RON | Romenian Leu.
  CURRENCY_RUR | Russian Rouble.
  CURRENCY_SIT | Slovenian Tolar.
  CURRENCY_SEK | Swedish Krona.
  CURRENCY_YTL | Turkish Lira.
  CURRENCY_SKK | Slovak Kornuna.
  CURRENCY_BRL | Brazilian Real.
  CURRENCY_EEK | Estonian Krooni.
  CURRENCY_LTL | Lithuanian Litas.
  CURRENCY_KRW | South Korean Won.
  CURRENCY_ZAR | South African Rand.
  CURRENCY_CUSTOM | Custom currency.
  CURRENCY_GEL | Georgian Lari.
  CURRENCY_IRR | Iranian Rial.
  CURRENCY_END | always the last item

Definition at line 26 of file currency.h.

## Function Documentation

StringID* BuildCurrencyDropdown | ( |  | ) |

Build a list of currency names StringIDs to use in a dropdown list.

Returns
  Pointer to a (static) array of StringIDs

Definition at line 163 of file currency.cpp.

References CURRENCY_END, and INVALID_STRING_ID.

Referenced by GameOptionsWindow::BuildDropDownList().

uint64 GetMaskOfAllowedCurrencies | ( |  | ) |

get a mask of the allowed currencies depending on the year

Returns
  mask of currencies

Definition at line 116 of file currency.cpp.

References _cur_year, CF_ISEURO, CF_NOEURO, CURRENCY_CUSTOM, CURRENCY_END, SetBit(), and CurrencySpec::to_euro.

Referenced by GameOptionsWindow::BuildDropDownList().

byte GetNewgrfCurrencyIdConverted | ( | byte | grfcurr_id | ) |

Will return the ottd's index correspondence to the ttdpatch's id.

If the id is bigger than the array, it is a grf written for ottd, thus returning the same id. Only called from newgrf.cpp

Parameters

  grfcurr_id | currency id coming from newgrf

Returns
  the corrected index

Definition at line 107 of file currency.cpp.

References lengthof, and TTDPatch_To_OTTDIndex.

Referenced by GlobalVarChangeInfo().

void ResetCurrencies | ( | bool | preserve_custom | ) |

Will fill _currency_specs array with default values from origin_currency_specs Called only from newgrf.cpp and settings.cpp.

Parameters

  preserve_custom | will not reset custom currency

Definition at line 151 of file currency.cpp.

References CURRENCY_CUSTOM, and CURRENCY_END.

Referenced by LoadFromConfig(), and ResetNewGRFData().