Files
@ r5388:b83fe4735739
Branch filter:
Location: cpp/openttd-patchpack/source/currency.c - annotation
r5388:b83fe4735739
5.7 KiB
text/x-c
(svn r7577) -Fix (r7565): Missed out some OSX files (Bjarni)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2306:83bf5acd9e01 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r4261:8c2d0c75e37a r2291:d8cfcbdcaa29 r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r5023:2a3f1edb013a r5108:28640689af54 r4377:af32a089870e r5108:28640689af54 r5108:28640689af54 r5092:1c1376e5051a r5092:1c1376e5051a r4377:af32a089870e r5108:28640689af54 r5092:1c1376e5051a r5092:1c1376e5051a r5092:1c1376e5051a r5092:1c1376e5051a r4377:af32a089870e r5092:1c1376e5051a r5092:1c1376e5051a r4377:af32a089870e r5092:1c1376e5051a r4377:af32a089870e r5092:1c1376e5051a r4377:af32a089870e r5092:1c1376e5051a r5092:1c1376e5051a r5092:1c1376e5051a r4377:af32a089870e r5092:1c1376e5051a r5092:1c1376e5051a r5092:1c1376e5051a r4602:a4d40440a037 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r4377:af32a089870e r4377:af32a089870e r2291:d8cfcbdcaa29 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4625:03dda9081db6 r4626:5bce4eb15edb r4625:03dda9081db6 r4625:03dda9081db6 r4377:af32a089870e r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r4377:af32a089870e r4297:03b852eaea64 r2291:d8cfcbdcaa29 r4293:cbb984a32af5 r4293:cbb984a32af5 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r3596:700022cb5115 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r2291:d8cfcbdcaa29 r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r2306:83bf5acd9e01 r2306:83bf5acd9e01 r2306:83bf5acd9e01 r2306:83bf5acd9e01 r4293:cbb984a32af5 r2306:83bf5acd9e01 r2306:83bf5acd9e01 r2306:83bf5acd9e01 r2306:83bf5acd9e01 r4138:2157fb419ffa r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e r4377:af32a089870e | /* $Id$ */
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
#include "news.h"
#include "variables.h"
#include "table/strings.h"
#include "date.h"
// exchange rate prefix symbol_pos
// | separator | postfix |
// | | Euro year | | | name
// | | | | | | |
static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
{ 1, ',', CF_NOEURO, "£", "", 0, STR_CURR_GBP }, // british pounds
{ 2, ',', CF_NOEURO, "$", "", 0, STR_CURR_USD }, // us dollars
{ 2, ',', CF_ISEURO, "€", "", 0, STR_CURR_EUR }, // Euro
{ 220, ',', CF_NOEURO, "¥", "", 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č", 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, ',', 2010, "", " 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_ROL }, // romanian Lei
{ 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, // russian rouble
{ 352, '.', CF_NOEURO, "", " SIT", 1, STR_CURR_SIT }, // slovenian tolar
{ 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, // swedish krona
{ 3, '.', CF_NOEURO, "", " YTL", 1, STR_CURR_YTL }, // turkish lira
{ 52, ',', CF_NOEURO, "", " Sk", 1, STR_CURR_SKK }, // slovak koruna
{ 4, ',', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRR }, // brazil real
{ 1, ' ', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, // custom currency
};
/* Array of currencies used by the system */
CurrencySpec _currency_specs[NUM_CURRENCY];
/**
* These enums are only declared in order to make sens
* out of the TTDPatch_To_OTTDIndex array that will follow
* Every currency used by Ottd is there, just in case TTDPatch will
* add those missing in its code
**/
enum {
CURR_GBP,
CURR_USD,
CURR_EUR,
CURR_YEN,
CURR_ATS,
CURR_BEF,
CURR_CHF,
CURR_CZK,
CURR_DEM,
CURR_DKK,
CURR_ESP,
CURR_FIM,
CURR_FRF,
CURR_GRD,
CURR_HUF,
CURR_ISK,
CURR_ITL,
CURR_NLG,
CURR_NOK,
CURR_PLN,
CURR_ROL,
CURR_RUR,
CURR_SIT,
CURR_SEK,
CURR_YTL,
};
/**
* This array represent the position of OpenTTD's currencies,
* compared to TTDPatch's ones.
* When a grf sends currencies, they are based on the order defined by TTDPatch.
* So, we must reindex them to our own order.
**/
const byte TTDPatch_To_OTTDIndex[] =
{
CURR_GBP,
CURR_USD,
CURR_FRF,
CURR_DEM,
CURR_YEN,
CURR_ESP,
CURR_HUF,
CURR_PLN,
CURR_ATS,
CURR_BEF,
CURR_DKK,
CURR_FIM,
CURR_GRD,
CURR_CHF,
CURR_NLG,
CURR_ITL,
CURR_SEK,
CURR_RUR,
CURR_EUR,
};
/**
* Will return the ottd's index correspondance to
* the ttdpatch's id. If the id is bigger then the array,
* it is a grf written for ottd, thus returning the same id.
* Only called from newgrf.c
* @param grfcurr_id currency id coming from newgrf
* @return the corrected index
**/
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id)
{
return (grfcurr_id >= lengthof(TTDPatch_To_OTTDIndex)) ? grfcurr_id : TTDPatch_To_OTTDIndex[grfcurr_id];
}
/* get a mask of the allowed currencies depending on the year */
uint GetMaskOfAllowedCurrencies(void)
{
uint mask = 0;
uint i;
for (i = 0; i < NUM_CURRENCY; i++) {
Year to_euro = _currency_specs[i].to_euro;
if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro) continue;
if (to_euro == CF_ISEURO && _cur_year < 2000) continue;
mask |= (1 << i);
}
mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency
return mask;
}
/**
* Verify if the currency chosen by the user is about to be converted to Euro
**/
void CheckSwitchToEuro(void)
{
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) {
_opt.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
}
}
/**
* Called only from newgrf.c. Will fill _currency_specs array with
* default values from origin_currency_specs
**/
void ResetCurrencies(void)
{
memcpy(&_currency_specs, &origin_currency_specs, sizeof(origin_currency_specs));
}
/**
* Build a list of currency names StringIDs to use in a dropdown list
* @return Pointer to a (static) array of StringIDs
*/
StringID* BuildCurrencyDropdown(void)
{
/* Allow room for all currencies, plus a terminator entry */
static StringID names[CUSTOM_CURRENCY_ID];
uint i;
/* Add each name */
for (i = 0; i < NUM_CURRENCY; i++) {
names[i] = _currency_specs[i].name;
}
/* Terminate the list */
names[i] = INVALID_STRING_ID;
return names;
}
|