# tile_cmd.h File Reference

Generic 'commands' that can be performed on all tiles. More...

`#include "slope_type.h"`
`#include "tile_type.h"`
`#include "command_type.h"`
`#include "vehicle_type.h"`
`#include "cargo_type.h"`
`#include "strings_type.h"`
`#include "date_type.h"`
`#include "company_type.h"`
`#include "direction_type.h"`
`#include "track_type.h"`
`#include "transport_type.h"`
`#include "tile_map.h"`

Go to the source code of this file.

## Data Structures

struct | TileInfo
| Tile information, used while rendering the tile. More...
struct | TileDesc
| Tile description for the 'land area information' tool. More...
struct | TileTypeProcs
| Set of callback functions for performing tile operations of a given tile type. More...

## Typedefs

typedef void | DrawTileProc (TileInfo *ti)
| Tile callback function signature for drawing a tile and its contents to the screen.
typedef uint | GetSlopeZProc (TileIndex tile, uint x, uint y)
typedef CommandCost | ClearTileProc (TileIndex tile, DoCommandFlag flags)
typedef void | GetAcceptedCargoProc (TileIndex tile, AcceptedCargo res)
| Tile callback function signature for obtaining accepted carog of a tile.
typedef void | GetTileDescProc (TileIndex tile, TileDesc *td)
| Tile callback function signature for obtaining a tile description.
typedef TrackStatus | GetTileTrackStatusProc (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
| Tile callback function signature for getting the possible tracks that can be taken on a given tile by a given transport.
typedef void | GetProducedCargoProc (TileIndex tile, CargoID *b)
| Tile callback function signature for obtaining the produced cargo of a tile.
typedef bool | ClickTileProc (TileIndex tile)
typedef void | AnimateTileProc (TileIndex tile)
typedef void | TileLoopProc (TileIndex tile)
typedef void | ChangeTileOwnerProc (TileIndex tile, Owner old_owner, Owner new_owner)
typedef VehicleEnterTileStatus | VehicleEnterTileProc (Vehicle *v, TileIndex tile, int x, int y)
typedef Foundation | GetFoundationProc (TileIndex tile, Slope tileh)
typedef CommandCost | TerraformTileProc (TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
| Tile callback function signature of the terraforming callback.

## Enumerations

enum | VehicleEnterTileStatus { VETS_ENTERED_STATION = 1, VETS_ENTERED_WORMHOLE = 2, VETS_CANNOT_ENTER = 3, VETS_STATION_ID_OFFSET = 8, VETS_STATION_MASK = 0xFFFF << VETS_STATION_ID_OFFSET, VETSB_CONTINUE = 0, VETSB_ENTERED_STATION = 1 << VETS_ENTERED_STATION, VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, VETSB_CANNOT_ENTER = 1 << VETS_CANNOT_ENTER }
| The returned bits of VehicleEnterTile. More...

## Functions

| DECLARE_ENUM_AS_BIT_SET (VehicleEnterTileStatus)
TrackStatus | GetTileTrackStatus (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side=INVALID_DIAGDIR)
| Returns information about trackdirs and signal states.
VehicleEnterTileStatus | VehicleEnterTile (Vehicle *v, TileIndex tile, int x, int y)
| Call the tile callback function for a vehicle entering a tile.
void | GetAcceptedCargo (TileIndex tile, AcceptedCargo ac)
void | ChangeTileOwner (TileIndex tile, Owner old_owner, Owner new_owner)
| Change the owner of a tile.
void | GetTileDesc (TileIndex tile, TileDesc *td)
static void | AnimateTile (TileIndex tile)
static bool | ClickTile (TileIndex tile)

## Variables

const TileTypeProcs *const | _tile_type_procs [16]
| Tile callback functions for each type of tile.

## Detailed Description

Generic 'commands' that can be performed on all tiles.

Definition in file tile_cmd.h.

## Typedef Documentation

typedef void DrawTileProc(TileInfo *ti)

Tile callback function signature for drawing a tile and its contents to the screen.

Parameters:

  | ti | Information about the tile to draw

Definition at line 68 of file tile_cmd.h.

typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res)

Tile callback function signature for obtaining accepted carog of a tile.

Parameters:

  | tile | Tile queried for its accepted cargo
  | res | Storage destination of the cargo accepted

Definition at line 77 of file tile_cmd.h.

typedef void GetProducedCargoProc(TileIndex tile, CargoID *b)

Tile callback function signature for obtaining the produced cargo of a tile.

Parameters:

  | tile | Tile being queried
  | b | Destination array of produced cargo

Definition at line 106 of file tile_cmd.h.

typedef void GetTileDescProc(TileIndex tile, TileDesc *td)

Tile callback function signature for obtaining a tile description.

Parameters:

  | tile | Tile being queried
  | td | Storage pointer for returned tile description

Definition at line 84 of file tile_cmd.h.

typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)

