author | truebrain |
Mon, 16 Jun 2008 00:07:49 +0000 | |
branch | noai |
changeset 10977 | 6c1a6657c7db |
parent 10715 | 6bdf79ffb022 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file tile_cmd.h Generic 'commands' that can be performed on all tiles. */ |
|
4 |
||
5 |
#ifndef TILE_CMD_H |
|
6 |
#define TILE_CMD_H |
|
7 |
||
8 |
#include "slope_type.h" |
|
9 |
#include "tile_type.h" |
|
10 |
#include "command_type.h" |
|
11 |
#include "vehicle_type.h" |
|
12 |
#include "cargo_type.h" |
|
13 |
#include "strings_type.h" |
|
14 |
#include "date_type.h" |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
15 |
#include "player_type.h" |
9732 | 16 |
#include "direction_type.h" |
17 |
#include "track_type.h" |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9732
diff
changeset
|
18 |
#include "transport_type.h" |
9723 | 19 |
|
20 |
/** The returned bits of VehicleEnterTile. */ |
|
21 |
enum VehicleEnterTileStatus { |
|
22 |
VETS_ENTERED_STATION = 1, ///< The vehicle entered a station |
|
23 |
VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel) |
|
24 |
VETS_CANNOT_ENTER = 3, ///< The vehicle cannot enter the tile |
|
25 |
||
26 |
/** |
|
27 |
* Shift the VehicleEnterTileStatus this many bits |
|
28 |
* to the right to get the station ID when |
|
29 |
* VETS_ENTERED_STATION is set |
|
30 |
*/ |
|
31 |
VETS_STATION_ID_OFFSET = 8, |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
32 |
VETS_STATION_MASK = 0xFFFF << VETS_STATION_ID_OFFSET, |
9723 | 33 |
|
34 |
/** Bit sets of the above specified bits */ |
|
35 |
VETSB_CONTINUE = 0, ///< The vehicle can continue normally |
|
36 |
VETSB_ENTERED_STATION = 1 << VETS_ENTERED_STATION, ///< The vehicle entered a station |
|
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) |
|
38 |
VETSB_CANNOT_ENTER = 1 << VETS_CANNOT_ENTER, ///< The vehicle cannot enter the tile |
|
39 |
}; |
|
40 |
DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus); |
|
41 |
||
42 |
struct TileInfo { |
|
43 |
uint x; |
|
44 |
uint y; |
|
45 |
Slope tileh; |
|
46 |
TileIndex tile; |
|
47 |
uint z; |
|
48 |
}; |
|
49 |
||
50 |
struct TileDesc { |
|
51 |
StringID str; |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
52 |
Owner owner[4]; |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
53 |
StringID owner_type[4]; |
9723 | 54 |
Date build_date; |
55 |
uint64 dparam[2]; |
|
56 |
}; |
|
57 |
||
58 |
typedef void DrawTileProc(TileInfo *ti); |
|
59 |
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y); |
|
60 |
typedef CommandCost ClearTileProc(TileIndex tile, byte flags); |
|
61 |
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); |
|
62 |
typedef void GetTileDescProc(TileIndex tile, TileDesc *td); |
|
63 |
||
64 |
/** |
|
65 |
* GetTileTrackStatusProcs return a value that contains the possible tracks |
|
9732 | 66 |
* that can be taken on a given tile by a given transport. |
67 |
* The return value contains the existing trackdirs and signal states. |
|
9723 | 68 |
* |
9732 | 69 |
* see track_func.h for usage of TrackStatus. |
9723 | 70 |
* |
71 |
* @param tile the tile to get the track status from |
|
72 |
* @param mode the mode of transportation |
|
73 |
* @param sub_mode used to differentiate between different kinds within the mode |
|
9732 | 74 |
* @return the track status information |
9723 | 75 |
*/ |
9732 | 76 |
typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side); |
9723 | 77 |
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b); |
78 |
typedef void ClickTileProc(TileIndex tile); |
|
79 |
typedef void AnimateTileProc(TileIndex tile); |
|
80 |
typedef void TileLoopProc(TileIndex tile); |
|
81 |
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player); |
|
82 |
||
83 |
/** @see VehicleEnterTileStatus to see what the return values mean */ |
|
84 |
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y); |
|
85 |
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh); |
|
86 |
||
87 |
/** |
|
88 |
* Called when a tile is affected by a terraforming operation. |
|
89 |
* The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype. |
|
90 |
* With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself). |
|
91 |
* |
|
92 |
* @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation. |
|
93 |
* |
|
94 |
* @param tile The involved tile. |
|
95 |
* @param flags Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.). |
|
96 |
* @param z_new TileZ after terraforming. |
|
97 |
* @param tileh_new Slope after terraforming. |
|
98 |
* @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.) |
|
99 |
*/ |
|
100 |
typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new); |
|
101 |
||
102 |
struct TileTypeProcs { |
|
103 |
DrawTileProc *draw_tile_proc; |
|
104 |
GetSlopeZProc *get_slope_z_proc; |
|
105 |
ClearTileProc *clear_tile_proc; |
|
106 |
GetAcceptedCargoProc *get_accepted_cargo_proc; |
|
107 |
GetTileDescProc *get_tile_desc_proc; |
|
108 |
GetTileTrackStatusProc *get_tile_track_status_proc; |
|
109 |
ClickTileProc *click_tile_proc; |
|
110 |
AnimateTileProc *animate_tile_proc; |
|
111 |
TileLoopProc *tile_loop_proc; |
|
112 |
ChangeTileOwnerProc *change_tile_owner_proc; |
|
113 |
GetProducedCargoProc *get_produced_cargo_proc; |
|
114 |
VehicleEnterTileProc *vehicle_enter_tile_proc; |
|
115 |
GetFoundationProc *get_foundation_proc; |
|
116 |
TerraformTileProc *terraform_tile_proc; |
|
117 |
}; |
|
118 |
||
119 |
extern const TileTypeProcs * const _tile_type_procs[16]; |
|
120 |
||
9732 | 121 |
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR); |
9723 | 122 |
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac); |
123 |
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player); |
|
124 |
void AnimateTile(TileIndex tile); |
|
125 |
void ClickTile(TileIndex tile); |
|
126 |
void GetTileDesc(TileIndex tile, TileDesc *td); |
|
127 |
||
128 |
#endif /* TILE_CMD_H */ |