src/aircraft.h
author belugas
Wed, 04 Apr 2007 01:35:16 +0000
changeset 6420 456c275f3313
parent 6415 cb61e1346600
child 6490 fe4443fba5e3
permissions -rw-r--r--
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
3963
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     1
/* $Id$ */
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     2
6121
2aae24b0881f (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: 6117
diff changeset
     3
/** @file aircraft.h */
6117
6507b2a7e71d (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: 6087
diff changeset
     4
3987
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     5
#ifndef AIRCRAFT_H
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     6
#define AIRCRAFT_H
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
     7
3963
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     8
#include "station_map.h"
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
     9
#include "vehicle.h"
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    10
6415
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    11
/** An aircraft can be one ot those types */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6245
diff changeset
    12
enum AircraftSubType {
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    13
	AIR_HELICOPTER = 0, ///< an helicopter
6410
415e9d86dae0 (svn r9546) -Fix (r9545): several typos...
rubidium
parents: 6409
diff changeset
    14
	AIR_AIRCRAFT   = 2, ///< an airplane
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    15
	AIR_SHADOW     = 4, ///< shadow of the aircraft
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    16
	AIR_ROTOR      = 6  ///< rotor of an helicopter
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6245
diff changeset
    17
};
5854
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    18
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    19
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    20
/** Check if the aircraft type is a normal flying device; eg
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    21
 * not a rotor or a shadow
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    22
 * @param v vehicle to check
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    23
 * @return Returns true if the aircraft is a helicopter/airplane and
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    24
 * false if it is a shadow or a rotor) */
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    25
static inline bool IsNormalAircraft(const Vehicle *v)
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    26
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    27
	assert(v->type == VEH_AIRCRAFT);
5854
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    28
	/* To be fully correct the commented out functionality is the proper one,
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    29
	 * but since value can only be 0 or 2, it is sufficient to only check <= 2
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    30
	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    31
	return v->subtype <= AIR_AIRCRAFT;
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    32
}
9eee280920f0 (svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents: 5780
diff changeset
    33
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    34
/** Check if this aircraft is in a hangar
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    35
 * @param v vehicle to check
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    36
 * @return true if in hangar
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    37
 */
3963
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    38
static inline bool IsAircraftInHangar(const Vehicle* v)
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    39
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    40
	assert(v->type == VEH_AIRCRAFT);
3963
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    41
	return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    42
}
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    43
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    44
/** Check if this aircraft is in a hangar and stopped
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    45
 * @param v vehicle to check
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    46
 * @return true if in hangar and stopped
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    47
 */
3963
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    48
static inline bool IsAircraftInHangarStopped(const Vehicle* v)
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    49
{
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    50
	return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
6cab57074a9a (svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
diff changeset
    51
}
3987
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
    52
6237
69427b23257f (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: 6121
diff changeset
    53
/** Checks if an aircraft is buildable at the tile in question
69427b23257f (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: 6121
diff changeset
    54
 * @param engine The engine to test
69427b23257f (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: 6121
diff changeset
    55
 * @param tile The tile where the hangar is
69427b23257f (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: 6121
diff changeset
    56
 * @return true if the aircraft can be build
69427b23257f (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: 6121
diff changeset
    57
 */
69427b23257f (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: 6121
diff changeset
    58
static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile)
69427b23257f (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: 6121
diff changeset
    59
{
69427b23257f (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: 6121
diff changeset
    60
	const Station *st = GetStationByTile(tile);
69427b23257f (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: 6121
diff changeset
    61
	const AirportFTAClass *apc = st->Airport();
69427b23257f (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: 6121
diff changeset
    62
	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
69427b23257f (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: 6121
diff changeset
    63
6245
a9033dde144b (svn r9048) -Fix r9040: non-bool used as bool
glx
parents: 6237
diff changeset
    64
	return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
6237
69427b23257f (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: 6121
diff changeset
    65
}
69427b23257f (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: 6121
diff changeset
    66
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    67
/**
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    68
 * Calculates cargo capacity based on an aircraft's passenger
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    69
 * and mail capacities.
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    70
 * @param cid Which cargo type to calculate a capacity for.
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    71
 * @param avi Which engine to find a cargo capacity for.
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    72
 * @return New cargo capacity value.
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    73
 */
6410
415e9d86dae0 (svn r9546) -Fix (r9545): several typos...
rubidium
parents: 6409
diff changeset
    74
uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi);
3987
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
    75
6415
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    76
/**
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    77
 * This is the Callback method after the construction attempt of an aircraft
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    78
 * @param success indicates completion (or not) of the operation
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    79
 * @param tile of depot where aircraft is built
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    80
 * @param p1 unused
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    81
 * @param p2 unused
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    82
 */
5780
b16aec7650c2 (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents: 5475
diff changeset
    83
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
6415
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    84
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    85
/**
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    86
 * This is the Callback method after the cloning attempt of an aircraft
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    87
 * @param success indicates completion (or not) of the operation
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    88
 * @param tile unused
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    89
 * @param p1 unused
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    90
 * @param p2 unused
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
    91
 */
4653
9f72ab9dc4a7 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 3987
diff changeset
    92
void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    93
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    94
/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    95
 * @param *v Vehicle that enters the hangar
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    96
 */
4732
4f1c405ac96e (svn r6644) -Fix(r6637): remove inline to allow MSVC compilation
belugas
parents: 4725
diff changeset
    97
void HandleAircraftEnterHangar(Vehicle *v);
6409
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    98
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
    99
/** Get the size of the sprite of an aircraft sprite heading west (used for lists)
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
   100
 * @param engine The engine to get the sprite from
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
   101
 * @param width The width of the sprite
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
   102
 * @param height The height of the sprite
2dc181151153 (svn r9545) -Documentation: Some corrections to previous doxygen work
belugas
parents: 6259
diff changeset
   103
 */
5972
59953719a3ff (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: 5854
diff changeset
   104
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
4653
9f72ab9dc4a7 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 3987
diff changeset
   105
6415
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
   106
/**
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
   107
 * Updates the status of the Aircraft heading or in the station
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
   108
 * @param st Station been updated
cb61e1346600 (svn r9551) -Documentation: Some more doxygen work
belugas
parents: 6410
diff changeset
   109
 */
6087
bfa159e740d9 (svn r8822) -Fix
tron
parents: 5972
diff changeset
   110
void UpdateAirplanesOnNewStation(const Station *st);
bfa159e740d9 (svn r8822) -Fix
tron
parents: 5972
diff changeset
   111
3987
22972f38e240 (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents: 3963
diff changeset
   112
#endif /* AIRCRAFT_H */