Changeset - r19046:7fa5045a9a14
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-02-07 22:46:26
frosch@openttd.org
(svn r23914) -Fix (r11252, r13855): Don't test validity of cargobits using a mask of cargoslots.
1 file changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/newgrf_cargo.cpp
Show inline comments
 
@@ -100,14 +100,22 @@ uint16 GetCargoCallback(CallbackID callb
 
	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,
 
			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;
0 comments (0 inline, 0 general)