src/vehicle.h
author rubidium
Fri, 21 Dec 2007 22:50:51 +0000
changeset 8615 6b91ca653bad
parent 8604 8afdd9877afd
child 8619 c2434269c3eb
permissions -rw-r--r--
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
     3
/** @vehicle.h */
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef VEHICLE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define VEHICLE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8602
diff changeset
     8
#include "vehicle_type.h"
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 5211
diff changeset
     9
#include "oldpool.h"
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
    10
#include "order.h"
8598
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
    11
#include "track_type.h"
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
    12
#include "rail_type.h"
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
    13
#include "road_type.h"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
    14
#include "cargo_type.h"
8602
9e75e594a068 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 8598
diff changeset
    15
#include "window_type.h"
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
    16
#include "cargopacket.h"
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
    17
#include "texteff.hpp"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
    18
#include "command_type.h"
6317
c73bda71ac16 (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 6206
diff changeset
    19
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    20
/** Road vehicle states */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    21
enum RoadVehicleStates {
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    22
	/*
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    23
	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    24
	 * When in a road stop (bit 5 or bit 6 set) these bits give the
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    25
	 * track direction of the entry to the road stop.
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    26
	 * As the entry direction will always be a diagonal
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    27
	 * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    28
	 * are needed to hold this direction. Bit 1 is then used to show
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    29
	 * that the vehicle is using the second road stop bay.
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    30
	 * Bit 2 is then used for drive-through stops to show the vehicle
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    31
	 * is stopping at this road stop.
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    32
	 */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    33
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    34
	/* Numeric values */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    35
	RVSB_IN_DEPOT                = 0xFE,                      ///< The vehicle is in a depot
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    36
	RVSB_WORMHOLE                = 0xFF,                      ///< The vehicle is in a tunnel and/or bridge
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    37
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    38
	/* Bit numbers */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    39
	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    40
	RVS_IS_STOPPING              =    2,                      ///< Only used for drive-through stops. Vehicle will stop here
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    41
	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    42
	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    43
	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    44
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    45
	/* Bit sets of the above specified bits */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    46
	RVSB_IN_ROAD_STOP            = 1 << RVS_IN_ROAD_STOP,     ///< The vehicle is in a road stop
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    47
	RVSB_IN_ROAD_STOP_END        = RVSB_IN_ROAD_STOP + TRACKDIR_END,
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    48
	RVSB_IN_DT_ROAD_STOP         = 1 << RVS_IN_DT_ROAD_STOP,  ///< The vehicle is in a drive-through road stop
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    49
	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    50
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    51
	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    52
	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    53
};
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    54
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    55
enum VehStatus {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    56
	VS_HIDDEN          = 0x01,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    57
	VS_STOPPED         = 0x02,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    58
	VS_UNCLICKABLE     = 0x04,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    59
	VS_DEFPAL          = 0x08,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    60
	VS_TRAIN_SLOWING   = 0x10,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    61
	VS_SHADOW          = 0x20,
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    62
	VS_AIRCRAFT_BROKEN = 0x40,
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    63
	VS_CRASHED         = 0x80,
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    64
};
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    65
6501
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    66
enum VehicleFlags {
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    67
	VF_LOADING_FINISHED,
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    68
	VF_CARGO_UNLOADING,
6502
7ca154aca2b7 (svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents: 6501
diff changeset
    69
	VF_BUILT_AS_PROTOTYPE,
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7510
diff changeset
    70
	VF_TIMETABLE_STARTED,  ///< Whether the vehicle has started running on the timetable yet.
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7510
diff changeset
    71
	VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
5211
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
    72
};
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
    73
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    74
/* Effect vehicle types */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    75
enum EffectVehicle {
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    76
	EV_CHIMNEY_SMOKE   = 0,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    77
	EV_STEAM_SMOKE     = 1,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    78
	EV_DIESEL_SMOKE    = 2,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    79
	EV_ELECTRIC_SPARK  = 3,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    80
	EV_SMOKE           = 4,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    81
	EV_EXPLOSION_LARGE = 5,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    82
	EV_BREAKDOWN_SMOKE = 6,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    83
	EV_EXPLOSION_SMALL = 7,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    84
	EV_BULLDOZER       = 8,
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    85
	EV_BUBBLE          = 9
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    86
};
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    87
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    88
struct VehicleRail {
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4404
diff changeset
    89
	uint16 last_speed; // NOSAVE: only used in UI
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	uint16 crash_anim_pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
    91
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
    92
	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
1905
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
    93
	uint16 cached_max_speed;  // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
    94
	uint32 cached_power;      // total power of the consist.
1922
797081e56d13 (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    95
	uint8 cached_veh_length;  // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
2587
d554e2a03afa (svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents: 2579
diff changeset
    96
	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
d554e2a03afa (svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents: 2579
diff changeset
    97
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
    98
	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
5162
f1d90a883266 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
    99
	uint32 cached_weight;     // total weight of the consist.
f1d90a883266 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
   100
	uint32 cached_veh_weight; // weight of the vehicle.
5588
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5573
diff changeset
   101
	uint32 cached_max_te;     // max tractive effort of consist
2595
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   102
	/**
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   103
	 * Position/type of visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   104
	 * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   105
	 * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   106
	 * bit     6 = disable visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   107
	 * bit     7 = disable powered wagons.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   108
	 */
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   109
	byte cached_vis_effect;
8377
77aaffeea0d7 (svn r11431) -Codechange: [NewGRF] Add support for changing rail vehicle user-defined bit mask (prop 25) via callback 36
glx
parents: 8299
diff changeset
   110
	byte user_def_data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   112
	/* NOSAVE: for wagon override - id of the first engine in train
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   113
	 * 0xffff == not in train */
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1790
diff changeset
   114
	EngineID first_engine;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   116
	TrackBitsByte track;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	byte force_proceed;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   118
	RailTypeByte railtype;
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3347
diff changeset
   119
	RailTypeMask compatible_railtypes;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	byte flags;
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 1977
diff changeset
   122
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   123
	/* Link between the two ends of a multiheaded engine */
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2666
diff changeset
   124
	Vehicle *other_multiheaded_part;
7099
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   125
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   126
	/* Cached wagon override spritegroup */
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   127
	const struct SpriteGroup *cached_override;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   128
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   131
	VRF_REVERSING         = 0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   133
	/* used to calculate if train is going up or down */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   134
	VRF_GOINGUP           = 1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   135
	VRF_GOINGDOWN         = 2,
1908
bc48a30aba72 (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1905
diff changeset
   136
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   137
	/* used to store if a wagon is powered or not */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   138
	VRF_POWEREDWAGON      = 3,
3256
a23d94f568b7 (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   139
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   140
	/* used to reverse the visible direction of the vehicle */
3256
a23d94f568b7 (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   141
	VRF_REVERSE_DIRECTION = 4,
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4734
diff changeset
   142
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   143
	/* used to mark train as lost because PF can't find the route */
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4734
diff changeset
   144
	VRF_NO_PATH_TO_DESTINATION = 5,
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   145
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   146
	/* used to mark that electric train engine is allowed to run on normal rail */
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   147
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   150
struct VehicleAir {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	uint16 crashed_counter;
6986
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6919
diff changeset
   152
	uint16 cached_max_speed;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
	byte pos;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3977
diff changeset
   154
	byte previous_pos;
3347
d5d8ace1bb13 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3344
diff changeset
   155
	StationID targetairport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	byte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   157
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   159
struct VehicleRoad {
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   160
	byte state;             ///< @see RoadVehicleStates
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	byte frame;
3009
c477ab0f00b3 (svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr
peter1138
parents: 3008
diff changeset
   162
	uint16 blocked_ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	byte overtaking;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	byte overtaking_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	uint16 crashed_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	byte reverse_ctr;
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   167
	struct RoadStop *slot;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   168
	byte slot_age;
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7269
diff changeset
   169
	EngineID first_engine;
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7269
diff changeset
   170
	byte cached_veh_length;
7179
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   171
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   172
	RoadType roadtype;
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   173
	RoadTypes compatible_roadtypes;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   174
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   176
struct VehicleSpecial {
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   177
	uint16 animation_state;
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   178
	byte animation_substate;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   179
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   181
struct VehicleDisaster {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	uint16 image_override;
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   183
	VehicleID big_ufo_destroyer_target;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   184
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   186
struct VehicleShip {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   187
	TrackBitsByte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   188
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   190
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   192
/* Some declarations of functions, so we can make them friendly */
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   193
struct SaveLoad;
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   194
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   195
extern void AfterLoadVehicles();
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   196
struct LoadgameState;
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   197
extern bool LoadOldVehicle(LoadgameState *ls, int num);
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   198
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   199
struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
7117
866a75f1ac5e (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 7112
diff changeset
   200
	VehicleTypeByte type;    ///< Type of vehicle
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6043
diff changeset
   201
	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   203
private:
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   204
	Vehicle *next;           // pointer to the next vehicle in the chain
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   205
	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   206
	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   207
public:
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   208
	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   209
	friend void AfterLoadVehicles();                              // So we can set the previous and first pointers while loading
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   210
	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   211
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   212
	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   214
	StringID string_id;      // Displayed string
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   216
	UnitID unitnumber;       // unit number, for display purposes only
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   217
	PlayerByte owner;        // which player owns the vehicle?
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   218
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   219
	TileIndex tile;          // Current tile index
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   220
	TileIndex dest_tile;     // Heading for this tile
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   221
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   222
	int32 x_pos;             // coordinates
1174
27e386195965 (svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents: 1139
diff changeset
   223
	int32 y_pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
	byte z_pos;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   225
	DirectionByte direction; // facing
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   227
	byte spritenum;          // currently displayed sprite index
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   228
	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   229
	                         // 0xff == reserved for another custom sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   230
	uint16 cur_image;        // sprite number for this vehicle
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   231
	byte sprite_width;       // width of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   232
	byte sprite_height;      // height of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   233
	byte z_height;           // z-height of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   234
	int8 x_offs;             // x offset for vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   235
	int8 y_offs;             // y offset for vehicle sprite
1770
b6bda4dc6da2 (svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
Darkvater
parents: 1765
diff changeset
   236
	EngineID engine_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   238
	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   239
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   240
	/* for randomized variational spritegroups
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   241
	 * bitmask used to resolve them; parts of it get reseeded when triggers
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   242
	 * of corresponding spritegroups get matched */
445
0e3fa3da3899 (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents: 395
diff changeset
   243
	byte random_bits;
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   244
	byte waiting_triggers;   // triggers to be yet matched
445
0e3fa3da3899 (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents: 395
diff changeset
   245
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   246
	uint16 max_speed;        // maximum speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   247
	uint16 cur_speed;        // current speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   248
	byte subspeed;           // fractional speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   249
	byte acceleration;       // used by train & aircraft
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
	byte progress;
4656
acffecd6f484 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 4635
diff changeset
   251
	uint32 motion_counter;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   253
	byte vehstatus;          // Status
3347
d5d8ace1bb13 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3344
diff changeset
   254
	StationID last_station_visited;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   255
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   256
	CargoID cargo_type;      // type of cargo this vehicle is carrying
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   257
	uint16 cargo_cap;        // total capacity
3870
766d7bd6c299 (svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents: 3580
diff changeset
   258
	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
   259
	CargoList cargo;         ///< The cargo this vehicle is carrying
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
   260
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   262
	byte day_counter;        // increased by one for each day
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   263
	byte tick_counter;       // increased by one for each tick
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   265
	/* Begin Order-stuff */
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   266
	Order current_order;     ///< The current order (+ status, like: loading)
4391
7bfd170bfdf5 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   267
	VehicleOrderID cur_order_index; ///< The index to the current order
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   268
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   269
	Order *orders;           ///< Pointer to the first order for this vehicle
4391
7bfd170bfdf5 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   270
	VehicleOrderID num_orders;      ///< How many orders there are in the list
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   271
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   272
	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   273
	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   274
	/* End Order-stuff */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   276
	/* Boundaries for the current position in the world and a next hash link.
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   277
	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
849
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   278
	int32 left_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   279
	int32 top_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   280
	int32 right_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   281
	int32 bottom_coord;
5825
d813480f22ac (svn r8007) -Codechange: Change _vehicle_position_hash from VehicleID to Vehicle*. This removes the need for look ups by index. Also declare the array static.
peter1138
parents: 5726
diff changeset
   282
	Vehicle *next_hash;
7367
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
   283
	Vehicle *next_new_hash;
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
   284
	Vehicle **old_new_hash;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   286
	/* Related to age and service time */
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   287
	Date age;     // Age in days
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   288
	Date max_age; // Maximum age
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   289
	Date date_of_last_service;
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   290
	Date service_interval;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	uint16 reliability;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	uint16 reliability_spd_dec;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	byte breakdown_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	byte breakdown_delay;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	byte breakdowns_since_last_service;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	byte breakdown_chance;
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   297
	Year build_year;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   299
	bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
2617
a9e1a187de99 (svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents: 2602
diff changeset
   300
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	uint16 load_unload_time_rem;
6501
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
   302
	byte vehicle_flags;         // Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   303
7449
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
   304
	Money profit_this_year;
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
   305
	Money profit_last_year;
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
   306
	Money value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7137
diff changeset
   308
	GroupID group_id;              ///< Index of group Pool array
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7137
diff changeset
   309
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   310
	/* Used for timetabling. */
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   311
	uint32 current_order_time;     ///< How many ticks have passed since this order started.
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   312
	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   313
8298
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
   314
	SpriteID colormap; // NOSAVE: cached color mapping
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
   315
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
	union {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
		VehicleRail rail;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
		VehicleAir air;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
		VehicleRoad road;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
		VehicleSpecial special;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
		VehicleDisaster disaster;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		VehicleShip ship;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	} u;
5902
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   324
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   325
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   326
	/**
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   327
	 * Allocates a lot of vehicles.
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   328
	 * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   329
	 * @param num number of vehicles to allocate room for
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   330
	 * @return true if there is room to allocate all the vehicles
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   331
	 */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   332
	static bool AllocateList(Vehicle **vl, int num);
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   333
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   334
	/** Create a new vehicle */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   335
	Vehicle();
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   336
7908
403a9694c42d (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7896
diff changeset
   337
	/** Destroy all stuff that (still) needs the virtual functions to work properly */
403a9694c42d (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7896
diff changeset
   338
	void PreDestructor();
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   339
	/** We want to 'destruct' the right class. */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   340
	virtual ~Vehicle();
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   341
5902
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   342
	void BeginLoading();
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   343
	void LeaveStation();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   344
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   345
	/**
7090
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   346
	 * Handle the loading of the vehicle; when not it skips through dummy
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   347
	 * orders and does nothing in all other cases.
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   348
	 * @param mode is the non-first call for this vehicle in this tick?
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   349
	 */
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   350
	void HandleLoading(bool mode = false);
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   351
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   352
	/**
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   353
	 * Get a string 'representation' of the vehicle type.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   354
	 * @return the string representation.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   355
	 */
7896
2a4cdd5ca7d5 (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7894
diff changeset
   356
	virtual const char* GetTypeString() const { return "base vehicle"; }
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   357
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   358
	/**
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   359
	 * Marks the vehicles to be redrawn and updates cached variables
8041
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   360
	 *
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   361
	 * This method marks the area of the vehicle on the screen as dirty.
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   362
	 * It can be use to repaint the vehicle.
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   363
	 *
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   364
	 * @ingroup dirty
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   365
	 */
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   366
	virtual void MarkDirty() {}
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   367
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   368
	/**
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   369
	 * Updates the x and y offsets and the size of the sprite used
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   370
	 * for this vehicle.
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   371
	 * @param direction the direction the vehicle is facing
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   372
	 */
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   373
	virtual void UpdateDeltaXY(Direction direction) {}
7058
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   374
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   375
	/**
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   376
	 * Sets the expense type associated to this vehicle type
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   377
	 * @param income whether this is income or (running) expenses of the vehicle
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   378
	 */
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   379
	virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
7058
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   380
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   381
	/**
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   382
	 * Invalidates the vehicle list window of this type of vehicle
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   383
	 */
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   384
	virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
7089
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   385
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   386
	/**
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   387
	 * Play the sound associated with leaving the station
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   388
	 */
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   389
	virtual void PlayLeaveStationSound() const {}
7269
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   390
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   391
	/**
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   392
	 * Whether this is the primary vehicle in the chain.
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   393
	 */
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   394
	virtual bool IsPrimaryVehicle() const { return false; }
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   395
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   396
	/**
7630
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   397
	 * Gets the sprite to show for the given direction
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   398
	 * @param direction the direction the vehicle is facing
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   399
	 * @return the sprite for the given vehicle in the given direction
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   400
	 */
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   401
	virtual int GetImage(Direction direction) const { return 0; }
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   402
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   403
	/**
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   404
	 * Gets the speed in mph that can be sent into SetDParam for string processing.
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   405
	 * @return the vehicle's speed
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   406
	 */
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   407
	virtual int GetDisplaySpeed() const { return 0; }
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   408
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   409
	/**
7980
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   410
	 * Gets the maximum speed in mph that can be sent into SetDParam for string processing.
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   411
	 * @return the vehicle's maximum speed
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   412
	 */
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   413
	virtual int GetDisplayMaxSpeed() const { return 0; }
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   414
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   415
	/**
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   416
	 * Gets the running cost of a vehicle
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   417
	 * @return the vehicle's running cost
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   418
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   419
	virtual Money GetRunningCost() const { return 0; }
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   420
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   421
	/**
7986
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   422
	 * Check whether the vehicle is in the depot.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   423
	 * @return true if and only if the vehicle is in the depot.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   424
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   425
	virtual bool IsInDepot() const { return false; }
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   426
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   427
	/**
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   428
	 * Check whether the vehicle is in the depot *and* stopped.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   429
	 * @return true if and only if the vehicle is in the depot and stopped.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   430
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   431
	virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   432
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   433
	/**
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   434
	 * Calls the tick handler of the vehicle
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   435
	 */
7896
2a4cdd5ca7d5 (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7894
diff changeset
   436
	virtual void Tick() {};
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   437
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   438
	/**
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   439
	 * Gets the running cost of a vehicle  that can be sent into SetDParam for string processing.
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   440
	 * @return the vehicle's running cost
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   441
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   442
	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   443
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   444
	/**
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   445
	 * Is this vehicle a valid vehicle?
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   446
	 * @return true if and only if the vehicle is valid.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   447
	 */
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   448
	inline bool IsValid() const { return this->type != VEH_INVALID; }
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   449
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   450
	/**
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   451
	 * Set the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   452
	 * @param next the next vehicle. NULL removes the next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   453
	 */
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   454
	void SetNext(Vehicle *next);
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   455
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   456
	/**
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   457
	 * Get the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   458
	 * @note articulated parts are also counted as vehicles.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   459
	 * @return the next vehicle or NULL when there isn't a next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   460
	 */
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   461
	inline Vehicle *Next() const { return this->next; }
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   462
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   463
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   464
	 * Get the previous vehicle of this vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   465
	 * @note articulated parts are also counted as vehicles.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   466
	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   467
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   468
	inline Vehicle *Previous() const { return this->previous; }
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   469
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   470
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   471
	 * Get the first vehicle of this vehicle chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   472
	 * @return the first vehicle of the chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   473
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   474
	inline Vehicle *First() const { return this->first; }
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   475
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   476
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   477
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   478
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   479
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   480
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   481
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   482
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   483
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   484
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   485
 * A special vehicle is one of the following:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   486
 *  - smoke
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   487
 *  - electric sparks for trains
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   488
 *  - explosions
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   489
 *  - bulldozer (road works)
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   490
 *  - bubbles (industry)
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   491
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   492
struct SpecialVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   493
	/** Initializes the Vehicle to a special vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   494
	SpecialVehicle() { this->type = VEH_SPECIAL; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   495
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   496
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   497
	virtual ~SpecialVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   498
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   499
	const char *GetTypeString() const { return "special vehicle"; }
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   500
	void UpdateDeltaXY(Direction direction);
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   501
	void Tick();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   502
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   503
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   504
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   505
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   506
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   507
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   508
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   509
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   510
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   511
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   512
struct DisasterVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   513
	/** Initializes the Vehicle to a disaster vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   514
	DisasterVehicle() { this->type = VEH_DISASTER; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   515
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   516
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   517
	virtual ~DisasterVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   518
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   519
	const char *GetTypeString() const { return "disaster vehicle"; }
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   520
	void UpdateDeltaXY(Direction direction);
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   521
	void Tick();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   522
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   523
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   524
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   525
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   526
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   527
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   528
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   529
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   530
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   531
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   532
struct InvalidVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   533
	/** Initializes the Vehicle to a invalid vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   534
	InvalidVehicle() { this->type = VEH_INVALID; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   535
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   536
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   537
	virtual ~InvalidVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   538
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   539
	const char *GetTypeString() const { return "invalid vehicle"; }
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   540
	void Tick() {}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   543
#define is_custom_sprite(x) (x >= 0xFD)
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   544
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   545
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
typedef void *VehicleFromPosProc(Vehicle *v, void *data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
578
86e352980acd (svn r998) now vehicles are serviced both when entering and when leaving depots to prevent that vehicles might need service when leaving after a long stay (ln--)
bjarni
parents: 577
diff changeset
   549
void VehicleServiceInDepot(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
void VehiclePositionChanged(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
Vehicle *GetLastVehicleInChain(Vehicle *v);
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
   552
uint CountVehiclesInChain(const Vehicle *v);
4574
497540b4a75f (svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents: 4544
diff changeset
   553
bool IsEngineCountable(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
void DeleteVehicleChain(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
7367
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
   556
void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   557
void CallVehicleTicks();
1605
c4630be67467 (svn r2109) -Fix: use FindVehicleOnTileZ(tile, 0) over FindVehicleBetween(tile, tile, 0)
truelight
parents: 1601
diff changeset
   558
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7506
diff changeset
   559
uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   561
void InitializeTrains();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   562
byte VehicleRandomBits();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   563
void ResetVehiclePosHash();
8298
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
   564
void ResetVehicleColorMap();
8299
d5c112dc0726 (svn r11353) -Codechange: add support for newgrf callback 32
glx
parents: 8298
diff changeset
   565
void CheckVehicle32Day(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
2704
dc9ae68dfd74 (svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
peter1138
parents: 2676
diff changeset
   567
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
3973
7624a250577b (svn r5146) - NewGRF: Support selection of aircraft default cargo type by checking its refit mask. If aircraft can be refitted to passengers, no change happens, else the first refittable type is chosen. Also use refit capacity to determine the default capacity.
peter1138
parents: 3948
diff changeset
   568
CargoID FindFirstRefittableCargo(EngineID engine_type);
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
   569
CommandCost GetRefitCost(EngineID engine_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
void ViewportAddVehicles(DrawPixelInfo *dpi);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
6117
b50b5ebc1c98 (svn r8448) -Codechange/Fix (r2993): Also update the helicopter's rotor when loading the game. This can solve crashes when a game is loaded with missing GRF's
Darkvater
parents: 6105
diff changeset
   573
SpriteID GetRotorImage(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
1359
8ba976aed634 (svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents: 1330
diff changeset
   575
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
8ba976aed634 (svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents: 1330
diff changeset
   576
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
8ba976aed634 (svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents: 1330
diff changeset
   577
Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   579
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
3881
b2a66893f250 (svn r4937) Reduce the use of _error_message a bit
tron
parents: 3870
diff changeset
   581
StringID VehicleInTheWayErrMsg(const Vehicle* v);
6191
12d69f54e920 (svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents: 6139
diff changeset
   582
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false);
8568
a82225425c24 (svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents: 8377
diff changeset
   583
Vehicle *GetVehicleTunnelBridge(TileIndex tile, TileIndex endtile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
3172
1605cb59ccd9 (svn r3803) Change the second parameter of UpdateSignalsOnSegment() from Direction to DiagDirection as that's what it really operates on
tron
parents: 3157
diff changeset
   585
bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction);
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   586
void SetSignalsOnBothDir(TileIndex tile, byte track);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
2116
cdfc27b696b7 (svn r2626) static, const, misc.
tron
parents: 2115
diff changeset
   588
Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
void DecreaseVehicleValue(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
void CheckVehicleBreakdown(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
void AgeVehicle(Vehicle *v);
2574
382fd3f37604 (svn r3111) -Fix: [autoreplace] [ 1341783 ] Assertion failure in vehicle.c line 378
bjarni
parents: 2564
diff changeset
   593
void VehicleEnteredDepotThisTick(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
void BeginVehicleMove(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
void EndVehicleMove(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   598
UnitID GetFreeUnitNumber(VehicleType type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
1905
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
   600
void TrainConsistChanged(Vehicle *v);
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3347
diff changeset
   601
void TrainPowerChanged(Vehicle *v);
7449
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
   602
Money GetTrainRunningCost(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
593
e303a764de50 (svn r1015) MFM r789
tron
parents: 578
diff changeset
   604
bool VehicleNeedsService(const Vehicle *v);
e303a764de50 (svn r1015) MFM r789
tron
parents: 578
diff changeset
   605
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   606
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   607
void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
   608
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
4725
f7284b86833f (svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents: 4681
diff changeset
   609
void VehicleEnterDepot(Vehicle *v);
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   610
7592
48055c5dd43d (svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
peter1138
parents: 7582
diff changeset
   611
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6191
diff changeset
   612
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
   613
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
7582
9f23c01ae23d (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7562
diff changeset
   614
bool CanBuildVehicleInfrastructure(VehicleType type);
6590
9bbf8fdc5e91 (svn r9073) -Codechange: moved autoreplace to a file of it's own (now autoreplace has a cmd and a gui file)
bjarni
parents: 6585
diff changeset
   615
7974
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7973
diff changeset
   616
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7973
diff changeset
   617
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   618
/* Flags to add to p2 for goto depot commands */
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   619
/* Note: bits 8-10 are used for VLW flags */
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   620
enum {
6988
76eba6a9cc6f (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6986
diff changeset
   621
	DEPOT_SERVICE       = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   622
	DEPOT_MASS_SEND     = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   623
	DEPOT_DONT_CANCEL   = (1 << 2), // Don't cancel current goto depot command if any
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   624
	DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   625
};
4463
3a70624c40eb (svn r6246) -Feature: added the many times requested "send all vehicle to depot" button
bjarni
parents: 4451
diff changeset
   626
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   627
struct GetNewVehiclePosResult {
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
   628
	int x, y;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   629
	TileIndex old_tile;
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   630
	TileIndex new_tile;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   631
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   633
/**
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   634
 * Returns the Trackdir on which the vehicle is currently located.
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   635
 * Works for trains and ships.
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   636
 * Currently works only sortof for road vehicles, since they have a fuzzy
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   637
 * concept of being "on" a trackdir. Dunno really what it returns for a road
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   638
 * vehicle that is halfway a tile, never really understood that part. For road
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   639
 * vehicles that are at the beginning or end of the tile, should just return
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   640
 * the diagonal trackdir on which they are driving. I _think_.
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   641
 * For other vehicles types, or vehicles with no clear trackdir (such as those
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   642
 * in depots), returns 0xFF.
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   643
 */
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1922
diff changeset
   644
Trackdir GetVehicleTrackdir(const Vehicle* v);
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   645
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
/* returns true if staying in the same tile */
6479
b228a94a1832 (svn r8897) -Fix
tron
parents: 6478
diff changeset
   647
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
   648
Direction GetDirectionTowards(const Vehicle *v, int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
#define BEGIN_ENUM_WAGONS(v) do {
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   651
#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   653
static inline VehicleID GetMaxVehicleIndex()
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   654
{
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   655
	/* TODO - This isn't the real content of the function, but
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   656
	 *  with the new pool-system this will be replaced with one that
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   657
	 *  _really_ returns the highest index. Now it just returns
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   658
	 *  the next safe value we are sure about everything is below.
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   659
	 */
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   660
	return GetVehiclePoolSize() - 1;
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   661
}
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   662
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   663
static inline uint GetNumVehicles()
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   664
{
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   665
	return GetVehiclePoolSize();
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   666
}
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   667
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   668
static inline bool IsPlayerBuildableVehicleType(VehicleType type)
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   669
{
6026
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   670
	switch (type) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   671
		case VEH_TRAIN:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   672
		case VEH_ROAD:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   673
		case VEH_SHIP:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   674
		case VEH_AIRCRAFT:
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   675
			return true;
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   676
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   677
		default: return false;
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   678
	}
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   679
}
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   680
6026
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   681
static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   682
{
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   683
	return IsPlayerBuildableVehicleType(v->type);
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   684
}
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   685
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   686
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   687
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   688
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
   689
/**
1279
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   690
 * Check if an index is a vehicle-index (so between 0 and max-vehicles)
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   691
 * @param index of the vehicle to query
1279
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   692
 * @return Returns true if the vehicle-id is in range
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   693
 */
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   694
static inline bool IsValidVehicleID(uint index)
1237
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   695
{
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   696
	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
1237
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   697
}
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   698
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   699
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   700
static inline Order *GetVehicleOrder(const Vehicle *v, int index)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   701
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   702
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   703
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   704
	if (index < 0) return NULL;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   705
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   706
	while (order != NULL && index-- > 0)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   707
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   708
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   709
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   710
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   711
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   712
/**
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   713
 * Returns the last order of a vehicle, or NULL if it doesn't exists
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   714
 * @param v Vehicle to query
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   715
 * @return last order of a vehicle, if available
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   716
 */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   717
static inline Order *GetLastVehicleOrder(const Vehicle *v)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   718
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   719
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   720
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   721
	if (order == NULL) return NULL;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   722
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   723
	while (order->next != NULL)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   724
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   725
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   726
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   727
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   728
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   729
/** Get the first vehicle of a shared-list, so we only have to walk forwards
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   730
 * @param v Vehicle to query
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   731
 * @return first vehicle of a shared-list
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   732
 */
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   733
static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   734
{
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   735
	Vehicle *u = (Vehicle *)v;
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   736
	while (u->prev_shared != NULL) u = u->prev_shared;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   737
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   738
	return u;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   739
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   741
/* NOSAVE: Return values from various commands. */
2564
371e0fa97e1e (svn r3101) -Codechange: added _new_vehicle_id
bjarni
parents: 2561
diff changeset
   742
VARDEF VehicleID _new_vehicle_id;
3008
7b519db78ce2 (svn r3588) - Refit: Use only one global to return the refit capacity rather than one per vehicle type.
peter1138
parents: 2916
diff changeset
   743
VARDEF uint16 _returned_refit_capacity;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   745
static const VehicleID INVALID_VEHICLE = 0xFFFF;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
7012
f20d04170833 (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6988
diff changeset
   747
const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
f20d04170833 (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6988
diff changeset
   748
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   749
/**
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   750
 * Get the colour map for an engine. This used for unbuilt engines in the user interface.
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   751
 * @param engine_type ID of engine
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   752
 * @param player ID of player
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   753
 * @return A ready-to-use palette modifier
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   754
 */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5902
diff changeset
   755
SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
3040
c3473d1fb81f (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   756
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   757
/**
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   758
 * Get the colour map for a vehicle.
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   759
 * @param v Vehicle to get colour map for
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   760
 * @return A ready-to-use palette modifier
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   761
 */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5902
diff changeset
   762
SpriteID GetVehiclePalette(const Vehicle *v);
3040
c3473d1fb81f (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   763
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 593
diff changeset
   764
/* A lot of code calls for the invalidation of the status bar, which is widget 5.
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 593
diff changeset
   765
 * Best is to have a virtual value for it when it needs to change again */
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 593
diff changeset
   766
#define STATUS_BAR 5
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 593
diff changeset
   767
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   768
extern const uint32 _veh_build_proc_table[];
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   769
extern const uint32 _veh_sell_proc_table[];
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   770
extern const uint32 _veh_refit_proc_table[];
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   771
extern const uint32 _send_to_depot_proc_table[];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   772
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   773
/* Functions to find the right command for certain vehicle type */
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   774
static inline uint32 GetCmdBuildVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   775
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   776
	return _veh_build_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   777
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   778
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   779
static inline uint32 GetCmdBuildVeh(const Vehicle *v)
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   780
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   781
	return GetCmdBuildVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   782
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   783
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   784
static inline uint32 GetCmdSellVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   785
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   786
	return _veh_sell_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   787
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   788
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   789
static inline uint32 GetCmdSellVeh(const Vehicle *v)
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   790
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   791
	return GetCmdSellVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   792
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   793
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   794
static inline uint32 GetCmdRefitVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   795
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   796
	return _veh_refit_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   797
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   798
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   799
static inline uint32 GetCmdRefitVeh(const Vehicle *v)
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   800
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   801
	return GetCmdRefitVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   802
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   803
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   804
static inline uint32 GetCmdSendToDepot(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   805
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   806
	return _send_to_depot_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   807
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   808
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   809
static inline uint32 GetCmdSendToDepot(const Vehicle *v)
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   810
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   811
	return GetCmdSendToDepot(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   812
}
4451
66603f0f732e (svn r6229) -Feature: Shared order lists now got a "goto depot" button
bjarni
parents: 4434
diff changeset
   813
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   814
/* This one is not used anymore. */
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   815
VARDEF VehicleID _vehicle_id_ctr_day;
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   816
VARDEF Vehicle *_place_clicked_vehicle;
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   817
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   818
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
#endif /* VEHICLE_H */