~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/currency.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: currency.cpp 11834 2008-01-13 14:37:30Z rubidium $ */
 
1
/* $Id: currency.cpp 15765 2009-03-18 19:50:34Z rubidium $ */
2
2
 
3
 
/** @file currency.cpp **/
 
3
/** @file currency.cpp Support for different currencies. */
4
4
 
5
5
#include "stdafx.h"
6
 
#include "openttd.h"
7
6
#include "currency.h"
8
 
#include "news.h"
 
7
#include "news_func.h"
9
8
#include "settings_type.h"
10
9
#include "date_func.h"
11
10
 
12
11
#include "table/strings.h"
13
12
 
14
 
        //   exchange rate    prefix             symbol_pos
15
 
        //   |  separator        |     postfix   |
16
 
        //   |   |    Euro year  |       |       |    name
17
 
        //   |   |    |          |       |       |    |
 
13
        /*   exchange rate    prefix                      symbol_pos
 
14
         *   |  separator        |           postfix          |
 
15
         *   |   |   Euro year   |              |             | name
 
16
         *   |   |    |          |              |             |  | */
18
17
static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
19
 
        {    1, ',', CF_NOEURO, "£",    "",      0,  STR_CURR_GBP    }, ///< british pounds
20
 
        {    2, ',', CF_NOEURO, "$",    "",      0,  STR_CURR_USD    }, ///< us dollars
21
 
        {    2, ',', CF_ISEURO, "€",    "",      0,  STR_CURR_EUR    }, ///< Euro
22
 
        {  220, ',', CF_NOEURO, "¥",    "",      0,  STR_CURR_YEN    }, ///< yen
23
 
        {   20, ',', 2002,      "",     " S.",   1,  STR_CURR_ATS    }, ///< austrian schilling
24
 
        {   59, ',', 2002,      "BEF ", "",      0,  STR_CURR_BEF    }, ///< belgian franc
25
 
        {    2, ',', CF_NOEURO, "CHF ", "",      0,  STR_CURR_CHF    }, ///< swiss franc
26
 
        {   41, ',', CF_NOEURO, "",     " Kč",   1,  STR_CURR_CZK    }, ///< czech koruna
27
 
        {    3, '.', 2002,      "DM ",  "",      0,  STR_CURR_DEM    }, ///< deutsche mark
28
 
        {   11, '.', CF_NOEURO, "",     " kr",   1,  STR_CURR_DKK    }, ///< danish krone
29
 
        {  245, '.', 2002,      "Pts ", "",      0,  STR_CURR_ESP    }, ///< spanish pesetas
30
 
        {    9, ',', 2002,      "",     " mk",   1,  STR_CURR_FIM    }, ///< finnish markka
31
 
        {   10, '.', 2002,      "FF ",  "",      0,  STR_CURR_FRF    }, ///< french francs
32
 
        {  500, ',', 2002,      "",     "Dr.",   1,  STR_CURR_GRD    }, ///< greek drachma
33
 
        {  378, ',', 2010,      "",     " Ft",   1,  STR_CURR_HUF    }, ///< hungarian forint
34
 
        {  130, '.', CF_NOEURO, "",     " Kr",   1,  STR_CURR_ISK    }, ///< icelandic krona
35
 
        { 2850, ',', 2002,      "",     " L.",   1,  STR_CURR_ITL    }, ///< italian lira
36
 
        {    3, ',', 2002,      "NLG ", "",      0,  STR_CURR_NLG    }, ///< dutch gulden
37
 
        {   12, '.', CF_NOEURO, "",     " Kr",   1,  STR_CURR_NOK    }, ///< norwegian krone
38
 
        {    6, ' ', CF_NOEURO, "",     " zl",   1,  STR_CURR_PLN    }, ///< polish zloty
39
 
        {    5, '.', CF_NOEURO, "",     " Lei",  1,  STR_CURR_ROL    }, ///< romanian Lei
40
 
        {   50, ' ', CF_NOEURO, "",     " p",    1,  STR_CURR_RUR    }, ///< russian rouble
41
 
        {  352, '.', CF_NOEURO, "",     " SIT",  1,  STR_CURR_SIT    }, ///< slovenian tolar
42
 
        {   13, '.', CF_NOEURO, "",     " Kr",   1,  STR_CURR_SEK    }, ///< swedish krona
43
 
        {    3, '.', CF_NOEURO, "",     " YTL",  1,  STR_CURR_YTL    }, ///< turkish lira
44
 
        {   52, ',', CF_NOEURO, "",     " Sk",   1,  STR_CURR_SKK    }, ///< slovak koruna
45
 
        {    4, ',', CF_NOEURO, "R$ ",  "",      0,  STR_CURR_BRR    }, ///< brazil real
46
 
        {    1, ' ', CF_NOEURO, "",     "",      2,  STR_CURR_CUSTOM }, ///< custom currency
 
18
        {    1, ',', CF_NOEURO, "\xC2\xA3",     "",           0, STR_CURR_GBP    }, ///< british pounds
 
19
        {    2, ',', CF_NOEURO, "$",            "",           0, STR_CURR_USD    }, ///< us dollars
 
20
        {    2, ',', CF_ISEURO, "\xE2\x82\xAC", "",           0, STR_CURR_EUR    }, ///< Euro
 
21
        {  220, ',', CF_NOEURO, "\xC2\xA5",     "",           0, STR_CURR_YEN    }, ///< yen
 
