Add: ScriptCargo::GetWeight to get cargo weights

This commit is contained in:
SamuXarick
2022-10-16 18:28:28 +02:00
committed by Michael Lutz
parent 3d45bc4abe
commit 8d0d45c431
4 changed files with 20 additions and 0 deletions
+6
View File
@@ -81,3 +81,9 @@
if (!ScriptCargo::IsValidCargo(cargo_type)) return INVALID_DISTRIBUTION_TYPE;
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
}
/* static */ int64 ScriptCargo::GetWeight(CargoID cargo_type, uint32 amount)
{
if (!IsValidCargo(cargo_type)) return -1;
return ::CargoSpec::Get(cargo_type)->weight * static_cast<int64>(amount) / 16;
}