diff options
author | frosch <frosch@openttd.org> | 2012-02-08 18:11:49 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-02-08 18:11:49 +0000 |
commit | b42fa8f76646933cd769dfd29377047cabb97b1d (patch) | |
tree | 4e11075d0450274d7d96f24db96f2db0f5eb9903 /src | |
parent | d5bc5ddd002dafcc9c012979bd79e906b603631b (diff) | |
download | openttd-b42fa8f76646933cd769dfd29377047cabb97b1d.tar.xz |
(svn r23917) -Fix (r11252,, r23914, r23915): Also use the CTT for refitmasks for version 6 GRFs. I.e. fix the cursed GetCargoTranslation() function for the fourth time.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_cargo.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index da463d4ff..85f203a33 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -111,21 +111,18 @@ uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const */ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) { - /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ - if (grffile->grf_version < 7) { - if (!usebit) return cargo; + /* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */ + if (grffile->grf_version < 7 && !usebit) return cargo; + + /* Other cases use (possibly translated) cargobits */ + + if (grffile->cargo_max > 0) { + /* ...and the cargo is in bounds, then get the cargo ID for + * the label */ + if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); + } else { /* Else the cargo value is a 'climate independent' 'bitnum' */ return GetCargoIDByBitnum(cargo); - } else { - /* If the GRF contains a translation table... */ - if (grffile->cargo_max > 0) { - /* ...and the cargo is in bounds, then get the cargo ID for - * the label */ - if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); - } else { - /* Else the cargo value is a 'climate independent' 'bitnum' */ - return GetCargoIDByBitnum(cargo); - } } return CT_INVALID; } |