mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r9471) [0.5] -Backport from trunk (r9467 & r9469):
Reset the whole currency array while preserving custom one. Also, max data of to_euro is now 300, not 1000, disabling any proper loading of the patch setting
This commit is contained in:
parent
c85022e3db
commit
a0688e8d85
13
currency.c
13
currency.c
|
@ -153,12 +153,17 @@ void CheckSwitchToEuro(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called only from newgrf.c. Will fill _currency_specs array with
|
* Will fill _currency_specs array with
|
||||||
* default values from origin_currency_specs
|
* default values from origin_currency_specs
|
||||||
**/
|
* Called only from newgrf.c and settings.c.
|
||||||
void ResetCurrencies(void)
|
* @param 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.void ResetCurrencies(bool preserve_custom)
|
||||||
|
*/
|
||||||
|
void ResetCurrencies(bool preserve_custom)
|
||||||
{
|
{
|
||||||
memcpy(&_currency_specs, &origin_currency_specs, sizeof(origin_currency_specs));
|
memcpy(&_currency_specs, &origin_currency_specs, sizeof(origin_currency_specs) - (preserve_custom ? sizeof(_custom_currency) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern CurrencySpec _currency_specs[NUM_CURRENCY];
|
||||||
|
|
||||||
uint GetMaskOfAllowedCurrencies(void);
|
uint GetMaskOfAllowedCurrencies(void);
|
||||||
void CheckSwitchToEuro(void);
|
void CheckSwitchToEuro(void);
|
||||||
void ResetCurrencies(void);
|
void ResetCurrencies(bool preserve_custom);
|
||||||
StringID* BuildCurrencyDropdown(void);
|
StringID* BuildCurrencyDropdown(void);
|
||||||
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
|
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
|
||||||
|
|
||||||
|
|
2
newgrf.c
2
newgrf.c
|
@ -3505,7 +3505,7 @@ static void ResetNewGRFData(void)
|
||||||
ResetPriceBaseMultipliers();
|
ResetPriceBaseMultipliers();
|
||||||
|
|
||||||
/* Reset the curencies array */
|
/* Reset the curencies array */
|
||||||
ResetCurrencies();
|
ResetCurrencies(false);
|
||||||
|
|
||||||
// Reset station classes
|
// Reset station classes
|
||||||
ResetStationClasses();
|
ResetStationClasses();
|
||||||
|
|
|
@ -1478,7 +1478,7 @@ const SettingDesc _patch_settings[] = {
|
||||||
static const SettingDesc _currency_settings[] = {
|
static const SettingDesc _currency_settings[] = {
|
||||||
SDT_VAR(CurrencySpec, rate, SLE_UINT16, S, 0, 1, 0, 100, 0, STR_NULL, NULL),
|
SDT_VAR(CurrencySpec, rate, SLE_UINT16, S, 0, 1, 0, 100, 0, STR_NULL, NULL),
|
||||||
SDT_CHR(CurrencySpec, separator, S, 0, ".", STR_NULL, NULL),
|
SDT_CHR(CurrencySpec, separator, S, 0, ".", STR_NULL, NULL),
|
||||||
SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0,1000, 0, STR_NULL, NULL),
|
SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0,3000, 0, STR_NULL, NULL),
|
||||||
SDT_STR(CurrencySpec, prefix, SLE_STRBQ, S, 0, NULL, STR_NULL, NULL),
|
SDT_STR(CurrencySpec, prefix, SLE_STRBQ, S, 0, NULL, STR_NULL, NULL),
|
||||||
SDT_STR(CurrencySpec, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL),
|
SDT_STR(CurrencySpec, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL),
|
||||||
SDT_END()
|
SDT_END()
|
||||||
|
@ -1654,6 +1654,7 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP
|
||||||
void LoadFromConfig(void)
|
void LoadFromConfig(void)
|
||||||
{
|
{
|
||||||
IniFile *ini = ini_load(_config_file);
|
IniFile *ini = ini_load(_config_file);
|
||||||
|
ResetCurrencies(false);
|
||||||
HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
|
HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
|
||||||
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
|
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
|
||||||
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);
|
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);
|
||||||
|
|
Loading…
Reference in New Issue