Multi-cargo ships: Sprite group cargo thresholds refer to entire ship
This commit is contained in:
@@ -83,6 +83,8 @@
|
||||
The default 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.
|
||||
<p>This requires the <span class="code">multi_part_ships</span> feature.</p>
|
||||
|
||||
<p>From version 3 of the <span class="code">multi_part_ships</span> feature, spritegroup loading/loaded cargo thresholds refer to the entire ship, not just the first vehicle.</p>
|
||||
</p>
|
||||
<p>
|
||||
Added callback: <span class="code">refit_part_name</span><br />
|
||||
|
@@ -975,6 +975,7 @@
|
||||
Additional ship parts may be refitted individually.
|
||||
</p>
|
||||
<p>This is indicated by the feature name: <font face="monospace">multi_part_ships</font>, version 1</p>
|
||||
<p>From version 3 of the <font face="monospace">multi_part_ships</font> feature, Action 2 loadtypes/loadingtypes cargo thresholds refer to the entire ship, not just the first vehicle.</p>
|
||||
<p><b>Callback EC008002 - Ship part name for refit window</b><br />
|
||||
This callback is called on the primary vehicle to get the name of each part of the ship (e.g. the name of each cargo hold) in the refit window.<br />
|
||||
This is not called for ships of only one part.<br />
|
||||
|
@@ -1151,8 +1151,18 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
||||
uint totalsets = in_motion ? (uint)group->loaded.size() : (uint)group->loading.size();
|
||||
|
||||
if (totalsets == 0) return nullptr;
|
||||
if (totalsets == 1) return in_motion ? group->loaded[0] : group->loading[0];
|
||||
|
||||
uint set = (v->cargo.StoredCount() * totalsets) / std::max<uint16_t>(1u, v->cargo_cap);
|
||||
uint stored = v->cargo.StoredCount();
|
||||
uint capacity = v->cargo_cap;
|
||||
if (v->type == VEH_SHIP) {
|
||||
for (const Vehicle *u = v->Next(); u != nullptr; u = u->Next()) {
|
||||
stored += u->cargo.StoredCount();
|
||||
capacity += u->cargo_cap;
|
||||
}
|
||||
}
|
||||
|
||||
uint set = (stored * totalsets) / std::max<uint16_t>(1u, capacity);
|
||||
set = std::min(set, totalsets - 1);
|
||||
|
||||
return in_motion ? group->loaded[set] : group->loading[set];
|
||||
|
@@ -72,7 +72,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
|
||||
GRFFeatureInfo("town_zone_callback", 1, GFTOF_TOWN_ZONE_CALLBACK),
|
||||
GRFFeatureInfo("varaction2_towns_town_xy", 1),
|
||||
GRFFeatureInfo("more_varaction2_types", 1, GFTOF_MORE_VARACTION2_TYPES),
|
||||
GRFFeatureInfo("multi_part_ships", 2, GFTOF_MULTI_PART_SHIPS),
|
||||
GRFFeatureInfo("multi_part_ships", 3, GFTOF_MULTI_PART_SHIPS),
|
||||
GRFFeatureInfo("more_stations_per_grf", 1),
|
||||
GRFFeatureInfo(),
|
||||
};
|
||||
|
Reference in New Issue
Block a user