Codechange: Use IsValidCargoID/IsValidCargoType.

IsValidCargoType() is used only for unmapped IDs.
This commit is contained in:
Peter Nelson
2023-05-04 11:29:21 +01:00
committed by PeterN
parent c4ca6a0f74
commit 76516d7f70
30 changed files with 130 additions and 134 deletions

View File

@@ -316,7 +316,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;
if (!IsValidCargoID(cargo)) return 0;
int index = this->industry->GetCargoProducedIndex(cargo);
if (index < 0) return 0; // invalid cargo
switch (variable) {
@@ -335,7 +335,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;
if (!IsValidCargoID(cargo)) 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];