mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-07-19 10:26:27 +01:00
(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.
This commit is contained in:
parent
32077448ba
commit
b51d58a44c
76
currency.c
76
currency.c
@ -44,6 +44,82 @@ const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
|
|||||||
/* Array of currencies used by the system */
|
/* Array of currencies used by the system */
|
||||||
CurrencySpec _currency_specs[NUM_CURRENCY];
|
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 */
|
/* get a mask of the allowed currencies depending on the year */
|
||||||
uint GetMaskOfAllowedCurrencies(void)
|
uint GetMaskOfAllowedCurrencies(void)
|
||||||
{
|
{
|
||||||
|
@ -40,5 +40,6 @@ uint GetMaskOfAllowedCurrencies(void);
|
|||||||
void CheckSwitchToEuro(void);
|
void CheckSwitchToEuro(void);
|
||||||
void ResetCurrencies(void);
|
void ResetCurrencies(void);
|
||||||
StringID* BuildCurrencyDropdown(void);
|
StringID* BuildCurrencyDropdown(void);
|
||||||
|
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
|
||||||
|
|
||||||
#endif /* CURRENCY_H */
|
#endif /* CURRENCY_H */
|
||||||
|
12
newgrf.c
12
newgrf.c
@ -1090,7 +1090,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0A: // Currency display names
|
case 0x0A: // Currency display names
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid + i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf));
|
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf));
|
||||||
|
|
||||||
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) {
|
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) {
|
||||||
@ -1101,7 +1101,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0B: // Currency multipliers
|
case 0x0B: // Currency multipliers
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid + i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
uint32 rate = grf_load_dword(&buf);
|
uint32 rate = grf_load_dword(&buf);
|
||||||
|
|
||||||
if (curidx < NUM_CURRENCY) {
|
if (curidx < NUM_CURRENCY) {
|
||||||
@ -1117,7 +1117,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0C: // Currency options
|
case 0x0C: // Currency options
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid +i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
uint16 options = grf_load_word(&buf);
|
uint16 options = grf_load_word(&buf);
|
||||||
|
|
||||||
if (curidx < NUM_CURRENCY) {
|
if (curidx < NUM_CURRENCY) {
|
||||||
@ -1133,7 +1133,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0D: // Currency prefix symbol
|
case 0x0D: // Currency prefix symbol
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid +i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
uint32 tempfix = grf_load_dword(&buf);
|
uint32 tempfix = grf_load_dword(&buf);
|
||||||
|
|
||||||
if (curidx < NUM_CURRENCY) {
|
if (curidx < NUM_CURRENCY) {
|
||||||
@ -1147,7 +1147,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0E: // Currency suffix symbol
|
case 0x0E: // Currency suffix symbol
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid +i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
uint32 tempfix = grf_load_dword(&buf);
|
uint32 tempfix = grf_load_dword(&buf);
|
||||||
|
|
||||||
if (curidx < NUM_CURRENCY) {
|
if (curidx < NUM_CURRENCY) {
|
||||||
@ -1161,7 +1161,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
|
|||||||
|
|
||||||
case 0x0F: // Euro introduction dates
|
case 0x0F: // Euro introduction dates
|
||||||
FOR_EACH_OBJECT {
|
FOR_EACH_OBJECT {
|
||||||
uint curidx = gvid +i;
|
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
|
||||||
Year year_euro = grf_load_word(&buf);
|
Year year_euro = grf_load_word(&buf);
|
||||||
|
|
||||||
if (curidx < NUM_CURRENCY) {
|
if (curidx < NUM_CURRENCY) {
|
||||||
|
Loading…
Reference in New Issue
Block a user