|
@@ -23,25 +23,24 @@
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
#include "safeguards.h"
|
|
|
|
|
|
extern void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index);
|
|
|
extern void ChangeVehicleNews(VehicleID from_index, VehicleID to_index);
|
|
|
extern void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index);
|
|
|
|
|
|
/**
|
|
|
* Figure out if two engines got at least one type of cargo in common (refitting if needed)
|
|
|
* @param engine_a one of the EngineIDs
|
|
|
* @param engine_b the other EngineID
|
|
|
* @param type the type of the engines
|
|
|
* @return true if they can both carry the same type of cargo (or at least one of them got no capacity at all)
|
|
|
*/
|
|
|
static bool EnginesHaveCargoInCommon(EngineID engine_a, EngineID engine_b)
|
|
|
{
|
|
|
CargoTypes available_cargoes_a = GetUnionOfArticulatedRefitMasks(engine_a, true);
|
|
|
CargoTypes available_cargoes_b = GetUnionOfArticulatedRefitMasks(engine_b, true);
|
|
|
return (available_cargoes_a == 0 || available_cargoes_b == 0 || (available_cargoes_a & available_cargoes_b) != 0);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Checks some basic properties whether autoreplace is allowed
|
|
|
* @param from Origin engine
|
|
@@ -228,25 +227,25 @@ static CargoID GetNewCargoTypeForReplace
|
|
|
|
|
|
if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return CT_INVALID; // Some refit orders lose their effect
|
|
|
|
|
|
return cargo_type;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the EngineID of the replacement for a vehicle
|
|
|
* @param v The vehicle to find a replacement for
|
|
|
* @param c The vehicle's owner (it's faster to forward the pointer than refinding it)
|
|
|
* @param always_replace Always replace, even if not old.
|
|
|
* @param [out] e the EngineID of the replacement. INVALID_ENGINE if no replacement is found
|
|
|
* @param[out] e the EngineID of the replacement. INVALID_ENGINE if no replacement is found
|
|
|
* @return Error if the engine to build is not available
|
|
|
*/
|
|
|
static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, bool always_replace, EngineID &e)
|
|
|
{
|
|
|
assert(v->type != VEH_TRAIN || !v->IsArticulatedPart());
|
|
|
|
|
|
e = INVALID_ENGINE;
|
|
|
|
|
|
if (v->type == VEH_TRAIN && Train::From(v)->IsRearDualheaded()) {
|
|
|
/* we build the rear ends of multiheaded trains with the front ones */
|
|
|
return CommandCost();
|
|
|
}
|