Files @ r15533:6e1324713e7a
Branch filter:

Location: cpp/openttd-patchpack/source/src/aircraft.h - annotation

translators
(svn r20202) -Update from WebTranslator v3.0:
chuvash - 93 changes by mefisteron
irish - 5 changes by tem
norwegian_nynorsk - 1 changes by 2rB
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r9111:983de9c5a848
r6117:d11b4c5c0aea
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r8144:1432edd15267
r5475:3f5cd13d1b63
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r6415:0ff8d179f802
r6248:b940b09d7ab8
r6409:8c320ab64062
r6410:c9e7142728ba
r6409:8c320ab64062
r6409:8c320ab64062
r6248:b940b09d7ab8
r5854:d116ce6001d7
r5854:d116ce6001d7
r6409:8c320ab64062
r6409:8c320ab64062
r6409:8c320ab64062
r11976:ae6aa97461b7
r6409:8c320ab64062
r6409:8c320ab64062
r6409:8c320ab64062
r6409:8c320ab64062
r6409:8c320ab64062
r6409:8c320ab64062
r5972:0afe141fca29
r5475:3f5cd13d1b63
r6415:0ff8d179f802
r6415:0ff8d179f802
r6415:0ff8d179f802
r6415:0ff8d179f802
r6087:a13ab75a089f
r6087:a13ab75a089f
r6490:ba88f1f6bfd1
r6490:ba88f1f6bfd1
r6490:ba88f1f6bfd1
r6490:ba88f1f6bfd1
r11976:ae6aa97461b7
r6490:ba88f1f6bfd1
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r10571:99cb9a95b4cf
r11983:0159b0bf2cf8
r11983:0159b0bf2cf8
r11983:0159b0bf2cf8
r11983:0159b0bf2cf8
r11983:0159b0bf2cf8
r6552:7cade7798fcb
r12033:6a560c929ec8
r6552:7cade7798fcb
r12029:5b077ec055c0
r11983:0159b0bf2cf8
r11983:0159b0bf2cf8
r11977:bc3933e2c9d0
r11977:bc3933e2c9d0
r11977:bc3933e2c9d0
r11977:bc3933e2c9d0
r11977:bc3933e2c9d0
r12903:0aae2e2e9a92
r12979:cc9fc96bd354
r11977:bc3933e2c9d0
r14203:aea88883737e
r14203:aea88883737e
r14203:aea88883737e
r12090:c20f83257241
r12090:c20f83257241
r6552:7cade7798fcb
r7412:e5f07529a093
r6552:7cade7798fcb
r6563:67c636a8e3d4
r6553:04028e73a0f7
r6558:469828caa298
r6563:67c636a8e3d4
r12374:50d157b51c2c
r9022:5be8b7703ae9
r10969:8b8a9653d684
r10969:8b8a9653d684
r10875:1cfbd5e0cc73
r7490:4e86e893fa7f
r11965:2b94ac4aa35a
r8467:0ea88f22d4aa
r13863:252b1a5c4f87
r8830:3bad3e96d573
r8890:02179c54681e
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r12374:50d157b51c2c
r6552:7cade7798fcb
r6552:7cade7798fcb
r12029:5b077ec055c0
r12029:5b077ec055c0
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r11976:ae6aa97461b7
r10154:41d5be1e6e2c
r5475:3f5cd13d1b63
/* $Id$ */

/*
 * This file is part of OpenTTD.
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 */

/** @file aircraft.h Base for aircraft. */

#ifndef AIRCRAFT_H
#define AIRCRAFT_H

#include "station_map.h"
#include "vehicle_base.h"

struct Aircraft;

/** An aircraft can be one ot those types */
enum AircraftSubType {
	AIR_HELICOPTER = 0, ///< an helicopter
	AIR_AIRCRAFT   = 2, ///< an airplane
	AIR_SHADOW     = 4, ///< shadow of the aircraft
	AIR_ROTOR      = 6  ///< rotor of an helicopter
};


/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
 * @param *v Vehicle that enters the hangar
 */
void HandleAircraftEnterHangar(Aircraft *v);

/** 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
 */
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);

/**
 * Updates the status of the Aircraft heading or in the station
 * @param st Station been updated
 */
void UpdateAirplanesOnNewStation(const Station *st);

/** Update cached values of an aircraft.
 * Currently caches callback 36 max speed.
 * @param v Vehicle
 */
void UpdateAircraftCache(Aircraft *v);

void AircraftLeaveHangar(Aircraft *v);
void AircraftNextAirportPos_and_Order(Aircraft *v);
void SetAircraftPosition(Aircraft *v, int x, int y, int z);
byte GetAircraftFlyingAltitude(const Aircraft *v);

/** Cached oftenly queried (NewGRF) values */
struct AircraftCache {
	uint16 cached_max_speed; ///< Cached maximum speed of the aircraft.
};

/**
 * Aircraft, helicopters, rotors and their shadows belong to this class.
 */
struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
	AircraftCache acache; ///< Cache of often used calculated values

	uint16 crashed_counter;
	byte pos;
	byte previous_pos;
	StationID targetairport;
	byte state;
	DirectionByte last_direction;
	byte number_consecutive_turns;

	/** Ticks between each turn to prevent > 45 degree turns. */
	byte turn_counter;

	/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
	Aircraft() : SpecializedVehicle<Aircraft, VEH_AIRCRAFT>() {}
	/** We want to 'destruct' the right class. */
	virtual ~Aircraft() { this->PreDestructor(); }

	const char *GetTypeString() const { return "aircraft"; }
	void MarkDirty();
	void UpdateDeltaXY(Direction direction);
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
	bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
	SpriteID GetImage(Direction direction) const;
	int GetDisplaySpeed() const { return this->cur_speed; }
	int GetDisplayMaxSpeed() const { return this->max_speed; }
	Money GetRunningCost() const;
	bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
	bool Tick();
	void OnNewDay();
	uint Crash(bool flooded = false);
	TileIndex GetOrderStationLocation(StationID station);
	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);

	/**
	 * Check if the aircraft type is a normal flying device; eg
	 * not a rotor or a shadow
	 * @return Returns true if the aircraft is a helicopter/airplane and
	 * false if it is a shadow or a rotor
	 */
	FORCEINLINE bool IsNormalAircraft() const
	{
		/* 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 (this->subtype == AIR_HELICOPTER) || (this->subtype == AIR_AIRCRAFT); */
		return this->subtype <= AIR_AIRCRAFT;
	}
};

#define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)

SpriteID GetRotorImage(const Aircraft *v);

Station *GetTargetAirportIfValid(const Aircraft *v);

#endif /* AIRCRAFT_H */