summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-03-30 07:13:08 +0000
committerMichael Lutz <michi@icosahedron.de>2021-04-22 22:57:00 +0200
commita05bc04b638020e7faa7d990a8dcc5404e58ea91 (patch)
treeadbd80101781ea10901bdf2f2c8324699279a008 /src/saveload
parentc56fce70b440a95914bf374f68ac045ca97b3610 (diff)
downloadopenttd-a05bc04b638020e7faa7d990a8dcc5404e58ea91.tar.xz
Feature: Per-group wagon removal flag.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp17
-rw-r--r--src/saveload/saveload.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index be6be8de6..d4b230dfd 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -3127,6 +3127,23 @@ bool AfterLoadGame()
}
}
+ if (IsSavegameVersionBefore(SLV_GROUP_REPLACE_WAGON_REMOVAL)) {
+ /* Propagate wagon removal flag for compatibility */
+ /* Temporary bitmask of company wagon removal setting */
+ uint16 wagon_removal = 0;
+ for (const Company *c : Company::Iterate()) {
+ if (c->settings.renew_keep_length) SetBit(wagon_removal, c->index);
+ }
+ for (Group *g : Group::Iterate()) {
+ if (g->flags != 0) {
+ /* Convert old replace_protection value to flag. */
+ g->flags = 0;
+ SetBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION);
+ }
+ if (HasBit(wagon_removal, g->owner)) SetBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
+ }
+ }
+
/* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */
Station::RecomputeCatchmentForAll();
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index 8ad29a640..cda6af82b 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -325,6 +325,7 @@ enum SaveLoadVersion : uint16 {
SLV_VEH_MOTION_COUNTER, ///< 288 PR#8591 Desync safe motion counter
SLV_INDUSTRY_TEXT, ///< 289 PR#8576 v1.11.0-RC1 Additional GS text for industries.
SLV_MAPGEN_SETTINGS_REVAMP, ///< 290 PR#8891 v1.11 Revamp of some mapgen settings (snow coverage, desert coverage, heightmap height, custom terrain type).
+ SLV_GROUP_REPLACE_WAGON_REMOVAL, ///< 291 PR#7441 Per-group wagon removal flag.
SL_MAX_VERSION, ///< Highest possible saveload version
};