summaryrefslogtreecommitdiff
path: root/src/cargotype.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
commit59399480b3af919eea479b1dd3e2ee69dcd0bc5a (patch)
tree78427100f591828f22b4bf1543e50769733875e1 /src/cargotype.cpp
parent39735f7b549d256e32b64ab837d15aaba6a82885 (diff)
downloadopenttd-59399480b3af919eea479b1dd3e2ee69dcd0bc5a.tar.xz
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r--src/cargotype.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp
index bea8edd65..6d8a2ca63 100644
--- a/src/cargotype.cpp
+++ b/src/cargotype.cpp
@@ -71,3 +71,21 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
/* No matching label was found, so it is invalid */
return CT_INVALID;
}
+
+
+/** Find the CargoID of a 'bitnum' value.
+ * @param bitnum 'bitnum' to find.
+ * @return First CargoID with the given bitnum, or CT_INVALID if not found.
+ */
+CargoID GetCargoIDByBitnum(uint8 bitnum)
+{
+ if (bitnum == INVALID_CARGO) return CT_INVALID;
+
+ for (CargoID c = 0; c < lengthof(_cargo); c++) {
+ if (_cargo[c].bitnum == bitnum) return c;
+ }
+
+ /* No matching label was found, so it is invalid */
+ return CT_INVALID;
+}
+