From 13eba00152fda7a1458b7820e0787b001c4e772a Mon Sep 17 00:00:00 2001 From: dominik Date: Wed, 22 Dec 2004 16:54:55 +0000 Subject: (svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones). --- economy.c | 25 +++++++++++++++++++++++++ lang/english.txt | 49 +++++++++++++++++++++++++------------------------ saveload.c | 2 +- strings.c | 53 ++++++++++++++--------------------------------------- table/currency.h | 52 ++++++++++++++++++++++++++++------------------------ ttd.c | 18 ++++++++++++++++++ 6 files changed, 111 insertions(+), 88 deletions(-) diff --git a/economy.c b/economy.c index 2367fe69d..d48f9a65b 100644 --- a/economy.c +++ b/economy.c @@ -18,6 +18,31 @@ #include "engine.h" #include "network_data.h" +// get a mask of the allowed currencies depending on the year +uint GetMaskOfAllowedCurrencies() +{ + int i; + uint mask = 0; + for(i=0; i!=lengthof(_currency_specs); i++) { + uint16 to_euro = _currency_specs[i].to_euro; + if (i == 23) mask |= (1 << 23); // always allow custom currency + if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-1920)) continue; + if (_cur_year < (2000-1920) && (to_euro == CF_ISEURO)) continue; + mask |= (1 << i); + } + return mask; +} + +void CheckSwitchToEuro() +{ + if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && + _currency_specs[_opt.currency].to_euro != CF_ISEURO && + _cur_year >= (_currency_specs[_opt.currency].to_euro-1920)) { + _opt.currency = 2; // this is the index of euro above. + AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); + } +} + void UpdatePlayerHouse(Player *p, uint score) { byte val; diff --git a/lang/english.txt b/lang/english.txt index 0f4ed9cf8..63e21eb2b 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -868,30 +868,31 @@ STR_TOWNNAME_ROMANIAN :Romanian STR_TOWNNAME_CZECH :Czech ############ end of townname region -STR_CURR_POUNDS :Pounds ({POUNDSIGN}) -STR_CURR_DOLLARS :Dollars ($) -STR_CURR_FF :Franc (FF) -STR_CURR_DM :Deutschmark (DM) -STR_CURR_YEN :Yen ({YENSIGN}) -STR_CURR_PT :Peseta (Pt) -STR_CURR_FT :Hungarian Forint (Ft) -STR_CURR_ZL :Polish Zloty (zl) -STR_CURR_ATS :Austrian Shilling (ATS) -STR_CURR_BEF :Belgian Franc (BEF) -STR_CURR_DKK :Danish Krone (DKK) -STR_CURR_FIM :Finnish Markka (FIM) -STR_CURR_GRD :Greek Drachma (GRD) -STR_CURR_CHF :Swiss Franc (CHF) -STR_CURR_NLG :Dutch Guilder (NLG) -STR_CURR_ITL :Italian Lira (ITL) -STR_CURR_CUSTOM :Custom... -STR_CURR_SEK :Swedish Krona (SEK) -STR_CURR_RUR :Russian Rubel (rur) -STR_CURR_CZK :Czech Koruna (CZK) -STR_CURR_ISK :Icelandic Krona (ISK) -STR_CURR_NOK :Norwegian Krone (NOK) -STR_CURR_ROL :Romanian Leu (Lei) -STR_CURR_EUR :Euro (¤) +STR_CURR_GBP :Pounds ({POUNDSIGN}) +STR_CURR_USD :Dollars ($) +STR_CURR_EUR :Euro (¤) +STR_CURR_YEN :Yen ({YENSIGN}) +STR_CURR_ATS :Austrian Shilling (ATS) +STR_CURR_BEF :Belgian Franc (BEF) +STR_CURR_CHF :Swiss Franc (CHF) +STR_CURR_CZK :Czech Koruna (CZK) +STR_CURR_DEM :Deutschmark (DEM) +STR_CURR_DKK :Danish Krone (DKK) +STR_CURR_ESP :Peseta (ESP) +STR_CURR_FIM :Finnish Markka (FIM) +STR_CURR_FRF :Franc (FRF) +STR_CURR_GRD :Greek Drachma (GRD) +STR_CURR_HUF :Hungarian Forint (HUF) +STR_CURR_ISK :Icelandic Krona (ISK) +STR_CURR_ITL :Italian Lira (ITL) +STR_CURR_NLG :Dutch Guilder (NLG) +STR_CURR_NOK :Norwegian Krone (NOK) +STR_CURR_PLN :Polish Zloty (PLN) +STR_CURR_ROL :Romanian Leu (ROL) +STR_CURR_RUR :Russian Rubles (RUR) +STR_CURR_SEK :Swedish Krona (SEK) + +STR_CURR_CUSTOM :Custom... STR_OPTIONS_LANG :{BLACK}Language STR_OPTIONS_LANG_CBO :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING} diff --git a/saveload.c b/saveload.c index b85eb9525..fc20194a0 100644 --- a/saveload.c +++ b/saveload.c @@ -9,7 +9,7 @@ enum { SAVEGAME_MAJOR_VERSION = 4, - SAVEGAME_MINOR_VERSION = 1, + SAVEGAME_MINOR_VERSION = 2, SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION }; diff --git a/strings.c b/strings.c index a6c2d5ee0..1928e8e52 100644 --- a/strings.c +++ b/strings.c @@ -33,29 +33,29 @@ typedef struct { } LanguagePackHeader; const uint16 _currency_string_list[] = { - STR_CURR_POUNDS, - STR_CURR_DOLLARS, - STR_CURR_FF, - STR_CURR_DM, + STR_CURR_GBP, + STR_CURR_USD, + STR_CURR_EUR, STR_CURR_YEN, - STR_CURR_PT, - STR_CURR_FT, - STR_CURR_ZL, STR_CURR_ATS, STR_CURR_BEF, + STR_CURR_CHF, + STR_CURR_CZK, + STR_CURR_DEM, STR_CURR_DKK, + STR_CURR_ESP, STR_CURR_FIM, + STR_CURR_FRF, STR_CURR_GRD, - STR_CURR_CHF, - STR_CURR_NLG, - STR_CURR_ITL, - STR_CURR_SEK, - STR_CURR_RUR, - STR_CURR_CZK, + STR_CURR_HUF, STR_CURR_ISK, + STR_CURR_ITL, + STR_CURR_NLG, STR_CURR_NOK, - STR_CURR_EUR, + STR_CURR_PLN, STR_CURR_ROL, + STR_CURR_RUR, + STR_CURR_SEK, STR_CURR_CUSTOM, INVALID_STRING_ID }; @@ -67,31 +67,6 @@ static const uint16 _cargo_string_list[NUM_LANDSCAPE][NUM_CARGO] = { /* LT_CANDY */ {STR_PASSENGERS, STR_TONS, STR_BAGS, STR_NOTHING, STR_NOTHING, STR_TONS, STR_TONS, STR_LITERS, STR_TONS, STR_NOTHING, STR_LITERS, STR_NOTHING} }; -// get a mask of the allowed currencies depending on the year -uint GetMaskOfAllowedCurrencies() -{ - int i; - uint mask = 0; - for(i=0; i!=lengthof(_currency_specs); i++) { - uint16 to_euro = _currency_specs[i].to_euro; - if (i == 23) mask |= (1 << 23); // always allow custom currency - if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-1920)) continue; - if (_cur_year < (2000-1920) && (to_euro == CF_ISEURO)) continue; - mask |= (1 << i); - } - return mask; -} - -void CheckSwitchToEuro() -{ - if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && - _currency_specs[_opt.currency].to_euro != CF_ISEURO && - _cur_year >= (_currency_specs[_opt.currency].to_euro-1920)) { - _opt.currency = 21; // this is the index of euro above. - AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); - } -} - static byte *str_cat(byte *dst, const byte *src) { while ( (*dst++ = *src++) != 0) {} diff --git a/table/currency.h b/table/currency.h index 7e99e8f26..3136e7675 100644 --- a/table/currency.h +++ b/table/currency.h @@ -1,26 +1,30 @@ - +// exchange rate prefix +// | separator | postfix +// | | Euro year | | +// | | | | | CurrencySpec _currency_specs[] = { -{ 1, ',', CF_NOEURO, "\xA3", "" }, // british pounds -{ 2, ',', CF_NOEURO, "$", "" }, // us dollars -{ 10, '.', 2002, "FF ", "" }, // french francs -{ 4, '.', 2002, "DM ", "" }, // deutsche mark -{ 200, ',', CF_NOEURO, "\xA5", "" }, // yen -{ 200, '.', 2002, "Pt", "" }, // spanish pesetas -{ 376, ',', 2002, "", " Ft" }, -{ 6, ' ', CF_NOEURO, "", " zl" }, -{ 19, ',', 2002, "ATS ", "" }, -{ 57, ',', 2002, "BEF ", "" }, -{ 10, '.', CF_NOEURO, "", " kr" }, -{ 8, ',', 2002, "FIM ", "" }, -{ 480, ',', 2002, "GRD ", "" }, -{ 2, ',', CF_NOEURO, "CHF ", "" }, -{ 3, ',', 2002, "NLG ", "" }, -{ 2730,',', 2002, "ITL ", "" }, -{ 13, '.', CF_NOEURO, "", " kr" }, -{ 5, ' ', CF_NOEURO, "", " rur" }, -{ 50, ',', CF_NOEURO, "", " Kc" }, -{ 130, '.', CF_NOEURO, "", " kr" }, -{ 11, '.', CF_NOEURO, "", " kr" }, -{ 2, ',', CF_ISEURO, "¤", "" }, -{ 6, '.', CF_NOEURO, "", " Lei" }, +{ 1, ',', CF_NOEURO, "\xA3", "" }, // british pounds +{ 2, ',', CF_NOEURO, "$", "" }, // us dollars +{ 2, ',', CF_ISEURO, "¤", "" }, // Euro +{ 200, ',', CF_NOEURO, "\xA5", "" }, // yen +{ 57, ',', 2002, "BEF ", "" }, // belgian franc +{ 2, ',', CF_NOEURO,"CHF ", "" }, // swiss franc +{ 480, ',', 2002, "", "Dr." }, // greek drachma +{ 4, '.', 2002, "DM ", "" }, // deutsche mark +{ 10, '.', 2002, "FF ", "" }, // french francs +{ 376, ',', 2002, "", " Ft" }, // forint +{ 50, ',', CF_NOEURO, "", " Kc" }, // czech koruna // TODO: Should use the "c" with an upside down "^" +{ 13, '.', CF_NOEURO, "", " Kr" }, // swedish krona +{ 130, '.', CF_NOEURO, "", " Kr" }, // icelandic krona +{ 11, '.', CF_NOEURO, "", " Kr" }, // norwegian krone +{ 10, '.', CF_NOEURO, "", " kr" }, // danish krone +{ 2730,',', 2002, "", " L." }, // italian lira +{ 6, '.', CF_NOEURO, ""," Lei" }, // romanian Lei +{ 8, ',', 2002, "", " MK" }, // finnish markka +{ 3, ',', 2002, "NLG ", "" }, // dutch gulden +{ 5, ' ', CF_NOEURO, "", " p" }, // russian rouble +{ 200, '.', 2002, "Pts ", "" }, // spanish pesetas +{ 19, ',', 2002, "", " S." }, // austrian schilling +{ 6, ' ', CF_NOEURO, "", " zl" }, // polish zloty +{ 1, ' ', CF_NOEURO, "", "" }, // custom currency }; diff --git a/ttd.c b/ttd.c index 3d7210bc8..725af1505 100644 --- a/ttd.c +++ b/ttd.c @@ -1185,6 +1185,19 @@ void UpdateExclusiveRights() */ } +byte covert_currency[] = { + 0, 1, 12, 8, 3, + 10, 14, 19, 4, 5, + 9, 11, 13, 6, 17, + 16, 22, 21, 7, 15, + 18, 2, 20, }; + +// since savegame version 4.2 the currencies are arranged differently +void UpdateCurrencies() +{ + _opt.currency = covert_currency[_opt.currency]; +} + extern void UpdateOldAircraft(); bool AfterLoadGame(uint version) @@ -1202,6 +1215,11 @@ bool AfterLoadGame(uint version) UpdateExclusiveRights(); } + // from version 4.2 of the savegame, currencies are in a different order + if (version <= 0x401) { + UpdateCurrencies(); + } + // convert road side to my format. if (_opt.road_side) _opt.road_side = 1; -- cgit v1.2.3-54-g00ecf