diff options
author | belugas <belugas@openttd.org> | 2006-09-20 00:34:06 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2006-09-20 00:34:06 +0000 |
commit | b51d58a44c9f8b52db59b842e4309b5eaf4b9c81 (patch) | |
tree | 1e18ce466f13c77758a0b7649707f86edc02fb32 /currency.c | |
parent | 32077448ba40487241b51f84efd1db26e0448e6c (diff) | |
download | openttd-b51d58a44c9f8b52db59b842e4309b5eaf4b9c81.tar.xz |
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
This will not reorder OTTD's currencies, but will make it so that
currencies affected by a grf will be those aimed by the writer.
Diffstat (limited to 'currency.c')
-rw-r--r-- | currency.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/currency.c b/currency.c index 7d2594647..3347d6eb4 100644 --- a/currency.c +++ b/currency.c @@ -44,6 +44,82 @@ const CurrencySpec origin_currency_specs[NUM_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 (grf_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) { |