summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-11-08 19:48:47 +0000
committeryexo <yexo@openttd.org>2011-11-08 19:48:47 +0000
commit5c838ff1c312c240e44bb7da95e5450bcfeaeff6 (patch)
tree0a1e0902aa4874cfbe77fe3c07620e41c3fba28a /src/saveload
parent704dcc0a475e1361a913a43ae0b5d601dde807cc (diff)
downloadopenttd-5c838ff1c312c240e44bb7da95e5450bcfeaeff6.tar.xz
(svn r23168) -Feature [FS#1824]: always draw fences around field tiles
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 3d660db37..2fc3e0e5e 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1267,10 +1267,6 @@ bool AfterLoadGame()
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) {
/* remove fields */
MakeClear(t, CLEAR_GRASS, 3);
- } else if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) {
- /* remove fences around fields */
- SetFenceSE(t, 0);
- SetFenceSW(t, 0);
}
}
@@ -2653,6 +2649,24 @@ bool AfterLoadGame()
_settings_game.game_creation.snow_line_height /= TILE_HEIGHT;
}
+ if (IsSavegameVersionBefore(164) && !IsSavegameVersionBefore(32)) {
+ /* We store 4 fences in the field tiles instead of only SE and SW. */
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (!IsTileType(t, MP_CLEAR) && !IsTileType(t, MP_TREES)) continue;
+ if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) continue;
+ uint fence = GB(_m[t].m4, 5, 3);
+ if (fence != 0 && IsTileType(TILE_ADDXY(t, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 1, 0), CLEAR_FIELDS)) {
+ SetFenceNE(TILE_ADDXY(t, 1, 0), fence);
+ }
+ fence = GB(_m[t].m4, 2, 3);
+ if (fence != 0 && IsTileType(TILE_ADDXY(t, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 0, 1), CLEAR_FIELDS)) {
+ SetFenceNW(TILE_ADDXY(t, 0, 1), fence);
+ }
+ SB(_m[t].m4, 2, 3, 0);
+ SB(_m[t].m4, 5, 3, 0);
+ }
+ }
+
/* When any NewGRF has been changed the availability of some vehicles might
* have been changed too. e->company_avail must be set to 0 in that case
* which is done by StartupEngines(). */