~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/api/ai_vehicle.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: ai_vehicle.hpp 15520 2009-02-19 09:01:34Z yexo $ */
 
2
 
 
3
/** @file ai_vehicle.hpp Everything to query and build vehicles. */
 
4
 
 
5
#ifndef AI_VEHICLE_HPP
 
6
#define AI_VEHICLE_HPP
 
7
 
 
8
#include "ai_object.hpp"
 
9
#include "ai_error.hpp"
 
10
#include "ai_road.hpp"
 
11
#include "ai_order.hpp"
 
12
 
 
13
/**
 
14
 * Class that handles all vehicle related functions.
 
15
 */
 
16
class AIVehicle : public AIObject {
 
17
public:
 
18
        static const char *GetClassName() { return "AIVehicle"; }
 
19
 
 
20
        /**
 
21
         * All vehicle related error messages.
 
22
         */
 
23
        enum ErrorMessages {
 
24
                /** Base for vehicle related errors */
 
25
                ERR_VEHICLE_BASE = AIError::ERR_CAT_VEHICLE << AIError::ERR_CAT_BIT_SIZE,
 
26
 
 
27
                /** Too many vehicles in the game, can't build any more. */
 
28
                ERR_VEHICLE_TOO_MANY,                   // [STR_00E1_TOO_MANY_VEHICLES_IN_GAME]
 
29
 
 
30
                /** Vehicle is not available */
 
31
                ERR_VEHICLE_NOT_AVAILABLE,              // [STR_AIRCRAFT_NOT_AVAILABLE, STR_ROAD_VEHICLE_NOT_AVAILABLE, STR_SHIP_NOT_AVAILABLE, STR_RAIL_VEHICLE_NOT_AVAILABLE]
 
32
 
 
33
                /** Vehicle can't be build due to game settigns */
 
34
                ERR_VEHICLE_BUILD_DISABLED,             // [STR_A008_CAN_T_BUILD_AIRCRAFT, STR_980D_CAN_T_BUILD_SHIP, STR_9009_CAN_T_BUILD_ROAD_VEHICLE, STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE]
 
35
 
 
36
                /** Vehicle can't be build in the selected depot */
 
37
                ERR_VEHICLE_WRONG_DEPOT,                // [STR_DEPOT_WRONG_DEPOT_TYPE]
 
38
 
 
39
                /** Vehicle can't return to the depot */
 
40
                ERR_VEHICLE_CANNOT_SEND_TO_DEPOT,       // [STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT, STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT, STR_9819_CAN_T_SEND_SHIP_TO_DEPOT, STR_A012_CAN_T_SEND_AIRCRAFT_TO]
 
41
 
 
42
                /** Vehicle can't start / stop */
 
43
                ERR_VEHICLE_CANNOT_START_STOP,          // [STR_883B_CAN_T_STOP_START_TRAIN, STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, STR_9818_CAN_T_STOP_START_SHIP, STR_A016_CAN_T_STOP_START_AIRCRAFT]
 
44
 
 
45
                /** Vehicle can't turn */
 
46
                ERR_VEHICLE_CANNOT_TURN,                // [STR_8869_CAN_T_REVERSE_DIRECTION, STR_9033_CAN_T_MAKE_VEHICLE_TURN]
 
47
 
 
48
                /** Vehicle can't be refit */
 
49
                ERR_VEHICLE_CANNOT_REFIT,               // [STR_RAIL_CAN_T_REFIT_VEHICLE, STR_REFIT_ROAD_VEHICLE_CAN_T, STR_9841_CAN_T_REFIT_SHIP, STR_A042_CAN_T_REFIT_AIRCRAFT]
 
50
 
 
51
                /** Vehicle is destroyed */
 
52
                ERR_VEHICLE_IS_DESTROYED,               // [STR_CAN_T_REFIT_DESTROYED_VEHICLE, STR_CAN_T_SELL_DESTROYED_VEHICLE]
 
53
 
 
54
                /** Vehicle is not in a depot */
 
55
                ERR_VEHICLE_NOT_IN_DEPOT,               // [STR_A01B_AIRCRAFT_MUST_BE_STOPPED, STR_9013_MUST_BE_STOPPED_INSIDE, STR_TRAIN_MUST_BE_STOPPED, STR_980B_SHIP_MUST_BE_STOPPED_IN]
 
56
 
 
57
                /** Vehicle is flying */
 
58
                ERR_VEHICLE_IN_FLIGHT,                  // [STR_A017_AIRCRAFT_IS_IN_FLIGHT]
 
59
 
 
60
                /** Vehicle is without power */
 
61
                ERR_VEHCILE_NO_POWER,                   // [STR_TRAIN_START_NO_CATENARY]
 
62
 
 
63
        };
 
64
 
 
65
        /**
 
66
         * The type of a vehicle available in the game. Trams for example are
 
67
         *  road vehicles, as maglev is a rail vehicle.
 
68
         */
 
69
        enum VehicleType {
 
70
                /* Order IS important, as it now matches the internal state of the game for vehicle type */
 
71
                VT_RAIL,           //!< Rail type vehicle.
 
72
                VT_ROAD,           //!< Road type vehicle (bus / truck).
 
73
                VT_WATER,          //!< Water type vehicle.
 
74
                VT_AIR,            //!< Air type vehicle.
 
75
                VT_INVALID = 0xFF, //!< Invalid vehicle type.
 
76
 
 
77
#ifdef DEFINE_SCRIPT_FILES
 
78
                VEHICLE_INVALID = -1, //!< Invalid VehicleID.
 
79
#endif /* DEFINE_SCRIPT_FILES */
 
80
        };
 
81
 
 
82
        /**
 
83
         * The different states a vehicle can be in.
 
84
         */
 
85
        enum VehicleState {
 
86
                VS_RUNNING,        //!< The vehicle is currently running.
 
87
                VS_STOPPED,        //!< The vehicle is stopped manually.
 
88
                VS_IN_DEPOT,       //!< The vehicle is stopped in the depot.
 
89
                VS_AT_STATION,     //!< The vehicle is stopped at a station and is currently loading or unloading.
 
90
                VS_BROKEN,         //!< The vehicle has broken down and will start running again in a while.
 
91
                VS_CRASHED,        //!< The vehicle is crashed (and will never run again).
 
92
 
 
93
                VS_INVALID = 0xFF, //!< An invalid vehicle state.
 
94
        };
 
95
 
 
96
        /**
 
97
         * Checks whether the given vehicle is valid and owned by you.
 
98
         * @param vehicle_id The vehicle to check.
 
99
         * @return True if and only if the vehicle is valid.
 
100
         */
 
101
        static bool IsValidVehicle(VehicleID vehicle_id);
 
102
 
 
103
        /**
 
104
         * Get the number of wagons a vehicle has.
 
105
         * @param vehicle_id The vehicle to get the number of wagons from.
 
106
         * @pre IsValidVehicle(vehicle_id).
 
107
         * @return The number of wagons the vehicle has.
 
108
         */
 
109
        static int32 GetNumWagons(VehicleID vehicle_id);
 
110
 
 
111
        /**
 
112
         * Set the name of a vehicle.
 
113
         * @param vehicle_id The vehicle to set the name for.
 
114
         * @param name The name for the vehicle.
 
115
         * @pre IsValidVehicle(vehicle_id).
 
116
         * @pre 'name' must have at least one character.
 
117
         * @pre 'name' must have at most 30 characters.
 
118
         * @exception AIError::ERR_NAME_IS_NOT_UNIQUE
 
119
         * @return True if and only if the name was changed.
 
120
         */
 
121
        static bool SetName(VehicleID vehicle_id, const char *name);
 
122
 
 
123
        /**
 
124
         * Get the name of a vehicle.
 
125
         * @param vehicle_id The vehicle to get the name of.
 
126
         * @pre IsValidVehicle(vehicle_id).
 
127
         * @return The name the vehicle has.
 
128
         */
 
129
        static char *GetName(VehicleID vehicle_id);
 
130
 
 
131
        /**
 
132
         * Get the current location of a vehicle.
 
133
         * @param vehicle_id The vehicle to get the location of.
 
134
         * @pre IsValidVehicle(vehicle_id).
 
135
         * @return The tile the vehicle is currently on.
 
136
         */
 
137
        static TileIndex GetLocation(VehicleID vehicle_id);
 
138
 
 
139
        /**
 
140
         * Get the engine-type of a vehicle.
 
141
         * @param vehicle_id The vehicle to get the engine-type of.
 
142
         * @pre IsValidVehicle(vehicle_id).
 
143
         * @return The engine type the vehicle has.
 
144
         */
 
145
        static EngineID GetEngineType(VehicleID vehicle_id);
 
146
 
 
147
        /**
 
148
         * Get the engine-type of a wagon.
 
149
         * @param vehicle_id The vehicle to get the engine-type of.
 
150
         * @param wagon The wagon in the vehicle to get the engine-type of.
 
151
         * @pre IsValidVehicle(vehicle_id).
 
152
         * @pre wagon < GetNumWagons(vehicle_id).
 
153
         * @return The engine type the vehicle has.
 
154
         */
 
155
        static EngineID GetWagonEngineType(VehicleID vehicle_id, int wagon);
 
156
 
 
157
        /**
 
158
         * Get the unitnumber of a vehicle.
 
159
         * @param vehicle_id The vehicle to get the unitnumber of.
 
160
         * @pre IsValidVehicle(vehicle_id).
 
161
         * @return The unitnumber the vehicle has.
 
162
         */
 
163
        static int32 GetUnitNumber(VehicleID vehicle_id);
 
164
 
 
165
        /**
 
166
         * Get the current age of a vehicle.
 
167
         * @param vehicle_id The vehicle to get the age of.
 
168
         * @pre IsValidVehicle(vehicle_id).
 
169
         * @return The current age the vehicle has.
 
170
         * @note The age is in days.
 
171
         */
 
172
        static int32 GetAge(VehicleID vehicle_id);
 
173
 
 
174
        /**
 
175
         * Get the current age of a second (or third, etc.) engine in a train vehicle.
 
176
         * @param vehicle_id The vehicle to get the age of.
 
177
         * @param wagon The wagon in the vehicle to get the age of.
 
178
         * @pre IsValidVehicle(vehicle_id).
 
179
         * @pre wagon < GetNumWagons(vehicle_id).
 
180
         * @return The current age the vehicle has.
 
181
         * @note The age is in days.
 
182
         */
 
183
        static int32 GetWagonAge(VehicleID vehicle_id, int wagon);
 
184
 
 
185
        /**
 
186
         * Get the maximum age of a vehicle.
 
187
         * @param vehicle_id The vehicle to get the age of.
 
188
         * @pre IsValidVehicle(vehicle_id).
 
189
         * @return The maximum age the vehicle has.
 
190
         * @note The age is in days.
 
191
         */
 
192
        static int32 GetMaxAge(VehicleID vehicle_id);
 
193
 
 
194
        /**
 
195
         * Get the age a vehicle has left (maximum - current).
 
196
         * @param vehicle_id The vehicle to get the age of.
 
197
         * @pre IsValidVehicle(vehicle_id).
 
198
         * @return The age the vehicle has left.
 
199
         * @note The age is in days.
 
200
         */
 
201
        static int32 GetAgeLeft(VehicleID vehicle_id);
 
202
 
 
203
        /**
 
204
         * Get the current speed of a vehicle.
 
205
         * @param vehicle_id The vehicle to get the age of.
 
206
         * @pre IsValidVehicle(vehicle_id).
 
207
         * @return The current speed of the vehicle.
 
208
         * @note The speed is in OpenTTD's internal speed unit.
 
209
         *       This is mph / 1.6, which is roughly km/h.
 
210
         *       To get km/h multiply this number by 1.00584.
 
211
         */
 
212
        static int32 GetCurrentSpeed(VehicleID vehicle_id);
 
213
 
 
214
        /**
 
215
         * Get the current state of a vehicle.
 
216
         * @param vehicle_id The vehicle to get the state of.
 
217
         * @pre IsValidVehicle(vehicle_id).
 
218
         * @return The current state of the vehicle.
 
219
         */
 
220
        static VehicleState GetState(VehicleID vehicle_id);
 
221
 
 
222
        /**
 
223
         * Get the running cost of this vehicle.
 
224
         * @param vehicle_id The vehicle to get the age of.
 
225
         * @pre IsValidVehicle(vehicle_id).
 
226
         * @return The running cost of the vehicle per year.
 
227
         * @note Cost is per year; divide by 365 to get per day.
 
228
         * @note This is not equal to AIEngine::GetRunningCost for Trains, because
 
229
         *   wagons and second engines can add up in the calculation too.
 
230
         */
 
231
        static Money GetRunningCost(VehicleID vehicle_id);
 
232
 
 
233
        /**
 
234
         * Get the current profit of a vehicle.
 
235
         * @param vehicle_id The vehicle to get the profit of.
 
236
         * @pre IsValidVehicle(vehicle_id).
 
237
         * @return The current profit the vehicle has.
 
238
         */
 
239
        static Money GetProfitThisYear(VehicleID vehicle_id);
 
240
 
 
241
        /**
 
242
         * Get the profit of last year of a vehicle.
 
243
         * @param vehicle_id The vehicle to get the profit of.
 
244
         * @pre IsValidVehicle(vehicle_id).
 
245
         * @return The profit the vehicle had last year.
 
246
         */
 
247
        static Money GetProfitLastYear(VehicleID vehicle_id);
 
248
 
 
249
 
 
250
        /**
 
251
         * Get the current value of a vehicle.
 
252
         * @param vehicle_id The vehicle to get the value of.
 
253
         * @pre IsValidVehicle(vehicle_id).
 
254
         * @return The value the vehicle currently has (the amount you should get
 
255
         *  when you would sell the vehicle right now).
 
256
         */
 
257
        static Money GetCurrentValue(VehicleID vehicle_id);
 
258
 
 
259
        /**
 
260
         * Get the type of vehicle.
 
261
         * @param vehicle_id The vehicle to get the type of.
 
262
         * @pre IsValidVehicle(vehicle_id).
 
263
         * @return The vehicle type.
 
264
         */
 
265
        static AIVehicle::VehicleType GetVehicleType(VehicleID vehicle_id);
 
266
 
 
267
        /**
 
268
         * Get the RoadType of the vehicle.
 
269
         * @param vehicle_id The vehicle to get the RoadType of.
 
270
         * @pre IsValidVehicle(vehicle_id).
 
271
         * @pre GetVehicleType(vehicle_id) == VT_ROAD.
 
272
         * @return The RoadType the vehicle has.
 
273
         */
 
274
        static AIRoad::RoadType GetRoadType(VehicleID vehicle_id);
 
275
 
 
276
        /**
 
277
         * Check if a vehicle is in a depot.
 
278
         * @param vehicle_id The vehicle to check.
 
279
         * @pre IsValidVehicle(vehicle_id).
 
280
         * @return True if and only if the vehicle is in a depot.
 
281
         */
 
282
        static bool IsInDepot(VehicleID vehicle_id);
 
283
 
 
284
        /**
 
285
         * Check if a vehicle is in a depot and stopped.
 
286
         * @param vehicle_id The vehicle to check.
 
287
         * @pre IsValidVehicle(vehicle_id).
 
288
         * @return True if and only if the vehicle is in a depot and stopped.
 
289
         */
 
290
        static bool IsStoppedInDepot(VehicleID vehicle_id);
 
291
 
 
292
        /**
 
293
         * Builds a vehicle with the given engine at the given depot.
 
294
         * @param depot The depot where the vehicle will be build.
 
295
         * @param engine_id The engine to use for this vehicle.
 
296
         * @pre The tile at depot has a depot that can build the engine and
 
297
         *   is owned by you.
 
298
         * @pre IsValidEngine(engine_id).
 
299
         * @exception AIVehicle::ERR_VEHICLE_TOO_MANY
 
300
         * @exception AIVehicle::ERR_VEHICLE_BUILD_DISABLED
 
301
         * @exception AIVehicle::ERR_VEHICLE_WRONG_DEPOT
 
302
         * @return The VehicleID of the new vehicle, or an invalid VehicleID when
 
303
         *   it failed. Check the return value using IsValidVehicle. In test-mode
 
304
         *   0 is returned if it was successful; any other value indicates failure.
 
305
         * @note In Test Mode it means you can't assign orders yet to this vehicle,
 
306
         *   as the vehicle isn't really built yet. Build it for real first before
 
307
         *   assigning orders.
 
308
         */
 
309
        static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id);
 
