OpenTTD: src/currency.cpp File Reference

OpenTTD

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

- File List
- Globals

Functions | Variables
currency.cpp File Reference

Support for different currencies. More...

`#include "stdafx.h"`
`#include "core/bitmath_func.hpp"`
`#include "currency.h"`
`#include "news_func.h"`
`#include "settings_type.h"`
`#include "date_func.h"`
`#include "string_type.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
byte | GetNewgrfCurrencyIdConverted (byte grfcurr_id)
| Will return the ottd's index correspondence to the ttdpatch's id.
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)
| 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.

## Variables
static const CurrencySpec | origin_currency_specs [CURRENCY_END]
| The original currency specifications.
CurrencySpec | _currency_specs [CURRENCY_END]
| Array of currencies used by the system.
const byte | TTDPatch_To_OTTDIndex []
| This array represent the position of OpenTTD's currencies, compared to TTDPatch's ones.

## Detailed Description

Support for different currencies.

Definition in file currency.cpp.

## 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().

## Variable Documentation

const CurrencySpec origin_currency_specs[CURRENCY_END]
| static

The original currency specifications.

Definition at line 30 of file currency.cpp.

const byte TTDPatch_To_OTTDIndex[]

Initial value:
{
CURRENCY_GBP,
CURRENCY_USD,
CURRENCY_FRF,
CURRENCY_DEM,
CURRENCY_JPY,
CURRENCY_ESP,
CURRENCY_HUF,
CURRENCY_PLN,
CURRENCY_ATS,
CURRENCY_BEF,
CURRENCY_DKK,
CURRENCY_FIM,
CURRENCY_GRD,
CURRENCY_CHF,
CURRENCY_NLG,
CURRENCY_ITL,
CURRENCY_SEK,
CURRENCY_RUR,
CURRENCY_EUR,
}

This array represent the position of OpenTTD's currencies, compared to TTDPatch's ones.

When a grf sends currencies, they are based on the order defined by TTDPatch. So, we must reindex them to our own order.

Definition at line 76 of file currency.cpp.

Referenced by GetNewgrfCurrencyIdConverted().