Codefix: Documentation comment in IndustryDirectoryWindow (#13059)
[openttd-github.git] / src / waypoint_base.h
blobcbf2e1e6088996b3d538ca5555da49c28fda4082
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file waypoint_base.h Base of waypoints. */
10 #ifndef WAYPOINT_BASE_H
11 #define WAYPOINT_BASE_H
13 #include "base_station_base.h"
15 /**
16 * Flags for Waypoint::waypoint_flags.
18 enum WaypointFlags {
19 WPF_ROAD = 0, ///< This is a road waypoint
22 /** Representation of a waypoint. */
23 struct Waypoint final : SpecializedStation<Waypoint, true> {
24 uint16_t town_cn; ///< The N-1th waypoint for this town (consecutive number)
25 uint16_t waypoint_flags{}; ///< Waypoint flags, see WaypointFlags
26 TileArea road_waypoint_area; ///< Tile area the road waypoint part covers
28 /**
29 * Create a waypoint at the given tile.
30 * @param tile The location of the waypoint.
32 Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
33 ~Waypoint();
35 void UpdateVirtCoord() override;
37 void MoveSign(TileIndex new_xy) override;
39 inline bool TileBelongsToRailStation(TileIndex tile) const override
41 return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
44 uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
46 void GetTileArea(TileArea *ta, StationType type) const override;
48 uint GetPlatformLength(TileIndex, DiagDirection) const override
50 return 1;
53 uint GetPlatformLength(TileIndex) const override
55 return 1;
58 /**
59 * Is this a single tile waypoint?
60 * @return true if it is.
62 inline bool IsSingleTile() const
64 return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
67 /**
68 * Is the "type" of waypoint the same as the given waypoint,
69 * i.e. are both a rail waypoint or are both a buoy?
70 * @param wp The waypoint to compare to.
71 * @return true iff their types are equal.
73 inline bool IsOfType(const Waypoint *wp) const
75 return this->string_id == wp->string_id;
79 #endif /* WAYPOINT_BASE_H */