310
 
 
311
        /**
 
312
         * Clones a vehicle at the given depot, copying or cloning it's orders.
 
313
         * @param depot The depot where the vehicle will be build.
 
314
         * @param vehicle_id The vehicle to use as example for the new vehicle.
 
315
         * @param share_orders Should the orders be copied or shared?
 
316
         * @pre The tile 'depot' has a depot on it, allowing 'vehicle_id'-type vehicles.
 
317
         * @pre IsValidVehicle(vehicle_id).
 
318
         * @exception AIVehicle::ERR_VEHICLE_TOO_MANY
 
319
         * @exception AIVehicle::ERR_VEHICLE_BUILD_DISABLED
 
320
         * @exception AIVehicle::ERR_VEHICLE_WRONG_DEPOT
 
321
         * @return The VehicleID of the new vehicle, or an invalid VehicleID when
 
322
         *   it failed. Check the return value using IsValidVehicle. In test-mode
 
323
         *   0 is returned if it was successful; any other value indicates failure.
 
324
         */
 
325
        static VehicleID CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders);
 
326
 
 
327
        /**
 
328
         * Move a wagon after another wagon.
 
329
         * @param source_vehicle_id The vehicle to move a wagon away from.
 
330
         * @param source_wagon The wagon in source_vehicle to move.
 
331
         * @param dest_vehicle_id The vehicle to move the wagon to, or -1 to create a new vehicle.
 
332
         * @param dest_wagon The wagon in dest_vehicle to place source_wagon after.
 
333
         * @pre IsValidVehicle(source_vehicle_id).
 
334
         * @pre source_wagon < GetNumWagons(source_vehicle_id).
 
335
         * @pre dest_vehicle_id == -1 || (IsValidVehicle(dest_vehicle_id) && dest_wagon < GetNumWagons(dest_vehicle_id)).
 
336
         * @pre GetVehicleType(source_vehicle_id) == VT_RAIL.
 
337
         * @pre dest_vehicle_id == -1 || GetVehicleType(dest_vehicle_id) == VT_RAIL.
 
338
         * @return Whether or not moving the wagon succeeded.
 
339
         */
 
