mirror of https://github.com/OpenTTD/OpenTTD
Add: [NewGRF] Vehicle prop that allows refittability based on cargo class intersection.
parent
c39810ff6a
commit
a3ee05737f
|
@ -320,8 +320,9 @@ struct GRFTempEngineData {
|
||||||
NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle.
|
NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle.
|
||||||
};
|
};
|
||||||
|
|
||||||
CargoClasses cargo_allowed;
|
CargoClasses cargo_allowed; ///< Bitmask of cargo classes that are allowed as a refit.
|
||||||
CargoClasses cargo_disallowed;
|
CargoClasses cargo_allowed_required; ///< Bitmask of cargo classes that are required to be all present to allow a cargo as a refit.
|
||||||
|
CargoClasses cargo_disallowed; ///< Bitmask of cargo classes that are disallowed as a refit.
|
||||||
RailTypeLabel railtypelabel;
|
RailTypeLabel railtypelabel;
|
||||||
uint8_t roadtramtype;
|
uint8_t roadtramtype;
|
||||||
const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'.
|
const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'.
|
||||||
|
@ -1336,6 +1337,10 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x32: // Cargo classes required for a refit.
|
||||||
|
_gted[e->index].cargo_allowed_required = buf.ReadWord();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
||||||
break;
|
break;
|
||||||
|
@ -1537,6 +1542,10 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x29: // Cargo classes required for a refit.
|
||||||
|
_gted[e->index].cargo_allowed_required = buf.ReadWord();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
||||||
break;
|
break;
|
||||||
|
@ -1724,6 +1733,10 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
svi->acceleration = std::max<uint8_t>(1, buf.ReadByte());
|
svi->acceleration = std::max<uint8_t>(1, buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x25: // Cargo classes required for a refit.
|
||||||
|
_gted[e->index].cargo_allowed_required = buf.ReadWord();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
||||||
break;
|
break;
|
||||||
|
@ -1889,6 +1902,10 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
|
||||||
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
SB(ei->callback_mask, 8, 8, buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x23: // Cargo classes required for a refit.
|
||||||
|
_gted[e->index].cargo_allowed_required = buf.ReadWord();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
ret = CommonVehicleChangeInfo(ei, prop, buf);
|
||||||
break;
|
break;
|
||||||
|
@ -9084,7 +9101,7 @@ static void CalculateRefitMasks()
|
||||||
if (_gted[engine].cargo_allowed != 0) {
|
if (_gted[engine].cargo_allowed != 0) {
|
||||||
/* Build up the list of cargo types from the set cargo classes. */
|
/* Build up the list of cargo types from the set cargo classes. */
|
||||||
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
||||||
if (_gted[engine].cargo_allowed & cs->classes) SetBit(mask, cs->Index());
|
if ((_gted[engine].cargo_allowed & cs->classes) != 0 && (_gted[engine].cargo_allowed_required & cs->classes) == _gted[engine].cargo_allowed_required) SetBit(mask, cs->Index());
|
||||||
if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, cs->Index());
|
if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, cs->Index());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue