src/vehicle_base.h
author Tero Marttila <terom@fixme.fi>
Fri, 18 Jul 2008 22:41:08 +0300
changeset 11177 6d9a43c48924
parent 11123 a3752bbcc23b
permissions -rw-r--r--
set the GRFConfig's next ptr to NULL
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"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    14
#include "gfx_type.h"
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    15
#include "command_type.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8634
diff changeset
    16
#include "date_type.h"
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
    17
#include "player_base.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"
9280
9c03416d26b1 (svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents: 9273
diff changeset
    20
#include "order_base.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"
9266
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 9162
diff changeset
    23
#include "group_type.h"
9273
ca5e00698c01 (svn r12476) -Codechange: split type engine related types from engine.h (and openttd.h) to engine_type.h.
rubidium
parents: 9266
diff changeset
    24
#include "engine_type.h"
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
    25
#include "order_func.h"
10444
3876060cdef7 (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents: 10398
diff changeset
    26
#include "transport_type.h"
6317
c73bda71ac16 (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 6206
diff changeset
    27
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
    28
/** 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
    29
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
    30
	/*
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
	 * 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
    32
	 * 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
    33
	 * 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
    34
	 * 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
    35
	 * 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
    36
	 * 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
    37
	 * 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
    38
	 * 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
    39
	 * 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
    40
	 */
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
	/* 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
    43
	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
    44
	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
    45
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
	/* 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
    47
	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
    48
	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
    49
	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
    50
	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
    51
	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
    52
c904c7ea1c8d (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 6317
diff changeset
    53
	/* 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
    54
	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
    55
	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
    56
	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
    57
	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
    58
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
    59
	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
    60
	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
    61
};
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
    62
1752
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    63
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
    64
	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
    65
	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
    66
	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
    67
	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
    68
	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
    69
	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
    70
	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
    71
	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
    72
};
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    73
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
    74
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
    75
	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
    76
	VF_CARGO_UNLOADING,
6502
7ca154aca2b7 (svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents: 6501
diff changeset
    77
	VF_BUILT_AS_PROTOTYPE,
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7510
diff changeset
    78
	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
    79
	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
    80
};
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5162
diff changeset
    81
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    82
struct VehicleRail {
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    83
	/* Link between the two ends of a multiheaded engine */
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    84
	Vehicle *other_multiheaded_part;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    85
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    86
	/* Cached wagon override spritegroup */
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    87
	const struct SpriteGroup *cached_override;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    88
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4404
diff changeset
    89
	uint16 last_speed; // NOSAVE: only used in UI
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	uint16 crash_anim_pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
    91
6919
339210ecccd3 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6590
diff changeset
    92
	/* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    93
	uint32 cached_power;        ///< total power of the consist.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    94
	uint16 cached_max_speed;    ///< max speed of the consist. (minimum of the max speed of all vehicles in the consist)
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
    95
	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    96
	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
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
    97
	bool cached_tilt;           ///< train can tilt; feature provides a bonus in curves
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
    98
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
    99
	/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   100
	uint32 cached_weight;     ///< total weight of the consist.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   101
	uint32 cached_veh_weight; ///< weight of the vehicle.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   102
	uint32 cached_max_te;     ///< max tractive effort of consist
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   103
2595
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   104
	/**
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   105
	 * Position/type of visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   106
	 * 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
   107
	 * 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
   108
	 * bit     6 = disable visual effect.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   109
	 * bit     7 = disable powered wagons.
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   110
	 */
0bab25144829 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents: 2587
diff changeset
   111
	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
   112
	byte user_def_data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
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
	/* 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
   115
	 * 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
   116
	EngineID first_engine;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   118
	byte flags;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   119
	TrackBitsByte track;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	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
   121
	RailTypeByte railtype;
8732
b18f578f7c16 (svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents: 8674
diff changeset
   122
	RailTypes compatible_railtypes;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   123
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
9162
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   125
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
   126
	VRF_REVERSING         = 0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
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 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
   129
	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
   130
	VRF_GOINGDOWN         = 2,
1908
bc48a30aba72 (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1905
diff changeset
   131
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
   132
	/* 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
   133
	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
   134
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
   135
	/* 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
   136
	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
   137
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
   138
	/* 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
   139
	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
   140
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
   141
	/* 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
   142
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
9162
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   143
10180
5f8bba5dd224 (svn r12711) -Codechange: remove unneeded loops
glx
parents: 10127
diff changeset
   144
	/* used for vehicle var 0xFE bit 8 (toggled each time the train is reversed, accurate for first vehicle only) */
9162
ec5f2f4eee15 (svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents: 9124
diff changeset
   145
	VRF_TOGGLE_REVERSE = 7,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   148
struct VehicleAir {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	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
   150
	uint16 cached_max_speed;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	byte pos;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3977
diff changeset
   152
	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
   153
	StationID targetairport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	byte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   155
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   157
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
   158
	byte state;             ///< @see RoadVehicleStates
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	byte frame;
3009
c477ab0f00b3 (svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr
peter1138
parents: 3008
diff changeset
   160
	uint16 blocked_ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	byte overtaking;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	byte overtaking_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	uint16 crashed_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	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
   165
	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
   166
	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
   167
	EngineID first_engine;
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7269
diff changeset
   168
	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
   169
3e123c2b7c93 (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 7139
diff changeset
   170
	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
   171
	RoadTypes compatible_roadtypes;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   172
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
10271
a20997d33fe8 (svn r12803) -Cleanup: rename SpecialVehicle to EffectVehicle to have a uniform naming of the thing instead of using both names for the same thing.
rubidium
parents: 10180
diff changeset
   174
struct VehicleEffect {
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   175
	uint16 animation_state;
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   176
	byte animation_substate;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   177
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   179
struct VehicleDisaster {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	uint16 image_override;
7830
210381b46ae6 (svn r10697) -Codechange: give a more sensible names to some of the unkX variables.
rubidium
parents: 7814
diff changeset
   181
	VehicleID big_ufo_destroyer_target;
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
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   184
struct VehicleShip {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5825
diff changeset
   185
	TrackBitsByte state;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   186
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
7894
dbe6e9295ec5 (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7883
diff changeset
   188
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
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
/* 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
   191
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
   192
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
   193
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
   194
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
   195
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
   196
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   197
struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
7989
116c8f9769af (svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents: 7988
diff changeset
   198
private:
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   199
	Vehicle *next;           ///< pointer to the next vehicle in the chain
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   200
	Vehicle *previous;       ///< NOSAVE: pointer to the previous vehicle in the chain
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   201
	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
   202
public:
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   203
	friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   204
	friend void AfterLoadVehicles(bool clear_te_id);              ///< So we can set the previous and first pointers while loading
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   205
	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
   206
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   207
	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
   208
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
   209
	char *name;              ///< Name of vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   211
	TileIndex tile;          ///< Current tile index
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   212
	TileIndex dest_tile;     ///< Heading for this tile
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
   213
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   214
	Vehicle *next_shared;    ///< If not NULL, this points to the next vehicle that shared the order
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   215
	Vehicle *prev_shared;    ///< If not NULL, this points to the prev vehicle that shared the order
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   216
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   217
	Money profit_this_year;        ///< Profit this year << 8, low 8 bits are fract
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   218
	Money profit_last_year;        ///< Profit last year << 8, low 8 bits are fract
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   219
	Money value;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   220
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   221
	/* Used for timetabling. */
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   222
	uint32 current_order_time;     ///< How many ticks have passed since this order started.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   223
	int32 lateness_counter;        ///< How many ticks late (or early if negative) this vehicle is.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   224
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   225
	/* Boundaries for the current position in the world and a next hash link.
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   226
	 * NOSAVE: All of those can be updated with VehiclePositionChanged() */
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   227
	int32 left_coord;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   228
	int32 top_coord;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   229
	int32 right_coord;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   230
	int32 bottom_coord;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   231
	Vehicle *next_hash;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   232
	Vehicle *next_new_hash;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   233
	Vehicle **old_new_hash;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   234
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   235
	SpriteID colormap; // NOSAVE: cached color mapping
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   236
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   237
	/* Related to age and service time */
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   238
	Year build_year;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   239
	Date age;     // Age in days
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   240
	Date max_age; // Maximum age
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   241
	Date date_of_last_service;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   242
	Date service_interval;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   243
	uint16 reliability;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   244
	uint16 reliability_spd_dec;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   245
	byte breakdown_ctr;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   246
	byte breakdown_delay;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   247
	byte breakdowns_since_last_service;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   248
	byte breakdown_chance;
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
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
	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
   251
	int32 y_pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	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
   253
	DirectionByte direction; // facing
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   255
	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
   256
	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
   257
	                         // 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
   258
	                         // 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
   259
	uint16 cur_image;        // sprite number for this vehicle
9289
92f1249c304e (svn r12531) -Codechange: Rename some variables for consistency.
frosch
parents: 9280
diff changeset
   260
	byte x_extent;           // x-extent of vehicle bounding box
92f1249c304e (svn r12531) -Codechange: Rename some variables for consistency.
frosch
parents: 9280
diff changeset
   261
	byte y_extent;           // y-extent of vehicle bounding box
92f1249c304e (svn r12531) -Codechange: Rename some variables for consistency.
frosch
parents: 9280
diff changeset
   262
	byte z_extent;           // z-extent of vehicle bounding box
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
   263
	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
   264
	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
   265
	EngineID engine_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   267
	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   268
	UnitID unitnumber;       // unit number, for display purposes only
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   269
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   270
	uint16 max_speed;        ///< maximum speed
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   271
	uint16 cur_speed;        ///< current speed
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   272
	byte subspeed;           ///< fractional speed
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   273
	byte acceleration;       ///< used by train & aircraft
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   274
	uint32 motion_counter;
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   275
	byte progress;
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   276
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
   277
	/* 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
   278
	 * 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
   279
	 * 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
   280
	byte random_bits;
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   281
	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
   282
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
   283
	StationID last_station_visited;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   284
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   285
	CargoID cargo_type;      ///< type of cargo this vehicle is carrying
3870
766d7bd6c299 (svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents: 3580
diff changeset
   286
	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   287
	uint16 cargo_cap;        ///< total capacity
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
   288
	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
   289
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
   290
	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
   291
	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
   292
	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
   293
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   294
	byte vehstatus;                 ///< Status
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   295
	Order current_order;            ///< The current order (+ status, like: loading)
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   296
	VehicleOrderID num_orders;      ///< How many orders there are in the list
4391
7bfd170bfdf5 (svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents: 4384
diff changeset
   297
	VehicleOrderID cur_order_index; ///< The index to the current order
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   298
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   299
	Order *orders;                  ///< Pointer to the first order for this vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   301
	bool leave_depot_instantly;     ///< NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   303
	byte vehicle_flags;             ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
	uint16 load_unload_time_rem;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 164
diff changeset
   305
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   306
	GroupID group_id;               ///< Index of group Pool array
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
10282
bd9c075efe67 (svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium
parents: 10272
diff changeset
   308
	byte subtype;                   ///< subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
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
   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;
10271
a20997d33fe8 (svn r12803) -Cleanup: rename SpecialVehicle to EffectVehicle to have a uniform naming of the thing instead of using both names for the same thing.
rubidium
parents: 10180
diff changeset
   314
		VehicleEffect effect;
0
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
	/**
7089
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   376
	 * 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
   377
	 */
7230d3e22a5f (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents: 7076
diff changeset
   378
	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
   379
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   380
	/**
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   381
	 * 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
   382
	 */
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7179
diff changeset
   383
	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
   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
	/**
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
   386
	 * 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
   387
	 * @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
   388
	 * @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
   389
	 */
10293
b3ca071d6716 (svn r12824) -Codechange: Standardise routines for drawing vehicle images, using correct types and less duplication.
peter1138
parents: 10282
diff changeset
   390
	virtual SpriteID 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
   391
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   392
	/**
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
   393
	 * 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
   394
	 * @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
   395
	 */
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
   396
	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
   397
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
	/**
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
   399
	 * 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
   400
	 * @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
   401
	 */
9b12784cc39c (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7974
diff changeset
   402
	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
   403
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
	/**
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   405
	 * 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
   406
	 * @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
   407
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   408
	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
   409
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   410
	/**
7986
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   411
	 * 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
   412
	 * @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
   413
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   414
	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
   415
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   416
	/**
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   417
	 * 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
   418
	 * @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
   419
	 */
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   420
	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
   421
881998b115c2 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7984
diff changeset
   422
	/**
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   423
	 * 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
   424
	 */
7896
2a4cdd5ca7d5 (svn r10772) -Codechange: also make use of the generic clean and destroy pool callback functions for vehicle.
rubidium
parents: 7894
diff changeset
   425
	virtual void Tick() {};
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   426
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   427
	/**
8963
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   428
	 * 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
   429
	 */
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   430
	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
   431
4b41ed1df7e5 (svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents: 8754
diff changeset
   432
	/**
7984
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   433
	 * 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
   434
	 * @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
   435
	 */
c539c9368e3c (svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents: 7982
diff changeset
   436
	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
   437
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
   438
	/**
9110
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   439
	 * 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
   440
	 * @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
   441
	 */
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   442
	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
   443
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   444
	/**
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   445
	 * 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
   446
	 * @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
   447
	 */
55864e1fc263 (svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents: 9052
diff changeset
   448
	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
   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
	/**
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
   451
	 * Set the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   452
	 * @param next the next vehicle. NULL removes the next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   453
	 */
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   454
	void SetNext(Vehicle *next);
7988
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   455
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   456
	/**
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   457
	 * Get the next vehicle of this vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   458
	 * @note articulated parts are also counted as vehicles.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   459
	 * @return the next vehicle or NULL when there isn't a next vehicle.
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   460
	 */
6075538f6111 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7986
diff changeset
   461
	inline Vehicle *Next() const { return this->next; }
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   462
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   463
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   464
	 * Get the previous vehicle of this vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   465
	 * @note articulated parts are also counted as vehicles.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   466
	 * @return the previous vehicle or NULL when there isn't a previous vehicle.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   467
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   468
	inline Vehicle *Previous() const { return this->previous; }
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   469
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   470
	/**
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   471
	 * Get the first vehicle of this vehicle chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   472
	 * @return the first vehicle of the chain.
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   473
	 */
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7989
diff changeset
   474
	inline Vehicle *First() const { return this->first; }
8965
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   475
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   476
	/**
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   477
	 * 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
   478
	 * 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
   479
	 * @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
   480
	 */
a145f62a6272 (svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas
parents: 8963
diff changeset
   481
	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
   482
eea8af2b73a8 (svn r12230) -Codechange: [autoreplace] made a function to detect if a vehicle needs autorenewing
bjarni
parents: 9110
diff changeset
   483
	bool NeedsAutorenewing(const Player *p) const;
9323
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   484
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   485
	/**
10098
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   486
	 * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement.
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   487
	 *
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   488
	 * @see NeedsAutomaticServicing()
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   489
	 * @return true if the vehicle should go to a depot if a opportunity presents itself.
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   490
	 */
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   491
	bool NeedsServicing() const;
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   492
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   493
	/**
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   494
	 * Checks if the current order should be interupted for a service-in-depot-order.
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   495
	 * @see NeedsServicing()
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   496
	 * @return true if the current order should be interupted.
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   497
	 */
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   498
	bool NeedsAutomaticServicing() const;
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   499
00ebbccc6181 (svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch
parents: 9323
diff changeset
   500
	/**
9323
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   501
	 * Determine the location for the station where the vehicle goes to next.
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   502
	 * Things done for example are allocating slots in a road stop or exact
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   503
	 * location of the platform is determined for ships.
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   504
	 * @param station the station to make the next location of the vehicle.
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   505
	 * @return the location (tile) to aim for.
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   506
	 */
9bc423363f6a (svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents: 9289
diff changeset
   507
	virtual TileIndex GetOrderStationLocation(StationID station) { return INVALID_TILE; }
10126
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   508
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   509
	/**
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   510
	 * Find the closest depot for this vehicle and tell us the location,
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   511
	 * DestinationID and whether we should reverse.
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   512
	 * @param location    where do we go to?
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   513
	 * @param destination what hangar do we go to?
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   514
	 * @param reverse     should the vehicle be reversed?
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   515
	 * @return true if a depot could be found.
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   516
	 */
bed2d9d38577 (svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents: 10098
diff changeset
   517
	virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { return false; }
10127
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   518
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   519
	/**
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   520
	 * Send this vehicle to the depot using the given command(s).
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   521
	 * @param flags   the command flags (like execute and such).
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   522
	 * @param command the command to execute.
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   523
	 * @return the cost of the depot action.
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   524
	 */
ab5e35f77e87 (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 10126
diff changeset
   525
	CommandCost SendToDepot(uint32 flags, DepotCommand command);
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
   526
};
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
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
/**
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
 * 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
   530
 * 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
   531
 * 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
   532
 *   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
   533
 *
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   534
 * 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
   535
 */
06b931095b26 (svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents: 7012
diff changeset
   536
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
   537
	/** 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
   538
	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
   539
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
	/** 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
   541
	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
   542
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   543
	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
   544
	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
   545
	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
   546
};
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
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
/**
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
 * 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
   550
 * 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
   551
 * 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
   552
 *   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
   553
 *
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
   554
 * 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
   555
 */
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
   556
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
   557
	/** 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
   558
	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
   559
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
   560
	/** 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
   561
	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
   562
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   563
	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
   564
	void Tick() {}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   567
static inline VehicleID GetMaxVehicleIndex()
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   568
{
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   569
	/* 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
   570
	 *  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
   571
	 *  _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
   572
	 *  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
   573
	 */
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
   574
	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
   575
}
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
   576
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
   577
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
   578
{
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   579
	return GetVehiclePoolSize();
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   580
}
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   581
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   582
#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
   583
#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
   584
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
   585
/**
1279
4f83fbde72de (svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents: 1266
diff changeset
   586
 * 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
   587
 * @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
   588
 * @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
   589
 */
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   590
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
   591
{
7883
7777bca58ae0 (svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
rubidium
parents: 7830
diff changeset
   592
	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
   593
}
0a1ce05c3d45 (svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents: 1217
diff changeset
   594
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   595
/* 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
   596
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
   597
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   598
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   599
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
   600
	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
   601
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   602
	while (order != NULL && index-- > 0)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   603
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   604
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   605
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   606
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   607
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
   608
/**
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
   609
 * 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
   610
 * @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
   611
 * @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
   612
 */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   613
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
   614
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   615
	Order *order = v->orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   616
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
   617
	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
   618
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   619
	while (order->next != NULL)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   620
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   621
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   622
	return order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   623
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   624
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
   625
/** 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
   626
 * @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
   627
 * @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
   628
 */
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   629
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
   630
{
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   631
	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
   632
	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
   633
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   634
	return u;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
   635
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   637
/**
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   638
 * 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
   639
 * Works for trains and ships.
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   640
 * 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
   641
 * 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
   642
 * 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
   643
 * 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
   644
 * 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
   645
 * 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
   646
 * 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
   647
 */
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   648
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
   649
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   650
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
   651
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   652
struct BackuppedVehicle {
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   653
private:
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   654
	Vehicle *vehicles;
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   655
	BackuppedOrders *orders;
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   656
	PlayerMoneyBackup *economy;
10398
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   657
	CargoPacket *cargo_packets;
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   658
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   659
	void BackupVehicle(Vehicle *v);
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   660
	Vehicle* RestoreBackupVehicle(Vehicle *v, Player *p);
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   661
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   662
public:
10398
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   663
	BackuppedVehicle(bool include_orders) : vehicles(NULL), economy(NULL), cargo_packets(NULL) {
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   664
		orders = include_orders ? new BackuppedOrders() : NULL;
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   665
	}
10398
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   666
	~BackuppedVehicle() { free(vehicles); delete orders; delete economy; free(cargo_packets); }
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   667
10398
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   668
	void Backup(Vehicle *v, Player *p = NULL);
e4cd3dc13498 (svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
bjarni
parents: 10372
diff changeset
   669
	Vehicle *Restore(Vehicle *v, Player *p);
10372
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   670
	bool ContainsBackup() { return vehicles != NULL; }
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   671
};
93844492fdd9 (svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni
parents: 10321
diff changeset
   672
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   673
#endif /* VEHICLE_BASE_H */