(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.

This commit is contained in:
rubidium
2007-07-08 17:40:04 +00:00
parent fd2d677849
commit 283a06e4a1
5 changed files with 57 additions and 15 deletions

View File

@@ -110,3 +110,20 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile)
/* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo);
}
uint8 GetReverseCargoTranslation(CargoID 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 cargo;
const CargoSpec *cs = GetCargo(cargo);
/* If the GRF contains a translation table (and the cargo is in the table)
* then get the cargo ID for the label */
for (uint i = 0; i < grffile->cargo_max; i++) {
if (cs->label == grffile->cargo_list[i]) return i;
}
/* No matching label was found, so we return the 'climate independent' 'bitnum' */
return cs->bitnum;;
}