340
        static bool MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
 
341
 
 
342
        /**
 
343
         * Move a chain of wagons after another wagon.
 
344
         * @param source_vehicle_id The vehicle to move a wagon away from.
 
345
         * @param source_wagon The first wagon in source_vehicle to move.
 
346
         * @param dest_vehicle_id The vehicle to move the wagons to, or -1 to create a new vehicle.
 
347
         * @param dest_wagon The wagon in dest_vehicle to place source_wagon and following wagons after.
 
348
         * @pre IsValidVehicle(source_vehicle_id).
 
349
         * @pre source_wagon < GetNumWagons(source_vehicle_id).
 
350
         * @pre dest_vehicle_id == -1 || (IsValidVehicle(dest_vehicle_id) && dest_wagon < GetNumWagons(dest_vehicle_id)).
 
351
         * @pre GetVehicleType(source_vehicle_id) == VT_RAIL.
 
352
         * @pre dest_vehicle_id == -1 || GetVehicleType(dest_vehicle_id) == VT_RAIL.
 
353
         * @return Whether or not moving the wagons succeeded.
 
354
         */
 
355
        static bool MoveWagonChain(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon);
 
356
 
 
357
        /**
 
358
         * Gets the capacity of the given vehicle when refited to the given cargo type.
 
359
         * @param vehicle_id The vehicle to refit.
 
360
         * @param cargo The cargo to refit to.
 
361
         * @pre IsValidVehicle(vehicle_id).
 
362
         * @pre AICargo::IsValidCargo(cargo).
 
363
         * @pre You must own the vehicle.
 
364
         * @pre The vehicle must be stopped in the depot.
 
365
         * @return The capacity the vehicle will have when refited.
 
366
         */
 
