(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65

This commit is contained in:
2007-04-13 19:32:18 +00:00
parent 39735f7b54
commit 59399480b3
5 changed files with 54 additions and 6 deletions

View File

@@ -94,3 +94,17 @@ uint16 GetCargoCallback(uint16 callback, uint32 param1, uint32 param2, const Car
return group->g.callback.result;
}
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile)
{
/* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */
if (grffile->grf_version < 7) return HASBIT(_cargo_mask, cargo) ? cargo : (CargoID) CT_INVALID;
/* If the GRF contains a translation table (and the cargo is in bounds)
* then get the cargo ID for the label */
if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
/* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo);
}