src/engine_type.h
changeset 9273 ca5e00698c01
parent 9270 54cae230092d
child 10382 d1d4452acbfc
equal deleted inserted replaced
9272:83630e52b5fe 9273:ca5e00698c01
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file engine_type.h Types related to engines. */
       
     4 
       
     5 #ifndef ENGINE_TYPE_H
       
     6 #define ENGINE_TYPE_H
       
     7 
       
     8 #include "rail_type.h"
       
     9 #include "cargo_type.h"
       
    10 #include "vehicle_type.h"
       
    11 #include "gfx_type.h"
       
    12 #include "date_type.h"
       
    13 #include "sound_type.h"
       
    14 #include "player_type.h"
       
    15 #include "strings_type.h"
       
    16 
       
    17 typedef uint16 EngineID;
       
    18 typedef uint16 EngineRenewID;
       
    19 typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
       
    20 
       
    21 enum RailVehicleTypes {
       
    22 	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
       
    23 	RAILVEH_MULTIHEAD,   ///< indicates a combination of two locomotives
       
    24 	RAILVEH_WAGON,       ///< simple wagon, not motorized
       
    25 };
       
    26 
       
    27 enum EngineClass {
       
    28 	EC_STEAM,
       
    29 	EC_DIESEL,
       
    30 	EC_ELECTRIC,
       
    31 	EC_MONORAIL,
       
    32 	EC_MAGLEV,
       
    33 };
       
    34 
       
    35 struct RailVehicleInfo {
       
    36 	byte image_index;
       
    37 	RailVehicleTypes railveh_type;
       
    38 	byte base_cost;
       
    39 	RailTypeByte railtype;
       
    40 	uint16 max_speed;
       
    41 	uint16 power;
       
    42 	uint16 weight;
       
    43 	byte running_cost;
       
    44 	byte running_cost_class;
       
    45 	EngineClass engclass;           ///< Class of engine for this vehicle
       
    46 	byte capacity;
       
    47 	CargoID cargo_type;
       
    48 	byte ai_rank;
       
    49 	byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
       
    50 	uint16 pow_wag_power;
       
    51 	byte pow_wag_weight;
       
    52 	byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
       
    53 	                    //       for when the 'powered wagon' callback fails. But it should really also determine what
       
    54 	                    //       kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
       
    55 	                    //       Same goes for the callback result, which atm is only used to check if a wagon is powered.
       
    56 	byte shorten_factor;   ///< length on main map for this type is 8 - shorten_factor
       
    57 	byte tractive_effort;  ///< Tractive effort coefficient
       
    58 	byte user_def_data;    ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
       
    59 };
       
    60 
       
    61 struct ShipVehicleInfo {
       
    62 	byte image_index;
       
    63 	byte base_cost;
       
    64 	uint16 max_speed;
       
    65 	CargoID cargo_type;
       
    66 	uint16 capacity;
       
    67 	byte running_cost;
       
    68 	SoundFxByte sfx;
       
    69 	bool refittable;
       
    70 };
       
    71 
       
    72 /* AircraftVehicleInfo subtypes, bitmask type.
       
    73  * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
       
    74  * in which case bit 1 tells us whether it's a big(fast) plane or not */
       
    75 enum {
       
    76 	AIR_HELI = 0,
       
    77 	AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
       
    78 	AIR_FAST = 2
       
    79 };
       
    80 
       
    81 struct AircraftVehicleInfo {
       
    82 	byte image_index;
       
    83 	byte base_cost;
       
    84 	byte running_cost;
       
    85 	byte subtype;
       
    86 	SoundFxByte sfx;
       
    87 	byte acceleration;
       
    88 	uint16 max_speed;
       
    89 	byte mail_capacity;
       
    90 	uint16 passenger_capacity;
       
    91 };
       
    92 
       
    93 struct RoadVehicleInfo {
       
    94 	byte image_index;
       
    95 	byte base_cost;
       
    96 	byte running_cost;
       
    97 	byte running_cost_class;
       
    98 	SoundFxByte sfx;
       
    99 	byte max_speed;
       
   100 	byte capacity;
       
   101 	CargoID cargo_type;
       
   102 };
       
   103 
       
   104 /** Information about a vehicle
       
   105  *  @see table/engines.h
       
   106  */
       
   107 struct EngineInfo {
       
   108 	Date base_intro;
       
   109 	Year lifelength;
       
   110 	Year base_life;
       
   111 	byte unk2;         ///< flag for carriage(bit 7) and decay speed(bits0..6)
       
   112 	byte load_amount;
       
   113 	byte climates;
       
   114 	uint32 refit_mask;
       
   115 	byte refit_cost;
       
   116 	byte misc_flags;
       
   117 	byte callbackmask;
       
   118 	int8 retire_early;  ///< Number of years early to retire vehicle
       
   119 	StringID string_id; ///< Default name of engine
       
   120 };
       
   121 
       
   122 struct Engine {
       
   123 	char *name;         ///< Custom name of engine
       
   124 	Date intro_date;
       
   125 	Date age;
       
   126 	uint16 reliability;
       
   127 	uint16 reliability_spd_dec;
       
   128 	uint16 reliability_start, reliability_max, reliability_final;
       
   129 	uint16 duration_phase_1, duration_phase_2, duration_phase_3;
       
   130 	byte lifelength;
       
   131 	byte flags;
       
   132 	uint8 preview_player_rank;
       
   133 	byte preview_wait;
       
   134 	byte player_avail;
       
   135 	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
       
   136 };
       
   137 
       
   138 /**
       
   139  * EngineInfo.misc_flags is a bitmask, with the following values
       
   140  */
       
   141 enum {
       
   142 	EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
       
   143 	EF_ROAD_TRAM  = 0, ///< Road vehicle is a tram/light rail vehicle
       
   144 	EF_USES_2CC   = 1, ///< Vehicle uses two company colours
       
   145 	EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
       
   146 };
       
   147 
       
   148 /**
       
   149  * Engine.flags is a bitmask, with the following values.
       
   150  */
       
   151 enum {
       
   152 	ENGINE_AVAILABLE         = 1, ///< This vehicle is available to everyone.
       
   153 	ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a player.
       
   154 	ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a player.
       
   155 };
       
   156 
       
   157 enum {
       
   158 	NUM_VEHICLE_TYPES = 6
       
   159 };
       
   160 
       
   161 static const EngineID INVALID_ENGINE = 0xFFFF;
       
   162 
       
   163 enum {
       
   164 	NUM_NORMAL_RAIL_ENGINES = 54,
       
   165 	NUM_MONORAIL_ENGINES    = 30,
       
   166 	NUM_MAGLEV_ENGINES      = 32,
       
   167 	NUM_TRAIN_ENGINES       = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
       
   168 	NUM_ROAD_ENGINES        = 88,
       
   169 	NUM_SHIP_ENGINES        = 11,
       
   170 	NUM_AIRCRAFT_ENGINES    = 41,
       
   171 	TOTAL_NUM_ENGINES       = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES,
       
   172 	AIRCRAFT_ENGINES_INDEX  = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
       
   173 	SHIP_ENGINES_INDEX      = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
       
   174 	ROAD_ENGINES_INDEX      = NUM_TRAIN_ENGINES,
       
   175 };
       
   176 
       
   177 #endif /* ENGINE_TYPE_H */