summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2019-03-08 18:30:44 +0000
committerGitHub <noreply@github.com>2019-03-08 18:30:44 +0000
commitdd20ccee88a55ed08abb2a47b88cafc7c92a5e81 (patch)
tree98b6230bacf879cab4abd26d4049e4abc237a310 /src/industry_cmd.cpp
parent41563a871b175f3469254d57dc019fda5210f8a9 (diff)
downloadopenttd-dd20ccee88a55ed08abb2a47b88cafc7c92a5e81.tar.xz
Feature: Industries with neutral stations (e.g. Oil Rig) only supply/accept cargo to/from their neutral station. (#7234)
This change is a controlled by a game setting, located under Environment -> Industries which allows toggling the behaviour. It defaults to enabled. "Company stations can serve industries with attached neutral stations" When enabled, industries with attached neutral station (such as Oil Rigs) may also be served by company-owned stations built nearby. This is the traditional behaviour. When disabled, these industries may only be served by their neutral station. Any nearby company-owned stations won't be able to serve them, nor will the neutral station serve anything else other than the industry.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index d918ef16b..ad12e5450 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -517,6 +517,12 @@ static bool TransportIndustryGoods(TileIndex tile)
bool moved_cargo = false;
StationFinder stations(i->location);
+ StationList neutral;
+
+ if (i->neutral_station != NULL && !_settings_game.station.serve_neutral_industries) {
+ /* Industry has a neutral station. Use it and ignore any other nearby stations. */
+ *neutral.Append() = i->neutral_station;
+ }
for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
uint cw = min(i->produced_cargo_waiting[j], 255);
@@ -528,7 +534,7 @@ static bool TransportIndustryGoods(TileIndex tile)
i->this_month_production[j] += cw;
- uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, stations.GetStations());
+ uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, neutral.Length() != 0 ? &neutral : stations.GetStations());
i->this_month_transported[j] += am;
moved_cargo |= (am != 0);