Codechange: Replace currency macros with functions. (#12396)

This commit is contained in:
Peter Nelson
2024-03-29 14:49:48 +00:00
committed by GitHub
parent e21c12afeb
commit 8d312b305b
8 changed files with 59 additions and 45 deletions

View File

@@ -11,7 +11,7 @@
#define CURRENCY_H
#include "timer/timer_game_calendar.h"
#include "string_func.h"
#include "settings_type.h"
#include "strings_type.h"
static constexpr TimerGameCalendar::Year CF_NOEURO = 0; ///< Currency never switches to the Euro (as far as known).
@@ -99,11 +99,25 @@ struct CurrencySpec {
}
};
extern CurrencySpec _currency_specs[CURRENCY_END];
extern std::array<CurrencySpec, CURRENCY_END> _currency_specs;
/* XXX small hack, but makes the rest of the code a bit nicer to read */
#define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
#define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
/**
* Get the custom currency.
* @return Reference to custom currency.
*/
inline CurrencySpec &GetCustomCurrency()
{
return _currency_specs[CURRENCY_CUSTOM];
}
/**
* Get the currently selected currency.
* @return Read-only reference to the current currency.
*/
inline const CurrencySpec &GetCurrency()
{
return _currency_specs[GetGameSettings().locale.currency];
}
uint64_t GetMaskOfAllowedCurrencies();
void ResetCurrencies(bool preserve_custom = true);