1
0
Fork 0

Fix #11392: Handle industry exclusivity for neutral stations.

pull/11393/head
Peter Nelson 2023-10-24 14:34:09 +01:00
parent 9cdf66d3a1
commit cdb7c25827
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
4 changed files with 15 additions and 2 deletions

View File

@ -1073,7 +1073,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);

View File

@ -430,6 +430,16 @@ void Station::RemoveFromAllNearbyLists()
for (Industry *i : Industry::Iterate()) { i->stations_near.erase(this); } for (Industry *i : Industry::Iterate()) { i->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

@ -499,6 +499,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

@ -4179,7 +4179,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