src/cargotype.cpp
branchgamebalance
changeset 9908 0fa543611bbe
parent 9906 6f41b8713b65
child 9624 b71483f2330f
--- a/src/cargotype.cpp	Thu Apr 19 14:48:10 2007 +0000
+++ b/src/cargotype.cpp	Tue Jun 12 11:56:35 2007 +0000
@@ -71,3 +71,21 @@
 	/* 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;
+}
+