Skip to content

Commit

Permalink
Multi-part ships: Require feature test to enable callback 16
Browse files Browse the repository at this point in the history
  • Loading branch information
JGRennison committed Mar 15, 2023
1 parent 87e4258 commit 8cd7c95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/newgrf-additions.html
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@ <h4 id="signals_signal_style">Signal style (mappable variable: signals_signal_st
<h3 id="callbacks_ships"><a href="https://newgrf-specs.tt-wiki.net/wiki/Callbacks">Callbacks - Ships</a></h3>
<h4 id="callbacks_ships_articulated">Multi-part ships</h4>
<p><b><a href="https://newgrf-specs.tt-wiki.net/wiki/Callbacks#Articulated_engine_.2816.29">Callback 16 - Articulated engine</a> may also be used for ships.</b><br />
This functions the same as for trains and road vehicles, and is enabled in the same way (bit 4 of ship property 12).<br />
The feature name: <font face="monospace">multi_part_ships</font> must be tested for to enable this callback for ships.<br />
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).<br />
Additional ship parts are not used for graphics, they are only used for additional cargo capacity.<br />
The graphics chain for the primary vehicle may check the cargo states of the other ship parts if required.<br />
Additional ship parts may be refitted individually.
Expand Down
5 changes: 5 additions & 0 deletions src/articulated_vehicles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "engine_func.h"
#include "company_func.h"
#include "newgrf.h"
#include "newgrf_extension.h"
#include <vector>

#include "table/strings.h"
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/newgrf_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};

Expand Down
1 change: 1 addition & 0 deletions src/newgrf_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit 8cd7c95

Please sign in to comment.