Index: src/saveload/afterload.cpp
===================================================================
--- src/saveload/afterload.cpp (revision 27203)
+++ src/saveload/afterload.cpp (working copy)
@@ -2985,6 +2985,17 @@
ResetSignalHandlers();
AfterLoadLinkGraphs();
+
+ if (IsSavegameVersionBefore(195)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsDockTile(t) && HasTileWaterGround(t)) {
+ if (HasTileWaterClass(t) && !GetWaterClass(t) == WATER_CLASS_CANAL) {
+ SetTileOwner(t, OWNER_WATER);
+ }
+ }
+ }
+ }
+
return true;
}
Index: src/saveload/company_sl.cpp
===================================================================
--- src/saveload/company_sl.cpp (revision 27203)
+++ src/saveload/company_sl.cpp (working copy)
@@ -141,7 +141,7 @@
case MP_STATION:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
+ if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile) && !IsDock(tile)) c->infrastructure.station++;
switch (GetStationType(tile)) {
case STATION_RAIL:
@@ -161,6 +161,11 @@
}
case STATION_DOCK:
+ if (IsDockTile(tile) && !HasTileWaterGround(tile)) {
+ if (c != NULL) c->infrastructure.station += 2;
+ }
+ /* FALL THROUGH */
+
case STATION_BUOY:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
if (c != NULL) c->infrastructure.water++;
Index: src/saveload/saveload.cpp
===================================================================
--- src/saveload/saveload.cpp (revision 27203)
+++ src/saveload/saveload.cpp (working copy)
@@ -262,8 +262,9 @@
* 192 26700
* 193 26802
* 194 26881 1.5.x
+ * 195 27202M
*/
-extern const uint16 SAVEGAME_VERSION = 194; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 195; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
Index: src/station_cmd.cpp
===================================================================
--- src/station_cmd.cpp (revision 27203)
+++ src/station_cmd.cpp (working copy)
@@ -2511,9 +2511,17 @@
/* Get the water class of the water tile before it is cleared.*/
WaterClass wc = GetWaterClass(tile_cur);
+ Owner o_wc = GetTileOwner(tile_cur);
+ bool self_canal = true;
- ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (ret.Failed()) return ret;
+ if (o_wc != OWNER_NONE || (o_wc == OWNER_NONE && !IsWater(tile_cur))) { // do not demolish canal of OWNER_NONE, but check for clearance
+ ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); // this demolishes own canal if it succeeds
+ if (ret.Failed() && !IsCanal(tile_cur)) {
+ return ret;
+ } else {
+ if (ret.Succeeded()) self_canal = false;
+ }
+ }
tile_cur += TileOffsByDiagDir(direction);
if (!IsTileType(tile_cur, MP_WATER) || !IsTileFlat(tile_cur)) {
@@ -2544,7 +2552,7 @@
/* If the water part of the dock is on a canal, update infrastructure counts.
* This is needed as we've unconditionally cleared that tile before. */
- if (wc == WATER_CLASS_CANAL) {
+ if (wc == WATER_CLASS_CANAL && o_wc != OWNER_NONE && !self_canal) {
Company::Get(st->owner)->infrastructure.water++;
}
Company::Get(st->owner)->infrastructure.station += 2;
@@ -2587,7 +2595,7 @@
if (flags & DC_EXEC) {
DoClearSquare(tile1);
MarkTileDirtyByTile(tile1);
- MakeWaterKeepingClass(tile2, st->owner);
+ MakeWaterKeepingClass(tile2, GetTileOwner(tile2));
st->rect.AfterRemoveTile(st, tile1);
st->rect.AfterRemoveTile(st, tile2);
@@ -3993,11 +4001,16 @@
}
/* Update station tile count. */
- if (!IsBuoy(tile) && !IsAirport(tile)) {
+ if (!IsBuoy(tile) && !IsAirport(tile) && !IsDock(tile)) {
old_company->infrastructure.station--;
new_company->infrastructure.station++;
}
+ if (IsDockTile(tile) && !HasTileWaterGround(tile)) {
+ old_company->infrastructure.station -= 2;
+ new_company->infrastructure.station += 2;
+ }
+
/* for buoys, owner of tile is owner of water, st->owner == OWNER_NONE */
SetTileOwner(tile, new_owner);
InvalidateWindowClassesData(WC_STATION_LIST, 0);
Index: src/station_map.h
===================================================================
--- src/station_map.h (revision 27203)
+++ src/station_map.h (working copy)
@@ -650,7 +650,7 @@
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
{
MakeStation(t, o, sid, STATION_DOCK, d);
- MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
+ MakeStation(t + TileOffsByDiagDir(d), IsWaterTile(t + TileOffsByDiagDir(d)) ? GetTileOwner (t + TileOffsByDiagDir(d)) : o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
}
/**