2006-06-05 12:43:41 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-02-23 08:37:33 +00:00
|
|
|
/** @file aircraft.h */
|
2007-02-23 01:48:53 +00:00
|
|
|
|
2006-06-09 06:34:28 +00:00
|
|
|
#ifndef AIRCRAFT_H
|
|
|
|
#define AIRCRAFT_H
|
|
|
|
|
2006-06-05 12:43:41 +00:00
|
|
|
#include "station_map.h"
|
|
|
|
#include "vehicle.h"
|
2007-08-29 21:27:16 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "variables.h"
|
2006-06-05 12:43:41 +00:00
|
|
|
|
2007-04-03 16:12:28 +00:00
|
|
|
/** An aircraft can be one ot those types */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum AircraftSubType {
|
2007-04-02 14:20:31 +00:00
|
|
|
AIR_HELICOPTER = 0, ///< an helicopter
|
2007-04-02 15:08:36 +00:00
|
|
|
AIR_AIRCRAFT = 2, ///< an airplane
|
2007-04-02 14:20:31 +00:00
|
|
|
AIR_SHADOW = 4, ///< shadow of the aircraft
|
|
|
|
AIR_ROTOR = 6 ///< rotor of an helicopter
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2007-01-27 12:29:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Check if the aircraft type is a normal flying device; eg
|
|
|
|
* not a rotor or a shadow
|
|
|
|
* @param v vehicle to check
|
|
|
|
* @return Returns true if the aircraft is a helicopter/airplane and
|
|
|
|
* false if it is a shadow or a rotor) */
|
|
|
|
static inline bool IsNormalAircraft(const Vehicle *v)
|
|
|
|
{
|
2007-03-08 16:27:54 +00:00
|
|
|
assert(v->type == VEH_AIRCRAFT);
|
2007-01-27 12:29:55 +00:00
|
|
|
/* To be fully correct the commented out functionality is the proper one,
|
|
|
|
* but since value can only be 0 or 2, it is sufficient to only check <= 2
|
|
|
|
* return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
|
|
|
|
return v->subtype <= AIR_AIRCRAFT;
|
|
|
|
}
|
|
|
|
|
2007-10-05 22:13:35 +00:00
|
|
|
/** Checks if an aircraft can use the station in question
|
2007-03-06 22:11:58 +00:00
|
|
|
* @param engine The engine to test
|
2007-10-05 22:13:35 +00:00
|
|
|
* @param st The station
|
|
|
|
* @return true if the aircraft can use the station
|
2007-03-06 22:11:58 +00:00
|
|
|
*/
|
2007-10-05 22:13:35 +00:00
|
|
|
static inline bool CanAircraftUseStation(EngineID engine, const Station *st)
|
2007-03-06 22:11:58 +00:00
|
|
|
{
|
|
|
|
const AirportFTAClass *apc = st->Airport();
|
|
|
|
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
|
|
|
|
|
2007-03-06 23:27:14 +00:00
|
|
|
return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
|
2007-03-06 22:11:58 +00:00
|
|
|
}
|
|
|
|
|
2007-10-05 22:13:35 +00:00
|
|
|
/** Checks if an aircraft can use the station at the tile in question
|
|
|
|
* @param engine The engine to test
|
|
|
|
* @param tile The tile where the station is
|
|
|
|
* @return true if the aircraft can use the station
|
|
|
|
*/
|
|
|
|
static inline bool CanAircraftUseStation(EngineID engine, TileIndex tile)
|
|
|
|
{
|
|
|
|
return CanAircraftUseStation(engine, GetStationByTile(tile));
|
|
|
|
}
|
|
|
|
|
2007-04-02 14:20:31 +00:00
|
|
|
/**
|
|
|
|
* Calculates cargo capacity based on an aircraft's passenger
|
|
|
|
* and mail capacities.
|
|
|
|
* @param cid Which cargo type to calculate a capacity for.
|
|
|
|
* @param avi Which engine to find a cargo capacity for.
|
|
|
|
* @return New cargo capacity value.
|
|
|
|
*/
|
2007-04-02 15:08:36 +00:00
|
|
|
uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi);
|
2006-06-09 06:34:28 +00:00
|
|
|
|
2007-04-03 16:12:28 +00:00
|
|
|
/**
|
|
|
|
* This is the Callback method after the construction attempt of an aircraft
|
|
|
|
* @param success indicates completion (or not) of the operation
|
|
|
|
* @param tile of depot where aircraft is built
|
|
|
|
* @param p1 unused
|
|
|
|
* @param p2 unused
|
|
|
|
*/
|
2007-01-21 22:57:52 +00:00
|
|
|
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2007-04-03 16:12:28 +00:00
|
|
|
|
2007-04-02 14:20:31 +00:00
|
|
|
/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
|
|
|
|
* @param *v Vehicle that enters the hangar
|
|
|
|
*/
|
2006-10-05 02:26:27 +00:00
|
|
|
void HandleAircraftEnterHangar(Vehicle *v);
|
2007-04-02 14:20:31 +00:00
|
|
|
|
|
|
|
/** Get the size of the sprite of an aircraft sprite heading west (used for lists)
|
|
|
|
* @param engine The engine to get the sprite from
|
|
|
|
* @param width The width of the sprite
|
|
|
|
* @param height The height of the sprite
|
|
|
|
*/
|
2007-02-10 13:37:32 +00:00
|
|
|
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
|
2006-09-27 15:40:55 +00:00
|
|
|
|
2007-04-03 16:12:28 +00:00
|
|
|
/**
|
|
|
|
* Updates the status of the Aircraft heading or in the station
|
|
|
|
* @param st Station been updated
|
|
|
|
*/
|
2007-02-20 06:39:09 +00:00
|
|
|
void UpdateAirplanesOnNewStation(const Station *st);
|
|
|
|
|
2007-04-18 18:37:40 +00:00
|
|
|
/** Update cached values of an aircraft.
|
|
|
|
* Currently caches callback 36 max speed.
|
|
|
|
* @param v Vehicle
|
|
|
|
*/
|
|
|
|
void UpdateAircraftCache(Vehicle *v);
|
|
|
|
|
2007-04-29 21:24:08 +00:00
|
|
|
/**
|
|
|
|
* This class 'wraps' Vehicle; you do not actually instantiate this class.
|
|
|
|
* You create a Vehicle using AllocateVehicle, so it is added to the pool
|
|
|
|
* and you reinitialize that to a Train using:
|
|
|
|
* v = new (v) Aircraft();
|
|
|
|
*
|
|
|
|
* As side-effect the vehicle type is set correctly.
|
|
|
|
*/
|
|
|
|
struct Aircraft : public Vehicle {
|
|
|
|
/** Initializes the Vehicle to an aircraft */
|
|
|
|
Aircraft() { this->type = VEH_AIRCRAFT; }
|
|
|
|
|
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 17:43:04 +00:00
|
|
|
virtual ~Aircraft() { this->PreDestructor(); }
|
2007-04-29 21:24:08 +00:00
|
|
|
|
2007-05-02 09:39:11 +00:00
|
|
|
const char *GetTypeString() const { return "aircraft"; }
|
2007-04-29 22:33:51 +00:00
|
|
|
void MarkDirty();
|
2007-05-01 16:35:14 +00:00
|
|
|
void UpdateDeltaXY(Direction direction);
|
2007-05-02 09:39:11 +00:00
|
|
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
|
|
|
|
WindowClass GetVehicleListWindowClass() const { return WC_AIRCRAFT_LIST; }
|
2007-06-01 12:03:10 +00:00
|
|
|
bool IsPrimaryVehicle() const { return IsNormalAircraft(this); }
|
2007-07-01 19:11:47 +00:00
|
|
|
int GetImage(Direction direction) const;
|
2007-08-26 20:43:22 +00:00
|
|
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
|
2007-08-28 06:46:33 +00:00
|
|
|
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; }
|
2007-08-29 21:27:16 +00:00
|
|
|
Money GetRunningCost() const { return AircraftVehInfo(this->engine_type)->running_cost * _price.aircraft_running; }
|
2007-08-29 21:49:08 +00:00
|
|
|
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
|
2007-07-01 19:24:54 +00:00
|
|
|
void Tick();
|
2007-04-29 21:24:08 +00:00
|
|
|
};
|
|
|
|
|
2006-06-09 06:34:28 +00:00
|
|
|
#endif /* AIRCRAFT_H */
|