src/vehicle.h
author skidd13
Sun, 02 Dec 2007 21:43:16 +0000
changeset 8004 1c54bc6f4bdf
parent 7881 7838dbc8bbab
child 8072 7b188d7b8199
permissions -rw-r--r--
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
     3
/** @vehicle.h */
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
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
5216
8bd14ee39af2 (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
     8
#include "oldpool.h"
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
     9
#include "order.h"
1944
dd9cba5fab2a (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1922
diff changeset
    10
#include "rail.h"
6683
b88ae30866ce (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 6643
diff changeset
    11
#include "road.h"
7010
6f0d9f03180d (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: 6998
diff changeset
    12
#include "cargopacket.h"
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6980
diff changeset
    13
#include "texteff.hpp"
577
f52de5e6a25d (svn r990) Fix a display bug in the order list:
tron
parents: 567
diff changeset
    14
5991
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    15
/** The returned bits of VehicleEnterTile. */
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    16
enum VehicleEnterTileStatus {
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    17
	VETS_ENTERED_STATION  = 1, ///< The vehicle entered a station
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    18
	VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    19
	VETS_CANNOT_ENTER     = 3, ///< The vehicle cannot enter the tile
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    20
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    21
	/**
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    22
	 * Shift the VehicleEnterTileStatus this many bits
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    23
	 * to the right to get the station ID when
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    24
	 * VETS_ENTERED_STATION is set
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    25
	 */
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    26
	VETS_STATION_ID_OFFSET = 8,
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    27
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    28
	/** Bit sets of the above specified bits */
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    29
	VETSB_CONTINUE         = 0,                          ///< The vehicle can continue normally
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    30
	VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,  ///< The vehicle entered a station
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    31
	VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    32
	VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,     ///< The vehicle cannot enter the tile
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    33
};
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
    34
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    35
/** Road vehicle states */
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    36
enum RoadVehicleStates {
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    37
	/*
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    38
	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
6161
b57d610d5eed (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6153
diff changeset
    39
	 * When in a road stop (bit 5 or bit 6 set) these bits give the
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    40
	 * track direction of the entry to the road stop.
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    41
	 * As the entry direction will always be a diagonal
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    42
	 * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    43
	 * are needed to hold this direction. Bit 1 is then used to show
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    44
	 * that the vehicle is using the second road stop bay.
6161
b57d610d5eed (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6153
diff changeset
    45
	 * Bit 2 is then used for drive-through stops to show the vehicle
b57d610d5eed (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6153
diff changeset
    46
	 * is stopping at this road stop.
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    47
	 */
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    48
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    49
	/* Numeric values */
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    50
	RVSB_IN_DEPOT                = 0xFE,                      ///< The vehicle is in a depot
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    51
	RVSB_WORMHOLE                = 0xFF,                      ///< The vehicle is in a tunnel and/or bridge
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    52
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    53
	/* Bit numbers */
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    54
	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6000
diff changeset
    55
	RVS_IS_STOPPING              =    2,                      ///< Only used for drive-through stops. Vehicle will stop here
6161
b57d610d5eed (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6153
diff changeset
    56
	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    57
	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6000
diff changeset
    58
	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    59
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    60
	/* Bit sets of the above specified bits */
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    61
	RVSB_IN_ROAD_STOP            = 1 << RVS_IN_ROAD_STOP,     ///< The vehicle is in a road stop
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    62
	RVSB_IN_ROAD_STOP_END        = RVSB_IN_ROAD_STOP + TRACKDIR_END,
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6000
diff changeset
    63
	RVSB_IN_DT_ROAD_STOP         = 1 << RVS_IN_DT_ROAD_STOP,  ///< The vehicle is in a drive-through road stop
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6000
diff changeset
    64
	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    65
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    66
	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    67
	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    68
};
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    69
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    70
enum VehicleType {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    71
	VEH_TRAIN,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    72
	VEH_ROAD,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    73
	VEH_SHIP,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    74
	VEH_AIRCRAFT,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    75
	VEH_SPECIAL,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    76
	VEH_DISASTER,
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    77
	VEH_END,
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    78
	VEH_INVALID = 0xFF,
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    79
};
7086
de7e83fb1602 (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: 7066
diff changeset
    80
DECLARE_POSTFIX_INCREMENT(VehicleType);
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    81
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    82
typedef TinyEnumT<VehicleType> VehicleTypeByte;
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    83
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    84
enum VehStatus {
4344
7e123fec5b0b (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
    85
	VS_HIDDEN          = 0x01,
7e123fec5b0b (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
    86
	VS_STOPPED         = 0x02,
7e123fec5b0b (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
    87
	VS_UNCLICKABLE     = 0x04,
7e123fec5b0b (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
    88
	VS_DEFPAL          = 0x08,
7e123fec5b0b (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
    89
	VS_TRAIN_SLOWING   = 0x10,
7e123fec5b0b (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
    90
	VS_SHADOW          = 0x20,
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    91
	VS_AIRCRAFT_BROKEN = 0x40,
4344
7e123fec5b0b (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
    92
	VS_CRASHED         = 0x80,
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    93
};
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    94
6175
313c2b5e7ae2 (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: 6161
diff changeset
    95
enum VehicleFlags {
313c2b5e7ae2 (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: 6161
diff changeset
    96
	VF_LOADING_FINISHED,
313c2b5e7ae2 (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: 6161
diff changeset
    97
	VF_CARGO_UNLOADING,
6176
153f0f24dc1b (svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents: 6175
diff changeset
    98
	VF_BUILT_AS_PROTOTYPE,
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7014
diff changeset
    99
	VF_TIMETABLE_STARTED,  ///< Whether the vehicle has started running on the timetable yet.
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7014
diff changeset
   100
	VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
5211
fb4dc0ca975d (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
   101
};
fb4dc0ca975d (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
   102
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   103
/* Effect vehicle types */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   104
enum EffectVehicle {
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   105
	EV_CHIMNEY_SMOKE   = 0,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   106
	EV_STEAM_SMOKE     = 1,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   107
	EV_DIESEL_SMOKE    = 2,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   108
	EV_ELECTRIC_SPARK  = 3,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   109
	EV_SMOKE           = 4,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   110
	EV_EXPLOSION_LARGE = 5,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   111
	EV_BREAKDOWN_SMOKE = 6,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   112
	EV_EXPLOSION_SMALL = 7,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   113
	EV_BULLDOZER       = 8,
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   114
	EV_BUBBLE          = 9
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   115
};
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   116
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   117
struct VehicleRail {
4434
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4404
diff changeset
   118
	uint16 last_speed; // NOSAVE: only used in UI
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	uint16 crash_anim_pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   120
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   121
	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
1905
c53f8d71f9b6 (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
   122
	uint16 cached_max_speed;  // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
c53f8d71f9b6 (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
   123
	uint32 cached_power;      // total power of the consist.
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
   124
	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
31647a23da0b (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
   125
	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
31647a23da0b (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
   126
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   127
	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
5162
f8da34a35a59 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
   128
	uint32 cached_weight;     // total weight of the consist.
f8da34a35a59 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
   129
	uint32 cached_veh_weight; // weight of the vehicle.
5400
bba42ad3223b (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5385
diff changeset
   130
	uint32 cached_max_te;     // max tractive effort of consist
2595
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   131
	/**
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   132
	 * Position/type of visual effect.
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   133
	 * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   134
	 * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   135
	 * bit     6 = disable visual effect.
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   136
	 * bit     7 = disable powered wagons.
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   137
	 */
1c5db200577c (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   138
	byte cached_vis_effect;
7881
7838dbc8bbab (svn r11431) -Codechange: [NewGRF] Add support for changing rail vehicle user-defined bit mask (prop 25) via callback 36
glx
parents: 7803
diff changeset
   139
	byte user_def_data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   141
	/* NOSAVE: for wagon override - id of the first engine in train
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   142
	 * 0xffff == not in train */
1796
614d996f6be7 (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
   143
	EngineID first_engine;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5574
diff changeset
   145
	TrackBitsByte track;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	byte force_proceed;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5574
diff changeset
   147
	RailTypeByte railtype;
3355
e414a0b104a6 (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
   148
	RailTypeMask compatible_railtypes;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	byte flags;
2008
cdb444f6d43c (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
   151
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   152
	/* Link between the two ends of a multiheaded engine */
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2666
diff changeset
   153
	Vehicle *other_multiheaded_part;
6603
076b05312635 (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: 6594
diff changeset
   154
076b05312635 (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: 6594
diff changeset
   155
	/* Cached wagon override spritegroup */
076b05312635 (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: 6594
diff changeset
   156
	const struct SpriteGroup *cached_override;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   157
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
enum {
4344
7e123fec5b0b (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
   160
	VRF_REVERSING         = 0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   162
	/* used to calculate if train is going up or down */
4344
7e123fec5b0b (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
   163
	VRF_GOINGUP           = 1,
7e123fec5b0b (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
   164
	VRF_GOINGDOWN         = 2,
1908
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1905
diff changeset
   165
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   166
	/* used to store if a wagon is powered or not */
4344
7e123fec5b0b (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
   167
	VRF_POWEREDWAGON      = 3,
3256
3ada27c81b7f (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   168
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   169
	/* used to reverse the visible direction of the vehicle */
3256
3ada27c81b7f (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   170
	VRF_REVERSE_DIRECTION = 4,
4870
2d8c7ffbbac9 (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
   171
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   172
	/* used to mark train as lost because PF can't find the route */
4870
2d8c7ffbbac9 (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
   173
	VRF_NO_PATH_TO_DESTINATION = 5,
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   174
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   175
	/* used to mark that electric train engine is allowed to run on normal rail */
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   176
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   179
struct VehicleAir {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	uint16 crashed_counter;
6490
fe4443fba5e3 (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: 6423
diff changeset
   181
	uint16 cached_max_speed;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	byte pos;
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3977
diff changeset
   183
	byte previous_pos;
3347
0ddacd451b81 (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
   184
	StationID targetairport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	byte state;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   186
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   188
struct VehicleRoad {
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   189
	byte state;             ///< @see RoadVehicleStates
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	byte frame;
3009
c75f1a8d5ff9 (svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr
peter1138
parents: 3008
diff changeset
   191
	uint16 blocked_ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	byte overtaking;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	byte overtaking_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
	uint16 crashed_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	byte reverse_ctr;
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   196
	struct RoadStop *slot;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   197
	byte slot_age;
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6773
diff changeset
   198
	EngineID first_engine;
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6773
diff changeset
   199
	byte cached_veh_length;
6683
b88ae30866ce (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 6643
diff changeset
   200
b88ae30866ce (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 6643
diff changeset
   201
	RoadType roadtype;
b88ae30866ce (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 6643
diff changeset
   202
	RoadTypes compatible_roadtypes;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   203
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   205
struct VehicleSpecial {
7334
ed9a43cf642a (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7318
diff changeset
   206
	uint16 animation_state;
ed9a43cf642a (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7318
diff changeset
   207
	byte animation_substate;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   208
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   210
struct VehicleDisaster {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
	uint16 image_override;
7334
ed9a43cf642a (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7318
diff changeset
   212
	VehicleID big_ufo_destroyer_target;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   213
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   215
struct VehicleShip {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5574
diff changeset
   216
	TrackBitsByte state;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   217
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
7398
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   219
struct Vehicle;
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   220
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
7537
0b720e804ae2 (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: 7497
diff changeset
   222
/* Some declarations of functions, so we can make them friendly */
7493
07944c9e005f (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: 7492
diff changeset
   223
struct SaveLoad;
7537
0b720e804ae2 (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: 7497
diff changeset
   224
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
0b720e804ae2 (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: 7497
diff changeset
   225
extern void AfterLoadVehicles();
0b720e804ae2 (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: 7497
diff changeset
   226
struct LoadgameState;
0b720e804ae2 (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: 7497
diff changeset
   227
extern bool LoadOldVehicle(LoadgameState *ls, int num);
7493
07944c9e005f (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: 7492
diff changeset
   228
7398
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   229
struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
   230
	VehicleTypeByte type;    ///< Type of vehicle
5854
9eee280920f0 (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: 5792
diff changeset
   231
	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
   232
7493
07944c9e005f (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: 7492
diff changeset
   233
private:
7492
35acee076719 (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: 7490
diff changeset
   234
	Vehicle *next;           // pointer to the next vehicle in the chain
7497
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   235
	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   236
	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
7493
07944c9e005f (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: 7492
diff changeset
   237
public:
07944c9e005f (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: 7492
diff changeset
   238
	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
7537
0b720e804ae2 (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: 7497
diff changeset
   239
	friend void AfterLoadVehicles();                              // So we can set the previous and first pointers while loading
0b720e804ae2 (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: 7497
diff changeset
   240
	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
7493
07944c9e005f (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: 7492
diff changeset
   241
7492
35acee076719 (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: 7490
diff changeset
   242
	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
   243
4344
7e123fec5b0b (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
	StringID string_id;      // Displayed string
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
4344
7e123fec5b0b (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
	UnitID unitnumber;       // unit number, for display purposes only
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   247
	PlayerByte owner;        // which player owns the vehicle?
4344
7e123fec5b0b (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
7e123fec5b0b (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
	TileIndex tile;          // Current tile index
7e123fec5b0b (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
   250
	TileIndex dest_tile;     // Heading for this tile
7e123fec5b0b (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
   251
7e123fec5b0b (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
   252
	int32 x_pos;             // coordinates
1174
6a5e747f3ba6 (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
   253
	int32 y_pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
	byte z_pos;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5574
diff changeset
   255
	DirectionByte direction; // facing
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
4344
7e123fec5b0b (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
	byte spritenum;          // currently displayed sprite index
7e123fec5b0b (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
   258
	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
7e123fec5b0b (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
   259
	                         // 0xff == reserved for another custom sprite
7e123fec5b0b (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
   260
	uint16 cur_image;        // sprite number for this vehicle
7e123fec5b0b (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
   261
	byte sprite_width;       // width of vehicle sprite
7e123fec5b0b (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 sprite_height;      // height of vehicle sprite
7e123fec5b0b (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 z_height;           // z-height of vehicle sprite
7e123fec5b0b (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
   264
	int8 x_offs;             // x offset for vehicle sprite
7e123fec5b0b (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
   265
	int8 y_offs;             // y offset for vehicle sprite
1770
18491bba9211 (svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
Darkvater
parents: 1765
diff changeset
   266
	EngineID engine_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6980
diff changeset
   268
	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6980
diff changeset
   269
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   270
	/* for randomized variational spritegroups
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   271
	 * bitmask used to resolve them; parts of it get reseeded when triggers
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   272
	 * of corresponding spritegroups get matched */
445
beafc0fb8f12 (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
   273
	byte random_bits;
4344
7e123fec5b0b (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
   274
	byte waiting_triggers;   // triggers to be yet matched
445
beafc0fb8f12 (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
   275
4344
7e123fec5b0b (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
   276
	uint16 max_speed;        // maximum speed
7e123fec5b0b (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
   277
	uint16 cur_speed;        // current speed
7e123fec5b0b (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
   278
	byte subspeed;           // fractional speed
7e123fec5b0b (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
   279
	byte acceleration;       // used by train & aircraft
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	byte progress;
4656
9c1d8c4d3e60 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 4635
diff changeset
   281
	uint32 motion_counter;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
4344
7e123fec5b0b (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
   283
	byte vehstatus;          // Status
3347
0ddacd451b81 (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
   284
	StationID last_station_visited;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   285
4344
7e123fec5b0b (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
   286
	CargoID cargo_type;      // type of cargo this vehicle is carrying
7e123fec5b0b (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
   287
	uint16 cargo_cap;        // total capacity
3870
d9ebc4ea750a (svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents: 3580
diff changeset
   288
	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
7010
6f0d9f03180d (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: 6998
diff changeset
   289
	CargoList cargo;         ///< The cargo this vehicle is carrying
6f0d9f03180d (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: 6998
diff changeset
   290
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
4344
7e123fec5b0b (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
   292
	byte day_counter;        // increased by one for each day
7e123fec5b0b (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
   293
	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
   294
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   295
	/* Begin Order-stuff */
3173
f56ca618721b (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   296
	Order current_order;     ///< The current order (+ status, like: loading)
4391
40c1c7dd05f3 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   297
	VehicleOrderID cur_order_index; ///< The index to the current order
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   298
3173
f56ca618721b (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   299
	Order *orders;           ///< Pointer to the first order for this vehicle
4391
40c1c7dd05f3 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   300
	VehicleOrderID num_orders;      ///< How many orders there are in the list
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   301
3173
f56ca618721b (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   302
	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
f56ca618721b (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   303
	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   304
	/* End Order-stuff */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   306
	/* Boundaries for the current position in the world and a next hash link.
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   307
	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
849
c3407041774f (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   308
	int32 left_coord;
c3407041774f (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   309
	int32 top_coord;
c3407041774f (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   310
	int32 right_coord;
c3407041774f (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   311
	int32 bottom_coord;
5574
2cb543714009 (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: 5475
diff changeset
   312
	Vehicle *next_hash;
6871
d8b53c9f0b13 (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: 6857
diff changeset
   313
	Vehicle *next_new_hash;
d8b53c9f0b13 (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: 6857
diff changeset
   314
	Vehicle **old_new_hash;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   316
	/* Related to age and service time */
4326
2e2c9d21ed96 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   317
	Date age;     // Age in days
2e2c9d21ed96 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   318
	Date max_age; // Maximum age
4289
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   319
	Date date_of_last_service;
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   320
	Date service_interval;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	uint16 reliability;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	uint16 reliability_spd_dec;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	byte breakdown_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	byte breakdown_delay;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	byte breakdowns_since_last_service;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
	byte breakdown_chance;
4326
2e2c9d21ed96 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   327
	Year build_year;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
4344
7e123fec5b0b (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
   329
	bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
2617
03120a0b1e39 (svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents: 2602
diff changeset
   330
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
	uint16 load_unload_time_rem;
6175
313c2b5e7ae2 (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: 6161
diff changeset
   332
	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
   333
6953
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6943
diff changeset
   334
	Money profit_this_year;
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6943
diff changeset
   335
	Money profit_last_year;
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6943
diff changeset
   336
	Money value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
6643
f81bee57bc09 (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: 6641
diff changeset
   338
	GroupID group_id;              ///< Index of group Pool array
f81bee57bc09 (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: 6641
diff changeset
   339
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6953
diff changeset
   340
	/* Used for timetabling. */
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6953
diff changeset
   341
	uint32 current_order_time;     ///< How many ticks have passed since this order started.
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6953
diff changeset
   342
	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6953
diff changeset
   343
7802
246a94599679 (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 7548
diff changeset
   344
	SpriteID colormap; // NOSAVE: cached color mapping
246a94599679 (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 7548
diff changeset
   345
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	union {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
		VehicleRail rail;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
		VehicleAir air;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
		VehicleRoad road;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
		VehicleSpecial special;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
		VehicleDisaster disaster;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
		VehicleShip ship;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	} u;
5651
79496e6d8a56 (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: 5587
diff changeset
   354
7398
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   355
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   356
	/**
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   357
	 * Allocates a lot of vehicles.
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   358
	 * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   359
	 * @param num number of vehicles to allocate room for
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   360
	 * @return true if there is room to allocate all the vehicles
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   361
	 */
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   362
	static bool AllocateList(Vehicle **vl, int num);
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   363
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   364
	/** Create a new vehicle */
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   365
	Vehicle();
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   366
7412
51db351a3313 (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7400
diff changeset
   367
	/** Destroy all stuff that (still) needs the virtual functions to work properly */
51db351a3313 (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7400
diff changeset
   368
	void PreDestructor();
7398
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   369
	/** We want to 'destruct' the right class. */
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   370
	virtual ~Vehicle();
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
   371
5651
79496e6d8a56 (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: 5587
diff changeset
   372
	void BeginLoading();
79496e6d8a56 (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: 5587
diff changeset
   373
	void LeaveStation();
6552
d87268e08799 (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: 6516
diff changeset
   374
d87268e08799 (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: 6516
diff changeset
   375
	/**
6594
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   376
	 * Handle the loading of the vehicle; when not it skips through dummy
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   377
	 * orders and does nothing in all other cases.
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   378
	 * @param mode is the non-first call for this vehicle in this tick?
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   379
	 */
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   380
	void HandleLoading(bool mode = false);
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   381
9673331eb174 (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 6593
diff changeset
   382
	/**
6552
d87268e08799 (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: 6516
diff changeset
   383
	 * Get a string 'representation' of the vehicle type.
d87268e08799 (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: 6516
diff changeset
   384
	 * @return the string representation.
d87268e08799 (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: 6516
diff changeset
   385
	 */
7400
e211c7b9cb8f (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7398
diff changeset
   386
	virtual const char* GetTypeString() const { return "base vehicle"; }
6553
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
   387
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
   388
	/**
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
   389
	 * Marks the vehicles to be redrawn and updates cached variables
7545
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7537
diff changeset
   390
	 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7537
diff changeset
   391
	 * This method marks the area of the vehicle on the screen as dirty.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7537
diff changeset
   392
	 * It can be use to repaint the vehicle.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7537
diff changeset
   393
	 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7537
diff changeset
   394
	 * @ingroup dirty
6553
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
   395
	 */
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
   396
	virtual void MarkDirty() {}
6558
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   397
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   398
	/**
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   399
	 * Updates the x and y offsets and the size of the sprite used
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   400
	 * for this vehicle.
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   401
	 * @param direction the direction the vehicle is facing
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   402
	 */
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   403
	virtual void UpdateDeltaXY(Direction direction) {}
6562
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   404
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   405
	/**
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   406
	 * Sets the expense type associated to this vehicle type
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   407
	 * @param income whether this is income or (running) expenses of the vehicle
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   408
	 */
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
   409
	virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
6562
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   410
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   411
	/**
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   412
	 * Invalidates the vehicle list window of this type of vehicle
077afce9a4ee (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 6558
diff changeset
   413
	 */
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
   414
	virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
6593
102aa05c5ca4 (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 6580
diff changeset
   415
102aa05c5ca4 (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 6580
diff changeset
   416
	/**
102aa05c5ca4 (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 6580
diff changeset
   417
	 * Play the sound associated with leaving the station
102aa05c5ca4 (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 6580
diff changeset
   418
	 */
102aa05c5ca4 (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 6580
diff changeset
   419
	virtual void PlayLeaveStationSound() const {}
6773
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   420
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   421
	/**
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   422
	 * Whether this is the primary vehicle in the chain.
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   423
	 */
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   424
	virtual bool IsPrimaryVehicle() const { return false; }
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   425
bc98b0b16ec4 (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6683
diff changeset
   426
	/**
7134
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7096
diff changeset
   427
	 * Gets the sprite to show for the given direction
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7096
diff changeset
   428
	 * @param direction the direction the vehicle is facing
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7096
diff changeset
   429
	 * @return the sprite for the given vehicle in the given direction
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7096
diff changeset
   430
	 */
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7096
diff changeset
   431
	virtual int GetImage(Direction direction) const { return 0; }
7135
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   432
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   433
	/**
7477
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   434
	 * Gets the speed in mph that can be sent into SetDParam for string processing.
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   435
	 * @return the vehicle's speed
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   436
	 */
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   437
	virtual int GetDisplaySpeed() const { return 0; }
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   438
ee28f55ab5e8 (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7413
diff changeset
   439
	/**
7484
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   440
	 * Gets the maximum speed in mph that can be sent into SetDParam for string processing.
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   441
	 * @return the vehicle's maximum speed
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   442
	 */
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   443
	virtual int GetDisplayMaxSpeed() const { return 0; }
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   444
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   445
	/**
7488
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   446
	 * Gets the running cost of a vehicle
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   447
	 * @return the vehicle's running cost
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   448
	 */
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   449
	virtual Money GetRunningCost() const { return 0; }
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   450
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   451
	/**
7490
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   452
	 * Check whether the vehicle is in the depot.
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   453
	 * @return true if and only if the vehicle is in the depot.
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   454
	 */
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   455
	virtual bool IsInDepot() const { return false; }
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   456
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   457
	/**
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   458
	 * Check whether the vehicle is in the depot *and* stopped.
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   459
	 * @return true if and only if the vehicle is in the depot and stopped.
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   460
	 */
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   461
	virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   462
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
   463
	/**
7135
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   464
	 * Calls the tick handler of the vehicle
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   465
	 */
7400
e211c7b9cb8f (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7398
diff changeset
   466
	virtual void Tick() {};
7387
c81fff74048b (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7334
diff changeset
   467
7488
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   468
	/**
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   469
	 * Gets the running cost of a vehicle  that can be sent into SetDParam for string processing.
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   470
	 * @return the vehicle's running cost
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   471
	 */
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   472
	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
6f51ddf4c225 (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7486
diff changeset
   473
7492
35acee076719 (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: 7490
diff changeset
   474
	/**
35acee076719 (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: 7490
diff changeset
   475
	 * Is this vehicle a valid vehicle?
35acee076719 (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: 7490
diff changeset
   476
	 * @return true if and only if the vehicle is valid.
35acee076719 (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: 7490
diff changeset
   477
	 */
35acee076719 (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: 7490
diff changeset
   478
	inline bool IsValid() const { return this->type != VEH_INVALID; }
35acee076719 (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: 7490
diff changeset
   479
35acee076719 (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: 7490
diff changeset
   480
	/**
35acee076719 (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: 7490
diff changeset
   481
	 * Set the next vehicle of this vehicle.
35acee076719 (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: 7490
diff changeset
   482
	 * @param next the next vehicle. NULL removes the next vehicle.
35acee076719 (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: 7490
diff changeset
   483
	 */
7497
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   484
	void SetNext(Vehicle *next);
7492
35acee076719 (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: 7490
diff changeset
   485
35acee076719 (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: 7490
diff changeset
   486
	/**
35acee076719 (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: 7490
diff changeset
   487
	 * Get the next vehicle of this vehicle.
35acee076719 (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: 7490
diff changeset
   488
	 * @note articulated parts are also counted as vehicles.
35acee076719 (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: 7490
diff changeset
   489
	 * @return the next vehicle or NULL when there isn't a next vehicle.
35acee076719 (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: 7490
diff changeset
   490
	 */
35acee076719 (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: 7490
diff changeset
   491
	inline Vehicle *Next() const { return this->next; }
7497
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   492
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   493
	/**
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   494
	 * Get the previous vehicle of this vehicle.
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   495
	 * @note articulated parts are also counted as vehicles.
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   496
	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   497
	 */
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   498
	inline Vehicle *Previous() const { return this->previous; }
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   499
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   500
	/**
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   501
	 * Get the first vehicle of this vehicle chain.
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   502
	 * @return the first vehicle of the chain.
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   503
	 */
40e457c0a8ac (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7493
diff changeset
   504
	inline Vehicle *First() const { return this->first; }
6552
d87268e08799 (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: 6516
diff changeset
   505
};
d87268e08799 (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: 6516
diff changeset
   506
d87268e08799 (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: 6516
diff changeset
   507
/**
d87268e08799 (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: 6516
diff changeset
   508
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
d87268e08799 (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: 6516
diff changeset
   509
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
d87268e08799 (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: 6516
diff changeset
   510
 * and you reinitialize that to a Train using:
d87268e08799 (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: 6516
diff changeset
   511
 *   v = new (v) Train();
d87268e08799 (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: 6516
diff changeset
   512
 *
d87268e08799 (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: 6516
diff changeset
   513
 * As side-effect the vehicle type is set correctly.
d87268e08799 (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: 6516
diff changeset
   514
 *
d87268e08799 (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: 6516
diff changeset
   515
 * A special vehicle is one of the following:
d87268e08799 (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: 6516
diff changeset
   516
 *  - smoke
d87268e08799 (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: 6516
diff changeset
   517
 *  - electric sparks for trains
d87268e08799 (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: 6516
diff changeset
   518
 *  - explosions
d87268e08799 (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: 6516
diff changeset
   519
 *  - bulldozer (road works)
d87268e08799 (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: 6516
diff changeset
   520
 *  - bubbles (industry)
d87268e08799 (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: 6516
diff changeset
   521
 */
d87268e08799 (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: 6516
diff changeset
   522
struct SpecialVehicle : public Vehicle {
d87268e08799 (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: 6516
diff changeset
   523
	/** Initializes the Vehicle to a special vehicle */
d87268e08799 (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: 6516
diff changeset
   524
	SpecialVehicle() { this->type = VEH_SPECIAL; }
d87268e08799 (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: 6516
diff changeset
   525
d87268e08799 (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: 6516
diff changeset
   526
	/** We want to 'destruct' the right class. */
d87268e08799 (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: 6516
diff changeset
   527
	virtual ~SpecialVehicle() {}
d87268e08799 (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: 6516
diff changeset
   528
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
   529
	const char *GetTypeString() const { return "special vehicle"; }
6558
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   530
	void UpdateDeltaXY(Direction direction);
7135
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   531
	void Tick();
6552
d87268e08799 (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: 6516
diff changeset
   532
};
d87268e08799 (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: 6516
diff changeset
   533
d87268e08799 (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: 6516
diff changeset
   534
/**
d87268e08799 (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: 6516
diff changeset
   535
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
d87268e08799 (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: 6516
diff changeset
   536
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
d87268e08799 (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: 6516
diff changeset
   537
 * and you reinitialize that to a Train using:
d87268e08799 (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: 6516
diff changeset
   538
 *   v = new (v) Train();
d87268e08799 (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: 6516
diff changeset
   539
 *
d87268e08799 (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: 6516
diff changeset
   540
 * As side-effect the vehicle type is set correctly.
d87268e08799 (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: 6516
diff changeset
   541
 */
d87268e08799 (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: 6516
diff changeset
   542
struct DisasterVehicle : public Vehicle {
d87268e08799 (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: 6516
diff changeset
   543
	/** Initializes the Vehicle to a disaster vehicle */
d87268e08799 (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: 6516
diff changeset
   544
	DisasterVehicle() { this->type = VEH_DISASTER; }
d87268e08799 (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: 6516
diff changeset
   545
d87268e08799 (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: 6516
diff changeset
   546
	/** We want to 'destruct' the right class. */
d87268e08799 (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: 6516
diff changeset
   547
	virtual ~DisasterVehicle() {}
d87268e08799 (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: 6516
diff changeset
   548
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
   549
	const char *GetTypeString() const { return "disaster vehicle"; }
6558
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
   550
	void UpdateDeltaXY(Direction direction);
7135
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   551
	void Tick();
6552
d87268e08799 (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: 6516
diff changeset
   552
};
d87268e08799 (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: 6516
diff changeset
   553
d87268e08799 (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: 6516
diff changeset
   554
/**
d87268e08799 (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: 6516
diff changeset
   555
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
d87268e08799 (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: 6516
diff changeset
   556
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
d87268e08799 (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: 6516
diff changeset
   557
 * and you reinitialize that to a Train using:
d87268e08799 (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: 6516
diff changeset
   558
 *   v = new (v) Train();
d87268e08799 (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: 6516
diff changeset
   559
 *
d87268e08799 (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: 6516
diff changeset
   560
 * As side-effect the vehicle type is set correctly.
d87268e08799 (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: 6516
diff changeset
   561
 */
d87268e08799 (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: 6516
diff changeset
   562
struct InvalidVehicle : public Vehicle {
d87268e08799 (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: 6516
diff changeset
   563
	/** Initializes the Vehicle to a invalid vehicle */
d87268e08799 (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: 6516
diff changeset
   564
	InvalidVehicle() { this->type = VEH_INVALID; }
d87268e08799 (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: 6516
diff changeset
   565
d87268e08799 (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: 6516
diff changeset
   566
	/** We want to 'destruct' the right class. */
d87268e08799 (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: 6516
diff changeset
   567
	virtual ~InvalidVehicle() {}
d87268e08799 (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: 6516
diff changeset
   568
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
   569
	const char *GetTypeString() const { return "invalid vehicle"; }
7135
3c1bcca0d6bb (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7134
diff changeset
   570
	void Tick() {}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
1765
155dfdbbbc8d (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
   573
#define is_custom_sprite(x) (x >= 0xFD)
155dfdbbbc8d (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
   574
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
155dfdbbbc8d (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
   575
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
typedef void *VehicleFromPosProc(Vehicle *v, void *data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
578
1e66514eb621 (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
   579
void VehicleServiceInDepot(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
void VehiclePositionChanged(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
Vehicle *GetLastVehicleInChain(Vehicle *v);
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7135
diff changeset
   582
uint CountVehiclesInChain(const Vehicle *v);
4574
61a17f80cfb9 (svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents: 4544
diff changeset
   583
bool IsEngineCountable(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
void DeleteVehicleChain(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
6871
d8b53c9f0b13 (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: 6857
diff changeset
   586
void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   587
void CallVehicleTicks();
1605
279dd2265cae (svn r2109) -Fix: use FindVehicleOnTileZ(tile, 0) over FindVehicleBetween(tile, tile, 0)
truelight
parents: 1601
diff changeset
   588
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7010
diff changeset
   589
uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   591
void InitializeTrains();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   592
byte VehicleRandomBits();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   593
void ResetVehiclePosHash();
7802
246a94599679 (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 7548
diff changeset
   594
void ResetVehicleColorMap();
7803
55307751965b (svn r11353) -Codechange: add support for newgrf callback 32
glx
parents: 7802
diff changeset
   595
void CheckVehicle32Day(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
2704
bdf6ae0cb27c (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
   597
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
3973
9d3cd1ed6ac0 (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
   598
CargoID FindFirstRefittableCargo(EngineID engine_type);
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6871
diff changeset
   599
CommandCost GetRefitCost(EngineID engine_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
void ViewportAddVehicles(DrawPixelInfo *dpi);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
5866
60ee9fff5c99 (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: 5854
diff changeset
   603
SpriteID GetRotorImage(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
1359
52782e5cf7c9 (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
   605
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
52782e5cf7c9 (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
   606
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
52782e5cf7c9 (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
   607
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
   608
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   609
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
   610
3881
c899867fd46e (svn r4937) Reduce the use of _error_message a bit
tron
parents: 3870
diff changeset
   611
StringID VehicleInTheWayErrMsg(const Vehicle* v);
5940
3bb99a7ad58f (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: 5888
diff changeset
   612
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
3172
ade284ef48ed (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
   614
bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction);
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   615
void SetSignalsOnBothDir(TileIndex tile, byte track);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
2116
23031555ff54 (svn r2626) static, const, misc.
tron
parents: 2115
diff changeset
   617
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
   618
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
void DecreaseVehicleValue(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
void CheckVehicleBreakdown(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
void AgeVehicle(Vehicle *v);
2574
70a4e3cb85bf (svn r3111) -Fix: [autoreplace] [ 1341783 ] Assertion failure in vehicle.c line 378
bjarni
parents: 2564
diff changeset
   622
void VehicleEnteredDepotThisTick(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
void BeginVehicleMove(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
void EndVehicleMove(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   627
UnitID GetFreeUnitNumber(VehicleType type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
1905
c53f8d71f9b6 (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
   629
void TrainConsistChanged(Vehicle *v);
3355
e414a0b104a6 (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
   630
void TrainPowerChanged(Vehicle *v);
6953
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6943
diff changeset
   631
Money GetTrainRunningCost(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
593
4240f624bca0 (svn r1015) MFM r789
tron
parents: 578
diff changeset
   633
bool VehicleNeedsService(const Vehicle *v);
4240f624bca0 (svn r1015) MFM r789
tron
parents: 578
diff changeset
   634
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   635
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   636
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);
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6871
diff changeset
   637
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
4725
40cccaaa042c (svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents: 4681
diff changeset
   638
void VehicleEnterDepot(Vehicle *v);
4506
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   639
7096
9b231813f232 (svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
peter1138
parents: 7086
diff changeset
   640
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
5944
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5940
diff changeset
   641
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6871
diff changeset
   642
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
7086
de7e83fb1602 (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: 7066
diff changeset
   643
bool CanBuildVehicleInfrastructure(VehicleType type);
6264
c2138d65160b (svn r9073) -Codechange: moved autoreplace to a file of it's own (now autoreplace has a cmd and a gui file)
bjarni
parents: 6259
diff changeset
   644
7478
893d987adeef (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7477
diff changeset
   645
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
893d987adeef (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7477
diff changeset
   646
4506
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   647
/* Flags to add to p2 for goto depot commands */
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   648
/* Note: bits 8-10 are used for VLW flags */
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   649
enum {
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6490
diff changeset
   650
	DEPOT_SERVICE       = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
4506
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   651
	DEPOT_MASS_SEND     = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   652
	DEPOT_DONT_CANCEL   = (1 << 2), // Don't cancel current goto depot command if any
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   653
	DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
e6a56518135c (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
   654
};
4463
4d67d3a36fc5 (svn r6246) -Feature: added the many times requested "send all vehicle to depot" button
bjarni
parents: 4451
diff changeset
   655
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   656
struct GetNewVehiclePosResult {
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7135
diff changeset
   657
	int x, y;
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   658
	TileIndex old_tile;
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
   659
	TileIndex new_tile;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   660
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   662
/**
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   663
 * Returns the Trackdir on which the vehicle is currently located.
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   664
 * Works for trains and ships.
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   665
 * Currently works only sortof for road vehicles, since they have a fuzzy
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   666
 * concept of being "on" a trackdir. Dunno really what it returns for a road
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   667
 * vehicle that is halfway a tile, never really understood that part. For road
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   668
 * vehicles that are at the beginning or end of the tile, should just return
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   669
 * the diagonal trackdir on which they are driving. I _think_.
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   670
 * For other vehicles types, or vehicles with no clear trackdir (such as those
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   671
 * in depots), returns 0xFF.
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   672
 */
1944
dd9cba5fab2a (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1922
diff changeset
   673
Trackdir GetVehicleTrackdir(const Vehicle* v);
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
   674
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
/* returns true if staying in the same tile */
6153
eb35b73b300a (svn r8897) -Fix
tron
parents: 6152
diff changeset
   676
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7135
diff changeset
   677
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
   678
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
#define BEGIN_ENUM_WAGONS(v) do {
7492
35acee076719 (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: 7490
diff changeset
   680
#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
   681
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   682
static inline VehicleID GetMaxVehicleIndex()
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   683
{
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   684
	/* TODO - This isn't the real content of the function, but
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   685
	 *  with the new pool-system this will be replaced with one that
5247
1f982de55b88 (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
   686
	 *  _really_ returns the highest index. Now it just returns
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   687
	 *  the next safe value we are sure about everything is below.
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   688
	 */
5247
1f982de55b88 (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
   689
	return GetVehiclePoolSize() - 1;
1f982de55b88 (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
   690
}
1f982de55b88 (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
   691
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6198
diff changeset
   692
static inline uint GetNumVehicles()
5247
1f982de55b88 (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
   693
{
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   694
	return GetVehiclePoolSize();
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   695
}
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   696
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   697
static inline bool IsPlayerBuildableVehicleType(VehicleType type)
5746
ab94eb9bdde6 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5683
diff changeset
   698
{
5775
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   699
	switch (type) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   700
		case VEH_TRAIN:
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   701
		case VEH_ROAD:
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   702
		case VEH_SHIP:
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   703
		case VEH_AIRCRAFT:
5746
ab94eb9bdde6 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5683
diff changeset
   704
			return true;
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   705
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   706
		default: return false;
5746
ab94eb9bdde6 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5683
diff changeset
   707
	}
ab94eb9bdde6 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5683
diff changeset
   708
}
ab94eb9bdde6 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5683
diff changeset
   709
5775
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   710
static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   711
{
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   712
	return IsPlayerBuildableVehicleType(v->type);
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   713
}
12aade4ec326 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5748
diff changeset
   714
7387
c81fff74048b (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7334
diff changeset
   715
#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
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   716
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   717
1330
5d76a0522a11 (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
   718
/**
1279
bc761aad52b3 (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   719
 * Check if an index is a vehicle-index (so between 0 and max-vehicles)
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   720
 * @param index of the vehicle to query
1279
bc761aad52b3 (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   721
 * @return Returns true if the vehicle-id is in range
bc761aad52b3 (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   722
 */
4352
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   723
static inline bool IsValidVehicleID(uint index)
1237
1c7a3f9c94b9 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   724
{
7387
c81fff74048b (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7334
diff changeset
   725
	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
1237
1c7a3f9c94b9 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   726
}
1c7a3f9c94b9 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   727
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   728
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   729
static inline Order *GetVehicleOrder(const Vehicle *v, int index)
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   730
{
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   731
	Order *order = v->orders;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   732
1765
155dfdbbbc8d (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
   733
	if (index < 0) return NULL;
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   734
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   735
	while (order != NULL && index-- > 0)
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   736
		order = order->next;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   737
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   738
	return order;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   739
}
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   740
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   741
/**
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   742
 * Returns the last order of a vehicle, or NULL if it doesn't exists
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   743
 * @param v Vehicle to query
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   744
 * @return last order of a vehicle, if available
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   745
 */
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   746
static inline Order *GetLastVehicleOrder(const Vehicle *v)
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   747
{
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   748
	Order *order = v->orders;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   749
1765
155dfdbbbc8d (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
   750
	if (order == NULL) return NULL;
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   751
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   752
	while (order->next != NULL)
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   753
		order = order->next;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   754
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   755
	return order;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   756
}
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   757
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   758
/** Get the first vehicle of a shared-list, so we only have to walk forwards
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   759
 * @param v Vehicle to query
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   760
 * @return first vehicle of a shared-list
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   761
 */
4494
2bde2b22ef3a (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   762
static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   763
{
4494
2bde2b22ef3a (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   764
	Vehicle *u = (Vehicle *)v;
2bde2b22ef3a (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   765
	while (u->prev_shared != NULL) u = u->prev_shared;
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   766
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   767
	return u;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   768
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6264
diff changeset
   770
/* NOSAVE: Return values from various commands. */
2564
24533c2db978 (svn r3101) -Codechange: added _new_vehicle_id
bjarni
parents: 2561
diff changeset
   771
VARDEF VehicleID _new_vehicle_id;
3008
cef26520c91e (svn r3588) - Refit: Use only one global to return the refit capacity rather than one per vehicle type.
peter1138
parents: 2916
diff changeset
   772
VARDEF uint16 _returned_refit_capacity;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5574
diff changeset
   774
static const VehicleID INVALID_VEHICLE = 0xFFFF;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
6516
0d14650b196b (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6492
diff changeset
   776
const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
0d14650b196b (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6492
diff changeset
   777
3105
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   778
/**
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   779
 * Get the colour map for an engine. This used for unbuilt engines in the user interface.
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   780
 * @param engine_type ID of engine
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   781
 * @param player ID of player
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   782
 * @return A ready-to-use palette modifier
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   783
 */
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5651
diff changeset
   784
SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
3040
7043c0de7c6d (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   785
3105
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   786
/**
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   787
 * Get the colour map for a vehicle.
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   788
 * @param v Vehicle to get colour map for
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   789
 * @return A ready-to-use palette modifier
02f849f946d0 (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   790
 */
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5651
diff changeset
   791
SpriteID GetVehiclePalette(const Vehicle *v);
3040
7043c0de7c6d (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   792
755
80091de50044 (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
   793
/* A lot of code calls for the invalidation of the status bar, which is widget 5.
80091de50044 (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
   794
 * Best is to have a virtual value for it when it needs to change again */
80091de50044 (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
   795
#define STATUS_BAR 5
80091de50044 (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
   796
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   797
extern const uint32 _veh_build_proc_table[];
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   798
extern const uint32 _veh_sell_proc_table[];
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   799
extern const uint32 _veh_refit_proc_table[];
4494
2bde2b22ef3a (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   800
extern const uint32 _send_to_depot_proc_table[];
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   801
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   802
/* Functions to find the right command for certain vehicle type */
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   803
static inline uint32 GetCmdBuildVeh(VehicleType type)
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   804
{
5955
fe61588d5188 (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: 5944
diff changeset
   805
	return _veh_build_proc_table[type];
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   806
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   807
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   808
static inline uint32 GetCmdBuildVeh(const Vehicle *v)
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   809
{
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   810
	return GetCmdBuildVeh(v->type);
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   811
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   812
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   813
static inline uint32 GetCmdSellVeh(VehicleType type)
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   814
{
5955
fe61588d5188 (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: 5944
diff changeset
   815
	return _veh_sell_proc_table[type];
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   816
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   817
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   818
static inline uint32 GetCmdSellVeh(const Vehicle *v)
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   819
{
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   820
	return GetCmdSellVeh(v->type);
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   821
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   822
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   823
static inline uint32 GetCmdRefitVeh(VehicleType type)
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   824
{
5955
fe61588d5188 (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: 5944
diff changeset
   825
	return _veh_refit_proc_table[type];
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   826
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   827
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   828
static inline uint32 GetCmdRefitVeh(const Vehicle *v)
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   829
{
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   830
	return GetCmdRefitVeh(v->type);
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   831
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   832
6641
1b14f8887cb7 (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 6621
diff changeset
   833
static inline uint32 GetCmdSendToDepot(VehicleType type)
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   834
{
5955
fe61588d5188 (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: 5944
diff changeset
   835
	return _send_to_depot_proc_table[type];
5792
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   836
}
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   837
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   838
static inline uint32 GetCmdSendToDepot(const Vehicle *v)
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   839
{
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   840
	return GetCmdSendToDepot(v->type);
c4dad358b30b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 5789
diff changeset
   841
}
4451
2e86da0081b5 (svn r6229) -Feature: Shared order lists now got a "goto depot" button
bjarni
parents: 4434
diff changeset
   842
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
#endif /* VEHICLE_H */