src/vehicle_base.h
author glx
Mon, 03 Mar 2008 20:56:30 +0000
changeset 9162 ec5f2f4eee15
parent 9124 eea8af2b73a8
child 9266 416385a64dcb
child 10474 80c90b755053
permissions -rw-r--r--
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     3
/** @file  vehicle_base.h Base class for all vehicles. */
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
     4
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     5
#ifndef VEHICLE_BASE_H
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     6
#define VEHICLE_BASE_H
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8602
diff changeset
     8
#include "vehicle_type.h"
8598
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
     9
#include "track_type.h"
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
    10
#include "rail_type.h"
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8568
diff changeset
    11
#include "road_type.h"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
    12
#include "cargo_type.h"
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8627
diff changeset
    13
#include "direction_type.h"
8602
9e75e594a068 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 8598
diff changeset
    14
#include "window_type.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    15
#include "gfx_type.h"
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    16
#include "command_type.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8634
diff changeset
    17
#include "date_type.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8732
diff changeset
    18
#include "player_type.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    19
#include "oldpool.h"
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    20
#include "order.h"
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
    21
#include "cargopacket.h"
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
    22
#include "texteff.hpp"
6317
c73bda71ac16 (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 6206
diff changeset
    23
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    24
/** Road vehicle states */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    25
enum RoadVehicleStates {
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    26
	/*
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    27
	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    28
	 * When in a road stop (bit 5 or bit 6 set) these bits give the
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    29
	 * track direction of the entry to the road stop.
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    30
	 * As the entry direction will always be a diagonal
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    31
	 * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    32
	 * are needed to hold this direction. Bit 1 is then used to show
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    33
	 * that the vehicle is using the second road stop bay.
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    34
	 * Bit 2 is then used for drive-through stops to show the vehicle
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    35
	 * is stopping at this road stop.
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    36
	 */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    37
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    38
	/* Numeric values */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    39
	RVSB_IN_DEPOT                = 0xFE,                      ///< The vehicle is in a depot
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    40
	RVSB_WORMHOLE                = 0xFF,                      ///< The vehicle is in a tunnel and/or bridge
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    41
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    42
	/* Bit numbers */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    43
	RVS_USING_SECOND_BAY         =    1,                      ///< Only used while in a road stop
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    44
	RVS_IS_STOPPING              =    2,                      ///< Only used for drive-through stops. Vehicle will stop here
6487
0e7285c3c059 (svn r8911) -Cleanup: fixup comments about the RoadVehicleStates and remove two unused enums.
rubidium
parents: 6479
diff changeset
    45
	RVS_DRIVE_SIDE               =    4,                      ///< Only used when retrieving move data
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    46
	RVS_IN_ROAD_STOP             =    5,                      ///< The vehicle is in a road stop
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    47
	RVS_IN_DT_ROAD_STOP          =    6,                      ///< The vehicle is in a drive-through road stop
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    48
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    49
	/* Bit sets of the above specified bits */
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    50
	RVSB_IN_ROAD_STOP            = 1 << RVS_IN_ROAD_STOP,     ///< The vehicle is in a road stop
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    51
	RVSB_IN_ROAD_STOP_END        = RVSB_IN_ROAD_STOP + TRACKDIR_END,
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    52
	RVSB_IN_DT_ROAD_STOP         = 1 << RVS_IN_DT_ROAD_STOP,  ///< The vehicle is in a drive-through road stop
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6326
diff changeset
    53
	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
6326
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    54
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    55
	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    56
	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    57
};
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    58
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    59
enum VehStatus {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    60
	VS_HIDDEN          = 0x01,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    61
	VS_STOPPED         = 0x02,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    62
	VS_UNCLICKABLE     = 0x04,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    63
	VS_DEFPAL          = 0x08,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    64
	VS_TRAIN_SLOWING   = 0x10,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    65
	VS_SHADOW          = 0x20,
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    66
	VS_AIRCRAFT_BROKEN = 0x40,
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    67
	VS_CRASHED         = 0x80,
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    68
};
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    69
6501
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    70
enum VehicleFlags {
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    71
	VF_LOADING_FINISHED,
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
    72
	VF_CARGO_UNLOADING,
6502
7ca154aca2b7 (svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents: 6501
diff changeset
    73
	VF_BUILT_AS_PROTOTYPE,
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7510
diff changeset
    74
	VF_TIMETABLE_STARTED,  ///< Whether the vehicle has started running on the timetable yet.
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7510
diff changeset
    75
	VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
5211
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
    76
};
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
    77
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    78
struct VehicleRail {
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4404
diff changeset
    79
	uint16 last_speed; // NOSAVE: only used in UI
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	uint16 crash_anim_pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
    81
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
    82
	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
1905
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
    83
	uint16 cached_max_speed;  // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
    84
	uint32 cached_power;      // total power of the consist.
8674
6dc3d2a35da0 (svn r11741) -Feature: Add support for NewGRF's train 'tilt' flag. Trains with tilt capability (specific details are per NewGRF set) will be given a 20% speed limit bonus on curves.
peter1138
parents: 8668
diff changeset
    85
	bool cached_tilt;         // train can tilt; feature provides a bonus in curves
1922
797081e56d13 (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    86
	uint8 cached_veh_length;  // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
2587
d554e2a03afa (svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents: 2579
diff changeset
    87
	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
d554e2a03afa (svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents: 2579
diff changeset
    88
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
    89
	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
5162
f1d90a883266 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
    90
	uint32 cached_weight;     // total weight of the consist.
f1d90a883266 (svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents: 5116
diff changeset
    91
	uint32 cached_veh_weight; // weight of the vehicle.
5588
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5573
diff changeset
    92
	uint32 cached_max_te;     // max tractive effort of consist
2595
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    93
	/**
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    94
	 * Position/type of visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    95
	 * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    96
	 * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    97
	 * bit     6 = disable visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    98
	 * bit     7 = disable powered wagons.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
    99
	 */
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   100
	byte cached_vis_effect;
8377
77aaffeea0d7 (svn r11431) -Codechange: [NewGRF] Add support for changing rail vehicle user-defined bit mask (prop 25) via callback 36
glx
parents: 8299
diff changeset
   101
	byte user_def_data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   103
	/* NOSAVE: for wagon override - id of the first engine in train
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   104
	 * 0xffff == not in train */
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1790
diff changeset
   105
	EngineID first_engine;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   107
	TrackBitsByte track;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	byte force_proceed;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   109
	RailTypeByte railtype;
8732
b18f578f7c16 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8674
diff changeset
   110
	RailTypes compatible_railtypes;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	byte flags;
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 1977
diff changeset
   113
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   114
	/* Link between the two ends of a multiheaded engine */
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2666
diff changeset
   115
	Vehicle *other_multiheaded_part;
7099
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   116
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   117
	/* Cached wagon override spritegroup */
1528b11097af (svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents: 7090
diff changeset
   118
	const struct SpriteGroup *cached_override;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   119
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
9162
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   121
enum VehicleRailFlags {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   122
	VRF_REVERSING         = 0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   124
	/* used to calculate if train is going up or down */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   125
	VRF_GOINGUP           = 1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   126
	VRF_GOINGDOWN         = 2,
1908
bc48a30aba72 (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1905
diff changeset
   127
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   128
	/* used to store if a wagon is powered or not */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   129
	VRF_POWEREDWAGON      = 3,
3256
a23d94f568b7 (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   130
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   131
	/* used to reverse the visible direction of the vehicle */
3256
a23d94f568b7 (svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents: 3173
diff changeset
   132
	VRF_REVERSE_DIRECTION = 4,
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4734
diff changeset
   133
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   134
	/* used to mark train as lost because PF can't find the route */
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4734
diff changeset
   135
	VRF_NO_PATH_TO_DESTINATION = 5,
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   136
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   137
	/* used to mark that electric train engine is allowed to run on normal rail */
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4972
diff changeset
   138
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
9162
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   139
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   140
	/* used for vehicle var 0xFE bit 8 (toggled each time the train is reversed) */
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   141
	VRF_TOGGLE_REVERSE = 7,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   144
struct VehicleAir {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	uint16 crashed_counter;
6986
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6919
diff changeset
   146
	uint16 cached_max_speed;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	byte pos;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3977
diff changeset
   148
	byte previous_pos;
3347
d5d8ace1bb13 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3344
diff changeset
   149
	StationID targetairport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	byte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   151
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   153
struct VehicleRoad {
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   154
	byte state;             ///< @see RoadVehicleStates
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	byte frame;
3009
c477ab0f00b3 (svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr
peter1138
parents: 3008
diff changeset
   156
	uint16 blocked_ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	byte overtaking;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	byte overtaking_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	uint16 crashed_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	byte reverse_ctr;
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   161
	struct RoadStop *slot;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1174
diff changeset
   162
	byte slot_age;
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7269
diff changeset
   163
	EngineID first_engine;
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7269
diff changeset
   164
	byte cached_veh_length;
7179
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   165
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   166
	RoadType roadtype;
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   167
	RoadTypes compatible_roadtypes;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   168
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   170
struct VehicleSpecial {
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   171
	uint16 animation_state;
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   172
	byte animation_substate;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   173
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   175
struct VehicleDisaster {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
	uint16 image_override;
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   177
	VehicleID big_ufo_destroyer_target;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   178
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   180
struct VehicleShip {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   181
	TrackBitsByte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   182
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   184
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   186
/* Some declarations of functions, so we can make them friendly */
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   187
struct SaveLoad;
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   188
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
8668
8860d9c43130 (svn r11735) -Fix [FS#1574]: Don't reset loading indicator IDs when only reloading NewGRFs.
peter1138
parents: 8640
diff changeset
   189
extern void AfterLoadVehicles(bool clear_te_id);
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   190
struct LoadgameState;
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   191
extern bool LoadOldVehicle(LoadgameState *ls, int num);
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   192
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   193
struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6043
diff changeset
   194
	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
   195
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   196
private:
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   197
	Vehicle *next;           // pointer to the next vehicle in the chain
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   198
	Vehicle *previous;       // NOSAVE: pointer to the previous vehicle in the chain
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   199
	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   200
public:
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   201
	friend const SaveLoad *GetVehicleDescription(VehicleType vt); // So we can use private/protected variables in the saveload code
8668
8860d9c43130 (svn r11735) -Fix [FS#1574]: Don't reset loading indicator IDs when only reloading NewGRFs.
peter1138
parents: 8640
diff changeset
   202
	friend void AfterLoadVehicles(bool clear_te_id);              // So we can set the previous and first pointers while loading
8033
f80315b59db1 (svn r11057) -Fix [FS#1215]: loading TTD savegames went into an infinite loop due to not yet properly set next and previous pointers.
rubidium
parents: 7993
diff changeset
   203
	friend bool LoadOldVehicle(LoadgameState *ls, int num);       // So we can set the proper next pointer while loading
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   204
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   205
	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
   206
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   207
	char *name;              ///< Name of vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   209
	UnitID unitnumber;       // unit number, for display purposes only
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   210
	PlayerByte owner;        // which player owns the vehicle?
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   211
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   212
	TileIndex tile;          // Current tile index
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   213
	TileIndex dest_tile;     // Heading for this tile
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   214
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   215
	int32 x_pos;             // coordinates
1174
27e386195965 (svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents: 1139
diff changeset
   216
	int32 y_pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	byte z_pos;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   218
	DirectionByte direction; // facing
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   220
	byte spritenum;          // currently displayed sprite index
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   221
	                         // 0xfd == custom sprite, 0xfe == custom second head sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   222
	                         // 0xff == reserved for another custom sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   223
	uint16 cur_image;        // sprite number for this vehicle
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   224
	byte sprite_width;       // width of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   225
	byte sprite_height;      // height of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   226
	byte z_height;           // z-height of vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   227
	int8 x_offs;             // x offset for vehicle sprite
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   228
	int8 y_offs;             // y offset for vehicle sprite
1770
b6bda4dc6da2 (svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
Darkvater
parents: 1765
diff changeset
   229
	EngineID engine_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   231
	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   232
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   233
	/* for randomized variational spritegroups
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   234
	 * bitmask used to resolve them; parts of it get reseeded when triggers
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   235
	 * of corresponding spritegroups get matched */
445
0e3fa3da3899 (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents: 395
diff changeset
   236
	byte random_bits;
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   237
	byte waiting_triggers;   // triggers to be yet matched
445
0e3fa3da3899 (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents: 395
diff changeset
   238
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   239
	uint16 max_speed;        // maximum speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   240
	uint16 cur_speed;        // current speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   241
	byte subspeed;           // fractional speed
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   242
	byte acceleration;       // used by train & aircraft
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
	byte progress;
4656
acffecd6f484 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 4635
diff changeset
   244
	uint32 motion_counter;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   246
	byte vehstatus;          // Status
3347
d5d8ace1bb13 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3344
diff changeset
   247
	StationID last_station_visited;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   248
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   249
	CargoID cargo_type;      // type of cargo this vehicle is carrying
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   250
	uint16 cargo_cap;        // total capacity
3870
766d7bd6c299 (svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents: 3580
diff changeset
   251
	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
   252
	CargoList cargo;         ///< The cargo this vehicle is carrying
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7494
diff changeset
   253
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
9052
392f5995d323 (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz
parents: 8965
diff changeset
   255
	byte day_counter;        ///< Increased by one for each day
392f5995d323 (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz
parents: 8965
diff changeset
   256
	byte tick_counter;       ///< Increased by one for each tick
392f5995d323 (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz
parents: 8965
diff changeset
   257
	byte running_ticks;      ///< Number of ticks this vehicle was not stopped this day
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   259
	/* Begin Order-stuff */
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   260
	Order current_order;     ///< The current order (+ status, like: loading)
4391
7bfd170bfdf5 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   261
	VehicleOrderID cur_order_index; ///< The index to the current order
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   262
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   263
	Order *orders;           ///< Pointer to the first order for this vehicle
4391
7bfd170bfdf5 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   264
	VehicleOrderID num_orders;      ///< How many orders there are in the list
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   265
3173
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   266
	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
1b75b9a6ff71 (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents: 3172
diff changeset
   267
	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   268
	/* End Order-stuff */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   270
	/* Boundaries for the current position in the world and a next hash link.
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   271
	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
849
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   272
	int32 left_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   273
	int32 top_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   274
	int32 right_coord;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   275
	int32 bottom_coord;
5825
d813480f22ac (svn r8007) -Codechange: Change _vehicle_position_hash from VehicleID to Vehicle*. This removes the need for look ups by index. Also declare the array static.
peter1138
parents: 5726
diff changeset
   276
	Vehicle *next_hash;
7367
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
   277
	Vehicle *next_new_hash;
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
   278
	Vehicle **old_new_hash;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   280
	/* Related to age and service time */
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   281
	Date age;     // Age in days
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   282
	Date max_age; // Maximum age
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   283
	Date date_of_last_service;
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4176
diff changeset
   284
	Date service_interval;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	uint16 reliability;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	uint16 reliability_spd_dec;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
	byte breakdown_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	byte breakdown_delay;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	byte breakdowns_since_last_service;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	byte breakdown_chance;
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   291
	Year build_year;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   293
	bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
2617
a9e1a187de99 (svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents: 2602
diff changeset
   294
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	uint16 load_unload_time_rem;
6501
1e95e8d993ff (svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
maedhros
parents: 6487
diff changeset
   296
	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
   297
9052
392f5995d323 (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz
parents: 8965
diff changeset
   298
	Money profit_this_year;        ///< Profit this year << 8, low 8 bits are fract
392f5995d323 (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz
parents: 8965
diff changeset
   299
	Money profit_last_year;        ///< Profit last year << 8, low 8 bits are fract
7449
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
   300
	Money value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7137
diff changeset
   302
	GroupID group_id;              ///< Index of group Pool array
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7137
diff changeset
   303
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   304
	/* Used for timetabling. */
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   305
	uint32 current_order_time;     ///< How many ticks have passed since this order started.
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   306
	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7449
diff changeset
   307
8298
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
   308
	SpriteID colormap; // NOSAVE: cached color mapping
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
   309
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
	union {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		VehicleRail rail;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		VehicleAir air;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		VehicleRoad road;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
		VehicleSpecial special;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
		VehicleDisaster disaster;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
		VehicleShip ship;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	} u;
5902
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   318
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   319
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   320
	/**
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   321
	 * Allocates a lot of vehicles.
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   322
	 * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   323
	 * @param num number of vehicles to allocate room for
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   324
	 * @return true if there is room to allocate all the vehicles
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   325
	 */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   326
	static bool AllocateList(Vehicle **vl, int num);
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   327
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   328
	/** Create a new vehicle */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   329
	Vehicle();
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   330
7908
403a9694c42d (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7896
diff changeset
   331
	/** Destroy all stuff that (still) needs the virtual functions to work properly */
403a9694c42d (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7896
diff changeset
   332
	void PreDestructor();
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   333
	/** We want to 'destruct' the right class. */
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   334
	virtual ~Vehicle();
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   335
5902
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   336
	void BeginLoading();
906fea1535ab (svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.
KUDr
parents: 5838
diff changeset
   337
	void LeaveStation();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   338
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   339
	/**
7090
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   340
	 * Handle the loading of the vehicle; when not it skips through dummy
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   341
	 * orders and does nothing in all other cases.
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   342
	 * @param mode is the non-first call for this vehicle in this tick?
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   343
	 */
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   344
	void HandleLoading(bool mode = false);
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   345
8e4a4ac64b2d (svn r9808) -Codechange: unify the Handle<VehicleType>Loading functions.
rubidium
parents: 7089
diff changeset
   346
	/**
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   347
	 * Get a string 'representation' of the vehicle type.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   348
	 * @return the string representation.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   349
	 */
7896
2a4cdd5ca7d5 (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7894
diff changeset
   350
	virtual const char* GetTypeString() const { return "base vehicle"; }
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   351
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   352
	/**
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   353
	 * Marks the vehicles to be redrawn and updates cached variables
8041
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   354
	 *
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   355
	 * This method marks the area of the vehicle on the screen as dirty.
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   356
	 * It can be use to repaint the vehicle.
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   357
	 *
63e760418a15 (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 8033
diff changeset
   358
	 * @ingroup dirty
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   359
	 */
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   360
	virtual void MarkDirty() {}
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   361
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   362
	/**
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   363
	 * Updates the x and y offsets and the size of the sprite used
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   364
	 * for this vehicle.
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   365
	 * @param direction the direction the vehicle is facing
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   366
	 */
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   367
	virtual void UpdateDeltaXY(Direction direction) {}
7058
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   368
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   369
	/**
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   370
	 * Sets the expense type associated to this vehicle type
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   371
	 * @param income whether this is income or (running) expenses of the vehicle
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   372
	 */
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   373
	virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
7058
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   374
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   375
	/**
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   376
	 * Invalidates the vehicle list window of this type of vehicle
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
   377
	 */
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   378
	virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
7089
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   379
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   380
	/**
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   381
	 * Play the sound associated with leaving the station
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   382
	 */
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   383
	virtual void PlayLeaveStationSound() const {}
7269
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   384
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   385
	/**
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   386
	 * Whether this is the primary vehicle in the chain.
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   387
	 */
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   388
	virtual bool IsPrimaryVehicle() const { return false; }
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   389
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   390
	/**
7630
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   391
	 * Gets the sprite to show for the given direction
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   392
	 * @param direction the direction the vehicle is facing
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   393
	 * @return the sprite for the given vehicle in the given direction
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   394
	 */
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7592
diff changeset
   395
	virtual int GetImage(Direction direction) const { return 0; }
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   396
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   397
	/**
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   398
	 * Gets the speed in mph that can be sent into SetDParam for string processing.
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   399
	 * @return the vehicle's speed
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   400
	 */
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   401
	virtual int GetDisplaySpeed() const { return 0; }
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   402
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7909
diff changeset
   403
	/**
7980
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   404
	 * Gets the maximum speed in mph that can be sent into SetDParam for string processing.
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   405
	 * @return the vehicle's maximum speed
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   406
	 */
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   407
	virtual int GetDisplayMaxSpeed() const { return 0; }
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   408
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   409
	/**
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   410
	 * Gets the running cost of a vehicle
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   411
	 * @return the vehicle's running cost
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   412
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   413
	virtual Money GetRunningCost() const { return 0; }
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   414
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   415
	/**
7986
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   416
	 * Check whether the vehicle is in the depot.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   417
	 * @return true if and only if the vehicle is in the depot.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   418
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   419
	virtual bool IsInDepot() const { return false; }
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   420
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   421
	/**
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   422
	 * Check whether the vehicle is in the depot *and* stopped.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   423
	 * @return true if and only if the vehicle is in the depot and stopped.
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   424
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   425
	virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; }
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   426
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   427
	/**
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   428
	 * Calls the tick handler of the vehicle
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   429
	 */
7896
2a4cdd5ca7d5 (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7894
diff changeset
   430
	virtual void Tick() {};
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   431
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   432
	/**
8963
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   433
	 * Calls the new day handler of the vehicle
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   434
	 */
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   435
	virtual void OnNewDay() {};
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   436
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   437
	/**
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   438
	 * Gets the running cost of a vehicle  that can be sent into SetDParam for string processing.
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   439
	 * @return the vehicle's running cost
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   440
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   441
	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   442
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   443
	/**
9110
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   444
	 * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing.
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   445
	 * @return the vehicle's profit this year
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   446
	 */
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   447
	Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   448
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   449
	/**
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   450
	 * Gets the profit vehicle had last year. It can be sent into SetDParam for string processing.
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   451
	 * @return the vehicle's profit last year
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   452
	 */
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   453
	Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   454
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   455
	/**
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   456
	 * Set the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   457
	 * @param next the next vehicle. NULL removes the next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   458
	 */
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   459
	void SetNext(Vehicle *next);
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   460
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   461
	/**
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   462
	 * Get the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   463
	 * @note articulated parts are also counted as vehicles.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   464
	 * @return the next vehicle or NULL when there isn't a next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   465
	 */
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   466
	inline Vehicle *Next() const { return this->next; }
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   467
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   468
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   469
	 * Get the previous vehicle of this vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   470
	 * @note articulated parts are also counted as vehicles.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   471
	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   472
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   473
	inline Vehicle *Previous() const { return this->previous; }
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   474
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   475
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   476
	 * Get the first vehicle of this vehicle chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   477
	 * @return the first vehicle of the chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   478
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   479
	inline Vehicle *First() const { return this->first; }
8965
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   480
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   481
	/**
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   482
	 * Check if we share our orders with another vehicle.
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   483
	 * This is done by checking the previous and next pointers in the shared chain.
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   484
	 * @return true if there are other vehicles sharing the same order
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   485
	 */
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   486
	inline bool IsOrderListShared() const { return this->next_shared != NULL || this->prev_shared != NULL; };
9124
eea8af2b73a8 (svn r12230) -Codechange: [autoreplace] made a function to detect if a vehicle needs autorenewing
bjarni
parents: 9110
diff changeset
   487
eea8af2b73a8 (svn r12230) -Codechange: [autoreplace] made a function to detect if a vehicle needs autorenewing
bjarni
parents: 9110
diff changeset
   488
	bool NeedsAutorenewing(const Player *p) const;
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   489
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   490
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   491
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   492
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   493
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   494
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   495
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   496
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   497
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   498
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   499
 * A special vehicle is one of the following:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   500
 *  - smoke
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   501
 *  - electric sparks for trains
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   502
 *  - explosions
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   503
 *  - bulldozer (road works)
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   504
 *  - bubbles (industry)
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   505
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   506
struct SpecialVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   507
	/** Initializes the Vehicle to a special vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   508
	SpecialVehicle() { this->type = VEH_SPECIAL; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   509
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   510
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   511
	virtual ~SpecialVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   512
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   513
	const char *GetTypeString() const { return "special vehicle"; }
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   514
	void UpdateDeltaXY(Direction direction);
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   515
	void Tick();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   516
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   517
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   518
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   519
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   520
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   521
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   522
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   523
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   524
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   525
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   526
struct DisasterVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   527
	/** Initializes the Vehicle to a disaster vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   528
	DisasterVehicle() { this->type = VEH_DISASTER; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   529
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   530
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   531
	virtual ~DisasterVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   532
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   533
	const char *GetTypeString() const { return "disaster vehicle"; }
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   534
	void UpdateDeltaXY(Direction direction);
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   535
	void Tick();
7048
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   536
};
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   537
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   538
/**
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   539
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   540
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   541
 * and you reinitialize that to a Train using:
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   542
 *   v = new (v) Train();
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   543
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   544
 * As side-effect the vehicle type is set correctly.
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   545
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   546
struct InvalidVehicle : public Vehicle {
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   547
	/** Initializes the Vehicle to a invalid vehicle */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   548
	InvalidVehicle() { this->type = VEH_INVALID; }
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   549
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   550
	/** We want to 'destruct' the right class. */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   551
	virtual ~InvalidVehicle() {}
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   552
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   553
	const char *GetTypeString() const { return "invalid vehicle"; }
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   554
	void Tick() {}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
#define BEGIN_ENUM_WAGONS(v) do {
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   558
#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
   559
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   560
static inline VehicleID GetMaxVehicleIndex()
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   561
{
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   562
	/* TODO - This isn't the real content of the function, but
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   563
	 *  with the new pool-system this will be replaced with one that
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   564
	 *  _really_ returns the highest index. Now it just returns
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   565
	 *  the next safe value we are sure about everything is below.
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   566
	 */
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   567
	return GetVehiclePoolSize() - 1;
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   568
}
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   569
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   570
static inline uint GetNumVehicles()
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
   571
{
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   572
	return GetVehiclePoolSize();
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   573
}
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   574
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   575
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   576
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   577
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
   578
/**
1279
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   579
 * Check if an index is a vehicle-index (so between 0 and max-vehicles)
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   580
 * @param index of the vehicle to query
1279
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   581
 * @return Returns true if the vehicle-id is in range
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   582
 */
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   583
static inline bool IsValidVehicleID(uint index)
1237
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   584
{
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   585
	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
1237
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   586
}
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   587
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   588
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   589
static inline Order *GetVehicleOrder(const Vehicle *v, int index)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   590
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   591
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   592
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   593
	if (index < 0) return NULL;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   594
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   595
	while (order != NULL && index-- > 0)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   596
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   597
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   598
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   599
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   600
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   601
/**
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   602
 * Returns the last order of a vehicle, or NULL if it doesn't exists
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   603
 * @param v Vehicle to query
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   604
 * @return last order of a vehicle, if available
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   605
 */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   606
static inline Order *GetLastVehicleOrder(const Vehicle *v)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   607
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   608
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   609
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
   610
	if (order == NULL) return NULL;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   611
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   612
	while (order->next != NULL)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   613
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   614
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   615
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   616
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   617
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   618
/** Get the first vehicle of a shared-list, so we only have to walk forwards
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   619
 * @param v Vehicle to query
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   620
 * @return first vehicle of a shared-list
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
   621
 */
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   622
static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   623
{
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   624
	Vehicle *u = (Vehicle *)v;
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   625
	while (u->prev_shared != NULL) u = u->prev_shared;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   626
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   627
	return u;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   628
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   630
/**
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   631
 * Returns the Trackdir on which the vehicle is currently located.
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   632
 * Works for trains and ships.
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   633
 * Currently works only sortof for road vehicles, since they have a fuzzy
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   634
 * concept of being "on" a trackdir. Dunno really what it returns for a road
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   635
 * vehicle that is halfway a tile, never really understood that part. For road
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   636
 * vehicles that are at the beginning or end of the tile, should just return
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   637
 * the diagonal trackdir on which they are driving. I _think_.
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   638
 * For other vehicles types, or vehicles with no clear trackdir (such as those
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   639
 * in depots), returns 0xFF.
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   640
 */
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   641
Trackdir GetVehicleTrackdir(const Vehicle* v);
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   642
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   643
void CheckVehicle32Day(Vehicle *v);
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   644
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   645
#endif /* VEHICLE_BASE_H */