367
        static int GetRefitCapacity(VehicleID vehicle_id, CargoID cargo);
 
368
 
 
369
        /**
 
370
         * Refits a vehicle to the given cargo type.
 
371
         * @param vehicle_id The vehicle to refit.
 
372
         * @param cargo The cargo to refit to.
 
373
         * @pre IsValidVehicle(vehicle_id).
 
374
         * @pre AICargo::IsValidCargo(cargo).
 
375
         * @pre You must own the vehicle.
 
376
         * @pre The vehicle must be stopped in the depot.
 
377
         * @exception AIVehicle::ERR_VEHICLE_CANNOT_REFIT
 
378
         * @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
 
379
         * @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
 
380
         * @return True if and only if the refit succeeded.
 
381
         */
 
382
        static bool RefitVehicle(VehicleID vehicle_id, CargoID cargo);
 
383
 
 
384
        /**
 
385
         * Sells the given vehicle.
 
386
         * @param vehicle_id The vehicle to sell.
 
387
         * @pre IsValidVehicle(vehicle_id).
 
388
         * @pre You must own the vehicle.
 
389
         * @pre The vehicle must be stopped in the depot.
 
390
         * @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
 
391
         * @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
 
392
         * @return True if and only if the vehicle has been sold.
 
393
         */
 
