diff options
-rw-r--r-- | src/newgrf_cargo.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index 9847a72c1..da463d4ff 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -100,14 +100,22 @@ uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const return group->GetCallbackResult(); } - +/** + * Translate a GRF-local cargo slot/bitnum into a CargoID. + * @param cargo GRF-local cargo slot/bitnum. + * @param grffile Originating GRF file. + * @param usebit Defines the meaning of \a cargo for GRF version < 7. + * If true, then \a cargo is a bitnum. If false, then \a cargo is a cargoslot. + * For GRF version >= 7 \a cargo is always a translated cargo bit. + * @return CargoID or CT_INVALID if the cargo is not available. + */ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) { /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ if (grffile->grf_version < 7) { if (!usebit) return cargo; /* Else the cargo value is a 'climate independent' 'bitnum' */ - if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo); + return GetCargoIDByBitnum(cargo); } else { /* If the GRF contains a translation table... */ if (grffile->cargo_max > 0) { @@ -116,7 +124,7 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); } else { /* Else the cargo value is a 'climate independent' 'bitnum' */ - if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo); + return GetCargoIDByBitnum(cargo); } } return CT_INVALID; |