OpenTTD Source 20260108-master-g8ba1860eaa
waypoint_base.h
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef WAYPOINT_BASE_H
11#define WAYPOINT_BASE_H
12
13#include "base_station_base.h"
14
18enum WaypointFlags : uint8_t {
20};
21
23struct Waypoint final : SpecializedStation<Waypoint, true> {
24 uint16_t town_cn = 0;
25 uint16_t waypoint_flags{};
27
34 ~Waypoint() override;
35
36 void UpdateVirtCoord() override;
37
38 void MoveSign(TileIndex new_xy) override;
39
40 inline bool TileBelongsToRailStation(TileIndex tile) const override
41 {
42 return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
43 }
44
45 uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
46
47 TileArea GetTileArea(StationType type) const override;
48
50 {
51 return 1;
52 }
53
54 uint GetPlatformLength(TileIndex) const override
55 {
56 return 1;
57 }
58
63 inline bool IsSingleTile() const
64 {
65 return this->facilities.Test(StationFacility::Train) && this->train_station.w == 1 && this->train_station.h == 1;
66 }
67
74 inline bool IsOfType(const Waypoint *wp) const
75 {
76 return this->string_id == wp->string_id;
77 }
78};
79
80#endif /* WAYPOINT_BASE_H */
Base classes/functions for base stations.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
DiagDirection
Enumeration for diagonal directions.
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
@ Train
Station with train station.
StationType
Station types.
StringID string_id
Default name (town area) of station.
StationFacilities facilities
The facilities that this station has.
TileArea train_station
Tile area the train 'station' part covers.
Represents the covered area of e.g.
uint16_t w
The width of the area.
uint16_t h
The height of the area.
const Tindex index
Index of this pool item.
Interface for SpriteGroup-s to access the gamestate.
Class defining several overloaded accessors so we don't have to cast base stations that often.
Representation of a waypoint.
bool IsSingleTile() const
Is this a single tile waypoint?
TileArea road_waypoint_area
Tile area the road waypoint part covers.
bool IsOfType(const Waypoint *wp) const
Is the "type" of waypoint the same as the given waypoint, i.e.
uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override
Helper function to get a NewGRF variable that isn't implemented by the base class.
Waypoint(StationID index, TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
TileArea GetTileArea(StationType type) const override
Get the tile area for a given station type.
Definition waypoint.cpp:35
uint16_t town_cn
The N-1th waypoint for this town (consecutive number)
uint GetPlatformLength(TileIndex, DiagDirection) const override
Determines the REMAINING length of a platform, starting at (and including) the given tile.
uint GetPlatformLength(TileIndex) const override
Obtain the length of a platform.
uint16_t waypoint_flags
Waypoint flags, see WaypointFlags.
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
void MoveSign(TileIndex new_xy) override
Move the waypoint main coordinate somewhere else.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
WaypointFlags
Flags for Waypoint::waypoint_flags.
@ WPF_ROAD
This is a road waypoint.