Tile callback function signature for getting the possible tracks that can be taken on a given tile by a given transport.

The return value contains the existing trackdirs and signal states.

see track_func.h for usage of TrackStatus.

Parameters:

  | tile | the tile to get the track status from
  | mode | the mode of transportation
  | sub_mode | used to differentiate between different kinds within the mode

Returns:
  the track status information

Definition at line 99 of file tile_cmd.h.

typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)

Tile callback function signature of the terraforming callback.

The function is called when a tile is affected by a terraforming operation. It has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype. With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).

Note:
  The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.

Parameters:

  | tile | The involved tile.
  | flags | Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
  | z_new | TileZ after terraforming.
  | tileh_new | Slope after terraforming.

Returns:
  Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)

Definition at line 131 of file tile_cmd.h.

typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y)

See also:
  VehicleEnterTileStatus to see what the return values mean

Definition at line 113 of file tile_cmd.h.

## Enumeration Type Documentation

enum VehicleEnterTileStatus

The returned bits of VehicleEnterTile.

Enumerator:

  VETS_ENTERED_STATION | The vehicle entered a station.
  VETS_ENTERED_WORMHOLE | The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel).
  VETS_CANNOT_ENTER | The vehicle cannot enter the tile.
  VETS_STATION_ID_OFFSET | Shift the VehicleEnterTileStatus this many bits to the right to get the station ID when VETS_ENTERED_STATION is set.
  VETSB_CONTINUE | Bit sets of the above specified bits. The vehicle can continue normally
  VETSB_ENTERED_STATION | The vehicle entered a station.
  VETSB_ENTERED_WORMHOLE | The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel).
  VETSB_CANNOT_ENTER | The vehicle cannot enter the tile.

Definition at line 22 of file tile_cmd.h.

## Function Documentation

void ChangeTileOwner | ( | TileIndex | tile,
|  | Owner | old_owner,
|  | Owner | new_owner |
| ) |  |  |

Change the owner of a tile.

Parameters:

  | tile | Tile to change
  | old_owner | Current owner of the tile
  | new_owner | New owner of the tile

Definition at line 502 of file landscape.cpp.

References TileTypeProcs::change_tile_owner_proc, and GetTileType().

TrackStatus GetTileTrackStatus | ( | TileIndex | tile,
|  | TransportType | mode,
|  | uint | sub_mode,
|  | DiagDirection | side |
| ) |  |  |

Returns information about trackdirs and signal states.

If there is any trackbit at 'side', return all trackdirbits. For TRANSPORT_ROAD, return no trackbits if there is no roadbit (of given subtype) at given side.

Parameters:

  | tile | tile to get info about
  | mode | transport type
  | sub_mode | for TRANSPORT_ROAD, roadtypes to check
  | side | side we are entering from, INVALID_DIAGDIR to return all trackbits

Returns:
  trackdirbits and other info depending on 'mode'

Definition at line 491 of file landscape.cpp.

References TileTypeProcs::get_tile_track_status_proc, and GetTileType().

Referenced by AIMarine::AreWaterTilesConnected(), CheckRoadBlockedForOvertaking(), DisasterTick_Submarine(), FixOwnerOfRailTrack(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GenericPlaceSignals(), GetDriveableTrackdirBits(), AITile::HasTransportType(), MaskWireBits(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), RoadFindPathToDest(), TrainCheckIfLineEnds(), TryPathReserve(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateSignalsInBuffer(), YapfFindNearestRoadDepot(), and YapfFindNearestRoadVehicleCompatibleStop().

VehicleEnterTileStatus VehicleEnterTile | ( | Vehicle * | v,
|  | TileIndex | tile,
|  | int | x,
|  | int | y |
| ) |  |  |

Call the tile callback function for a vehicle entering a tile.

Parameters:

  | v | Vehicle entering the tile
  | tile | Tile entered
  | x | X position
  | y | Y position

Returns:
  Some meta-data over the to be entered tile.

See also:
  VehicleEnterTileStatus to see what the bits in the return value mean.

Definition at line 1253 of file vehicle.cpp.

References _tile_type_procs, GetTileType(), and TileTypeProcs::vehicle_enter_tile_proc.

## Variable Documentation

const TileTypeProcs* const _tile_type_procs[16]

Tile callback functions for each type of tile.

See also:
  TileType

Definition at line 45 of file landscape.cpp.

Referenced by CmdTerraformLand(), GetProductionAroundTiles(), and VehicleEnterTile().