summaryrefslogtreecommitdiff
path: root/src/newgrf_cargo.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2007-10-13 02:23:11 +0000
committerglx <glx@openttd.org>2007-10-13 02:23:11 +0000
commitac9f287f205d561dd863649abe67f9b2b764ffc2 (patch)
treebf1a8fa343d89f308517e78ca707b1847cda4ffe /src/newgrf_cargo.cpp
parent63f54c43b3ec8ad83c7b9e0303139e3b100100bf (diff)
downloadopenttd-ac9f287f205d561dd863649abe67f9b2b764ffc2.tar.xz
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
Diffstat (limited to 'src/newgrf_cargo.cpp')
-rw-r--r--src/newgrf_cargo.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index 1a731b835..e9323f930 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -98,17 +98,19 @@ uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const
}
-CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile)
+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) return HASBIT(_cargo_mask, cargo) ? cargo : (CargoID) CT_INVALID;
-
- /* If the GRF contains a translation table (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 the cargo value is a 'climate independent' 'bitnum' */
- return GetCargoIDByBitnum(cargo);
+ if (grffile->grf_version < 7) {
+ if (!usebit) return cargo;
+ /* Else the cargo value is a 'climate independent' 'bitnum' */
+ if (HASBIT(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
+ } else {
+ /* If the GRF contains a translation table (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]);
+ }
+ return CT_INVALID;
}
uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile)