(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:
belugas 2007-03-26 00:20:22 +00:00
parent c85022e3db
commit a0688e8d85
4 changed files with 13 additions and 7 deletions

View File

@ -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
**/
void ResetCurrencies(void)
* Called only from newgrf.c and settings.c.
* @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));
}
/**

View File

@ -38,7 +38,7 @@ extern CurrencySpec _currency_specs[NUM_CURRENCY];
uint GetMaskOfAllowedCurrencies(void);
void CheckSwitchToEuro(void);
void ResetCurrencies(void);
void ResetCurrencies(bool preserve_custom);
StringID* BuildCurrencyDropdown(void);
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);

View File

@ -3505,7 +3505,7 @@ static void ResetNewGRFData(void)
ResetPriceBaseMultipliers();
/* Reset the curencies array */
ResetCurrencies();
ResetCurrencies(false);
// Reset station classes
ResetStationClasses();

View File

@ -1478,7 +1478,7 @@ const SettingDesc _patch_settings[] = {
static const SettingDesc _currency_settings[] = {
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_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, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL),
SDT_END()
@ -1654,6 +1654,7 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP
void LoadFromConfig(void)
{
IniFile *ini = ini_load(_config_file);
ResetCurrencies(false);
HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);