Translations update
[openttd/fttd.git] / src / engine_type.h
blob2efd9c6100018d6ed1da6cc9e458fec6ebb30a6e
1 /* $Id$ */
3 /*
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/>.
8 */
10 /** @file engine_type.h Types related to engines. */
12 #ifndef ENGINE_TYPE_H
13 #define ENGINE_TYPE_H
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.
24 struct EngineState;
25 struct 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. */
35 enum EngineClass {
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 {
45 byte image_index;
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 {
68 byte image_index;
69 byte cost_factor;
70 uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
71 uint16 capacity;
72 byte running_cost;
73 SoundID sfx;
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;
87 /**
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 {
93 AIR_HELI = 0,
94 AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
95 AIR_FAST = 2
98 /** Information about a aircraft vehicle. */
99 struct AircraftVehicleInfo {
100 byte image_index;
101 byte cost_factor;
102 byte running_cost;
103 byte subtype; ///< Type of aircraft. @see AircraftSubTypeBits
104 SoundID sfx;
105 byte acceleration;
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 {
114 byte image_index;
115 byte cost_factor;
116 byte running_cost;
117 Price running_cost_class;
118 SoundID sfx;
119 uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
120 byte capacity;
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
133 struct EngineInfo {
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.
137 byte decay_speed;
138 byte load_amount;
139 byte climates; ///< Climates supported by the engine.
140 CargoID cargo_type;
141 uint32 refit_mask;
142 byte refit_cost;
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.
168 enum EngineFlags {
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 */