OpenTTD Source 20260621-master-g720d10536d
currency_func.h File Reference

Functions to handle different currencies. More...

#include "currency_type.h"
#include "settings_type.h"

Go to the source code of this file.

Functions

CurrencySpecGetCustomCurrency ()
 Get the custom currency.
const CurrencySpecGetCurrency ()
 Get the currently selected currency.
Currencies GetMaskOfAllowedCurrencies ()
 get a mask of the allowed currencies depending on the year
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.
uint8_t GetNewgrfCurrencyIdConverted (uint8_t grfcurr_id)
 Will return the ottd's index correspondence to the ttdpatch's id.

Variables

std::array< CurrencySpec, CURRENCY_END_currency_specs
 Array of currencies used by the system.

Detailed Description

Functions to handle different currencies.

Definition in file currency_func.h.

Function Documentation

◆ GetCurrency()

const CurrencySpec & GetCurrency ( )
inline

◆ GetCustomCurrency()

CurrencySpec & GetCustomCurrency ( )
inline

Get the custom currency.

Returns
Reference to custom currency.

Definition at line 22 of file currency_func.h.

References _currency_specs, and CURRENCY_CUSTOM.

Referenced by CustomCurrencyWindow::GetWidgetString(), CustomCurrencyWindow::OnClick(), CustomCurrencyWindow::OnQueryTextFinished(), and SurveySettings().

◆ GetMaskOfAllowedCurrencies()

Currencies GetMaskOfAllowedCurrencies ( )

get a mask of the allowed currencies depending on the year

Returns
mask of currencies

Definition at line 128 of file currency.cpp.

References _currency_specs, CF_ISEURO, CF_NOEURO, CURRENCY_CUSTOM, CURRENCY_END, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and TimerGameCalendar::year.

Referenced by GameOptionsWindow::BuildDropDownList().

◆ GetNewgrfCurrencyIdConverted()

uint8_t GetNewgrfCurrencyIdConverted ( uint8_t 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_idcurrency id coming from newgrf
Returns
the corrected index

Definition at line 119 of file currency.cpp.

References lengthof, and TTDPatch_To_OTTDIndex.

Referenced by GlobalVarChangeInfo().

◆ ResetCurrencies()

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_customwill not reset custom currency

Definition at line 162 of file currency.cpp.

References _currency_specs, CURRENCY_CUSTOM, CURRENCY_END, and origin_currency_specs.

Referenced by LoadFromConfig(), and ResetNewGRFData().

Variable Documentation

◆ _currency_specs