diff options
author | frosch <frosch@openttd.org> | 2021-01-10 15:12:06 +0100 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2021-01-10 21:24:38 +0100 |
commit | 5b089605606ecbf6d7e9996b49f6cb0605deaa68 (patch) | |
tree | e4b22a637d8d1507d0bf0e34c2771e9a53956589 /src/newgrf_industries.cpp | |
parent | 0078554d6a9df92ce25e07706c4e51143151b2c8 (diff) | |
download | openttd-5b089605606ecbf6d7e9996b49f6cb0605deaa68.tar.xz |
Fix: [NewGRF] industry variables 69 to 71 did not check, whether the queried cargo is valid.
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r-- | src/newgrf_industries.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 6579c5b09..5e59634e8 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -311,6 +311,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout case 0x70: case 0x71: { CargoID cargo = GetCargoTranslation(parameter, this->ro.grffile); + if (cargo == CT_INVALID) return 0; int index = this->industry->GetCargoProducedIndex(cargo); if (index < 0) return 0; // invalid cargo switch (variable) { @@ -329,6 +330,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout case 0x6E: case 0x6F: { CargoID cargo = GetCargoTranslation(parameter, this->ro.grffile); + if (cargo == CT_INVALID) return 0; int index = this->industry->GetCargoAcceptedIndex(cargo); if (index < 0) return 0; // invalid cargo if (variable == 0x6E) return this->industry->last_cargo_accepted_at[index]; |