mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use SQInteger for generic numbers in script_cargo
This commit is contained in:
parent
83826b1793
commit
40424601c6
|
@ -70,9 +70,12 @@
|
||||||
return (ScriptCargo::TownEffect)::CargoSpec::Get(cargo_type)->town_effect;
|
return (ScriptCargo::TownEffect)::CargoSpec::Get(cargo_type)->town_effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit)
|
/* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit)
|
||||||
{
|
{
|
||||||
if (!IsValidCargo(cargo_type)) return -1;
|
if (!IsValidCargo(cargo_type)) return -1;
|
||||||
|
|
||||||
|
distance = Clamp<SQInteger>(distance, 0, UINT32_MAX);
|
||||||
|
|
||||||
return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type);
|
return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +85,11 @@
|
||||||
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
|
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int64 ScriptCargo::GetWeight(CargoID cargo_type, uint32 amount)
|
/* static */ SQInteger ScriptCargo::GetWeight(CargoID cargo_type, SQInteger amount)
|
||||||
{
|
{
|
||||||
if (!IsValidCargo(cargo_type)) return -1;
|
if (!IsValidCargo(cargo_type)) return -1;
|
||||||
|
|
||||||
|
amount = Clamp<SQInteger>(amount, 0, UINT32_MAX);
|
||||||
|
|
||||||
return ::CargoSpec::Get(cargo_type)->WeightOfNUnits(amount);
|
return ::CargoSpec::Get(cargo_type)->WeightOfNUnits(amount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,12 @@ public:
|
||||||
* @param cargo_type The cargo to transport.
|
* @param cargo_type The cargo to transport.
|
||||||
* @pre ScriptCargo::IsValidCargo(cargo_type).
|
* @pre ScriptCargo::IsValidCargo(cargo_type).
|
||||||
* @param distance The distance the cargo travels from begin to end.
|
* @param distance The distance the cargo travels from begin to end.
|
||||||
* @param days_in_transit Amount of (game) days the cargo is in transit. The max value of this variable is 637. Any value higher returns the same as 637 would.
|
* The value will be clamped to 0 .. MAX(uint32).
|
||||||
|
* @param days_in_transit Amount of (game) days the cargo is in transit.
|
||||||
|
* The max value of this variable is 637. Any value higher returns the same as 637 would.
|
||||||
* @return The amount of money that would be earned by this trip.
|
* @return The amount of money that would be earned by this trip.
|
||||||
*/
|
*/
|
||||||
static Money GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit);
|
static Money GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cargo distribution type for a cargo.
|
* Get the cargo distribution type for a cargo.
|
||||||
|
@ -159,10 +161,11 @@ public:
|
||||||
* cargo for the specified type.
|
* cargo for the specified type.
|
||||||
* @param cargo_type The cargo to check on.
|
* @param cargo_type The cargo to check on.
|
||||||
* @param amount The quantity of cargo.
|
* @param amount The quantity of cargo.
|
||||||
|
* The value will be clamped to 0 .. MAX(uint32).
|
||||||
* @pre ScriptCargo::IsValidCargo(cargo_type).
|
* @pre ScriptCargo::IsValidCargo(cargo_type).
|
||||||
* @return The weight in tonnes for that quantity of cargo.
|
* @return The weight in tonnes for that quantity of cargo.
|
||||||
*/
|
*/
|
||||||
static int64 GetWeight(CargoID cargo_type, uint32 amount);
|
static SQInteger GetWeight(CargoID cargo_type, SQInteger amount);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCRIPT_CARGO_HPP */
|
#endif /* SCRIPT_CARGO_HPP */
|
||||||
|
|
Loading…
Reference in New Issue