mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
Fix: GetCargoTranslation could return out-of-bounds index for old-style NewGRF using cargo-slots.
This commit is contained in:
parent
63288f80f3
commit
0078554d6a
@ -91,7 +91,10 @@ uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const
|
||||
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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user