394
        static bool SellVehicle(VehicleID vehicle_id);
 
395
 
 
396
        /**
 
397
         * Sells the given wagon from the vehicle.
 
398
         * @param vehicle_id The vehicle to sell a wagon from.
 
399
         * @param wagon The wagon to sell.
 
400
         * @pre IsValidVehicle(vehicle_id).
 
401
         * @pre wagon < GetNumWagons(vehicle_id).
 
402
         * @pre You must own the vehicle.
 
403
         * @pre The vehicle must be stopped in the depot.
 
404
         * @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
 
405
         * @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
 
406
         * @return True if and only if the wagon has been sold.
 
407
         */
 
408
        static bool SellWagon(VehicleID vehicle_id, int wagon);
 
409
 
 
410
        /**
 
411
         * Sells all wagons from the vehicle starting from a given position.
 
412
         * @param vehicle_id The vehicle to sell a wagon from.
 
413
         * @param wagon The wagon to sell.
 
414
         * @pre IsValidVehicle(vehicle_id).
 
415
         * @pre wagon < GetNumWagons(vehicle_id).
 
416
         * @pre You must own the vehicle.
 
417
         * @pre The vehicle must be stopped in the depot.
 
418
         * @exception AIVehicle::ERR_VEHICLE_IS_DESTROYED
 
419
         * @exception AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT
 
420
         * @return True if and only if the wagons have been sold.
 
421
         */
 
