10455
|
1 |
/* $Id$ */
|
|
2 |
|
|
3 |
/** @file engine_base.h Base class for engines. */
|
|
4 |
|
|
5 |
#ifndef ENGINE_BASE_H
|
|
6 |
#define ENGINE_BASE_H
|
|
7 |
|
|
8 |
#include "engine_type.h"
|
|
9 |
#include "oldpool.h"
|
|
10 |
|
|
11 |
DECLARE_OLD_POOL(Engine, Engine, 6, 10000)
|
|
12 |
|
|
13 |
struct Engine : PoolItem<Engine, EngineID, &_Engine_pool> {
|
|
14 |
char *name; ///< Custom name of engine
|
|
15 |
Date intro_date;
|
|
16 |
Date age;
|
|
17 |
uint16 reliability;
|
|
18 |
uint16 reliability_spd_dec;
|
|
19 |
uint16 reliability_start, reliability_max, reliability_final;
|
|
20 |
uint16 duration_phase_1, duration_phase_2, duration_phase_3;
|
|
21 |
byte lifelength;
|
|
22 |
byte flags;
|
|
23 |
uint8 preview_player_rank;
|
|
24 |
byte preview_wait;
|
|
25 |
byte player_avail;
|
|
26 |
uint8 image_index; ///< Original vehicle image index
|
|
27 |
VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
|
|
28 |
|
|
29 |
EngineInfo info;
|
|
30 |
|
|
31 |
union {
|
|
32 |
RailVehicleInfo rail;
|
|
33 |
RoadVehicleInfo road;
|
|
34 |
ShipVehicleInfo ship;
|
|
35 |
AircraftVehicleInfo air;
|
|
36 |
} u;
|
|
37 |
|
|
38 |
/* NewGRF related data */
|
|
39 |
const struct GRFFile *grffile;
|
|
40 |
const struct SpriteGroup *group[NUM_CARGO + 2];
|
|
41 |
uint16 internal_id; ///< ID within the GRF file
|
|
42 |
uint16 overrides_count;
|
|
43 |
struct WagonOverride *overrides;
|
|
44 |
uint16 list_position;
|
|
45 |
|
|
46 |
Engine();
|
|
47 |
Engine(VehicleType type, EngineID base);
|
|
48 |
~Engine();
|
|
49 |
|
|
50 |
inline bool IsValid() const { return this->info.climates != 0; }
|
|
51 |
};
|
|
52 |
|
|
53 |
static inline bool IsEngineIndex(uint index)
|
|
54 |
{
|
|
55 |
return index < GetEnginePoolSize();
|
|
56 |
}
|
|
57 |
|
|
58 |
#define FOR_ALL_ENGINES_FROM(e, start) for (e = GetEngine(start); e != NULL; e = (e->index + 1U < GetEnginePoolSize()) ? GetEngine(e->index + 1U) : NULL) if (e->IsValid())
|
|
59 |
#define FOR_ALL_ENGINES(e) FOR_ALL_ENGINES_FROM(e, 0)
|
|
60 |
|
|
61 |
#define FOR_ALL_ENGINES_OF_TYPE(e, engine_type) FOR_ALL_ENGINES(e) if (e->type == engine_type)
|
|
62 |
|
|
63 |
static inline const EngineInfo *EngInfo(EngineID e)
|
|
64 |
{
|
|
65 |
return &GetEngine(e)->info;
|
|
66 |
}
|
|
67 |
|
|
68 |
static inline const RailVehicleInfo *RailVehInfo(EngineID e)
|
|
69 |
{
|
|
70 |
return &GetEngine(e)->u.rail;
|
|
71 |
}
|
|
72 |
|
|
73 |
static inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
|
|
74 |
{
|
|
75 |
return &GetEngine(e)->u.road;
|
|
76 |
}
|
|
77 |
|
|
78 |
static inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
|
|
79 |
{
|
|
80 |
return &GetEngine(e)->u.ship;
|
|
81 |
}
|
|
82 |
|
|
83 |
static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
|
|
84 |
{
|
|
85 |
return &GetEngine(e)->u.air;
|
|
86 |
}
|
|
87 |
|
|
88 |
#endif /* ENGINE_TYPE_H */
|