diff options
-rw-r--r-- | src/articulated_vehicles.cpp | 10 | ||||
-rw-r--r-- | src/articulated_vehicles.h | 1 | ||||
-rw-r--r-- | src/script/api/script_engine.cpp | 2 |
3 files changed, 12 insertions, 1 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index d153a169f..a889ab3d8 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -55,6 +55,16 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle } /** + * Does a NewGRF report that this should be an articulated vehicle? + * @param engine_type The engine to check. + * @return True iff the articulated engine callback flag is set. + */ +bool IsArticulatedEngine(EngineID engine_type) +{ + return HasBit(EngInfo(engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE); +} + +/** * Count the number of articulated parts of an engine. * @param engine_type The engine to get the number of parts of. * @param purchase_window Whether we are in the scope of the purchase window or not, i.e. whether we cannot allocate vehicles. diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h index f9df46b08..46b4da374 100644 --- a/src/articulated_vehicles.h +++ b/src/articulated_vehicles.h @@ -23,6 +23,7 @@ uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_car uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *cargo_type); bool IsArticulatedVehicleRefittable(EngineID engine); +bool IsArticulatedEngine(EngineID engine_type); void CheckConsistencyOfArticulatedVehicle(const Vehicle *v); diff --git a/src/script/api/script_engine.cpp b/src/script/api/script_engine.cpp index 54fc54cb1..adad559c5 100644 --- a/src/script/api/script_engine.cpp +++ b/src/script/api/script_engine.cpp @@ -233,7 +233,7 @@ if (!IsValidEngine(engine_id)) return false; if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD && GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false; - return CountArticulatedParts(engine_id, true) != 0; + return IsArticulatedEngine(engine_id); } /* static */ ScriptAirport::PlaneType ScriptEngine::GetPlaneType(EngineID engine_id) |