--- a/src/newgrf_cargo.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/newgrf_cargo.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -94,3 +94,17 @@
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);
+}