From b1a3a31a8389aa90fc42c81e7b8cf7df0d7b7b31 Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 7 Feb 2012 22:46:26 +0000 Subject: (svn r23914) -Fix (r11252, r13855): Don't test validity of cargobits using a mask of cargoslots. --- src/newgrf_cargo.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-54-g00ecf