22
        {   20, ',', 2002,      "",             " S.",        1, STR_CURR_ATS    }, ///< austrian schilling
 
23
        {   59, ',', 2002,      "BEF ",         "",           0, STR_CURR_BEF    }, ///< belgian franc
 
24
        {    2, ',', CF_NOEURO, "CHF ",         "",           0, STR_CURR_CHF    }, ///< swiss franc
 
25
        {   41, ',', CF_NOEURO, "",             " K\xC4\x8D", 1, STR_CURR_CZK    }, ///< czech koruna
 
26
        {    3, '.', 2002,      "DM ",          "",           0, STR_CURR_DEM    }, ///< deutsche mark
 
27
        {   11, '.', CF_NOEURO, "",             " kr",        1, STR_CURR_DKK    }, ///< danish krone
 
28
        {  245, '.', 2002,      "Pts ",         "",           0, STR_CURR_ESP    }, ///< spanish pesetas
 
29
        {    9, ',', 2002,      "",             " mk",        1, STR_CURR_FIM    }, ///< finnish markka
 
30
        {   10, '.', 2002,      "FF ",          "",           0, STR_CURR_FRF    }, ///< french francs
 
31
        {  500, ',', 2002,      "",             "Dr.",        1, STR_CURR_GRD    }, ///< greek drachma
 
32
        {  378, ',', CF_NOEURO, "",             " Ft",        1, STR_CURR_HUF    }, ///< hungarian forint
 
33
        {  130, '.', CF_NOEURO, "",             " Kr",        1, STR_CURR_ISK    }, ///< icelandic krona
 
34
        { 2850, ',', 2002,      "",             " L.",        1, STR_CURR_ITL    }, ///< italian lira
 
35
        {    3, ',', 2002,      "NLG ",         "",           0, STR_CURR_NLG    }, ///< dutch gulden
 
36
        {   12, '.', CF_NOEURO, "",             " Kr",        1, STR_CURR_NOK    }, ///< norwegian krone
 
37
        {    6, ' ', CF_NOEURO, "",             " zl",        1, STR_CURR_PLN    }, ///< polish zloty
 
38
        {    5, '.', CF_NOEURO, "",             " Lei",       1, STR_CURR_ROL    }, ///< romanian Lei
 
39
        {   50, ' ', CF_NOEURO, "",             " p",         1, STR_CURR_RUR    }, ///< russian rouble
 
40
        {  352, '.', 2007,      "",             " SIT",       1, STR_CURR_SIT    }, ///< slovenian tolar
 
41
        {   13, '.', CF_NOEURO, "",             " Kr",        1, STR_CURR_SEK    }, ///< swedish krona
 
42
        {    3, '.', CF_NOEURO, "",             " TL",        1, STR_CURR_TRY    }, ///< turkish lira
 
43
        {   52, ',', 2009,      "",             " Sk",        1, STR_CURR_SKK    }, ///< slovak koruna
 
44
        {    4, ',', CF_NOEURO, "R$ ",          "",           0, STR_CURR_BRL    }, ///< brazil real
 
45
        {   20, '.', CF_NOEURO, "",             " EEK",       1, STR_CURR_EEK    }, ///< estonian krooni
 
46
        {    1, ' ', CF_NOEURO, "",             "",           2, STR_CURR_CUSTOM }, ///< custom currency
47
47
};
48
48
 
49
49
/* Array of currencies used by the system */
81
81
        CURR_SIT,
82
82
        CURR_SEK,
83
83
        CURR_YTL,
 
84
        CURR_SKK,
 
85
        CURR_BRL,
 
86
        CURR_EEK,
84
87
};
85
88
 
86
89
/**
114
117
 
115
118
/**
116
119
 * Will return the ottd's index correspondance to
117
 
 * the ttdpatch's id.  If the id is bigger then the array,
118
 
 * it is  a grf written for ottd, thus returning the same id.
119
 
 * Only called from newgrf.c
 
120
 * the ttdpatch's id.  If the id is bigger than the array,
 
121
 * it is a grf written for ottd, thus returning the same id.
 
122
 * Only called from newgrf.cpp
120
123
 * @param grfcurr_id currency id coming from newgrf
121
124
 * @return the corrected index
122
125
 **/
150
153
 **/
151
154
void CheckSwitchToEuro()
152
155
{
153
 
        if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
154
 
                        _currency_specs[_opt.currency].to_euro != CF_ISEURO &&
155
 
                        _cur_year >= _currency_specs[_opt.currency].to_euro) {
156
 
                _opt.currency = 2; // this is the index of euro above.
157
 
                AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
 
156
        if (_currency_specs[_settings_game.locale.currency].to_euro != CF_NOEURO &&
 
157
                        _currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO &&
 
158
                        _cur_year >= _currency_specs[_settings_game.locale.currency].to_euro) {
 
159
                _settings_game.locale.currency = 2; // this is the index of euro above.
 
160
                AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0);
158
161
        }
159
162
}
160
163
 
176
179
 * Build a list of currency names StringIDs to use in a dropdown list
177
180
 * @return Pointer to a (static) array of StringIDs
178
181
 */
179
 
StringID* BuildCurrencyDropdown()
 
182
StringID *BuildCurrencyDropdown()
180
183
{
181
184
        /* Allow room for all currencies, plus a terminator entry */
182
185
        static StringID names[NUM_CURRENCY + 1];