summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-03-25 23:42:55 +0000
committerbelugas <belugas@openttd.org>2007-03-25 23:42:55 +0000
commit683aae8abf2486a124938691c32172f043d8a45f (patch)
tree17be004bb6cdaa3f396df286149703a5d9bde6d2 /src
parent45e788d524b4ce088b1f3e4ba27ed3a5340fdcda (diff)
downloadopenttd-683aae8abf2486a124938691c32172f043d8a45f.tar.xz
(svn r9467) -Fix(FS#703,6108): When resetting the array of currencies, the custom currency was reset too, thus loosing the setting a user could have used for it.(glx)
Diffstat (limited to 'src')
-rw-r--r--src/currency.cpp11
-rw-r--r--src/currency.h2
-rw-r--r--src/settings.cpp1
3 files changed, 10 insertions, 4 deletions
diff --git a/src/currency.cpp b/src/currency.cpp
index 4abf7cbd9..8d7ecbef7 100644
--- a/src/currency.cpp
+++ b/src/currency.cpp
@@ -158,12 +158,17 @@ void CheckSwitchToEuro()
}
/**
- * Called only from newgrf.c. Will fill _currency_specs array with
+ * Will fill _currency_specs array with
* default values from origin_currency_specs
+ * Called only from newgrf.cpp and settings.cpp.
+ * @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()
+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));
}
/**
diff --git a/src/currency.h b/src/currency.h
index a72eab7d0..86b46e713 100644
--- a/src/currency.h
+++ b/src/currency.h
@@ -40,7 +40,7 @@ extern CurrencySpec _currency_specs[NUM_CURRENCY];
uint GetMaskOfAllowedCurrencies();
void CheckSwitchToEuro();
-void ResetCurrencies();
+void ResetCurrencies(bool preserve_custom = true);
StringID* BuildCurrencyDropdown();
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
diff --git a/src/settings.cpp b/src/settings.cpp
index d82eec7d7..1aec9d641 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1685,6 +1685,7 @@ extern void CheckDifficultyLevels();
void LoadFromConfig()
{
IniFile *ini = ini_load(_config_file);
+ ResetCurrencies(false); // Initialize the array of curencies, without preserving the custom one
HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);