summaryrefslogtreecommitdiff
path: root/src/newgrf_cargo.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-08 17:40:04 +0000
committerrubidium <rubidium@openttd.org>2007-07-08 17:40:04 +0000
commit283a06e4a195fabea413c55e236586a880c794f6 (patch)
treee8b08f0eebf44557962f1210eb8b7887d9d999bf /src/newgrf_cargo.cpp
parentfd2d67784911fc545883f3911790ecc38d43e0e0 (diff)
downloadopenttd-283a06e4a195fabea413c55e236586a880c794f6.tar.xz
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
Diffstat (limited to 'src/newgrf_cargo.cpp')
-rw-r--r--src/newgrf_cargo.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index 6724edb53..ff9a633bc 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -110,3 +110,20 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile)
/* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo);
}
+
+uint8 GetReverseCargoTranslation(CargoID 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 cargo;
+
+ const CargoSpec *cs = GetCargo(cargo);
+
+ /* If the GRF contains a translation table (and the cargo is in the table)
+ * then get the cargo ID for the label */
+ for (uint i = 0; i < grffile->cargo_max; i++) {
+ if (cs->label == grffile->cargo_list[i]) return i;
+ }
+
+ /* No matching label was found, so we return the 'climate independent' 'bitnum' */
+ return cs->bitnum;;
+}