OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

engine_type.h
Go to the documentation of this file.
1 /* $Id: engine_type.h 24810 2012-12-09 16:55:03Z frosch $ */
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 "cargo_type.h"
18 #include "date_type.h"
19 #include "sound_type.h"
20 #include "strings_type.h"
21
22 typedef uint16 EngineID;
23
24 struct Engine;
25
27 enum RailVehicleTypes {
28 RAILVEH_SINGLEHEAD,
29 RAILVEH_MULTIHEAD,
30 RAILVEH_WAGON,
31 };
32
34 enum EngineClass {
35 EC_STEAM,
36 EC_DIESEL,
37 EC_ELECTRIC,
38 EC_MONORAIL,
39 EC_MAGLEV,
40 };
41
43 struct RailVehicleInfo {
44 byte image_index;
45 RailVehicleTypes railveh_type;
46 byte cost_factor;
47 RailTypeByte railtype;
48 uint16 max_speed;
49 uint16 power;
50 uint16 weight;
51 byte running_cost;
52 Price running_cost_class;
53 EngineClass engclass;
54 byte capacity;
55 byte ai_passenger_only;
56 uint16 pow_wag_power;
57 byte pow_wag_weight;
58 byte visual_effect;
59 byte shorten_factor;
60 byte tractive_effort;
61 byte air_drag;
62 byte user_def_data;
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 };
127
132 struct EngineInfo {
133 Date base_intro;
134 Year lifelength;
135 Year base_life;
136 byte decay_speed;
137 byte load_amount;
138 byte climates;
139 CargoID cargo_type;
140 uint32 refit_mask;
141 byte refit_cost;
142 byte misc_flags;
143 byte callback_mask;
144 int8 retire_early;
145 StringID string_id;
146 uint16 cargo_age_period;
147 };
148
152 enum EngineMiscFlags {
153 EF_RAIL_TILTS = 0,
154 EF_ROAD_TRAM = 0,
155 EF_USES_2CC = 1,
156 EF_RAIL_IS_MU = 2,
157 EF_RAIL_FLIPS = 3,
158 EF_AUTO_REFIT = 4,
159 EF_NO_DEFAULT_CARGO_MULTIPLIER = 5,
160 EF_NO_BREAKDOWN_SMOKE = 6,
161 };
162
166 enum EngineFlags {
167 ENGINE_AVAILABLE = 1,
168 ENGINE_EXCLUSIVE_PREVIEW = 2,
169 };
170
171 static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32;
172
173 static const EngineID INVALID_ENGINE = 0xFFFF;
174
175 #endif /* ENGINE_TYPE_H */