Data Structures | Defines | 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...

Defines

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

Functions

uint 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.
StringIDBuildCurrencyDropdown ()
 Build a list of currency names StringIDs to use in a dropdown list.
byte GetNewgrfCurrencyIdConverted (byte grfcurr_id)
 Will return the ottd's index correspondance 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.
static const uint NUM_CURRENCY = 29
 Number of currencies.
static const int CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1
 Index of the custom currency.
CurrencySpec _currency_specs [NUM_CURRENCY]
 Array of currencies used by the system.

Detailed Description

Functions to handle different currencies.

Definition in 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 191 of file currency.cpp.

References INVALID_STRING_ID, and NUM_CURRENCY.

Referenced by GameOptionsWindow::BuildDropDownList().

uint GetMaskOfAllowedCurrencies (  ) 

get a mask of the allowed currencies depending on the year

Returns:
mask of currencies

Definition at line 144 of file currency.cpp.

References _cur_year, CF_ISEURO, CF_NOEURO, CUSTOM_CURRENCY_ID, NUM_CURRENCY, and CurrencySpec::to_euro.

Referenced by GameOptionsWindow::BuildDropDownList().

byte GetNewgrfCurrencyIdConverted ( byte  grfcurr_id  ) 

Will return the ottd's index correspondance 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 135 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 (the latest one on the list) if ever it is flagged to true. In which case, the total size of the memory to move will be one currency spec less, thus preserving the custom curreny from been overwritten.

Definition at line 182 of file currency.cpp.

Referenced by LoadFromConfig(), and ResetNewGRFData().