OpenTTD Source: src/waypoint_base.h Source File

OpenTTD Source 15.3

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
18 enum WaypointFlags : uint8_t {
19 WPF_ROAD = 0,
20};
21
23 struct Waypoint final : SpecializedStation<Waypoint, true> {
24 uint16_t town_cn = 0;
25 uint16_t waypoint_flags{};
26 TileArea road_waypoint_area{};
27
32 Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
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 TileArea GetTileArea(StationType type) const override;
47
48 uint GetPlatformLength(TileIndex, DiagDirection) const override
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.Test(StationFacility::Train) && 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_station_base.h
Base classes/functions for base stations.
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:78
IsRailWaypointTile
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
Definition station_map.h:123
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
StationFacility::Train
@ Train
Station with train station.
StationType
StationType
Station types.
Definition station_type.h:29
BaseStation::string_id
StringID string_id
Default name (town area) of station.
Definition base_station_base.h:64
BaseStation::facilities
StationFacilities facilities
The facilities that this station has.
Definition base_station_base.h:69
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition base_station_base.h:83
OrthogonalTileArea
Represents the covered area of e.g.
Definition tilearea_type.h:18
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition tilearea_type.h:20
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition tilearea_type.h:21
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:288
SpecializedStation
Class defining several overloaded accessors so we don't have to cast base stations that often.
Definition base_station_base.h:211
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Waypoint
Representation of a waypoint.
Definition waypoint_base.h:23
Waypoint::IsSingleTile
bool IsSingleTile() const
Is this a single tile waypoint?
Definition waypoint_base.h:62
Waypoint::road_waypoint_area
TileArea road_waypoint_area
Tile area the road waypoint part covers.
Definition waypoint_base.h:26
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::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
Waypoint::GetTileArea
TileArea GetTileArea(StationType type) const override
Get the tile area for a given station type.
Definition waypoint.cpp:35
Waypoint::town_cn
uint16_t town_cn
The N-1th waypoint for this town (consecutive number)
Definition waypoint_base.h:24
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
Waypoint::GetPlatformLength
uint GetPlatformLength(TileIndex) const override
Obtain the length of a platform.
Definition waypoint_base.h:53
Waypoint::waypoint_flags
uint16_t waypoint_flags
Waypoint flags, see WaypointFlags.
Definition waypoint_base.h:25
Waypoint::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition waypoint_base.h:39
Waypoint::MoveSign
void MoveSign(TileIndex new_xy) override
Move the waypoint main coordinate somewhere else.
Definition waypoint_cmd.cpp:65
Waypoint::UpdateVirtCoord
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
Definition waypoint_cmd.cpp:48
Waypoint::Waypoint
Waypoint(TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
Definition waypoint_base.h:32
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
WaypointFlags
WaypointFlags
Flags for Waypoint::waypoint_flags.
Definition waypoint_base.h:18
WPF_ROAD
@ WPF_ROAD
This is a road waypoint.
Definition waypoint_base.h:19