422
        static bool SellWagonChain(VehicleID vehicle_id, int wagon);
 
423
 
 
424
        /**
 
425
         * Sends the given vehicle to a depot.
 
426
         * @param vehicle_id The vehicle to send to a depot.
 
427
         * @pre IsValidVehicle(vehicle_id).
 
428
         * @exception AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT
 
429
         * @return True if and only if the vehicle has been sent to a depot.
 
430
         */
 
431
        static bool SendVehicleToDepot(VehicleID vehicle_id);
 
432
 
 
433
        /**
 
434
         * Starts or stops the given vehicle depending on the current state.
 
435
         * @param vehicle_id The vehicle to start/stop.
 
436
         * @pre IsValidVehicle(vehicle_id).
 
437
         * @exception AIVehicle::ERR_VEHICLE_CANNOT_START_STOP
 
438
         * @exception (For aircraft only): AIVehicle::ERR_VEHICLE_IN_FLIGHT
 
439
         * @exception (For trains only): AIVehicle::ERR_VEHICLE_NO_POWER
 
440
         * @return True if and only if the vehicle has been started or stopped.
 
441
         */
 
442
        static bool StartStopVehicle(VehicleID vehicle_id);
 
443
 
 
444
        /**
 
445
         * Skips the current order of the given vehicle.
 
446
         * @param vehicle_id The vehicle to skip the order for.
 
447
         * @param order_position The selected order to which we want to skip.
 
448
         * @pre IsValidVehicleOrder(vehicle_id, order_position).
 
449
         * @return True if and only if the order has been skipped.
 
450
         */
 
