summaryrefslogtreecommitdiff
path: root/src/newgrf_cargo.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-04-13 19:32:18 +0000
committerpeter1138 <peter1138@openttd.org>2007-04-13 19:32:18 +0000
commited8a66e3d187f95cfe026cf797839e5db631a620 (patch)
tree78427100f591828f22b4bf1543e50769733875e1 /src/newgrf_cargo.cpp
parent5775fb475f27a7c32f6f697a047ca9f6c7be45c0 (diff)
downloadopenttd-ed8a66e3d187f95cfe026cf797839e5db631a620.tar.xz
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
Diffstat (limited to 'src/newgrf_cargo.cpp')
-rw-r--r--src/newgrf_cargo.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index c09cb10d2..788e2fbe5 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -94,3 +94,17 @@ uint16 GetCargoCallback(uint16 callback, uint32 param1, uint32 param2, const Car
return group->g.callback.result;
}
+
+
+CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile)
+{
+ /* 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);
+}