OpenTTD
waypoint_base.h
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef WAYPOINT_BASE_H
13 #define WAYPOINT_BASE_H
14 
15 #include "base_station_base.h"
16 
18 struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
19  uint16 town_cn;
20 
26  ~Waypoint();
27 
28  void UpdateVirtCoord() override;
29 
30  void MoveSign(TileIndex new_xy) override;
31 
32  inline bool TileBelongsToRailStation(TileIndex tile) const override
33  {
34  return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
35  }
36 
37  uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override;
38 
39  void GetTileArea(TileArea *ta, StationType type) const override;
40 
41  uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
42  {
43  return 1;
44  }
45 
46  uint GetPlatformLength(TileIndex tile) const override
47  {
48  return 1;
49  }
50 
55  inline bool IsSingleTile() const
56  {
57  return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
58  }
59 
66  inline bool IsOfType(const Waypoint *wp) const
67  {
68  return this->string_id == wp->string_id;
69  }
70 };
71 
76 #define FOR_ALL_WAYPOINTS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Waypoint, var)
77 
78 #endif /* WAYPOINT_BASE_H */
StationFacility facilities
The facilities that this station has.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
Definition: waypoint_base.h:19
Interface for SpriteGroup-s to access the gamestate.
TileArea train_station
Tile area the train &#39;station&#39; part covers.
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
static bool IsRailWaypointTile(TileIndex t)
Is this tile a station tile and a rail waypoint?
Definition: station_map.h:125
Representation of a waypoint.
Definition: waypoint_base.h:18
uint GetPlatformLength(TileIndex tile) const override
Obtain the length of a platform.
Definition: waypoint_base.h:46
uint16 w
The width of the area.
Definition: tilearea_type.h:20
void MoveSign(TileIndex new_xy) override
Move the waypoint main coordinate somewhere else.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition: waypoint.cpp:36
bool IsSingleTile() const
Is this a single tile waypoint?
Definition: waypoint_base.h:55
Represents the covered area of e.g.
Definition: tilearea_type.h:18
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: waypoint_base.h:32
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:30
StationType
Station types.
Definition: station_type.h:34
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
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:41
bool IsOfType(const Waypoint *wp) const
Is the "type" of waypoint the same as the given waypoint, i.e.
Definition: waypoint_base.h:66
Base classes/functions for base stations.
Waypoint(TileIndex tile=INVALID_TILE)
Create a waypoint at the given tile.
Definition: waypoint_base.h:25
DiagDirection
Enumeration for diagonal directions.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
Station with train station.
Definition: station_type.h:54
uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override
Helper function to get a NewGRF variable that isn&#39;t implemented by the base class.
uint16 h
The height of the area.
Definition: tilearea_type.h:21
StringID string_id
Default name (town area) of station.
Class defining several overloaded accessors so we don&#39;t have to cast base stations that often...