451
        static bool SkipToVehicleOrder(VehicleID vehicle_id, AIOrder::OrderPosition order_position);
 
452
 
 
453
        /**
 
454
         * Turn the given vehicle so it'll drive the other way.
 
455
         * @param vehicle_id The vehicle to turn.
 
456
         * @pre IsValidVehicle(vehicle_id).
 
457
         * @pre GetVehicleType(vehicle_id) == VT_ROAD || GetVehicleType(vehicle_id) == VT_RAIL.
 
458
         * @return True if and only if the vehicle has started to turn.
 
459
         * @note Vehicles cannot always be reversed. For example busses and trucks need to be running
 
460
         *  and not be inside a depot.
 
461
         */
 
462
        static bool ReverseVehicle(VehicleID vehicle_id);
 
463
 
 
464
        /**
 
465
         * Get the maximum amount of a specific cargo the given vehicle can transport.
 
466
         * @param vehicle_id The vehicle to get the capacity of.
 
467
         * @param cargo The cargo to get the capacity for.
 
468
         * @pre IsValidVehicle(vehicle_id).
 
469
         * @pre AICargo::IsValidCargo(cargo).
 
470
         * @return The maximum amount of the given cargo the vehicle can transport.
 
471
         */
 
472
        static int32 GetCapacity(VehicleID vehicle_id, CargoID cargo);
 
473
 
 
474
        /**
 
475
         * Get the length of a the total vehicle in 1/16's of a tile.
 
476
         * @param vehicle_id The vehicle to get the length of.
 
477
         * @pre IsValidVehicle(vehicle_id).
 
478
         * @pre GetVehicleType(vehicle_id) == VT_ROAD || GetVehicleType(vehicle_id) == VT_RAIL.
 
479
         * @return The length of the engine.
 
480
         */
 
481
        static int GetLength(VehicleID vehicle_id);
 
482
 
 
483
        /**
 
484
         * Get the amount of a specific cargo the given vehicle transports.
 
485
         * @param vehicle_id The vehicle to get the load amount of.
 
486
         * @param cargo The cargo to get the load amount for.
 
487
         * @pre IsValidVehicle(vehicle_id).
 
488
         * @pre AICargo::IsValidCargo(cargo).
 
489
         * @return The amount of the given cargo the vehicle currently transports.
 
490
         */
 
491
        static int32 GetCargoLoad(VehicleID vehicle_id, CargoID cargo);
 
492
 
 
493
        /**
 
494
         * Get the group of a given vehicle.
 
495
         * @param vehicle_id The vehicle to get the group from.
 
496
         * @return The group of the given vehicle.
 
497
         */
 
498
        static GroupID GetGroupID(VehicleID vehicle_id);
 
499
 
 
500
        /**
 
501
         * Check if the vehicle is articulated.
 
502
         * @param vehicle_id The vehicle to check.
 
503
         * @pre IsValidVehicle(vehicle_id).
 
504
         * @pre GetVehicleType(vehicle_id) == VT_ROAD || GetVehicleType(vehicle_id) == VT_RAIL.
 
505
         * @return True if the vehicle is articulated.
 
506
         */
 
507
        static bool IsArticulated(VehicleID vehicle_id);
 
508
 
 
509
        /**
 
510
         * Check if the vehicle has shared orders.
 
511
         * @param vehicle_id The vehicle to check.
 
512
         * @pre IsValidVehicle(vehicle_id).
 
513
         * @return True if the vehicle has shared orders.
 
514
         */
 
515
        static bool HasSharedOrders(VehicleID vehicle_id);
 
516
 
 
517
private:
 
518
        /**
 
519
         * Internal function used by SellWagon(Chain).
 
520
         */
 
521
        static bool _SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons);
 
522
 
 
523
        /**
 
524
         * Internal function used by MoveWagon(Chain).
 
525
         */
 
526
        static bool _MoveWagonInternal(VehicleID source_vehicle_id, int source_wagon, bool move_attached_wagons, int dest_vehicle_id, int dest_wagon);
 
527
};
 
528
 
 
529
#endif /* AI_VEHICLE_HPP */