From baf7cc858ba1f21d5698275a693ce55f681e32bd Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 16 Sep 2023 23:51:49 +0200 Subject: [PATCH] Codechange: Rename ship docking tile related functions. --- src/ship_cmd.cpp | 2 +- src/station_cmd.cpp | 14 -------------- src/station_func.h | 1 - src/station_map.h | 27 +++++---------------------- src/water_cmd.cpp | 2 +- 5 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index cab94cf334..2e0186d714 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -624,7 +624,7 @@ bool IsShipDestinationTile(TileIndex tile, StationID station) for (DiagDirection d = DIAGDIR_BEGIN; d != DIAGDIR_END; d++) { TileIndex t = tile + TileOffsByDiagDir(d); if (!IsValidTile(t)) continue; - if (IsDockTile(t) && GetStationIndex(t) == station && IsValidDockingDirectionForDock(t, d)) return true; + if (IsDockTile(t) && GetStationIndex(t) == station && IsDockWaterPart(t)) return true; if (IsTileType(t, MP_INDUSTRY)) { const Industry *i = Industry::GetByTile(t); if (i->neutral_station != nullptr && i->neutral_station->index == station) return true; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index cb0afc4b54..2ab50585e9 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2740,20 +2740,6 @@ void ClearDockingTilesCheckingNeighbours(TileIndex tile) } } -/** - * Check if a dock tile can be docked from the given direction. - * @param t Tile index of dock. - * @param d DiagDirection adjacent to dock being tested. (unused) - * @return True iff the dock can be docked from the given direction. - */ -bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d) -{ - assert(IsDockTile(t)); - - StationGfx gfx = GetStationGfx(t); - return gfx >= GFX_DOCK_BASE_WATER_PART; -} - /** * Find the part of a dock that is land-based * @param t Dock tile to find land part of diff --git a/src/station_func.h b/src/station_func.h index 8d96c473ab..6b1fbd0413 100644 --- a/src/station_func.h +++ b/src/station_func.h @@ -40,7 +40,6 @@ void DeleteOilRig(TileIndex t); void UpdateStationDockingTiles(Station *st); void RemoveDockingTile(TileIndex t); void ClearDockingTilesCheckingNeighbours(TileIndex tile); -bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d); /* Check if a rail station tile is traversable. */ bool IsStationTileBlocked(TileIndex tile); diff --git a/src/station_map.h b/src/station_map.h index f525cb48ba..7eee619e02 100644 --- a/src/station_map.h +++ b/src/station_map.h @@ -435,30 +435,13 @@ static inline DiagDirection GetDockDirection(Tile t) } /** - * Get the tileoffset from this tile a ship should target to get to this dock. - * @param t Tile to query - * @pre IsTileType(t, MP_STATION) - * @pre IsBuoy(t) || IsOilRig(t) || IsDock(t) - * @return The offset from this tile that should be used as destination for ships. + * Check whether a dock tile is the tile on water. */ -static inline TileIndexDiffC GetDockOffset(Tile t) +static inline bool IsDockWaterPart(Tile t) { - static const TileIndexDiffC buoy_offset = {0, 0}; - static const TileIndexDiffC oilrig_offset = {2, 0}; - static const TileIndexDiffC dock_offset[DIAGDIR_END] = { - {-2, 0}, - { 0, 2}, - { 2, 0}, - { 0, -2}, - }; - assert(IsTileType(t, MP_STATION)); - - if (IsBuoy(t)) return buoy_offset; - if (IsOilRig(t)) return oilrig_offset; - - assert(IsDock(t)); - - return dock_offset[GetDockDirection(t)]; + assert(IsDockTile(t)); + StationGfx gfx = GetStationGfx(t); + return gfx >= GFX_DOCK_BASE_WATER_PART; } /** diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 312f2452d2..15e24734ba 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -186,7 +186,7 @@ void CheckForDockingTile(TileIndex t) TileIndex tile = t + TileOffsByDiagDir(d); if (!IsValidTile(tile)) continue; - if (IsDockTile(tile) && IsValidDockingDirectionForDock(tile, d)) { + if (IsDockTile(tile) && IsDockWaterPart(tile)) { Station::GetByTile(tile)->docking_station.Add(t); SetDockingTile(t, true); }