From f538179878370b3bec8bf1575dc30c1377461ebc Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 11 Mar 2019 10:37:47 +0000 Subject: Feature: Multi-tile docks and docking points. --- src/saveload/afterload.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/saveload/afterload.cpp') diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 662f5a77b..770237d53 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -57,6 +57,7 @@ #include "../error.h" #include "../disaster_vehicle.h" #include "../ship.h" +#include "../water.h" #include "saveload_internal.h" @@ -675,7 +676,6 @@ bool AfterLoadGame() Station *st; FOR_ALL_STATIONS(st) { if (st->airport.tile == 0) st->airport.tile = INVALID_TILE; - if (st->dock_tile == 0) st->dock_tile = INVALID_TILE; if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE; } @@ -3177,6 +3177,27 @@ bool AfterLoadGame() } } + /* Update structures for multitile docks */ + if (IsSavegameVersionBefore(SLV_MULTITILE_DOCKS)) { + for (TileIndex t = 0; t < map_size; t++) { + /* Clear docking tile flag from relevant tiles as it + * was not previously cleared. */ + if (IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE)) { + SetDockingTile(t, false); + } + /* Add docks and oilrigs to Station::ship_station. */ + if (IsTileType(t, MP_STATION)) { + if (IsDock(t) || IsOilRig(t)) Station::GetByTile(t)->ship_station.Add(t); + } + } + + /* Scan for docking tiles */ + Station *st; + FOR_ALL_STATIONS(st) { + if (st->ship_station.tile != INVALID_TILE) UpdateStationDockingTiles(st); + } + } + /* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */ Station::RecomputeCatchmentForAll(); -- cgit v1.2.3-54-g00ecf