author | glx |
Mon, 26 May 2008 17:40:33 +0000 | |
branch | noai |
changeset 10718 | 7e9d9e40e16f |
parent 10715 | 6bdf79ffb022 |
child 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 |
||
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
72 |
/* Old style list kept for migration */ |
9723 | 73 |
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type); |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
74 |
void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type); |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
75 |
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list); |
9723 | 76 |
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id); |
77 |
void VehicleEnterDepot(Vehicle *v); |
|
78 |
||
10294 | 79 |
CommandCost MaybeReplaceVehicle(Vehicle *v, uint32 flags, bool display_costs); |
9723 | 80 |
bool CanBuildVehicleInfrastructure(VehicleType type); |
81 |
||
82 |
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2); |
|
83 |
||
84 |
||
85 |
struct GetNewVehiclePosResult { |
|
86 |
int x, y; |
|
87 |
TileIndex old_tile; |
|
88 |
TileIndex new_tile; |
|
89 |
}; |
|
90 |
||
91 |
/* returns true if staying in the same tile */ |
|
92 |
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v); |
|
93 |
Direction GetDirectionTowards(const Vehicle *v, int x, int y); |
|
94 |
||
95 |
static inline bool IsPlayerBuildableVehicleType(VehicleType type) |
|
96 |
{ |
|
97 |
switch (type) { |
|
98 |
case VEH_TRAIN: |
|
99 |
case VEH_ROAD: |
|
100 |
case VEH_SHIP: |
|
101 |
case VEH_AIRCRAFT: |
|
102 |
return true; |
|
103 |
||
104 |
default: return false; |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
static inline bool IsPlayerBuildableVehicleType(const BaseVehicle *v) |
|
109 |
{ |
|
110 |
return IsPlayerBuildableVehicleType(v->type); |
|
111 |
} |
|
112 |
||
113 |
const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v); |
|
114 |
||
115 |
/** |
|
116 |
* Get the colour map for an engine. This used for unbuilt engines in the user interface. |
|
117 |
* @param engine_type ID of engine |
|
118 |
* @param player ID of player |
|
119 |
* @return A ready-to-use palette modifier |
|
120 |
*/ |
|
121 |
SpriteID GetEnginePalette(EngineID engine_type, PlayerID player); |
|
122 |
||
123 |
/** |
|
124 |
* Get the colour map for a vehicle. |
|
125 |
* @param v Vehicle to get colour map for |
|
126 |
* @return A ready-to-use palette modifier |
|
127 |
*/ |
|
128 |
SpriteID GetVehiclePalette(const Vehicle *v); |
|
129 |
||
130 |
extern const uint32 _veh_build_proc_table[]; |
|
131 |
extern const uint32 _veh_sell_proc_table[]; |
|
132 |
extern const uint32 _veh_refit_proc_table[]; |
|
133 |
extern const uint32 _send_to_depot_proc_table[]; |
|
134 |
||
135 |
/* Functions to find the right command for certain vehicle type */ |
|
136 |
static inline uint32 GetCmdBuildVeh(VehicleType type) |
|
137 |
{ |
|
138 |
return _veh_build_proc_table[type]; |
|
139 |
} |
|
140 |
||
141 |
static inline uint32 GetCmdBuildVeh(const BaseVehicle *v) |
|
142 |
{ |
|
143 |
return GetCmdBuildVeh(v->type); |
|
144 |
} |
|
145 |
||
146 |
static inline uint32 GetCmdSellVeh(VehicleType type) |
|
147 |
{ |
|
148 |
return _veh_sell_proc_table[type]; |
|
149 |
} |
|
150 |
||
151 |
static inline uint32 GetCmdSellVeh(const BaseVehicle *v) |
|
152 |
{ |
|
153 |
return GetCmdSellVeh(v->type); |
|
154 |
} |
|
155 |
||
156 |
static inline uint32 GetCmdRefitVeh(VehicleType type) |
|
157 |
{ |
|
158 |
return _veh_refit_proc_table[type]; |
|
159 |
} |
|
160 |
||
161 |
static inline uint32 GetCmdRefitVeh(const BaseVehicle *v) |
|
162 |
{ |
|
163 |
return GetCmdRefitVeh(v->type); |
|
164 |
} |
|
165 |
||
166 |
static inline uint32 GetCmdSendToDepot(VehicleType type) |
|
167 |
{ |
|
168 |
return _send_to_depot_proc_table[type]; |
|
169 |
} |
|
170 |
||
171 |
static inline uint32 GetCmdSendToDepot(const BaseVehicle *v) |
|
172 |
{ |
|
173 |
return GetCmdSendToDepot(v->type); |
|
174 |
} |
|
175 |
||
176 |
bool EnsureNoVehicleOnGround(TileIndex tile); |
|
177 |
void StopAllVehicles(); |
|
178 |
||
179 |
extern VehicleID _vehicle_id_ctr_day; |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
180 |
extern const Vehicle *_place_clicked_vehicle; |
9723 | 181 |
extern VehicleID _new_vehicle_id; |
182 |
extern uint16 _returned_refit_capacity; |
|
183 |
||
10294 | 184 |
#endif /* VEHICLE_FUNC_H */ |