tron@2186: /* $Id$ */ tron@2186: tron@2291: #include "stdafx.h" tron@2291: #include "openttd.h" tron@2291: #include "currency.h" tron@2306: #include "news.h" tron@2291: #include "variables.h" tron@2291: #include "table/strings.h" tron@2291: dominik@762: // exchange rate prefix dominik@762: // | separator | postfix dominik@762: // | | Euro year | | dominik@762: // | | | | | dominik@759: CurrencySpec _currency_specs[] = { tron@2291: { 1, ',', CF_NOEURO, "\xA3", "" }, // british pounds tron@2291: { 2, ',', CF_NOEURO, "$", "" }, // us dollars tron@2291: { 2, ',', CF_ISEURO, "¤", "" }, // Euro tron@2291: { 200, ',', CF_NOEURO, "\xA5", "" }, // yen tron@2291: { 19, ',', 2002, "", " S." }, // austrian schilling tron@2291: { 57, ',', 2002, "BEF ", "" }, // belgian franc tron@2291: { 2, ',', CF_NOEURO, "CHF ", "" }, // swiss franc tron@2291: { 50, ',', CF_NOEURO, "", " Kc" }, // czech koruna // TODO: Should use the "c" with an upside down "^" tron@2291: { 4, '.', 2002, "DM ", "" }, // deutsche mark tron@2291: { 10, '.', CF_NOEURO, "", " kr" }, // danish krone tron@2291: { 200, '.', 2002, "Pts ", "" }, // spanish pesetas tron@2495: { 8, ',', 2002, "", " mk" }, // finnish markka tron@2291: { 10, '.', 2002, "FF ", "" }, // french francs tron@2291: { 480, ',', 2002, "", "Dr." }, // greek drachma tron@2291: { 376, ',', 2002, "", " Ft" }, // hungarian forint tron@2291: { 130, '.', CF_NOEURO, "", " Kr" }, // icelandic krona tron@2291: { 2730, ',', 2002, "", " L." }, // italian lira tron@2291: { 3, ',', 2002, "NLG ", "" }, // dutch gulden tron@2291: { 11, '.', CF_NOEURO, "", " Kr" }, // norwegian krone tron@2291: { 6, ' ', CF_NOEURO, "", " zl" }, // polish zloty tron@2291: { 6, '.', CF_NOEURO, "", " Lei" }, // romanian Lei tron@2291: { 5, ' ', CF_NOEURO, "", " p" }, // russian rouble tron@2291: { 13, '.', CF_NOEURO, "", " Kr" }, // swedish krona tron@2291: { 1, ' ', CF_NOEURO, "", "" }, // custom currency dominik@759: }; dominik@768: tron@2291: const StringID _currency_string_list[] = { tron@2291: STR_CURR_GBP, tron@2291: STR_CURR_USD, tron@2291: STR_CURR_EUR, tron@2291: STR_CURR_YEN, tron@2291: STR_CURR_ATS, tron@2291: STR_CURR_BEF, tron@2291: STR_CURR_CHF, tron@2291: STR_CURR_CZK, tron@2291: STR_CURR_DEM, tron@2291: STR_CURR_DKK, tron@2291: STR_CURR_ESP, tron@2291: STR_CURR_FIM, tron@2291: STR_CURR_FRF, tron@2291: STR_CURR_GRD, tron@2291: STR_CURR_HUF, tron@2291: STR_CURR_ISK, tron@2291: STR_CURR_ITL, tron@2291: STR_CURR_NLG, tron@2291: STR_CURR_NOK, tron@2291: STR_CURR_PLN, tron@2291: STR_CURR_ROL, tron@2291: STR_CURR_RUR, tron@2291: STR_CURR_SEK, tron@2291: STR_CURR_CUSTOM, tron@2291: INVALID_STRING_ID tron@2291: }; tron@2291: tron@2291: // NOTE: Make sure both lists are in the same order tron@2291: // + 1 string list terminator tron@2291: assert_compile(lengthof(_currency_specs) + 1 == lengthof(_currency_string_list)); tron@2291: tron@2291: tron@2291: // get a mask of the allowed currencies depending on the year tron@2291: uint GetMaskOfAllowedCurrencies(void) tron@2291: { tron@2291: uint mask = 0; tron@2291: uint i; tron@2291: tron@2291: for (i = 0; i != lengthof(_currency_specs); i++) { tron@2291: uint16 to_euro = _currency_specs[i].to_euro; tron@2291: tron@2291: if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro - MAX_YEAR_BEGIN_REAL) continue; tron@2291: if (to_euro == CF_ISEURO && _cur_year < 2000 - MAX_YEAR_BEGIN_REAL) continue; tron@2291: mask |= (1 << i); tron@2291: } tron@2291: mask |= (1 << 23); // always allow custom currency tron@2291: return mask; tron@2291: } tron@2291: tron@2291: tron@2306: void CheckSwitchToEuro(void) tron@2306: { tron@2306: if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && tron@2306: _currency_specs[_opt.currency].to_euro != CF_ISEURO && tron@2306: MAX_YEAR_BEGIN_REAL + _cur_year >= _currency_specs[_opt.currency].to_euro) { tron@2306: _opt.currency = 2; // this is the index of euro above. tron@2306: AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0); tron@2306: } tron@2306: }