diff options
author | peter1138 <peter1138@openttd.org> | 2019-04-06 23:33:09 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-06-30 16:46:32 +0200 |
commit | ec2656ab7ef6d924f3c30624bf1d3c7449403c6f (patch) | |
tree | 1d936631285034aca11bb4bc49faeb255cefbb91 /src/station_cmd.cpp | |
parent | f538179878370b3bec8bf1575dc30c1377461ebc (diff) | |
download | openttd-ec2656ab7ef6d924f3c30624bf1d3c7449403c6f.tar.xz |
Codechange: Restrict docking points of docks.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index a7d986676..546aecc26 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2632,6 +2632,28 @@ 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. + * @return True iff the dock can be docked from the given direction. + */ +bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d) +{ + assert(IsDockTile(t)); + + /** Bitmap of valid directions for each dock tile part. */ + static const uint8 _valid_docking_tile[] = { + 0, 0, 0, 0, // No docking against the slope part. + 1 << DIAGDIR_NE | 1 << DIAGDIR_SW, // Docking permitted at the end + 1 << DIAGDIR_NW | 1 << DIAGDIR_SE, // of the flat piers. + }; + + StationGfx gfx = GetStationGfx(t); + assert(gfx < lengthof(_valid_docking_tile)); + return HasBit(_valid_docking_tile[gfx], d); +} + +/** * Find the part of a dock that is land-based * @param t Dock tile to find land part of * @return tile of land part of dock |