diff options
author | frosch <frosch@openttd.org> | 2008-02-06 15:32:06 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-02-06 15:32:06 +0000 |
commit | 9b2ca61044df8bf90db74f07ceaa9a7b71df2542 (patch) | |
tree | b5b474ed58e225718126beb6492afa26fc617e6e /src | |
parent | 831e678120e55e5295216a0a2e31e04b0708deb7 (diff) | |
download | openttd-9b2ca61044df8bf90db74f07ceaa9a7b71df2542.tar.xz |
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
Diffstat (limited to 'src')
-rw-r--r-- | src/openttd.cpp | 15 | ||||
-rw-r--r-- | src/water_cmd.cpp | 27 | ||||
-rw-r--r-- | src/water_map.h | 8 |
3 files changed, 33 insertions, 17 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 1b298de8b..85722845a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2333,9 +2333,16 @@ bool AfterLoadGame() if (_m[t].m5 == 2) { MakeRiver(t, Random()); } else { - Owner o = GetTileOwner(t); - if (IsWater(t) && o != OWNER_WATER) { - MakeCanal(t, o, Random()); + if (IsWater(t)) { + Owner o = GetTileOwner(t); + if (o == OWNER_WATER) { + MakeWater(t); + } else { + MakeCanal(t, o, Random()); + } + } else if (IsShipDepot(t)) { + Owner o = (Owner)_m[t].m4; // Original water owner + SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL); } } } @@ -2347,7 +2354,7 @@ bool AfterLoadGame() for (TileIndex t = 0; t < map_size; t++) { if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue; - if (IsTileType(t, MP_WATER) && (GetWaterTileType(t) == WATER_TILE_LOCK || IsShipDepot(t))) SetWaterClassDependingOnSurroundings(t); + if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t); if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t); } } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 5f73b526c..f569412a1 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -96,6 +96,9 @@ static void MarkCanalsAndRiversAroundDirty(TileIndex tile) /** * Makes a tile canal or water depending on the surroundings. + * + * Must only be used for converting old savegames. Use WaterClass now. + * * This as for example docks and shipdepots do not store * whether the tile used to be canal or 'normal' water. * @param t the tile to change. @@ -116,9 +119,17 @@ void SetWaterClassDependingOnSurroundings(TileIndex t) TileIndex neighbour = TileAddByDiagDir(t, dir); switch (GetTileType(neighbour)) { case MP_WATER: - has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER); - has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER); - has_river |= IsRiver(neighbour); + /* clear water and shipdepots have already a WaterClass associated */ + if (IsCoast(neighbour)) { + has_water = true; + } else if (!IsLock(neighbour)) { + switch (GetWaterClass(neighbour)) { + case WATER_CLASS_SEA: has_water = true; break; + case WATER_CLASS_CANAL: has_canal = true; break; + case WATER_CLASS_RIVER: has_river = true; break; + default: NOT_REACHED(); + } + } break; case MP_RAILWAY: @@ -174,8 +185,6 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 WaterClass wc1 = GetWaterClass(tile); WaterClass wc2 = GetWaterClass(tile2); - Owner o1 = GetTileOwner(tile); - Owner o2 = GetTileOwner(tile2); ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return CMD_ERROR; ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); @@ -188,8 +197,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 if (flags & DC_EXEC) { depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; - MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1, o1); - MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2, o2); + MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); + MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile2); d_auto_delete.Detach(); @@ -225,8 +234,8 @@ static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) /* Kill the depot, which is registered at the northernmost tile. Use that one */ delete GetDepotByTile(tile2 < tile ? tile2 : tile); - MakeWaterKeepingClass(tile, GetShipDepotWaterOwner(tile)); - MakeWaterKeepingClass(tile2, GetShipDepotWaterOwner(tile2)); + MakeWaterKeepingClass(tile, GetTileOwner(tile)); + MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile2); } diff --git a/src/water_map.h b/src/water_map.h index b9bb4344a..ca3ba061a 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -106,9 +106,9 @@ static inline DiagDirection GetShipDepotDirection(TileIndex t) return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); } -static inline Owner GetShipDepotWaterOwner(TileIndex t) +static inline bool IsLock(TileIndex t) { - return (Owner)_m[t].m4; + return IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END); } static inline DiagDirection GetLockDirection(TileIndex t) @@ -169,13 +169,13 @@ static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits) _m[t].m5 = 0; } -static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class, Owner original_owner) +static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class) { SetTileType(t, MP_WATER); SetTileOwner(t, o); _m[t].m2 = 0; _m[t].m3 = original_water_class; - _m[t].m4 = original_owner; + _m[t].m4 = 0; _m[t].m5 = base + a * 2; } |