96 |
96 |
97 return group->g.callback.result; |
97 return group->g.callback.result; |
98 } |
98 } |
99 |
99 |
100 |
100 |
101 CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile) |
101 CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) |
102 { |
102 { |
103 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
103 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
104 if (grffile->grf_version < 7) return HASBIT(_cargo_mask, cargo) ? cargo : (CargoID) CT_INVALID; |
104 if (grffile->grf_version < 7) { |
105 |
105 if (!usebit) return cargo; |
106 /* If the GRF contains a translation table (and the cargo is in bounds) |
106 /* Else the cargo value is a 'climate independent' 'bitnum' */ |
107 * then get the cargo ID for the label */ |
107 if (HASBIT(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo); |
108 if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); |
108 } else { |
109 |
109 /* If the GRF contains a translation table (and the cargo is in bounds) |
110 /* Else the cargo value is a 'climate independent' 'bitnum' */ |
110 * then get the cargo ID for the label */ |
111 return GetCargoIDByBitnum(cargo); |
111 if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); |
|
112 } |
|
113 return CT_INVALID; |
112 } |
114 } |
113 |
115 |
114 uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile) |
116 uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile) |
115 { |
117 { |
116 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
118 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |