OpenTTD Source  20241120-master-g6d3adc6169
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 
19  WPF_ROAD = 0,
20 };
21 
23 struct 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?
Definition: station_map.h:123
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition: station_map.h:28
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:54
StationType
Station types.
Definition: station_type.h:31
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.
Definition: tilearea_type.h:18
uint16_t w
The width of the area.
Definition: tilearea_type.h:20
uint16_t h
The height of the area.
Definition: tilearea_type.h:21
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
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.
Definition: waypoint_base.h:23
bool IsSingleTile() const
Is this a single tile waypoint?
Definition: waypoint_base.h:62
TileArea road_waypoint_area
Tile area the road waypoint part covers.
Definition: waypoint_base.h:26
bool IsOfType(const Waypoint *wp) const
Is the "type" of waypoint the same as the given waypoint, i.e.
Definition: waypoint_base.h:73
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)
Definition: waypoint_base.h:24
uint GetPlatformLength(TileIndex, DiagDirection) const override
Determines the REMAINING length of a platform, starting at (and including) the given tile.
Definition: waypoint_base.h:48
uint GetPlatformLength(TileIndex) const override
Obtain the length of a platform.
Definition: waypoint_base.h:53
uint16_t waypoint_flags
Waypoint flags, see WaypointFlags.
Definition: waypoint_base.h:25
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: waypoint_base.h:39
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.
Definition: waypoint_base.h:32
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
WaypointFlags
Flags for Waypoint::waypoint_flags.
Definition: waypoint_base.h:18
@ WPF_ROAD
This is a road waypoint.
Definition: waypoint_base.h:19