43 byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value |
43 byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value |
44 // for when the 'powered wagon' callback fails. But it should really also determine what |
44 // for when the 'powered wagon' callback fails. But it should really also determine what |
45 // kind of visual effect to generate for a vehicle (default, steam, diesel, electric). |
45 // kind of visual effect to generate for a vehicle (default, steam, diesel, electric). |
46 // Same goes for the callback result, which atm is only used to check if a wagon is powered. |
46 // Same goes for the callback result, which atm is only used to check if a wagon is powered. |
47 byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor |
47 byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor |
48 byte tractive_effort; ///< Tractive effort coefficient |
48 byte tractive_effort; ///< Tractive effort coefficient |
49 byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles |
49 byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles |
50 }; |
50 }; |
51 |
51 |
52 struct ShipVehicleInfo { |
52 struct ShipVehicleInfo { |
53 byte image_index; |
53 byte image_index; |
260 |
260 |
261 /************************************************************************ |
261 /************************************************************************ |
262 * Engine Replacement stuff |
262 * Engine Replacement stuff |
263 ************************************************************************/ |
263 ************************************************************************/ |
264 |
264 |
|
265 struct EngineRenew; |
|
266 /** |
|
267 * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is |
|
268 * placed here so the only exception to this rule, the saveload code, can use |
|
269 * it. |
|
270 */ |
|
271 DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) |
|
272 |
265 /** |
273 /** |
266 * Struct to store engine replacements. DO NOT USE outside of engine.c. Is |
274 * Struct to store engine replacements. DO NOT USE outside of engine.c. Is |
267 * placed here so the only exception to this rule, the saveload code, can use |
275 * placed here so the only exception to this rule, the saveload code, can use |
268 * it. |
276 * it. |
269 */ |
277 */ |
270 struct EngineRenew { |
278 struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> { |
271 EngineRenewID index; |
|
272 EngineID from; |
279 EngineID from; |
273 EngineID to; |
280 EngineID to; |
274 EngineRenew *next; |
281 EngineRenew *next; |
275 GroupID group_id; |
282 GroupID group_id; |
276 }; |
283 |
277 |
284 EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {} |
278 /** |
285 ~EngineRenew() { this->from = INVALID_ENGINE; } |
279 * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is |
286 |
280 * placed here so the only exception to this rule, the saveload code, can use |
287 bool IsValid() const { return this->from != INVALID_ENGINE; } |
281 * it. |
288 }; |
282 */ |
289 |
283 DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) |
290 #define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid()) |
284 |
|
285 /** |
|
286 * Check if a EngineRenew really exists. |
|
287 */ |
|
288 static inline bool IsValidEngineRenew(const EngineRenew *er) |
|
289 { |
|
290 return er->from != INVALID_ENGINE; |
|
291 } |
|
292 |
|
293 static inline void DeleteEngineRenew(EngineRenew *er) |
|
294 { |
|
295 er->from = INVALID_ENGINE; |
|
296 } |
|
297 |
|
298 #define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->from != INVALID_ENGINE) if (IsValidEngineRenew(er)) |
|
299 #define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0) |
291 #define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0) |
300 |
292 |
301 |
293 |
302 /** |
294 /** |
303 * A list to group EngineRenew directives together (such as per-player). |
295 * A list to group EngineRenew directives together (such as per-player). |
307 /** |
299 /** |
308 * Remove all engine replacement settings for the player. |
300 * Remove all engine replacement settings for the player. |
309 * @param erl The renewlist for a given player. |
301 * @param erl The renewlist for a given player. |
310 * @return The new renewlist for the player. |
302 * @return The new renewlist for the player. |
311 */ |
303 */ |
312 void RemoveAllEngineReplacement(EngineRenewList* erl); |
304 void RemoveAllEngineReplacement(EngineRenewList *erl); |
313 |
305 |
314 /** |
306 /** |
315 * Retrieve the engine replacement in a given renewlist for an original engine type. |
307 * Retrieve the engine replacement in a given renewlist for an original engine type. |
316 * @param erl The renewlist to search in. |
308 * @param erl The renewlist to search in. |
317 * @param engine Engine type to be replaced. |
309 * @param engine Engine type to be replaced. |
326 * @param old_engine The original engine type. |
318 * @param old_engine The original engine type. |
327 * @param new_engine The replacement engine type. |
319 * @param new_engine The replacement engine type. |
328 * @param flags The calling command flags. |
320 * @param flags The calling command flags. |
329 * @return 0 on success, CMD_ERROR on failure. |
321 * @return 0 on success, CMD_ERROR on failure. |
330 */ |
322 */ |
331 CommandCost AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags); |
323 CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags); |
332 |
324 |
333 /** |
325 /** |
334 * Remove an engine replacement from a given renewlist. |
326 * Remove an engine replacement from a given renewlist. |
335 * @param erl The renewlist from which to remove the replacement |
327 * @param erl The renewlist from which to remove the replacement |
336 * @param engine The original engine type. |
328 * @param engine The original engine type. |
337 * @param flags The calling command flags. |
329 * @param flags The calling command flags. |
338 * @return 0 on success, CMD_ERROR on failure. |
330 * @return 0 on success, CMD_ERROR on failure. |
339 */ |
331 */ |
340 CommandCost RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, GroupID group, uint32 flags); |
332 CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags); |
341 |
333 |
342 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists |
334 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists |
343 * @param type The type of engine |
335 * @param type The type of engine |
344 */ |
336 */ |
345 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type); |
337 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type); |