OpenTTD Source  20240915-master-g3784a3d3d6
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 */
BaseStation::facilities
StationFacility facilities
The facilities that this station has.
Definition: base_station_base.h:70
Waypoint::MoveSign
void MoveSign(TileIndex new_xy) override
Move the waypoint main coordinate somewhere else.
Definition: waypoint_cmd.cpp:60
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:54
Waypoint::GetPlatformLength
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
SpecializedStation
Class defining several overloaded accessors so we don't have to cast base stations that often.
Definition: base_station_base.h:217
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:308
Waypoint::town_cn
uint16_t town_cn
The N-1th waypoint for this town (consecutive number)
Definition: waypoint_base.h:24
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
Waypoint::IsOfType
bool IsOfType(const Waypoint *wp) const
Is the "type" of waypoint the same as the given waypoint, i.e.
Definition: waypoint_base.h:73
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:23
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
Waypoint::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: waypoint_base.h:39
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Waypoint::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition: waypoint.cpp:35
IsRailWaypointTile
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
Definition: station_map.h:123
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition: tilearea_type.h:21
StationType
StationType
Station types.
Definition: station_type.h:31
WaypointFlags
WaypointFlags
Flags for Waypoint::waypoint_flags.
Definition: waypoint_base.h:18
BaseStation::string_id
StringID string_id
Default name (town area) of station.
Definition: base_station_base.h:65
Waypoint::UpdateVirtCoord
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
Definition: waypoint_cmd.cpp:42
Waypoint::IsSingleTile
bool IsSingleTile() const
Is this a single tile waypoint?
Definition: waypoint_base.h:62
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:84
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
Waypoint::GetPlatformLength
uint GetPlatformLength(TileIndex) const override
Obtain the length of a platform.
Definition: waypoint_base.h:53
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition: station_map.h:28
Waypoint::Waypoint
Waypoint(TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
Definition: waypoint_base.h:32
base_station_base.h
WPF_ROAD
@ WPF_ROAD
This is a road waypoint.
Definition: waypoint_base.h:19
Waypoint::road_waypoint_area
TileArea road_waypoint_area
Tile area the road waypoint part covers.
Definition: waypoint_base.h:26
Waypoint::waypoint_flags
uint16_t waypoint_flags
Waypoint flags, see WaypointFlags.
Definition: waypoint_base.h:25
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition: tilearea_type.h:20
Waypoint::GetNewGRFVariable
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.
Definition: newgrf_station.cpp:473