src/tile_cmd.h
author rubidium
Sun, 25 May 2008 19:17:03 +0000
changeset 9354 845e07db4549
parent 9322 cf7dc39f9576
child 9714 5d785e184f2d
permissions -rw-r--r--
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
-Codechange: move all Settings into substructs of _settings in a way that they are logically grouped.
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     1
/* $Id$ */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     2
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     3
/** @file tile_cmd.h Generic 'commands' that can be performed on all tiles. */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     4
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     5
#ifndef TILE_CMD_H
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     6
#define TILE_CMD_H
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     7
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
     8
#include "slope_type.h"
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
     9
#include "tile_type.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    10
#include "command_type.h"
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    11
#include "vehicle_type.h"
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    12
#include "cargo_type.h"
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    13
#include "strings_type.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8138
diff changeset
    14
#include "date_type.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8140
diff changeset
    15
#include "player_type.h"
8596
c3404405f3f5 (svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents: 8373
diff changeset
    16
#include "direction_type.h"
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    17
#include "track_type.h"
9126
5648d696456b (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents: 9125
diff changeset
    18
#include "transport_type.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    19
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    20
/** The returned bits of VehicleEnterTile. */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    21
enum VehicleEnterTileStatus {
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    22
	VETS_ENTERED_STATION  = 1, ///< The vehicle entered a station
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    23
	VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    24
	VETS_CANNOT_ENTER     = 3, ///< The vehicle cannot enter the tile
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    25
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    26
	/**
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    27
	 * Shift the VehicleEnterTileStatus this many bits
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    28
	 * to the right to get the station ID when
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    29
	 * VETS_ENTERED_STATION is set
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    30
	 */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    31
	VETS_STATION_ID_OFFSET = 8,
8373
7431d91527f2 (svn r11939) -Codechange: some type fixes and very initial steps into supporting NDS by default. Based on work by Dominik.
rubidium
parents: 8254
diff changeset
    32
	VETS_STATION_MASK      = 0xFFFF << VETS_STATION_ID_OFFSET,
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    33
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    34
	/** Bit sets of the above specified bits */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    35
	VETSB_CONTINUE         = 0,                          ///< The vehicle can continue normally
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    36
	VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,  ///< The vehicle entered a station
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    37
	VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    38
	VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,     ///< The vehicle cannot enter the tile
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    39
};
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    40
DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    41
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    42
struct TileInfo {
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    43
	uint x;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    44
	uint y;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    45
	Slope tileh;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    46
	TileIndex tile;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    47
	uint z;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    48
};
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    49
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    50
struct TileDesc {
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    51
	StringID str;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9126
diff changeset
    52
	Owner owner[4];
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9126
diff changeset
    53
	StringID owner_type[4];
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    54
	Date build_date;
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    55
	uint64 dparam[2];
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    56
};
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    57
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    58
typedef void DrawTileProc(TileInfo *ti);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    59
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    60
typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    61
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    62
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    63
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    64
/**
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    65
 * GetTileTrackStatusProcs return a value that contains the possible tracks
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    66
 * that can be taken on a given tile by a given transport.
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    67
 * The return value contains the existing trackdirs and signal states.
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    68
 *
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    69
 * see track_func.h for usage of TrackStatus.
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    70
 *
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    71
 * @param tile     the tile to get the track status from
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    72
 * @param mode     the mode of transportation
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    73
 * @param sub_mode used to differentiate between different kinds within the mode
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    74
 * @return the track status information
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    75
 */
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
    76
typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side);
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    77
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    78
typedef void ClickTileProc(TileIndex tile);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    79
typedef void AnimateTileProc(TileIndex tile);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    80
typedef void TileLoopProc(TileIndex tile);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    81
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    82
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    83
/** @see VehicleEnterTileStatus to see what the return values mean */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    84
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    85
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    86
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    87
/**
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    88
 * Called when a tile is affected by a terraforming operation.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    89
 * The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    90
 * With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    91
 *
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    92
 * @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    93
 *
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    94
 * @param tile      The involved tile.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    95
 * @param flags     Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    96
 * @param z_new     TileZ after terraforming.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    97
 * @param tileh_new Slope after terraforming.
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    98
 * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
    99
 */
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   100
typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   101
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   102
struct TileTypeProcs {
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   103
	DrawTileProc *draw_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   104
	GetSlopeZProc *get_slope_z_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   105
	ClearTileProc *clear_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   106
	GetAcceptedCargoProc *get_accepted_cargo_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   107
	GetTileDescProc *get_tile_desc_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   108
	GetTileTrackStatusProc *get_tile_track_status_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   109
	ClickTileProc *click_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   110
	AnimateTileProc *animate_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   111
	TileLoopProc *tile_loop_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   112
	ChangeTileOwnerProc *change_tile_owner_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   113
	GetProducedCargoProc *get_produced_cargo_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   114
	VehicleEnterTileProc *vehicle_enter_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   115
	GetFoundationProc *get_foundation_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   116
	TerraformTileProc *terraform_tile_proc;
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   117
};
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   118
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   119
extern const TileTypeProcs * const _tile_type_procs[16];
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   120
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8596
diff changeset
   121
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   122
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   123
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   124
void AnimateTile(TileIndex tile);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   125
void ClickTile(TileIndex tile);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   126
void GetTileDesc(TileIndex tile, TileDesc *td);
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   127
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
diff changeset
   128
#endif /* TILE_CMD_H */