summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp27
-rw-r--r--src/saveload/saveload.cpp2
2 files changed, 25 insertions, 4 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 8116b6d17..d5eb046bc 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -120,7 +120,7 @@ void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_wate
case MP_TREES:
/* trees on shore */
- has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE);
+ has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
break;
default: break;
@@ -1437,8 +1437,8 @@ bool AfterLoadGame()
if (CheckSavegameVersion(81)) {
for (TileIndex t = 0; t < map_size; t++) {
if (GetTileType(t) == MP_TREES) {
- TreeGround groundType = GetTreeGround(t);
- if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3);
+ TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
+ if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
}
}
}
@@ -1976,6 +1976,27 @@ bool AfterLoadGame()
}
}
+ /* The bits for the tree ground and tree density have
+ * been swapped (m2 bits 7..6 and 5..4. */
+ if (CheckSavegameVersion(135)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsTileType(t, MP_CLEAR)) {
+ if (GetRawClearGround(t) == CLEAR_SNOW) {
+ SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
+ SetBit(_m[t].m3, 4);
+ } else {
+ ClrBit(_m[t].m3, 4);
+ }
+ }
+ if (IsTileType(t, MP_TREES)) {
+ uint density = GB(_m[t].m2, 6, 2);
+ uint ground = GB(_m[t].m2, 4, 2);
+ uint counter = GB(_m[t].m2, 0, 4);
+ _m[t].m2 = ground << 6 | density << 4 | counter;
+ }
+ }
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index e7e40c72d..ed899e550 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -47,7 +47,7 @@
#include "saveload_internal.h"
-extern const uint16 SAVEGAME_VERSION = 134;
+extern const uint16 SAVEGAME_VERSION = 135;
SavegameType _savegame_type; ///< type of savegame we are loading