OpenTTD Source 20241224-master-gf74b0cf984
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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef WAYPOINT_BASE_H
11#define WAYPOINT_BASE_H
12
13#include "base_station_base.h"
14
20};
21
23struct Waypoint final : SpecializedStation<Waypoint, true> {
24 uint16_t town_cn;
25 uint16_t waypoint_flags{};
27
33 ~Waypoint();
34
35 void UpdateVirtCoord() override;
36
37 void MoveSign(TileIndex new_xy) override;
38
39 inline bool TileBelongsToRailStation(TileIndex tile) const override
40 {
41 return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
42 }
43
44 uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override;
45
46 void GetTileArea(TileArea *ta, StationType type) const override;
47
49 {
50 return 1;
51 }
52
53 uint GetPlatformLength(TileIndex) const override
54 {
55 return 1;
56 }
57
62 inline bool IsSingleTile() const
63 {
64 return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
65 }
66
73 inline bool IsOfType(const Waypoint *wp) const
74 {
75 return this->string_id == wp->string_id;
76 }
77};
78
79#endif /* WAYPOINT_BASE_H */
Base classes/functions for base stations.
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
@ FACIL_TRAIN
Station with train station.
StationType
Station types.
StationFacility facilities
The facilities that this station has.
StringID string_id
Default name (town area) of station.
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.
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.
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 GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition waypoint.cpp:35
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.
Waypoint(TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
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.