Changeset - r27299:7b81a5510ce8
[Not reviewed]
master
0 4 0
Peter Nelson - 18 months ago 2023-05-08 22:10:14
peter1138@openttd.org
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.
4 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -423,9 +423,9 @@ uint Engine::GetDisplayMaxTractiveEffort
 
	/* Only trains and road vehicles have 'tractive effort'. */
 
	switch (this->type) {
 
		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:
 
			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();
 
	}
src/script/api/script_engine.cpp
Show inline comments
 
@@ -172,7 +172,7 @@
 
	if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) 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)
src/strings.cpp
Show inline comments
 
@@ -748,9 +748,9 @@ static const UnitsLong _units_volume[] =
 

	
 
/** Unit conversions for force. */
 
static const Units _units_force[] = {
 
	{ { 224.809 }, STR_UNITS_FORCE_IMPERIAL, 0 },
 
	{ { 101.972 }, STR_UNITS_FORCE_METRIC,   0 },
 
	{ {   1.0   }, STR_UNITS_FORCE_SI,       0 },
 
	{ { 0.224809 }, STR_UNITS_FORCE_IMPERIAL, 0 },
 
	{ { 0.101972 }, STR_UNITS_FORCE_METRIC,   0 },
 
	{ { 0.001    }, STR_UNITS_FORCE_SI,       0 },
 
};
 

	
 
/** Unit conversions for height. */
src/vehicle_gui.cpp
Show inline comments
 
@@ -2498,7 +2498,7 @@ struct VehicleDetailsWindow : Window {
 
					SetDParam(2, PackVelocity(v->GetDisplayMaxSpeed(), v->type));
 
					SetDParam(1, gcache->cached_power);
 
					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 ||
 
							GetRailTypeInfo(Train::From(v)->railtype)->acceleration_type == 2)) {
 
						string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
0 comments (0 inline, 0 general)