From e38719b1b015c0143c42c7b12f6ed028212accff Mon Sep 17 00:00:00 2001 From: HyperJeanJean <75644348+HyperJeanJean@users.noreply.github.com> Date: Sun, 27 Jul 2025 13:22:17 +0200 Subject: [PATCH] Change: Disable electric railway when loading very old save Previous to this change, railways got automatically converted to electric railway if there was any electric locomotive, as electric railways could not be disabled until version 38 --- src/saveload/afterload.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index da1386915f..5e2632432c 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1328,39 +1328,39 @@ bool AfterLoadGame() } } - /* Elrails got added in rev 24 */ + /* Elrails got added in rev 24 but can be disabled since version 38 */ if (IsSavegameVersionBefore(SLV_24)) { - RailType min_rail = RAILTYPE_ELECTRIC; - for (Train *v : Train::Iterate()) { RailType rt = RailVehInfo(v->engine_type)->railtype; v->railtype = rt; - if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; } - /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */ + _settings_game.vehicle.disable_elrails = true; + + /* We update the entire map to keep monorail and maglev in place */ + RailType monorail = (RailType)1; // monorail was 1 before elrails were introduced for (const auto t : Map::Iterate()) { switch (GetTileType(t)) { case MP_RAILWAY: - SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); + SetRailType(t, UpdateRailType(GetRailType(t), monorail)); break; case MP_ROAD: if (IsLevelCrossing(t)) { - SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); + SetRailType(t, UpdateRailType(GetRailType(t), monorail)); } break; case MP_STATION: if (HasStationRail(t)) { - SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); + SetRailType(t, UpdateRailType(GetRailType(t), monorail)); } break; case MP_TUNNELBRIDGE: if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) { - SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); + SetRailType(t, UpdateRailType(GetRailType(t), monorail)); } break; @@ -1369,6 +1369,14 @@ bool AfterLoadGame() } } } + else if (IsSavegameVersionBefore(SLV_38)) { + /* since we cannot know the preference of a user, let elrails enabled; it + * can be disabled manually */ + _settings_game.vehicle.disable_elrails = false; + } + /* do the same as when elrails were enabled/disabled manually just now */ + UpdateDisableElrailSettingState(_settings_game.vehicle.disable_elrails, false); + InitializeRailGUI(); /* In version 16.1 of the savegame a company can decide if trains, which get * replaced, shall keep their old length. In all prior versions, just default @@ -1500,13 +1508,6 @@ bool AfterLoadGame() } } - /* from version 38 we have optional elrails, since we cannot know the - * preference of a user, let elrails enabled; it can be disabled manually */ - if (IsSavegameVersionBefore(SLV_38)) _settings_game.vehicle.disable_elrails = false; - /* do the same as when elrails were enabled/disabled manually just now */ - UpdateDisableElrailSettingState(_settings_game.vehicle.disable_elrails, false); - InitializeRailGUI(); - /* From version 53, the map array was changed for house tiles to allow * space for newhouses grf features. A new byte, m7, was also added. */ if (IsSavegameVersionBefore(SLV_53)) {