OpenTTD Source: src/waypoint_base.h Source File

OpenTTD Source 1.11.0-RC1

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
16 struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
17 uint16 town_cn;
18
23 Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
24 ~Waypoint();
25
26 void UpdateVirtCoord() override;
27
28 void MoveSign(TileIndex new_xy) override;
29
30 inline bool TileBelongsToRailStation(TileIndex tile) const override
31 {
32 return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
33 }
34
35 uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override;
36
37 void GetTileArea(TileArea *ta, StationType type) const override;
38
39 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
40 {
41 return 1;
42 }
43
44 uint GetPlatformLength(TileIndex tile) const override
45 {
46 return 1;
47 }
48
53 inline bool IsSingleTile() const
54 {
55 return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
56 }
57
64 inline bool IsOfType(const Waypoint *wp) const
65 {
66 return this->string_id == wp->string_id;
67 }
68 };
69
70 #endif /* WAYPOINT_BASE_H */
BaseStation::facilities
StationFacility facilities
The facilities that this station has.
Definition: base_station_base.h:63
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
Waypoint::MoveSign
void MoveSign(TileIndex new_xy) override
Move the waypoint main coordinate somewhere else.
Definition: waypoint_cmd.cpp:57
IsRailWaypointTile
static bool IsRailWaypointTile(TileIndex t)
Is this tile a station tile and a rail waypoint?
Definition: station_map.h:123
SpecializedStation
Class defining several overloaded accessors so we don't have to cast base stations that often.
Definition: base_station_base.h:182
Waypoint::GetNewGRFVariable
uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override
Helper function to get a NewGRF variable that isn't implemented by the base class.
Definition: newgrf_station.cpp:463
Waypoint::town_cn
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
Definition: waypoint_base.h:17
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:227
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:315
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:64
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:16
Waypoint::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: waypoint_base.h:30
Waypoint::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition: waypoint.cpp:34
BaseStation::string_id
StringID string_id
Default name (town area) of station.
Definition: base_station_base.h:58
StationType
StationType
Station types.
Definition: station_type.h:32
Waypoint::UpdateVirtCoord
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
Definition: waypoint_cmd.cpp:39
Waypoint::IsSingleTile
bool IsSingleTile() const
Is this a single tile waypoint?
Definition: waypoint_base.h:53
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:75
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:18
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:16
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
Waypoint::GetPlatformLength
uint GetPlatformLength(TileIndex tile) const override
Obtain the length of a platform.
Definition: waypoint_base.h:44
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:19
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:52
Waypoint::Waypoint
Waypoint(TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
Definition: waypoint_base.h:23
GetStationIndex
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:28
base_station_base.h
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
Waypoint::GetPlatformLength
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
Determines the REMAINING length of a platform, starting at (and including) the given tile.
Definition: waypoint_base.h:39