From 76e77aefada54d1a0dbf7e4b7fb12a9c5f3cb838 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 24 Mar 2019 00:12:31 +0000 Subject: Fix #7400: Water class for tree tiles was not converted for old saves preventing industry creation. As the information is always available from the tree ground type, unconditionally update the map array for tree tiles. --- src/saveload/afterload.cpp | 7 +++++++ src/tree_map.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 6f32c5506..f94063265 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3111,6 +3111,13 @@ bool AfterLoadGame() FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != NULL) ind->neutral_station->industry = ind; } + { + /* Update water class for trees for all current savegame versions. */ + for (TileIndex t = 0; t < map_size; t++) { + if (IsTileType(t, MP_TREES)) SetWaterClass(t, GetTreeGround(t) == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID); + } + } + /* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */ Station::RecomputeCatchmentForAll(); diff --git a/src/tree_map.h b/src/tree_map.h index df9fd441c..bd1567b54 100644 --- a/src/tree_map.h +++ b/src/tree_map.h @@ -277,6 +277,7 @@ static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, { SetTileType(t, MP_TREES); SetTileOwner(t, OWNER_NONE); + SetWaterClass(t, ground == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID); _m[t].m2 = ground << 6 | density << 4 | 0; _m[t].m3 = type; _m[t].m4 = 0 << 5 | 0 << 2; -- cgit v1.2.3-70-g09d2