author | truebrain |
Mon, 30 Jun 2008 13:36:06 +0000 | |
branch | noai |
changeset 11100 | b960288098b9 |
parent 10776 | 07203fc29812 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
3 |
/** @file vehicle_func.h Functions related to vehicles. */ |
9723 | 4 |
|
5 |
#ifndef VEHICLE_FUNC_H |
|
6 |
#define VEHICLE_FUNC_H |
|
7 |
||
8 |
#include "tile_type.h" |
|
9 |
#include "strings_type.h" |
|
10 |
#include "gfx_type.h" |
|
11 |
#include "direction_type.h" |
|
12 |
#include "cargo_type.h" |
|
13 |
#include "command_type.h" |
|
14 |
#include "vehicle_type.h" |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
15 |
#include "player_type.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9724
diff
changeset
|
16 |
#include "engine_type.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
17 |
#include "transport_type.h" |
9723 | 18 |
|
19 |
#define is_custom_sprite(x) (x >= 0xFD) |
|
20 |
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD) |
|
21 |
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE) |
|
22 |
||
23 |
typedef void *VehicleFromPosProc(Vehicle *v, void *data); |
|
24 |
||
25 |
void VehicleServiceInDepot(Vehicle *v); |
|
26 |
void VehiclePositionChanged(Vehicle *v); |
|
27 |
Vehicle *GetLastVehicleInChain(Vehicle *v); |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
28 |
const Vehicle *GetLastVehicleInChain(const Vehicle *v); |
9723 | 29 |
uint CountVehiclesInChain(const Vehicle *v); |
30 |
bool IsEngineCountable(const Vehicle *v); |
|
31 |
void DeleteVehicleChain(Vehicle *v); |
|
32 |
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc); |
|
33 |
void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc); |
|
34 |
void CallVehicleTicks(); |
|
35 |
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z); |
|
10645 | 36 |
uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *color); |
9723 | 37 |
|
38 |
void InitializeTrains(); |
|
39 |
byte VehicleRandomBits(); |
|
40 |
void ResetVehiclePosHash(); |
|
41 |
void ResetVehicleColorMap(); |
|
42 |
||
43 |
bool CanRefitTo(EngineID engine_type, CargoID cid_to); |
|
44 |
CargoID FindFirstRefittableCargo(EngineID engine_type); |
|
45 |
CommandCost GetRefitCost(EngineID engine_type); |
|
46 |
||
47 |
void ViewportAddVehicles(DrawPixelInfo *dpi); |
|
48 |
||
49 |
SpriteID GetRotorImage(const Vehicle *v); |
|
50 |
||
51 |
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y); |
|
52 |
||
53 |
StringID VehicleInTheWayErrMsg(const Vehicle* v); |
|
54 |
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false); |
|
55 |
Vehicle *GetVehicleTunnelBridge(TileIndex tile, TileIndex endtile); |
|
56 |
||
57 |
void DecreaseVehicleValue(Vehicle *v); |
|
58 |
void CheckVehicleBreakdown(Vehicle *v); |
|
59 |
void AgeVehicle(Vehicle *v); |
|
60 |
void VehicleEnteredDepotThisTick(Vehicle *v); |
|
61 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
62 |
void BeginVehicleMove(const Vehicle *v); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
63 |
void EndVehicleMove(const Vehicle *v); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
64 |
void MarkSingleVehicleDirty(const Vehicle *v); |
9723 | 65 |
|
66 |
UnitID GetFreeUnitNumber(VehicleType type); |
|
67 |
||
68 |
void TrainConsistChanged(Vehicle *v); |
|
69 |
void TrainPowerChanged(Vehicle *v); |
|
70 |
Money GetTrainRunningCost(const Vehicle *v); |
|
71 |
||
72 |
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id); |
|
73 |
void VehicleEnterDepot(Vehicle *v); |
|
74 |
||
10294 | 75 |
CommandCost MaybeReplaceVehicle(Vehicle *v, uint32 flags, bool display_costs); |
9723 | 76 |
bool CanBuildVehicleInfrastructure(VehicleType type); |
77 |
||
78 |
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2); |
|
79 |
||
80 |
||
81 |
struct GetNewVehiclePosResult { |
|
82 |
int x, y; |
|
83 |
TileIndex old_tile; |
|
84 |
TileIndex new_tile; |
|
85 |
}; |
|
86 |
||
87 |
/* returns true if staying in the same tile */ |
|
88 |
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v); |
|
89 |
Direction GetDirectionTowards(const Vehicle *v, int x, int y); |
|
90 |
||
91 |
static inline bool IsPlayerBuildableVehicleType(VehicleType type) |
|
92 |
{ |
|
93 |
switch (type) { |
|
94 |
case VEH_TRAIN: |
|
95 |
case VEH_ROAD: |
|
96 |
case VEH_SHIP: |
|
97 |
case VEH_AIRCRAFT: |
|
98 |
return true; |
|
99 |
||
100 |
default: return false; |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
static inline bool IsPlayerBuildableVehicleType(const BaseVehicle *v) |
|
105 |
{ |
|
106 |
return IsPlayerBuildableVehicleType(v->type); |
|
107 |
} |
|
108 |
||
109 |
const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v); |
|
110 |
||
111 |
/** |
|
112 |
* Get the colour map for an engine. This used for unbuilt engines in the user interface. |
|
113 |
* @param engine_type ID of engine |
|
114 |
* @param player ID of player |
|
115 |
* @return A ready-to-use palette modifier |
|
116 |
*/ |
|
117 |
SpriteID GetEnginePalette(EngineID engine_type, PlayerID player); |
|
118 |
||
119 |
/** |
|
120 |
* Get the colour map for a vehicle. |
|
121 |
* @param v Vehicle to get colour map for |
|
122 |
* @return A ready-to-use palette modifier |
|
123 |
*/ |
|
124 |
SpriteID GetVehiclePalette(const Vehicle *v); |
|
125 |
||
126 |
extern const uint32 _veh_build_proc_table[]; |
|
127 |
extern const uint32 _veh_sell_proc_table[]; |
|
128 |
extern const uint32 _veh_refit_proc_table[]; |
|
129 |
extern const uint32 _send_to_depot_proc_table[]; |
|
130 |
||
131 |
/* Functions to find the right command for certain vehicle type */ |
|
132 |
static inline uint32 GetCmdBuildVeh(VehicleType type) |
|
133 |
{ |
|
134 |
return _veh_build_proc_table[type]; |
|
135 |
} |
|
136 |
||
137 |
static inline uint32 GetCmdBuildVeh(const BaseVehicle *v) |
|
138 |
{ |
|
139 |
return GetCmdBuildVeh(v->type); |
|
140 |
} |
|
141 |
||
142 |
static inline uint32 GetCmdSellVeh(VehicleType type) |
|
143 |
{ |
|
144 |
return _veh_sell_proc_table[type]; |
|
145 |
} |
|
146 |
||
147 |
static inline uint32 GetCmdSellVeh(const BaseVehicle *v) |
|
148 |
{ |
|
149 |
return GetCmdSellVeh(v->type); |
|
150 |
} |
|
151 |
||
152 |
static inline uint32 GetCmdRefitVeh(VehicleType type) |
|
153 |
{ |
|
154 |
return _veh_refit_proc_table[type]; |
|
155 |
} |
|
156 |
||
157 |
static inline uint32 GetCmdRefitVeh(const BaseVehicle *v) |
|
158 |
{ |
|
159 |
return GetCmdRefitVeh(v->type); |
|
160 |
} |
|
161 |
||
162 |
static inline uint32 GetCmdSendToDepot(VehicleType type) |
|
163 |
{ |
|
164 |
return _send_to_depot_proc_table[type]; |
|
165 |
} |
|
166 |
||
167 |
static inline uint32 GetCmdSendToDepot(const BaseVehicle *v) |
|
168 |
{ |
|
169 |
return GetCmdSendToDepot(v->type); |
|
170 |
} |
|
171 |
||
172 |
bool EnsureNoVehicleOnGround(TileIndex tile); |
|
173 |
void StopAllVehicles(); |
|
174 |
||
175 |
extern VehicleID _vehicle_id_ctr_day; |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
176 |
extern const Vehicle *_place_clicked_vehicle; |
9723 | 177 |
extern VehicleID _new_vehicle_id; |
178 |
extern uint16 _returned_refit_capacity; |
|
179 |
||
10294 | 180 |
#endif /* VEHICLE_FUNC_H */ |