summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-25 20:16:56 +0000
committerrubidium <rubidium@openttd.org>2009-04-25 20:16:56 +0000
commit802d31aab683d1e6baeafd8f53bbe7187b39e69a (patch)
treec5ab4701130437738a9e223bcf1189a270a322b9 /src
parent4ec6456feb28f3530573b1452f714bf0b7d589fd (diff)
downloadopenttd-802d31aab683d1e6baeafd8f53bbe7187b39e69a.tar.xz
(svn r16144) -Fix (r16129): setting the custom digit grouping separator required to restart OpenTTD to take effect. Now also support non 1 ASCII character custom grouping separators.
Diffstat (limited to 'src')
-rw-r--r--src/currency.cpp58
-rw-r--r--src/currency.h2
-rw-r--r--src/newgrf.cpp3
-rw-r--r--src/settings_gui.cpp10
-rw-r--r--src/strings.cpp5
5 files changed, 36 insertions, 42 deletions
diff --git a/src/currency.cpp b/src/currency.cpp
index 131c9d65f..84f76e0dd 100644
--- a/src/currency.cpp
+++ b/src/currency.cpp
@@ -15,35 +15,35 @@
* | | Euro year | | | name
* | | | | | | | */
static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
- { 1, '\0', CF_NOEURO, "\xC2\xA3", "", 0, STR_CURR_GBP }, ///< british pounds
- { 2, '\0', CF_NOEURO, "$", "", 0, STR_CURR_USD }, ///< us dollars
- { 2, '\0', CF_ISEURO, "\xE2\x82\xAC", "", 0, STR_CURR_EUR }, ///< Euro
- { 220, '\0', CF_NOEURO, "\xC2\xA5", "", 0, STR_CURR_YEN }, ///< yen
- { 20, '\0', 2002, "", " S.", 1, STR_CURR_ATS }, ///< austrian schilling
- { 59, '\0', 2002, "BEF ", "", 0, STR_CURR_BEF }, ///< belgian franc
- { 2, '\0', CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, ///< swiss franc
- { 41, '\0', CF_NOEURO, "", " K\xC4\x8D", 1, STR_CURR_CZK }, ///< czech koruna
- { 3, '\0', 2002, "DM ", "", 0, STR_CURR_DEM }, ///< deutsche mark
- { 11, '\0', CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, ///< danish krone
- { 245, '\0', 2002, "Pts ", "", 0, STR_CURR_ESP }, ///< spanish pesetas
- { 9, '\0', 2002, "", " mk", 1, STR_CURR_FIM }, ///< finnish markka
- { 10, '\0', 2002, "FF ", "", 0, STR_CURR_FRF }, ///< french francs
- { 500, '\0', 2002, "", "Dr.", 1, STR_CURR_GRD }, ///< greek drachma
- { 378, '\0', CF_NOEURO, "", " Ft", 1, STR_CURR_HUF }, ///< hungarian forint
- { 130, '\0', CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, ///< icelandic krona
- { 2850, '\0', 2002, "", " L.", 1, STR_CURR_ITL }, ///< italian lira
- { 3, '\0', 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden
- { 12, '\0', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone
- { 6, '\0', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty
- { 5, '\0', CF_NOEURO, "", " Lei", 1, STR_CURR_RON }, ///< romanian Lei
- { 50, '\0', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble
- { 352, '\0', 2007, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar
- { 13, '\0', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona
- { 3, '\0', CF_NOEURO, "", " TL", 1, STR_CURR_TRY }, ///< turkish lira
- { 52, '\0', 2009, "", " Sk", 1, STR_CURR_SKK }, ///< slovak koruna
- { 4, '\0', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRL }, ///< brazil real
- { 20, '\0', CF_NOEURO, "", " EEK", 1, STR_CURR_EEK }, ///< estonian krooni
- { 1, '\0', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, ///< custom currency
+ { 1, "", CF_NOEURO, "\xC2\xA3", "", 0, STR_CURR_GBP }, ///< british pounds
+ { 2, "", CF_NOEURO, "$", "", 0, STR_CURR_USD }, ///< us dollars
+ { 2, "", CF_ISEURO, "\xE2\x82\xAC", "", 0, STR_CURR_EUR }, ///< Euro
+ { 220, "", CF_NOEURO, "\xC2\xA5", "", 0, STR_CURR_YEN }, ///< yen
+ { 20, "", 2002, "", " S.", 1, STR_CURR_ATS }, ///< austrian schilling
+ { 59, "", 2002, "BEF ", "", 0, STR_CURR_BEF }, ///< belgian franc
+ { 2, "", CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, ///< swiss franc
+ { 41, "", CF_NOEURO, "", " K\xC4\x8D", 1, STR_CURR_CZK }, ///< czech koruna
+ { 3, "", 2002, "DM ", "", 0, STR_CURR_DEM }, ///< deutsche mark
+ { 11, "", CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, ///< danish krone
+ { 245, "", 2002, "Pts ", "", 0, STR_CURR_ESP }, ///< spanish pesetas
+ { 9, "", 2002, "", " mk", 1, STR_CURR_FIM }, ///< finnish markka
+ { 10, "", 2002, "FF ", "", 0, STR_CURR_FRF }, ///< french francs
+ { 500, "", 2002, "", "Dr.", 1, STR_CURR_GRD }, ///< greek drachma
+ { 378, "", CF_NOEURO, "", " Ft", 1, STR_CURR_HUF }, ///< hungarian forint
+ { 130, "", CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, ///< icelandic krona
+ { 2850, "", 2002, "", " L.", 1, STR_CURR_ITL }, ///< italian lira
+ { 3, "", 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden
+ { 12, "", CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone
+ { 6, "", CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty
+ { 5, "", CF_NOEURO, "", " Lei", 1, STR_CURR_RON }, ///< romanian Lei
+ { 50, "", CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble
+ { 352, "", 2007, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar
+ { 13, "", CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona
+ { 3, "", CF_NOEURO, "", " TL", 1, STR_CURR_TRY }, ///< turkish lira
+ { 52, "", 2009, "", " Sk", 1, STR_CURR_SKK }, ///< slovak koruna
+ { 4, "", CF_NOEURO, "R$ ", "", 0, STR_CURR_BRL }, ///< brazil real
+ { 20, "", CF_NOEURO, "", " EEK", 1, STR_CURR_EEK }, ///< estonian krooni
+ { 1, "", CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, ///< custom currency
};
/* Array of currencies used by the system */
diff --git a/src/currency.h b/src/currency.h
index a6600e744..2f58ce612 100644
--- a/src/currency.h
+++ b/src/currency.h
@@ -17,7 +17,7 @@ enum {
struct CurrencySpec {
uint16 rate;
- char separator;
+ char separator[8];
Year to_euro;
char prefix[16];
char suffix[16];
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 21c39d2dd..6ed173463 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1717,7 +1717,8 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, by
uint16 options = grf_load_word(&buf);
if (curidx < NUM_CURRENCY) {
- _currency_specs[curidx].separator = GB(options, 0, 8);
+ _currency_specs[curidx].separator[0] = GB(options, 0, 8);
+ _currency_specs[curidx].separator[1] = '\0';
/* By specifying only one bit, we prevent errors,
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */
_currency_specs[curidx].symbol_pos = GB(options, 8, 1);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index ac3af105a..d52ed96c6 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1587,13 +1587,10 @@ enum CustomCurrencyWidgets {
};
struct CustomCurrencyWindow : Window {
- char separator[2];
int query_widget;
CustomCurrencyWindow(const WindowDesc *desc) : Window(desc)
{
- this->separator[0] = _custom_currency.separator;
- this->separator[1] = '\0';
this->FindWindowPlacementAndResize(desc);
SetButtonState();
@@ -1611,7 +1608,7 @@ struct CustomCurrencyWindow : Window {
{
SetDParam(0, 1);
SetDParam(1, 1);
- SetDParamStr(2, this->separator);
+ SetDParamStr(2, _custom_currency.separator);
SetDParamStr(3, _custom_currency.prefix);
SetDParamStr(4, _custom_currency.suffix);
SetDParam(5, _custom_currency.to_euro);
@@ -1650,7 +1647,7 @@ struct CustomCurrencyWindow : Window {
case CUSTCURR_SEPARATOR_EDIT:
case CUSTCURR_SEPARATOR:
- SetDParamStr(0, this->separator);
+ SetDParamStr(0, _custom_currency.separator);
str = STR_JUST_RAW_STRING;
len = 1;
line = CUSTCURR_SEPARATOR;
@@ -1712,8 +1709,7 @@ struct CustomCurrencyWindow : Window {
break;
case CUSTCURR_SEPARATOR: // Thousands seperator
- _custom_currency.separator = StrEmpty(str) ? ' ' : str[0];
- strecpy(this->separator, str, lastof(this->separator));
+ strecpy(_custom_currency.separator, str, lastof(_custom_currency.separator));
break;
case CUSTCURR_PREFIX:
diff --git a/src/strings.cpp b/src/strings.cpp
index 9ba0a6e7c..64db048c4 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -336,10 +336,7 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
}
const char *separator = _settings_game.locale.digit_group_separator_currency;
- if (separator == NULL && _currency->separator != '\0') {
- static char sep[] = { _currency->separator, '\0' };
- separator = sep;
- }
+ if (separator == NULL && !StrEmpty(_currency->separator)) separator = _currency->separator;
if (separator == NULL) separator = _langpack->digit_group_separator_currency;
buff = FormatNumber(buff, number, last, separator);
buff = strecpy(buff, multiplier, last);