equal
deleted
inserted
replaced
108 if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); |
108 if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); |
109 |
109 |
110 /* Else the cargo value is a 'climate independent' 'bitnum' */ |
110 /* Else the cargo value is a 'climate independent' 'bitnum' */ |
111 return GetCargoIDByBitnum(cargo); |
111 return GetCargoIDByBitnum(cargo); |
112 } |
112 } |
|
113 |
|
114 uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile) |
|
115 { |
|
116 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
|
117 if (grffile->grf_version < 7) return cargo; |
|
118 |
|
119 const CargoSpec *cs = GetCargo(cargo); |
|
120 |
|
121 /* If the GRF contains a translation table (and the cargo is in the table) |
|
122 * then get the cargo ID for the label */ |
|
123 for (uint i = 0; i < grffile->cargo_max; i++) { |
|
124 if (cs->label == grffile->cargo_list[i]) return i; |
|
125 } |
|
126 |
|
127 /* No matching label was found, so we return the 'climate independent' 'bitnum' */ |
|
128 return cs->bitnum;; |
|
129 } |