OpenTTD Source: src/engine_type.h Source File

OpenTTD Source 12.2

engine_type.h
Go to the documentation of this file.
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 */
7
10 #ifndef ENGINE_TYPE_H
11 #define ENGINE_TYPE_H
12
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"
20
21 typedef uint16 EngineID;
22
23 struct Engine;
24
26 enum RailVehicleTypes {
27 RAILVEH_SINGLEHEAD,
28 RAILVEH_MULTIHEAD,
29 RAILVEH_WAGON,
30 };
31
33 enum EngineClass {
34 EC_STEAM,
35 EC_DIESEL,
36 EC_ELECTRIC,
37 EC_MONORAIL,
38 EC_MAGLEV,
39 };
40
42 struct RailVehicleInfo {
43 byte image_index;
44 RailVehicleTypes railveh_type;
45 byte cost_factor;
46 RailType railtype;
47 uint16 max_speed;
48 uint16 power;
49 uint16 weight;
50 byte running_cost;
51 Price running_cost_class;
52 EngineClass engclass;
53 byte capacity;
54 byte ai_passenger_only;
55 uint16 pow_wag_power;
56 byte pow_wag_weight;
57 byte visual_effect;
58 byte shorten_factor;
59 byte tractive_effort;
60 byte air_drag;
61 byte user_def_data;
62 int16 curve_speed_mod;
63 };
64
66 struct ShipVehicleInfo {
67 byte image_index;
68 byte cost_factor;
69 uint16 max_speed;
70 uint16 capacity;
71 byte running_cost;
72 SoundID sfx;
73 bool old_refittable;
74 byte visual_effect;
75 byte ocean_speed_frac;
76 byte canal_speed_frac;
77
79 uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
80 {
81 /* speed_frac == 0 means no reduction while 0xFF means reduction to 1/256. */
82 return raw_speed * (256 - (is_ocean ? this->ocean_speed_frac : this->canal_speed_frac)) / 256;
83 }
84 };
85
91 enum AircraftSubTypeBits {
92 AIR_HELI = 0,
93 AIR_CTOL = 1,
94 AIR_FAST = 2
95 };
96
98 struct AircraftVehicleInfo {
99 byte image_index;
100 byte cost_factor;
101 byte running_cost;
102 byte subtype;
103 SoundID sfx;
104 byte acceleration;
105 uint16 max_speed;
106 byte mail_capacity;
107 uint16 passenger_capacity;
108 uint16 max_range;
109 };
110
112 struct RoadVehicleInfo {
113 byte image_index;
114 byte cost_factor;
115 byte running_cost;
116 Price running_cost_class;
117 SoundID sfx;
118 uint16 max_speed;
119 byte capacity;
120 uint8 weight;
121 uint8 power;
122 uint8 tractive_effort;
123 uint8 air_drag;
124 byte visual_effect;
125 byte shorten_factor;
126 RoadType roadtype;
127 };
128
133 struct EngineInfo {
134 Date base_intro;
135 Year lifelength;
136 Year base_life;
137 byte decay_speed;
138 byte load_amount;
139 byte climates;
140 CargoID cargo_type;
141 CargoTypes refit_mask;
142 byte refit_cost;
143 byte misc_flags;
144 byte callback_mask;
145 int8 retire_early;
146 StringID string_id;
147 uint16 cargo_age_period;
148 };
149
153 enum EngineMiscFlags {
154 EF_RAIL_TILTS = 0,
155 EF_ROAD_TRAM = 0,
156 EF_USES_2CC = 1,
157 EF_RAIL_IS_MU = 2,
158 EF_RAIL_FLIPS = 3,
159 EF_AUTO_REFIT = 4,
160 EF_NO_DEFAULT_CARGO_MULTIPLIER = 5,
161 EF_NO_BREAKDOWN_SMOKE = 6,
162 EF_SPRITE_STACK = 7,
163 };
164
168 enum EngineFlags {
169 ENGINE_AVAILABLE = 1,
170 ENGINE_EXCLUSIVE_PREVIEW = 2,
171 };
172
173 static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32;
174
175 static const EngineID INVALID_ENGINE = 0xFFFF;
176
177 #endif /* ENGINE_TYPE_H */
EF_RAIL_TILTS
@ EF_RAIL_TILTS
Rail vehicle tilts in curves.
Definition: engine_type.h:154
INVALID_ENGINE
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
Definition: engine_type.h:175
EngineInfo::base_life
Year base_life
Basic duration of engine availability (without random parts). 0xFF means infinite life.
Definition: engine_type.h:136
RailVehicleInfo::pow_wag_weight
byte pow_wag_weight
Extra weight applied to consist if wagon should be powered.
Definition: engine_type.h:56
AircraftVehicleInfo::subtype
byte subtype
Type of aircraft.
Definition: engine_type.h:102
ShipVehicleInfo::canal_speed_frac
byte canal_speed_frac
Fraction of maximum speed for canal/river tiles.
Definition: engine_type.h:76
Price
Price
Enumeration of all base prices for use with Prices.
Definition: economy_type.h:74
EC_STEAM
@ EC_STEAM
Steam rail engine.
Definition: engine_type.h:34
AircraftVehicleInfo::passenger_capacity
uint16 passenger_capacity
Passenger capacity (persons).
Definition: engine_type.h:107
sound_type.h
EF_NO_BREAKDOWN_SMOKE
@ EF_NO_BREAKDOWN_SMOKE
Do not show black smoke during a breakdown.
Definition: engine_type.h:161
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
AircraftVehicleInfo::max_speed
uint16 max_speed
Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
Definition: engine_type.h:105
RailVehicleInfo::power
uint16 power
Power of engine (hp); For multiheaded engines the sum of both engine powers.
Definition: engine_type.h:48
EngineInfo
Information about a vehicle.
Definition: engine_type.h:133
EngineInfo::base_intro
Date base_intro
Basic date of engine introduction (without random parts).
Definition: engine_type.h:134
Engine
Definition: engine_base.h:27
strings_type.h
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:126
RoadVehicleInfo::air_drag
uint8 air_drag
Coefficient of air drag.
Definition: engine_type.h:123
RailVehicleInfo::cost_factor
byte cost_factor
Purchase cost factor; For multiheaded engines the sum of both engine prices.
Definition: engine_type.h:45
EC_ELECTRIC
@ EC_ELECTRIC
Electric rail engine.
Definition: engine_type.h:36
EngineInfo::lifelength
Year lifelength
Lifetime of a single vehicle.
Definition: engine_type.h:135
ShipVehicleInfo::visual_effect
byte visual_effect
Bitstuffed NewGRF visual effect data.
Definition: engine_type.h:74
RoadVehicleInfo::max_speed
uint16 max_speed
Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
Definition: engine_type.h:118
ENGINE_EXCLUSIVE_PREVIEW
@ ENGINE_EXCLUSIVE_PREVIEW
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
Definition: engine_type.h:170
EC_MAGLEV
@ EC_MAGLEV
Maglev engine.
Definition: engine_type.h:38
RailVehicleInfo::visual_effect
byte visual_effect
Bitstuffed NewGRF visual effect data.
Definition: engine_type.h:57
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
RailVehicleInfo::ai_passenger_only
byte ai_passenger_only
Bit value to tell AI that this engine is for passenger use only.
Definition: engine_type.h:54
RailVehicleInfo
Information about a rail vehicle.
Definition: engine_type.h:42
RailVehicleInfo::engclass
EngineClass engclass
Class of engine for this vehicle.
Definition: engine_type.h:52
EF_AUTO_REFIT
@ EF_AUTO_REFIT
Automatic refitting is allowed.
Definition: engine_type.h:159
AircraftSubTypeBits
AircraftSubTypeBits
AircraftVehicleInfo subtypes, bitmask type.
Definition: engine_type.h:91
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
RailVehicleInfo::air_drag
byte air_drag
Coefficient of air drag.
Definition: engine_type.h:60
EngineInfo::callback_mask
byte callback_mask
Bitmask of vehicle callbacks that have to be called.
Definition: engine_type.h:144
RoadVehicleInfo
Information about a road vehicle.
Definition: engine_type.h:112
RoadVehicleInfo::visual_effect
byte visual_effect
Bitstuffed NewGRF visual effect data.
Definition: engine_type.h:124
cargo_type.h
EF_USES_2CC
@ EF_USES_2CC
Vehicle uses two company colours.
Definition: engine_type.h:156
RailVehicleTypes
RailVehicleTypes
Available types of rail vehicles.
Definition: engine_type.h:26
MAX_LENGTH_ENGINE_NAME_CHARS
static const uint MAX_LENGTH_ENGINE_NAME_CHARS
The maximum length of an engine name in characters including '\0'.
Definition: engine_type.h:173
AircraftVehicleInfo::max_range
uint16 max_range
Maximum range of this aircraft.
Definition: engine_type.h:108
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
EC_DIESEL
@ EC_DIESEL
Diesel rail engine.
Definition: engine_type.h:35
EF_RAIL_IS_MU
@ EF_RAIL_IS_MU
Rail vehicle is a multiple-unit (DMU/EMU)
Definition: engine_type.h:157
EngineInfo::retire_early
int8 retire_early
Number of years early to retire vehicle.
Definition: engine_type.h:145
RailVehicleInfo::tractive_effort
byte tractive_effort
Tractive effort coefficient.
Definition: engine_type.h:59
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
RailVehicleInfo::pow_wag_power
uint16 pow_wag_power
Extra power applied to consist if wagon should be powered.
Definition: engine_type.h:55
RailVehicleInfo::weight
uint16 weight
Weight of vehicle (tons); For multiheaded engines the weight of each single engine.
Definition: engine_type.h:49
EngineClass
EngineClass
Type of rail engine.
Definition: engine_type.h:33
ENGINE_AVAILABLE
@ ENGINE_AVAILABLE
This vehicle is available to everyone.
Definition: engine_type.h:169
EngineInfo::misc_flags
byte misc_flags
Miscellaneous flags.
Definition: engine_type.h:143
RAILVEH_WAGON
@ RAILVEH_WAGON
simple wagon, not motorized
Definition: engine_type.h:29
ShipVehicleInfo::old_refittable
bool old_refittable
Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
Definition: engine_type.h:73
date_type.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
RoadVehicleInfo::shorten_factor
byte shorten_factor
length on main map for this type is 8 - shorten_factor
Definition: engine_type.h:125
RailVehicleInfo::max_speed
uint16 max_speed
Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
Definition: engine_type.h:47
EF_NO_DEFAULT_CARGO_MULTIPLIER
@ EF_NO_DEFAULT_CARGO_MULTIPLIER
Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipl...
Definition: engine_type.h:160
RAILVEH_MULTIHEAD
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
Definition: engine_type.h:28
RailVehicleInfo::user_def_data
byte user_def_data
Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles.
Definition: engine_type.h:61
ShipVehicleInfo
Information about a ship vehicle.
Definition: engine_type.h:66
RoadVehicleInfo::tractive_effort
uint8 tractive_effort
Coefficient of tractive effort.
Definition: engine_type.h:122
AircraftVehicleInfo::mail_capacity
byte mail_capacity
Mail capacity (bags).
Definition: engine_type.h:106
rail_type.h
EF_SPRITE_STACK
@ EF_SPRITE_STACK
Draw vehicle by stacking multiple sprites.
Definition: engine_type.h:162
RoadVehicleInfo::weight
uint8 weight
Weight in 1/4t units.
Definition: engine_type.h:120
RailVehicleInfo::shorten_factor
byte shorten_factor
length on main map for this type is 8 - shorten_factor
Definition: engine_type.h:58
AIR_CTOL
@ AIR_CTOL
Conventional Take Off and Landing, i.e. planes.
Definition: engine_type.h:93
EngineFlags
EngineFlags
Engine.flags is a bitmask, with the following values.
Definition: engine_type.h:168
road_type.h
RoadVehicleInfo::power
uint8 power
Power in 10hp units.
Definition: engine_type.h:121
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
EngineMiscFlags
EngineMiscFlags
EngineInfo.misc_flags is a bitmask, with the following values.
Definition: engine_type.h:153
EF_RAIL_FLIPS
@ EF_RAIL_FLIPS
Rail vehicle can be flipped in the depot.
Definition: engine_type.h:158
RAILVEH_SINGLEHEAD
@ RAILVEH_SINGLEHEAD
indicates a "standalone" locomotive
Definition: engine_type.h:27
ShipVehicleInfo::max_speed
uint16 max_speed
Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
Definition: engine_type.h:69
RailVehicleInfo::running_cost
byte running_cost
Running cost of engine; For multiheaded engines the sum of both running costs.
Definition: engine_type.h:50
EF_ROAD_TRAM
@ EF_ROAD_TRAM
Road vehicle is a tram/light rail vehicle.
Definition: engine_type.h:155
EngineInfo::climates
byte climates
Climates supported by the engine.
Definition: engine_type.h:139
RailVehicleInfo::capacity
byte capacity
Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
Definition: engine_type.h:53
EngineInfo::string_id
StringID string_id
Default name of engine.
Definition: engine_type.h:146
AircraftVehicleInfo
Information about a aircraft vehicle.
Definition: engine_type.h:98
economy_type.h
ShipVehicleInfo::ApplyWaterClassSpeedFrac
uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
Apply ocean/canal speed fraction to a velocity.
Definition: engine_type.h:79
EngineInfo::cargo_age_period
uint16 cargo_age_period
Number of ticks before carried cargo is aged.
Definition: engine_type.h:147
RailVehicleInfo::curve_speed_mod
int16 curve_speed_mod
Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits)
Definition: engine_type.h:62
ShipVehicleInfo::ocean_speed_frac
byte ocean_speed_frac
Fraction of maximum speed for ocean tiles.
Definition: engine_type.h:75
EC_MONORAIL
@ EC_MONORAIL
Mono rail engine.
Definition: engine_type.h:37