--- a/currency.c Sat Mar 24 15:16:41 2007 +0000
+++ b/currency.c Mon Mar 26 00:20:22 2007 +0000
@@ -153,12 +153,17 @@
}
/**
- * 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));
}
/**
--- a/currency.h Sat Mar 24 15:16:41 2007 +0000
+++ b/currency.h Mon Mar 26 00:20:22 2007 +0000
@@ -38,7 +38,7 @@
uint GetMaskOfAllowedCurrencies(void);
void CheckSwitchToEuro(void);
-void ResetCurrencies(void);
+void ResetCurrencies(bool preserve_custom);
StringID* BuildCurrencyDropdown(void);
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
--- a/newgrf.c Sat Mar 24 15:16:41 2007 +0000
+++ b/newgrf.c Mon Mar 26 00:20:22 2007 +0000
@@ -3505,7 +3505,7 @@
ResetPriceBaseMultipliers();
/* Reset the curencies array */
- ResetCurrencies();
+ ResetCurrencies(false);
// Reset station classes
ResetStationClasses();
--- a/settings.c Sat Mar 24 15:16:41 2007 +0000
+++ b/settings.c Mon Mar 26 00:20:22 2007 +0000
@@ -1478,7 +1478,7 @@
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 @@
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);