Cargo type orders: Add support for 64 cargo types

This commit is contained in:
Jonathan G Rennison
2018-07-02 19:20:59 +01:00
parent 0ae32838ea
commit 00b1fe6246
9 changed files with 39 additions and 38 deletions

View File

@@ -2168,12 +2168,12 @@ void Vehicle::CancelReservation(StationID next, Station *st)
}
}
uint32 Vehicle::GetLastLoadingStationValidCargoMask() const
CargoTypes Vehicle::GetLastLoadingStationValidCargoMask() const
{
if (!HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP)) {
return (this->last_loading_station != INVALID_STATION) ? ~0 : 0;
return (this->last_loading_station != INVALID_STATION) ? ALL_CARGOTYPES : 0;
} else {
uint32 cargo_mask = 0;
CargoTypes cargo_mask = 0;
for (const Vehicle *u = this; u != NULL; u = u->Next()) {
if (u->cargo_type < NUM_CARGO && u->last_loading_station != INVALID_STATION) {
SetBit(cargo_mask, u->cargo_type);
@@ -2197,11 +2197,11 @@ void Vehicle::LeaveStation()
/* Only update the timetable if the vehicle was supposed to stop here. */
if (this->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE) UpdateVehicleTimetable(this, false);
uint32 cargoes_can_load_unload = this->current_order.FilterLoadUnloadTypeCargoMask([&](const Order *o, CargoID cargo) {
CargoTypes cargoes_can_load_unload = this->current_order.FilterLoadUnloadTypeCargoMask([&](const Order *o, CargoID cargo) {
return ((o->GetCargoLoadType(cargo) & OLFB_NO_LOAD) == 0) || ((o->GetCargoUnloadType(cargo) & OUFB_NO_UNLOAD) == 0);
});
uint32 has_cargo_mask = this->GetLastLoadingStationValidCargoMask();
uint32 cargoes_can_leave_with_cargo = FilterCargoMask([&](CargoID cargo) {
CargoTypes has_cargo_mask = this->GetLastLoadingStationValidCargoMask();
CargoTypes cargoes_can_leave_with_cargo = FilterCargoMask([&](CargoID cargo) {
return this->current_order.CanLeaveWithCargo(HasBit(has_cargo_mask, cargo), cargo);
}, cargoes_can_load_unload);
@@ -2214,7 +2214,7 @@ void Vehicle::LeaveStation()
LinkRefresher::Run(this, true, false, cargoes_can_leave_with_cargo);
}
if (cargoes_can_leave_with_cargo == (uint32) ~0) {
if (cargoes_can_leave_with_cargo == ALL_CARGOTYPES) {
/* can leave with all cargoes */
/* if the vehicle could load here or could stop with cargo loaded set the last loading station */