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