diff --git a/docs/newgrf-additions.html b/docs/newgrf-additions.html index 36edf055e0..60e31b3618 100644 --- a/docs/newgrf-additions.html +++ b/docs/newgrf-additions.html @@ -895,7 +895,8 @@

Callbacks - Ships

Multi-part ships

Callback 16 - Articulated engine may also be used for ships.
- This functions the same as for trains and road vehicles, and is enabled in the same way (bit 4 of ship property 12).
+ The feature name: multi_part_ships must be tested for to enable this callback for ships.
+ This functions the same as for trains and road vehicles, and is enabled for individual engines in the same way (bit 4 of ship property 12).
Additional ship parts are not used for graphics, they are only used for additional cargo capacity.
The graphics chain for the primary vehicle may check the cargo states of the other ship parts if required.
Additional ship parts may be refitted individually. diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index a029c4b1a8..23255fa4a4 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -15,6 +15,7 @@ #include "engine_func.h" #include "company_func.h" #include "newgrf.h" +#include "newgrf_extension.h" #include #include "table/strings.h" @@ -37,6 +38,10 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle const Engine *front_engine = Engine::Get(front_type); + if (front_engine->type == VEH_SHIP && !(front_engine->GetGRF() != nullptr && HasBit(front_engine->GetGRF()->observed_feature_tests, GFTOF_MULTI_PART_SHIPS))) { + return INVALID_ENGINE; + } + uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front); if (callback == CALLBACK_FAILED) return INVALID_ENGINE; diff --git a/src/newgrf_extension.cpp b/src/newgrf_extension.cpp index 617523b945..39f4f5b063 100644 --- a/src/newgrf_extension.cpp +++ b/src/newgrf_extension.cpp @@ -66,7 +66,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("town_uncapped_variables", 1), GRFFeatureInfo("town_zone_callback", 1, GFTOF_TOWN_ZONE_CALLBACK), GRFFeatureInfo("more_varaction2_types", 1, GFTOF_MORE_VARACTION2_TYPES), - GRFFeatureInfo("multi_part_ships", 1), + GRFFeatureInfo("multi_part_ships", 1, GFTOF_MULTI_PART_SHIPS), GRFFeatureInfo(), }; diff --git a/src/newgrf_extension.h b/src/newgrf_extension.h index d3e06548cb..38b4196f88 100644 --- a/src/newgrf_extension.h +++ b/src/newgrf_extension.h @@ -101,6 +101,7 @@ enum GRFFeatureTestObservationFlag : uint8 { GFTOF_MORE_ACTION2_IDS, GFTOF_TOWN_ZONE_CALLBACK, GFTOF_MORE_VARACTION2_TYPES, + GFTOF_MULTI_PART_SHIPS, GFTOF_INVALID = 0xFF, };