# waypoint.h File Reference

Base of waypoints. More...

`#include "waypoint_type.h"`
`#include "oldpool.h"`
`#include "rail_map.h"`
`#include "command_type.h"`
`#include "station_type.h"`
`#include "town_type.h"`
`#include "viewport_type.h"`
`#include "date_type.h"`

Go to the source code of this file.

## Data Structures
struct | Waypoint
## Defines
#define | FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid())
#define | FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
## Functions
static bool | IsValidWaypointID (WaypointID index)
static Waypoint * | GetWaypointByTile (TileIndex tile)
| Fetch a waypoint by tile.
CommandCost | RemoveTrainWaypoint (TileIndex tile, DoCommandFlag flags, bool justremove)
| Remove a waypoint.
Station * | ComposeWaypointStation (TileIndex tile)
| This hacks together some dummy one-shot Station structure for a waypoint.
void | ShowWaypointWindow (const Waypoint *wp)
void | DrawWaypointSprite (int x, int y, int stat_id, RailType railtype)
| Draw a waypoint.
void | UpdateAllWaypointSigns ()
| Update all signs.
void | UpdateWaypointSign (Waypoint *wp)
| Update the sign for the waypoint.
void | RedrawWaypointSign (const Waypoint *wp)
| Redraw the sign of a waypoint.

## Detailed Description

Base of waypoints.

Definition in file waypoint.h.

## Function Documentation

Station* ComposeWaypointStation | ( | TileIndex | tile | ) |

This hacks together some dummy one-shot Station structure for a waypoint.

Parameters:

  | tile | on which to work

Returns:
  pointer to a Station

Definition at line 49 of file waypoint.cpp.

References GetWaypointByTile().

void DrawWaypointSprite | ( | int | x,
|  | int | y,
|  | int | stat_id,
|  | RailType | railtype |
| ) |  |  |

Draw a waypoint.

Parameters:

  | x | coordinate
  | y | coordinate
  | stat_id | station id
  | railtype | RailType to use for

Definition at line 72 of file waypoint.cpp.

References AXIS_X, DrawStationTile(), and STAT_CLASS_WAYP.

static Waypoint* GetWaypointByTile | ( | TileIndex | tile | ) | `[inline, static]`

Fetch a waypoint by tile.

Parameters:

  | tile | Tile of waypoint

Returns:
  Waypoint

Definition at line 57 of file waypoint.h.

References GetWaypointIndex(), and IsRailWaypointTile().

Referenced by ComposeWaypointStation(), and RemoveTrainWaypoint().

void RedrawWaypointSign | ( | const Waypoint * | wp | ) |

Redraw the sign of a waypoint.

Parameters:

  | wp | Waypoint to redraw sign

Definition at line 41 of file waypoint_cmd.cpp.

References MarkAllViewportsDirty(), and RedrawWaypointSign().

Referenced by CmdBuildTrainWaypoint(), RedrawWaypointSign(), and RemoveTrainWaypoint().

CommandCost RemoveTrainWaypoint | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | bool | justremove |
| ) |  |  |

Remove a waypoint.

Parameters:

  | tile | from which to remove waypoint
  | flags | type of operation
  | justremove | will indicate if it is removed from rail or if rails are removed too

Returns:
  cost of operation or error

Definition at line 243 of file waypoint_cmd.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, FreeTrainTrackReservation(), GetDepotWaypointReservation(), GetRailType(), GetRailWaypointBits(), GetRailWaypointTrack(), GetTrainForReservation(), GetWaypointByTile(), IsRailWaypointTile(), MarkTileDirtyByTile(), OWNER_WATER, RedrawWaypointSign(), RemoveTrainWaypoint(), SetTrackReservation(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

Referenced by CmdRemoveTrainWaypoint(), and RemoveTrainWaypoint().

void UpdateWaypointSign | ( | Waypoint * | wp | ) |

Update the sign for the waypoint.

Parameters:

  | wp | Waypoint to update sign

Definition at line 31 of file waypoint_cmd.cpp.

References TILE_SIZE, TileX(), TileY(), UpdateWaypointSign(), Point::x, and Point::y.

Referenced by CmdBuildTrainWaypoint(), CmdRenameWaypoint(), UpdateAllWaypointSigns(), and UpdateWaypointSign().