diff --git a/src/economy.cpp b/src/economy.cpp index b478882f45..d6817cd1ca 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1635,10 +1635,14 @@ static void LoadUnloadVehicle(Vehicle *front) StationID last_visited = front->last_station_visited; Station *st = Station::Get(last_visited); + /* If this is a neutral station, check its industry for exclusivity. */ + bool can_load = front->owner == st->GetExclusivityConsumer(); + bool can_unload = front->owner == st->GetExclusivitySupplier(); + StationIDStack next_station = front->GetNextStoppingStation(); bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CT_AUTO_REFIT; CargoArray consist_capleft{}; - if (_settings_game.order.improved_load && use_autorefit ? + if (can_load && _settings_game.order.improved_load && use_autorefit ? front->cargo_payment == nullptr : (front->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0) { ReserveConsist(st, front, (use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : nullptr, @@ -1680,7 +1684,7 @@ static void LoadUnloadVehicle(Vehicle *front) GoodsEntry *ge = &st->goods[v->cargo_type]; - if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) { + if (can_unload && HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) { uint cargo_count = v->cargo.UnloadCount(); uint amount_unloaded = _settings_game.order.gradual_loading ? std::min(cargo_count, GetLoadAmount(v)) : cargo_count; bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here? @@ -1747,7 +1751,7 @@ static void LoadUnloadVehicle(Vehicle *front) } /* Do not pick up goods when we have no-load set or loading is stopped. */ - if (front->current_order.GetLoadType() & OLFB_NO_LOAD || HasBit(front->vehicle_flags, VF_STOP_LOADING)) continue; + if (!can_load || front->current_order.GetLoadType() & OLFB_NO_LOAD || HasBit(front->vehicle_flags, VF_STOP_LOADING)) continue; /* This order has a refit, if this is the first vehicle part carrying cargo and the whole vehicle is empty, try refitting. */ if (front->current_order.IsRefit() && artic_part == 1) {