mirror of https://github.com/OpenTTD/OpenTTD
Change: Units-system can convert from N to kN, don't preconvert.
This allows force to passed as is and avoid premature rounding. The AI function "GetMaxTractiveEffort" still needs to return kN to avoid breaking the API.pull/10782/head
parent
e2f583a34f
commit
bf9caa425b
|
@ -423,9 +423,9 @@ uint Engine::GetDisplayMaxTractiveEffort() const
|
||||||
/* Only trains and road vehicles have 'tractive effort'. */
|
/* Only trains and road vehicles have 'tractive effort'. */
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256 / 1000;
|
return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256;
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256 / 1000;
|
return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256;
|
||||||
|
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
|
||||||
if (IsWagon(engine_id)) return -1;
|
if (IsWagon(engine_id)) return -1;
|
||||||
|
|
||||||
return ::Engine::Get(engine_id)->GetDisplayMaxTractiveEffort();
|
return ::Engine::Get(engine_id)->GetDisplayMaxTractiveEffort() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptDate::Date ScriptEngine::GetDesignDate(EngineID engine_id)
|
/* static */ ScriptDate::Date ScriptEngine::GetDesignDate(EngineID engine_id)
|
||||||
|
|
|
@ -748,9 +748,9 @@ static const UnitsLong _units_volume[] = {
|
||||||
|
|
||||||
/** Unit conversions for force. */
|
/** Unit conversions for force. */
|
||||||
static const Units _units_force[] = {
|
static const Units _units_force[] = {
|
||||||
{ { 224.809 }, STR_UNITS_FORCE_IMPERIAL, 0 },
|
{ { 0.224809 }, STR_UNITS_FORCE_IMPERIAL, 0 },
|
||||||
{ { 101.972 }, STR_UNITS_FORCE_METRIC, 0 },
|
{ { 0.101972 }, STR_UNITS_FORCE_METRIC, 0 },
|
||||||
{ { 1.0 }, STR_UNITS_FORCE_SI, 0 },
|
{ { 0.001 }, STR_UNITS_FORCE_SI, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Unit conversions for height. */
|
/** Unit conversions for height. */
|
||||||
|
|
|
@ -2498,7 +2498,7 @@ struct VehicleDetailsWindow : Window {
|
||||||
SetDParam(2, PackVelocity(v->GetDisplayMaxSpeed(), v->type));
|
SetDParam(2, PackVelocity(v->GetDisplayMaxSpeed(), v->type));
|
||||||
SetDParam(1, gcache->cached_power);
|
SetDParam(1, gcache->cached_power);
|
||||||
SetDParam(0, gcache->cached_weight);
|
SetDParam(0, gcache->cached_weight);
|
||||||
SetDParam(3, gcache->cached_max_te / 1000);
|
SetDParam(3, gcache->cached_max_te);
|
||||||
if (v->type == VEH_TRAIN && (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
|
if (v->type == VEH_TRAIN && (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
|
||||||
GetRailTypeInfo(Train::From(v)->railtype)->acceleration_type == 2)) {
|
GetRailTypeInfo(Train::From(v)->railtype)->acceleration_type == 2)) {
|
||||||
string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
|
string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
|
||||||
|
|
Loading…
Reference in New Issue