Changeset - r24633:c06360c1c210
[Not reviewed]
master
0 1 0
frosch - 3 years ago 2021-01-10 14:10:03
frosch@openttd.org
Fix: GetCargoTranslation could return out-of-bounds index for old-style NewGRF using cargo-slots.
1 file changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_cargo.cpp
Show inline comments
 
@@ -91,7 +91,10 @@ uint16 GetCargoCallback(CallbackID callb
 
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
 
{
 
	/* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */
 
	if (grffile->grf_version < 7 && !usebit) return cargo;
 
	if (grffile->grf_version < 7 && !usebit) {
 
		if (cargo >= CargoSpec::GetArraySize() || !CargoSpec::Get(cargo)->IsValid()) return CT_INVALID;
 
		return cargo;
 
	}
 

	
 
	/* Other cases use (possibly translated) cargobits */
 

	
0 comments (0 inline, 0 general)