1
0
Fork 0
pull/11393/merge
Peter Nelson 2024-11-16 15:10:15 +08:00 committed by GitHub
commit a6165a60ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 5 deletions

View File

@ -1080,7 +1080,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
/* Check if industry temporarily refuses acceptance */ /* Check if industry temporarily refuses acceptance */
if (IndustryTemporarilyRefusesCargo(ind, cargo_type)) continue; if (IndustryTemporarilyRefusesCargo(ind, cargo_type)) continue;
if (ind->exclusive_supplier != INVALID_OWNER && ind->exclusive_supplier != st->owner) continue; if (ind->exclusive_supplier != INVALID_OWNER && ind->exclusive_supplier != st->GetExclusivitySupplier()) continue;
/* Insert the industry into _cargo_delivery_destinations, if not yet contained */ /* Insert the industry into _cargo_delivery_destinations, if not yet contained */
include(_cargo_delivery_destinations, ind); include(_cargo_delivery_destinations, ind);
@ -1644,10 +1644,14 @@ static void LoadUnloadVehicle(Vehicle *front)
StationID last_visited = front->last_station_visited; StationID last_visited = front->last_station_visited;
Station *st = Station::Get(last_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(); StationIDStack next_station = front->GetNextStoppingStation();
bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CARGO_AUTO_REFIT; bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CARGO_AUTO_REFIT;
CargoArray consist_capleft{}; 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) { front->cargo_payment == nullptr : (front->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0) {
ReserveConsist(st, front, ReserveConsist(st, front,
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : nullptr, (use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : nullptr,
@ -1689,7 +1693,7 @@ static void LoadUnloadVehicle(Vehicle *front)
GoodsEntry *ge = &st->goods[v->cargo_type]; 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 cargo_count = v->cargo.UnloadCount();
uint amount_unloaded = _settings_game.order.gradual_loading ? std::min(cargo_count, GetLoadAmount(v)) : cargo_count; 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? bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
@ -1754,7 +1758,7 @@ static void LoadUnloadVehicle(Vehicle *front)
} }
/* Do not pick up goods when we have no-load set or loading is stopped. */ /* 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. */ /* 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) { if (front->current_order.IsRefit() && artic_part == 1) {

View File

@ -438,6 +438,16 @@ void Station::RemoveFromAllNearbyLists()
for (const IndustryID &industryid : industries) { Industry::Get(industryid)->stations_near.erase(this); } for (const IndustryID &industryid : industries) { Industry::Get(industryid)->stations_near.erase(this); }
} }
Owner Station::GetExclusivityConsumer() const
{
return this->industry == nullptr || this->industry->exclusive_consumer == INVALID_OWNER ? this->owner : this->industry->exclusive_consumer;
}
Owner Station::GetExclusivitySupplier() const
{
return this->industry == nullptr || this->industry->exclusive_supplier == INVALID_OWNER ? this->owner : this->industry->exclusive_supplier;
}
/** /**
* Test if the given town ID is covered by our catchment area. * Test if the given town ID is covered by our catchment area.
* This is used when removing a house tile to determine if it was the last house tile * This is used when removing a house tile to determine if it was the last house tile

View File

@ -496,6 +496,9 @@ public:
void RemoveIndustryToDeliver(Industry *ind); void RemoveIndustryToDeliver(Industry *ind);
void RemoveFromAllNearbyLists(); void RemoveFromAllNearbyLists();
Owner GetExclusivityConsumer() const;
Owner GetExclusivitySupplier() const;
inline bool TileIsInCatchment(TileIndex tile) const inline bool TileIsInCatchment(TileIndex tile) const
{ {
return this->catchment_tiles.HasTile(tile); return this->catchment_tiles.HasTile(tile);

View File

@ -4406,7 +4406,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
std::vector<StationInfo> used_stations; std::vector<StationInfo> used_stations;
for (Station *st : *all_stations) { for (Station *st : *all_stations) {
if (exclusivity != INVALID_OWNER && exclusivity != st->owner) continue; if (exclusivity != INVALID_OWNER && exclusivity != st->GetExclusivityConsumer()) continue;
if (!CanMoveGoodsToStation(st, type)) continue; if (!CanMoveGoodsToStation(st, type)) continue;
/* Avoid allocating a vector if there is only one station to significantly /* Avoid allocating a vector if there is only one station to significantly