src/engine.h
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6585 7da94b26498a
child 6720 35756db7e577
equal deleted inserted replaced
6718:5a8b295aa345 6719:4cc327ad39d5
    12 
    12 
    13 enum RailVehicleTypes {
    13 enum RailVehicleTypes {
    14 	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
    14 	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
    15 	RAILVEH_MULTIHEAD,   ///< indicates a combination of two locomotives
    15 	RAILVEH_MULTIHEAD,   ///< indicates a combination of two locomotives
    16 	RAILVEH_WAGON,       ///< simple wagon, not motorized
    16 	RAILVEH_WAGON,       ///< simple wagon, not motorized
       
    17 };
       
    18 
       
    19 enum EngineClass {
       
    20 	EC_STEAM,
       
    21 	EC_DIESEL,
       
    22 	EC_ELECTRIC,
       
    23 	EC_MONORAIL,
       
    24 	EC_MAGLEV,
    17 };
    25 };
    18 
    26 
    19 struct RailVehicleInfo {
    27 struct RailVehicleInfo {
    20 	byte image_index;
    28 	byte image_index;
    21 	RailVehicleTypes railveh_type;
    29 	RailVehicleTypes railveh_type;
    24 	uint16 max_speed;
    32 	uint16 max_speed;
    25 	uint16 power;
    33 	uint16 power;
    26 	uint16 weight;
    34 	uint16 weight;
    27 	byte running_cost_base;
    35 	byte running_cost_base;
    28 	byte running_cost_class;
    36 	byte running_cost_class;
    29 	byte engclass;         ///< 0: steam, 1: diesel, 2: electric
    37 	EngineClass engclass;           ///< Class of engine for this vehicle
    30 	byte capacity;
    38 	byte capacity;
    31 	CargoID cargo_type;
    39 	CargoID cargo_type;
    32 	byte ai_rank;
    40 	byte ai_rank;
    33 	uint16 pow_wag_power;
    41 	uint16 pow_wag_power;
    34 	byte pow_wag_weight;
    42 	byte pow_wag_weight;
    88  */
    96  */
    89 struct EngineInfo {
    97 struct EngineInfo {
    90 	Date base_intro;
    98 	Date base_intro;
    91 	Year lifelength;
    99 	Year lifelength;
    92 	Year base_life;
   100 	Year base_life;
    93 	byte unk2;         ///< Carriages have the highest bit set in this one
   101 	byte unk2;         ///< flag for carriage(bit 7) and decay speed(bits0..6)
    94 	byte load_amount;
   102 	byte load_amount;
    95 	byte climates;
   103 	byte climates;
    96 	uint32 refit_mask;
   104 	uint32 refit_mask;
    97 	byte refit_cost;
   105 	byte refit_cost;
    98 	byte misc_flags;
   106 	byte misc_flags;
    99 	byte callbackmask;
   107 	byte callbackmask;
       
   108 	byte retire_early; ///< Number of years early to retire vehicle
   100 };
   109 };
   101 
   110 
   102 struct Engine {
   111 struct Engine {
   103 	Date intro_date;
   112 	Date intro_date;
   104 	Date age;
   113 	Date age;
   109 	byte lifelength;
   118 	byte lifelength;
   110 	byte flags;
   119 	byte flags;
   111 	PlayerByte preview_player;
   120 	PlayerByte preview_player;
   112 	byte preview_wait;
   121 	byte preview_wait;
   113 	byte player_avail;
   122 	byte player_avail;
   114 	byte type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. Same as in vehicle.h
   123 	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. Same as in vehicle.h
   115 };
   124 };
   116 
   125 
   117 /**
   126 /**
   118  * EngineInfo.misc_flags is a bitmask, with the following values
   127  * EngineInfo.misc_flags is a bitmask, with the following values
   119  */
   128  */
   120 enum {
   129 enum {
   121 	EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves (unsupported)
   130 	EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
   122 	EF_ROAD_TRAM  = 0, ///< Road vehicle is a tram/light rail vehicle (unsup)
   131 	EF_ROAD_TRAM  = 0, ///< Road vehicle is a tram/light rail vehicle
   123 	EF_USES_2CC   = 1, ///< Vehicle uses two company colours
   132 	EF_USES_2CC   = 1, ///< Vehicle uses two company colours
   124 	EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
   133 	EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
   125 };
   134 };
   126 
   135 
   127 /**
   136 /**
   151 
   160 
   152 void LoadCustomEngineNames();
   161 void LoadCustomEngineNames();
   153 void DeleteCustomEngineNames();
   162 void DeleteCustomEngineNames();
   154 
   163 
   155 bool IsEngineBuildable(EngineID engine, byte type, PlayerID player);
   164 bool IsEngineBuildable(EngineID engine, byte type, PlayerID player);
       
   165 CargoID GetEngineCargoType(EngineID engine);
   156 
   166 
   157 enum {
   167 enum {
   158 	NUM_NORMAL_RAIL_ENGINES = 54,
   168 	NUM_NORMAL_RAIL_ENGINES = 54,
   159 	NUM_MONORAIL_ENGINES    = 30,
   169 	NUM_MONORAIL_ENGINES    = 30,
   160 	NUM_MAGLEV_ENGINES      = 32,
   170 	NUM_MAGLEV_ENGINES      = 32,
   260 struct EngineRenew {
   270 struct EngineRenew {
   261 	EngineRenewID index;
   271 	EngineRenewID index;
   262 	EngineID from;
   272 	EngineID from;
   263 	EngineID to;
   273 	EngineID to;
   264 	EngineRenew *next;
   274 	EngineRenew *next;
       
   275 	GroupID group_id;
   265 };
   276 };
   266 
   277 
   267 /**
   278 /**
   268  * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
   279  * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
   269  * placed here so the only exception to this rule, the saveload code, can use
   280  * placed here so the only exception to this rule, the saveload code, can use
   293  */
   304  */
   294 typedef EngineRenew* EngineRenewList;
   305 typedef EngineRenew* EngineRenewList;
   295 
   306 
   296 /**
   307 /**
   297  * Remove all engine replacement settings for the player.
   308  * Remove all engine replacement settings for the player.
   298  * @param  er The renewlist for a given player.
   309  * @param  erl The renewlist for a given player.
   299  * @return The new renewlist for the player.
   310  * @return The new renewlist for the player.
   300  */
   311  */
   301 void RemoveAllEngineReplacement(EngineRenewList* erl);
   312 void RemoveAllEngineReplacement(EngineRenewList* erl);
   302 
   313 
   303 /**
   314 /**
   305  * @param  erl The renewlist to search in.
   316  * @param  erl The renewlist to search in.
   306  * @param  engine Engine type to be replaced.
   317  * @param  engine Engine type to be replaced.
   307  * @return The engine type to replace with, or INVALID_ENGINE if no
   318  * @return The engine type to replace with, or INVALID_ENGINE if no
   308  * replacement is in the list.
   319  * replacement is in the list.
   309  */
   320  */
   310 EngineID EngineReplacement(EngineRenewList erl, EngineID engine);
   321 EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
   311 
   322 
   312 /**
   323 /**
   313  * Add an engine replacement to the given renewlist.
   324  * Add an engine replacement to the given renewlist.
   314  * @param erl The renewlist to add to.
   325  * @param erl The renewlist to add to.
   315  * @param old_engine The original engine type.
   326  * @param old_engine The original engine type.
   316  * @param new_engine The replacement engine type.
   327  * @param new_engine The replacement engine type.
   317  * @param flags The calling command flags.
   328  * @param flags The calling command flags.
   318  * @return 0 on success, CMD_ERROR on failure.
   329  * @return 0 on success, CMD_ERROR on failure.
   319  */
   330  */
   320 int32 AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, uint32 flags);
   331 int32 AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
   321 
   332 
   322 /**
   333 /**
   323  * Remove an engine replacement from a given renewlist.
   334  * Remove an engine replacement from a given renewlist.
   324  * @param erl The renewlist from which to remove the replacement
   335  * @param erl The renewlist from which to remove the replacement
   325  * @param engine The original engine type.
   336  * @param engine The original engine type.
   326  * @param flags The calling command flags.
   337  * @param flags The calling command flags.
   327  * @return 0 on success, CMD_ERROR on failure.
   338  * @return 0 on success, CMD_ERROR on failure.
   328  */
   339  */
   329 int32 RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, uint32 flags);
   340 int32 RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, GroupID group, uint32 flags);
   330 
   341 
   331 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
   342 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
   332  * @param type The type of engine
   343  * @param type The type of engine
   333  */
   344  */
   334 void AddRemoveEngineFromAutoreplaceAndBuildWindows(byte type);
   345 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
   335 
   346 
   336 /* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
   347 /* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
   337 void EngList_Create(EngineList *el);            ///< Creates engine list
   348 void EngList_Create(EngineList *el);            ///< Creates engine list
   338 void EngList_Destroy(EngineList *el);           ///< Deallocate and destroy engine list
   349 void EngList_Destroy(EngineList *el);           ///< Deallocate and destroy engine list
   339 uint EngList_Count(const EngineList *el);       ///< Returns number of items in the engine list
   350 uint EngList_Count(const EngineList *el);       ///< Returns number of items in the engine list