summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuXarick <43006711+SamuXarick@users.noreply.github.com>2019-02-21 21:23:37 +0000
committerPeterN <peter@fuzzle.org>2019-02-21 21:23:37 +0000
commit456e67ac1c52431f9b7ae4d15f8188b94b2daea6 (patch)
treed34aed778d4acfb031030d8ac0e1669bd833c244 /src
parent673f6753e9428a8ded6343f60c0fd74681dd5e6a (diff)
downloadopenttd-456e67ac1c52431f9b7ae4d15f8188b94b2daea6.tar.xz
Change: Owner of vehicle with exclusive transport rights may now load cargo from neutral stations (#7256)
Diffstat (limited to 'src')
-rw-r--r--src/economy.cpp15
-rw-r--r--src/station_cmd.cpp2
2 files changed, 14 insertions, 3 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 97283ae44..74c4cf079 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1518,6 +1518,17 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
cur_company.Restore();
}
+/**
+ * Test whether a vehicle can load cargo at a station even if exclusive transport rights are present.
+ * @param st Station with cargo waiting to be loaded.
+ * @param v Vehicle loading the cargo.
+ * @return true when a vehicle can load the cargo.
+ */
+static bool MayLoadUnderExclusiveRights(const Station *st, const Vehicle *v)
+{
+ return st->owner != OWNER_NONE || st->town->exclusive_counter == 0 || st->town->exclusivity == v->owner;
+}
+
struct ReserveCargoAction {
Station *st;
StationIDStack *next_station;
@@ -1527,7 +1538,7 @@ struct ReserveCargoAction {
bool operator()(Vehicle *v)
{
- if (v->cargo_cap > v->cargo.RemainingCount()) {
+ if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
&v->cargo, st->xy, *next_station);
}
@@ -1751,7 +1762,7 @@ static void LoadUnloadVehicle(Vehicle *front)
/* If there's goods waiting at the station, and the vehicle
* has capacity for it, load it on the vehicle. */
uint cap_left = v->cargo_cap - v->cargo.StoredCount();
- if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0)) {
+ if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0) && MayLoadUnderExclusiveRights(st, v)) {
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
if (_settings_game.order.gradual_loading) cap_left = min(cap_left, GetLoadAmount(v));
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 6be22de0c..e6864d70d 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3853,7 +3853,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
Station *st = *st_iter;
/* Is the station reserved exclusively for somebody else? */
- if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
+ if (st->owner != OWNER_NONE && st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore