# waypoint.h File Reference

`#include "oldpool.h"`
`#include "rail_map.h"`
`#include "command_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, uint32 flags, bool justremove)
| Remove a waypoint.
Station * | ComposeWaypointStation (TileIndex tile)
| This hacks together some dummy one-shot Station structure for a waypoint.
void | ShowRenameWaypointWindow (const Waypoint *cp)
void | DrawWaypointSprite (int x, int y, int stat_id, RailType railtype)
| Draw a waypoint.
void | FixOldWaypoints ()
| Fix savegames which stored waypoints in their old format.
void | UpdateAllWaypointSigns ()
| Update all signs.
void | AfterLoadWaypoints ()
| Update waypoint graphics id against saved GRFID/localidx.

## Detailed Description

Definition in file waypoint.h.

## Function Documentation

void AfterLoadWaypoints | ( |  | ) |

Update waypoint graphics id against saved GRFID/localidx.

This is to ensure the chosen graphics are correct if GRF files are changed.

Definition at line 159 of file waypoint.cpp.

References GetCustomStationSpec(), GetNumCustomStations(), and STAT_CLASS_WAYP.

Referenced by ReloadNewGRFData().

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 402 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 425 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 52 of file waypoint.h.

References GetWaypointIndex(), IsRailWaypoint(), IsTileType(), and MP_RAILWAY.

Referenced by ComposeWaypointStation(), and RemoveTrainWaypoint().

CommandCost RemoveTrainWaypoint | ( | TileIndex | tile,
|  | uint32 | 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 297 of file waypoint.cpp.

References AddTrackToSignalBuffer(), CMD_ERROR, DC_EXEC, GetRailType(), GetRailWaypointBits(), GetRailWaypointTrack(), GetTileOwner(), GetWaypointByTile(), IsRailWaypoint(), IsTileType(), MarkTileDirtyByTile(), MP_RAILWAY, OWNER_WATER, RedrawWaypointSign(), and YapfNotifyTrackLayoutChange().

Referenced by CmdRemoveTrainWaypoint().