From dd20ccee88a55ed08abb2a47b88cafc7c92a5e81 Mon Sep 17 00:00:00 2001 From: PeterN Date: Fri, 8 Mar 2019 18:30:44 +0000 Subject: 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. --- src/saveload/afterload.cpp | 19 +++++++++++++++++++ src/saveload/industry_sl.cpp | 1 + src/saveload/saveload.h | 2 ++ 3 files changed, 22 insertions(+) (limited to 'src/saveload') diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 55552413a..a29635eab 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3085,6 +3085,25 @@ bool AfterLoadGame() _settings_game.economy.town_cargogen_mode = TCGM_ORIGINAL; } + if (IsSavegameVersionBefore(SLV_SERVE_NEUTRAL_INDUSTRIES)) { + /* Ensure the original neutral industry/station behaviour is used */ + _settings_game.station.serve_neutral_industries = true; + + /* Link oil rigs to their industry and back. */ + Station *st; + FOR_ALL_STATIONS(st) { + if (IsTileType(st->xy, MP_STATION) && IsOilRig(st->xy)) { + /* Industry tile is always adjacent during construction by TileDiffXY(0, 1) */ + st->industry = Industry::GetByTile(st->xy + TileDiffXY(0, 1)); + st->industry->neutral_station = st; + } + } + } else { + /* Link neutral station back to industry, as this is not saved. */ + Industry *ind; + FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != NULL) ind->neutral_station->industry = ind; + } + /* Station acceptance is some kind of cache */ if (IsSavegameVersionBefore(SLV_127)) { Station *st; diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 9e81861c4..e5a0b74a3 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -25,6 +25,7 @@ static const SaveLoad _industry_desc[] = { SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16), SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16), SLE_REF(Industry, town, REF_TOWN), + SLE_CONDREF(Industry, neutral_station, REF_STATION, SLV_SERVE_NEUTRAL_INDUSTRIES, SL_MAX_VERSION), SLE_CONDNULL( 2, SL_MIN_VERSION, SLV_61), ///< used to be industry's produced_cargo SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS), SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SL_MAX_VERSION), diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index d881a76c2..331d62d7f 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -294,6 +294,8 @@ enum SaveLoadVersion : uint16 { SLV_TOWN_CARGOGEN, ///< 208 PR#6965 New algorithms for town building cargo generation. SLV_SHIP_CURVE_PENALTY, ///< 209 PR#7289 Configurable ship curve penalties. + SLV_SERVE_NEUTRAL_INDUSTRIES, ///< 210 PR#7234 Company stations can serve industries with attached neutral stations. + SL_MAX_VERSION, ///< Highest possible saveload version }; -- cgit v1.2.3-70-g09d2