src/aircraft.h
author rubidium
Sun, 26 Aug 2007 21:21:59 +0000
changeset 7974 6fcdebd75c19
parent 7973 ce69b7781d4a
child 7980 9b12784cc39c
permissions -rw-r--r--
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
3963
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     1
/* $Id$ */
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     2
6447
3b71e57fd22b (svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents: 6443
diff changeset
     3
/** @file aircraft.h */
6443
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6413
diff changeset
     4
3987
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     5
#ifndef AIRCRAFT_H
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     6
#define AIRCRAFT_H
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     7
3963
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     8
#include "station_map.h"
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     9
#include "vehicle.h"
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    10
6911
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    11
/** An aircraft can be one ot those types */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6571
diff changeset
    12
enum AircraftSubType {
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    13
	AIR_HELICOPTER = 0, ///< an helicopter
6906
a9c4efb4e633 (svn r9546) -Fix (r9545): several typos...
rubidium
parents: 6905
diff changeset
    14
	AIR_AIRCRAFT   = 2, ///< an airplane
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    15
	AIR_SHADOW     = 4, ///< shadow of the aircraft
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    16
	AIR_ROTOR      = 6  ///< rotor of an helicopter
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6571
diff changeset
    17
};
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    18
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    19
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    20
/** Check if the aircraft type is a normal flying device; eg
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    21
 * not a rotor or a shadow
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    22
 * @param v vehicle to check
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    23
 * @return Returns true if the aircraft is a helicopter/airplane and
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    24
 * false if it is a shadow or a rotor) */
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    25
static inline bool IsNormalAircraft(const Vehicle *v)
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    26
{
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
    27
	assert(v->type == VEH_AIRCRAFT);
6105
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    28
	/* To be fully correct the commented out functionality is the proper one,
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    29
	 * but since value can only be 0 or 2, it is sufficient to only check <= 2
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    30
	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    31
	return v->subtype <= AIR_AIRCRAFT;
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    32
}
761d393829d6 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 6031
diff changeset
    33
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    34
/** Check if this aircraft is in a hangar
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    35
 * @param v vehicle to check
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    36
 * @return true if in hangar
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    37
 */
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
    38
static inline bool IsAircraftInHangar(const Vehicle *v)
3963
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    39
{
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
    40
	assert(v->type == VEH_AIRCRAFT);
3963
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    41
	return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    42
}
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    43
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    44
/** Check if this aircraft is in a hangar and stopped
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    45
 * @param v vehicle to check
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    46
 * @return true if in hangar and stopped
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    47
 */
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
    48
static inline bool IsAircraftInHangarStopped(const Vehicle *v)
3963
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    49
{
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    50
	return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
d7d284c2f1f7 (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    51
}
3987
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
    52
6563
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    53
/** Checks if an aircraft is buildable at the tile in question
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    54
 * @param engine The engine to test
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    55
 * @param tile The tile where the hangar is
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    56
 * @return true if the aircraft can be build
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    57
 */
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    58
static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile)
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    59
{
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    60
	const Station *st = GetStationByTile(tile);
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    61
	const AirportFTAClass *apc = st->Airport();
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    62
	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    63
6571
a0f5bf2afa6c (svn r9048) -Fix r9040: non-bool used as bool
glx
parents: 6563
diff changeset
    64
	return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
6563
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    65
}
d08d813ecd42 (svn r9040) -Codechange: the build window and CmdBuildAircraft() now shares the code to figure out if an aircraft is buildable in the hangar in question
bjarni
parents: 6447
diff changeset
    66
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    67
/**
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    68
 * Calculates cargo capacity based on an aircraft's passenger
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    69
 * and mail capacities.
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    70
 * @param cid Which cargo type to calculate a capacity for.
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    71
 * @param avi Which engine to find a cargo capacity for.
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    72
 * @return New cargo capacity value.
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    73
 */
6906
a9c4efb4e633 (svn r9546) -Fix (r9545): several typos...
rubidium
parents: 6905
diff changeset
    74
uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi);
3987
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
    75
6911
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    76
/**
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    77
 * This is the Callback method after the construction attempt of an aircraft
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    78
 * @param success indicates completion (or not) of the operation
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    79
 * @param tile of depot where aircraft is built
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    80
 * @param p1 unused
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    81
 * @param p2 unused
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    82
 */
6031
f6d1eef3fa24 (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents: 5726
diff changeset
    83
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
6911
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    84
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    85
/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    86
 * @param *v Vehicle that enters the hangar
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    87
 */
4732
da9d305d1c94 (svn r6644) -Fix(r6637): remove inline to allow MSVC compilation
belugas
parents: 4725
diff changeset
    88
void HandleAircraftEnterHangar(Vehicle *v);
6905
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    89
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    90
/** Get the size of the sprite of an aircraft sprite heading west (used for lists)
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    91
 * @param engine The engine to get the sprite from
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    92
 * @param width The width of the sprite
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    93
 * @param height The height of the sprite
c0a93961678a (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6585
diff changeset
    94
 */
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6105
diff changeset
    95
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
4653
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 3987
diff changeset
    96
6911
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    97
/**
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    98
 * Updates the status of the Aircraft heading or in the station
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
    99
 * @param st Station been updated
ee97929ba49e (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6906
diff changeset
   100
 */
6413
3d660a812fbd (svn r8822) -Fix
tron
parents: 6223
diff changeset
   101
void UpdateAirplanesOnNewStation(const Station *st);
3d660a812fbd (svn r8822) -Fix
tron
parents: 6223
diff changeset
   102
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: 6911
diff changeset
   103
/** Update cached values of an aircraft.
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: 6911
diff changeset
   104
 * Currently caches callback 36 max speed.
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: 6911
diff changeset
   105
 * @param v Vehicle
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: 6911
diff changeset
   106
 */
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: 6911
diff changeset
   107
void UpdateAircraftCache(Vehicle *v);
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: 6911
diff changeset
   108
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: 6986
diff changeset
   109
/**
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: 6986
diff changeset
   110
 * 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: 6986
diff changeset
   111
 * 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: 6986
diff changeset
   112
 * 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: 6986
diff changeset
   113
 *   v = new (v) Aircraft();
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: 6986
diff changeset
   114
 *
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: 6986
diff changeset
   115
 * 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: 6986
diff changeset
   116
 */
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: 6986
diff changeset
   117
struct Aircraft : 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: 6986
diff changeset
   118
	/** Initializes the Vehicle to an aircraft */
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: 6986
diff changeset
   119
	Aircraft() { this->type = VEH_AIRCRAFT; }
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: 6986
diff changeset
   120
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: 6986
diff changeset
   121
	/** We want to 'destruct' the right class. */
7908
403a9694c42d (svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents: 7814
diff changeset
   122
	virtual ~Aircraft() { this->PreDestructor(); }
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: 6986
diff changeset
   123
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   124
	const char *GetTypeString() const { return "aircraft"; }
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
   125
	void MarkDirty();
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
   126
	void UpdateDeltaXY(Direction direction);
7059
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   127
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
3d5c57a7e729 (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 7058
diff changeset
   128
	WindowClass GetVehicleListWindowClass() const { return WC_AIRCRAFT_LIST; }
7269
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 7059
diff changeset
   129
	bool IsPrimaryVehicle() const { return IsNormalAircraft(this); }
7630
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7269
diff changeset
   130
	int GetImage(Direction direction) const;
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: 7908
diff changeset
   131
	int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
   132
	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: 6986
diff changeset
   133
};
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: 6986
diff changeset
   134
3987
96b119a9fb94 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
   135
#endif /* AIRCRAFT_H */