4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file engine_type.h Types related to engines. */
15 #include "economy_type.h"
16 #include "rail_type.h"
17 #include "cargo_type.h"
18 #include "date_type.h"
19 #include "sound_type.h"
20 #include "strings_type.h"
22 typedef uint16 EngineID
; ///< Unique identification number of an engine.
27 /** Available types of rail vehicles. */
28 enum RailVehicleTypes
{
29 RAILVEH_SINGLEHEAD
, ///< indicates a "standalone" locomotive
30 RAILVEH_MULTIHEAD
, ///< indicates a combination of two locomotives
31 RAILVEH_WAGON
, ///< simple wagon, not motorized
34 /** Type of rail engine. */
36 EC_STEAM
, ///< Steam rail engine.
37 EC_DIESEL
, ///< Diesel rail engine.
38 EC_ELECTRIC
, ///< Electric rail engine.
39 EC_MONORAIL
, ///< Mono rail engine.
40 EC_MAGLEV
, ///< Maglev engine.
43 /** Information about a rail vehicle. */
44 struct RailVehicleInfo
{
46 RailVehicleTypes railveh_type
;
47 byte cost_factor
; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices.
48 RailTypeByte railtype
;
49 uint16 max_speed
; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
50 uint16 power
; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers.
51 uint16 weight
; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine.
52 byte running_cost
; ///< Running cost of engine; For multiheaded engines the sum of both running costs.
53 Price running_cost_class
;
54 EngineClass engclass
; ///< Class of engine for this vehicle
55 byte capacity
; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
56 byte ai_passenger_only
; ///< Bit value to tell AI that this engine is for passenger use only
57 uint16 pow_wag_power
; ///< Extra power applied to consist if wagon should be powered
58 byte pow_wag_weight
; ///< Extra weight applied to consist if wagon should be powered
59 byte visual_effect
; ///< Bitstuffed NewGRF visual effect data
60 byte shorten_factor
; ///< length on main map for this type is 8 - shorten_factor
61 byte tractive_effort
; ///< Tractive effort coefficient
62 byte air_drag
; ///< Coefficient of air drag
63 byte user_def_data
; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
66 /** Information about a ship vehicle. */
67 struct ShipVehicleInfo
{
70 uint16 max_speed
; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
74 bool old_refittable
; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
75 byte visual_effect
; ///< Bitstuffed NewGRF visual effect data
76 byte ocean_speed_frac
; ///< Fraction of maximum speed for ocean tiles.
77 byte canal_speed_frac
; ///< Fraction of maximum speed for canal/river tiles.
79 /** Apply ocean/canal speed fraction to a velocity */
80 uint
ApplyWaterClassSpeedFrac(uint raw_speed
, bool is_ocean
) const
82 /* speed_frac == 0 means no reduction while 0xFF means reduction to 1/256. */
83 return raw_speed
* (256 - (is_ocean
? this->ocean_speed_frac
: this->canal_speed_frac
)) / 256;
88 * AircraftVehicleInfo subtypes, bitmask type.
89 * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
90 * in which case bit 1 tells us whether it's a big(fast) plane or not.
92 enum AircraftSubTypeBits
{
94 AIR_CTOL
= 1, ///< Conventional Take Off and Landing, i.e. planes
98 /** Information about a aircraft vehicle. */
99 struct AircraftVehicleInfo
{
103 byte subtype
; ///< Type of aircraft. @see AircraftSubTypeBits
106 uint16 max_speed
; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
107 byte mail_capacity
; ///< Mail capacity (bags).
108 uint16 passenger_capacity
; ///< Passenger capacity (persons).
109 uint16 max_range
; ///< Maximum range of this aircraft.
112 /** Information about a road vehicle. */
113 struct RoadVehicleInfo
{
117 Price running_cost_class
;
119 uint16 max_speed
; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
121 uint8 weight
; ///< Weight in 1/4t units
122 uint8 power
; ///< Power in 10hp units
123 uint8 tractive_effort
; ///< Coefficient of tractive effort
124 uint8 air_drag
; ///< Coefficient of air drag
125 byte visual_effect
; ///< Bitstuffed NewGRF visual effect data
126 byte shorten_factor
; ///< length on main map for this type is 8 - shorten_factor
130 * Information about a vehicle
131 * @see table/engines.h
134 Date base_intro
; ///< Basic date of engine introduction (without random parts).
135 Year lifelength
; ///< Lifetime of a single vehicle
136 Year base_life
; ///< Basic duration of engine availability (without random parts). \c 0xFF means infinite life.
139 byte climates
; ///< Climates supported by the engine.
143 byte misc_flags
; ///< Miscellaneous flags. @see EngineMiscFlags
144 byte callback_mask
; ///< Bitmask of vehicle callbacks that have to be called
145 int8 retire_early
; ///< Number of years early to retire vehicle
146 StringID string_id
; ///< Default name of engine
147 uint16 cargo_age_period
; ///< Number of ticks before carried cargo is aged.
151 * EngineInfo.misc_flags is a bitmask, with the following values
153 enum EngineMiscFlags
{
154 EF_RAIL_TILTS
= 0, ///< Rail vehicle tilts in curves
155 EF_ROAD_TRAM
= 0, ///< Road vehicle is a tram/light rail vehicle
156 EF_USES_2CC
= 1, ///< Vehicle uses two company colours
157 EF_RAIL_IS_MU
= 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
158 EF_RAIL_FLIPS
= 3, ///< Rail vehicle can be flipped in the depot
159 EF_AUTO_REFIT
= 4, ///< Automatic refitting is allowed
160 EF_NO_DEFAULT_CARGO_MULTIPLIER
= 5, ///< Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipliers. CB 15 is also called in purchase list.
161 EF_NO_BREAKDOWN_SMOKE
= 6, ///< Do not show black smoke during a breakdown.
162 EF_SPRITE_STACK
= 7, ///< Draw vehicle by stacking multiple sprites.
166 * Engine.flags is a bitmask, with the following values.
169 ENGINE_AVAILABLE
= 1, ///< This vehicle is available to everyone.
170 ENGINE_EXCLUSIVE_PREVIEW
= 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a company.
173 static const uint MAX_LENGTH_ENGINE_NAME_CHARS
= 32; ///< The maximum length of an engine name in characters including '\0'
175 static const EngineID INVALID_ENGINE
= 0xFFFF; ///< Constant denoting an invalid engine.
177 #endif /* ENGINE_TYPE_H */