Codechange: be consistent in naming the paint function Paint()
[openttd-github.git] / src / engine_type.h
blob83f8dc307eafe10e3f901a06b984135467c75fe8
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file engine_type.h Types related to engines. */
10 #ifndef ENGINE_TYPE_H
11 #define ENGINE_TYPE_H
13 #include "economy_type.h"
14 #include "rail_type.h"
15 #include "road_type.h"
16 #include "cargo_type.h"
17 #include "date_type.h"
18 #include "sound_type.h"
19 #include "strings_type.h"
21 typedef uint16 EngineID; ///< Unique identification number of an engine.
23 struct Engine;
25 /** Available types of rail vehicles. */
26 enum RailVehicleTypes {
27 RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive
28 RAILVEH_MULTIHEAD, ///< indicates a combination of two locomotives
29 RAILVEH_WAGON, ///< simple wagon, not motorized
32 /** Type of rail engine. */
33 enum EngineClass {
34 EC_STEAM, ///< Steam rail engine.
35 EC_DIESEL, ///< Diesel rail engine.
36 EC_ELECTRIC, ///< Electric rail engine.
37 EC_MONORAIL, ///< Mono rail engine.
38 EC_MAGLEV, ///< Maglev engine.
41 /** Information about a rail vehicle. */
42 struct RailVehicleInfo {
43 byte image_index;
44 RailVehicleTypes railveh_type;
45 byte cost_factor; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices.
46 RailType railtype;
47 uint16 max_speed; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
48 uint16 power; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers.
49 uint16 weight; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine.
50 byte running_cost; ///< Running cost of engine; For multiheaded engines the sum of both running costs.
51 Price running_cost_class;
52 EngineClass engclass; ///< Class of engine for this vehicle
53 byte capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
54 byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
55 uint16 pow_wag_power; ///< Extra power applied to consist if wagon should be powered
56 byte pow_wag_weight; ///< Extra weight applied to consist if wagon should be powered
57 byte visual_effect; ///< Bitstuffed NewGRF visual effect data
58 byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
59 byte tractive_effort; ///< Tractive effort coefficient
60 byte air_drag; ///< Coefficient of air drag
61 byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
64 /** Information about a ship vehicle. */
65 struct ShipVehicleInfo {
66 byte image_index;
67 byte cost_factor;
68 uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
69 uint16 capacity;
70 byte running_cost;
71 SoundID sfx;
72 bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
73 byte visual_effect; ///< Bitstuffed NewGRF visual effect data
74 byte ocean_speed_frac; ///< Fraction of maximum speed for ocean tiles.
75 byte canal_speed_frac; ///< Fraction of maximum speed for canal/river tiles.
77 /** Apply ocean/canal speed fraction to a velocity */
78 uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
80 /* speed_frac == 0 means no reduction while 0xFF means reduction to 1/256. */
81 return raw_speed * (256 - (is_ocean ? this->ocean_speed_frac : this->canal_speed_frac)) / 256;
85 /**
86 * AircraftVehicleInfo subtypes, bitmask type.
87 * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
88 * in which case bit 1 tells us whether it's a big(fast) plane or not.
90 enum AircraftSubTypeBits {
91 AIR_HELI = 0,
92 AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
93 AIR_FAST = 2
96 /** Information about a aircraft vehicle. */
97 struct AircraftVehicleInfo {
98 byte image_index;
99 byte cost_factor;
100 byte running_cost;
101 byte subtype; ///< Type of aircraft. @see AircraftSubTypeBits
102 SoundID sfx;
103 byte acceleration;
104 uint16 max_speed; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
105 byte mail_capacity; ///< Mail capacity (bags).
106 uint16 passenger_capacity; ///< Passenger capacity (persons).
107 uint16 max_range; ///< Maximum range of this aircraft.
110 /** Information about a road vehicle. */
111 struct RoadVehicleInfo {
112 byte image_index;
113 byte cost_factor;
114 byte running_cost;
115 Price running_cost_class;
116 SoundID sfx;
117 uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
118 byte capacity;
119 uint8 weight; ///< Weight in 1/4t units
120 uint8 power; ///< Power in 10hp units
121 uint8 tractive_effort; ///< Coefficient of tractive effort
122 uint8 air_drag; ///< Coefficient of air drag
123 byte visual_effect; ///< Bitstuffed NewGRF visual effect data
124 byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
125 RoadType roadtype; ///< Road type
129 * Information about a vehicle
130 * @see table/engines.h
132 struct EngineInfo {
133 Date base_intro; ///< Basic date of engine introduction (without random parts).
134 Year lifelength; ///< Lifetime of a single vehicle
135 Year base_life; ///< Basic duration of engine availability (without random parts). \c 0xFF means infinite life.
136 byte decay_speed;
137 byte load_amount;
138 byte climates; ///< Climates supported by the engine.
139 CargoID cargo_type;
140 CargoTypes refit_mask;
141 byte refit_cost;
142 byte misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags
143 byte callback_mask; ///< Bitmask of vehicle callbacks that have to be called
144 int8 retire_early; ///< Number of years early to retire vehicle
145 StringID string_id; ///< Default name of engine
146 uint16 cargo_age_period; ///< Number of ticks before carried cargo is aged.
150 * EngineInfo.misc_flags is a bitmask, with the following values
152 enum EngineMiscFlags {
153 EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
154 EF_ROAD_TRAM = 0, ///< Road vehicle is a tram/light rail vehicle
155 EF_USES_2CC = 1, ///< Vehicle uses two company colours
156 EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
157 EF_RAIL_FLIPS = 3, ///< Rail vehicle can be flipped in the depot
158 EF_AUTO_REFIT = 4, ///< Automatic refitting is allowed
159 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.
160 EF_NO_BREAKDOWN_SMOKE = 6, ///< Do not show black smoke during a breakdown.
161 EF_SPRITE_STACK = 7, ///< Draw vehicle by stacking multiple sprites.
165 * Engine.flags is a bitmask, with the following values.
167 enum EngineFlags {
168 ENGINE_AVAILABLE = 1, ///< This vehicle is available to everyone.
169 ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a company.
172 static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32; ///< The maximum length of an engine name in characters including '\0'
174 static const EngineID INVALID_ENGINE = 0xFFFF; ///< Constant denoting an invalid engine.
176 #endif /* ENGINE_TYPE_H */