Changeset - r23008:cfd113ad34d0
[Not reviewed]
master
0 4 0
Johannes E. Krause - 6 years ago 2018-09-29 11:26:44
j.k@eclipso.de
Fix #6920: Make 9.8m/s^2 a common constant for TE-calculation
4 files changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
bin/ai/regression/tst_regression/result.txt
Show inline comments
 
@@ -1283,25 +1283,25 @@ ERROR: IsEnd() is invalid as Begin() is 
 
    IsValidEngine():    true
 
    GetName():          Kirby Paul Tank (Steam)
 
    GetCargoType():     255
 
    CanRefitCargo():    false
 
    GetCapacity():      -1
 
    GetReliability():   75
 
    GetMaxSpeed():      64
 
    GetPrice():         8203
 
    GetMaxAge():        5490
 
    GetRunningCost():   820
 
    GetPower():         300
 
    GetWeight():        47
 
    GetMaxTractiveEffort(): 139
 
    GetMaxTractiveEffort(): 136
 
    GetVehicleType():   0
 
    GetRailType():      0
 
    GetRoadType():      -1
 
    GetPlaneType():     -1
 
  Engine 1
 
    IsValidEngine():    false
 
    GetName():          (null : 0x00000000)
 
    GetCargoType():     255
 
    CanRefitCargo():    false
 
    GetCapacity():      -1
 
    GetReliability():   -1
 
    GetMaxSpeed():      -1
 
@@ -1427,43 +1427,43 @@ ERROR: IsEnd() is invalid as Begin() is 
 
    IsValidEngine():    true
 
    GetName():          Chaney 'Jubilee' (Steam)
 
    GetCargoType():     255
 
    CanRefitCargo():    false
 
    GetCapacity():      -1
 
    GetReliability():   80
 
    GetMaxSpeed():      112
 
    GetPrice():         15234
 
    GetMaxAge():        7686
 
    GetRunningCost():   1968
 
    GetPower():         1000
 
    GetWeight():        131
 
    GetMaxTractiveEffort(): 388
 
    GetMaxTractiveEffort(): 381
 
    GetVehicleType():   0
 
    GetRailType():      0
 
    GetRoadType():      -1
 
    GetPlaneType():     -1
 
  Engine 9
 
    IsValidEngine():    true
 
    GetName():          Ginzu 'A4' (Steam)
 
    GetCargoType():     255
 
    CanRefitCargo():    false
 
    GetCapacity():      -1
 
    GetReliability():   84
 
    GetMaxSpeed():      128
 
    GetPrice():         22265
 
    GetMaxAge():        7320
 
    GetRunningCost():   2296
 
    GetPower():         1200
 
    GetWeight():        162
 
    GetMaxTractiveEffort(): 480
 
    GetMaxTractiveEffort(): 471
 
    GetVehicleType():   0
 
    GetRailType():      0
 
    GetRoadType():      -1
 
    GetPlaneType():     -1
 
  Engine 10
 
    IsValidEngine():    false
 
    GetName():          (null : 0x00000000)
 
    GetCargoType():     255
 
    CanRefitCargo():    false
 
    GetCapacity():      -1
 
    GetReliability():   -1
 
    GetMaxSpeed():      -1
src/engine.cpp
Show inline comments
 
@@ -422,27 +422,27 @@ uint Engine::GetDisplayWeight() const
 
}
 

	
 
/**
 
 * Returns the tractive effort of the engine for display purposes.
 
 * For dual-headed train-engines this is the tractive effort of both heads
 
 * @return tractive effort in display units kN
 
 */
 
uint Engine::GetDisplayMaxTractiveEffort() const
 
{
 
	/* Only trains and road vehicles have 'tractive effort'. */
 
	switch (this->type) {
 
		case VEH_TRAIN:
 
			return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256;
 
			return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256 / 1000;
 
		case VEH_ROAD:
 
			return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256;
 
			return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256 / 1000;
 

	
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
/**
 
 * Returns the vehicle's (not model's!) life length in days.
 
 * @return the life length
 
 */
 
Date Engine::GetLifeLengthInDays() const
 
{
 
	/* Assume leap years; this gives the player a bit more than the given amount of years, but never less. */
src/ground_vehicle.cpp
Show inline comments
 
@@ -49,25 +49,25 @@ void GroundVehicle<T, Type>::PowerChange
 
	/* If air drag is set to zero (default), the resulting air drag coefficient is dependent on max speed. */
 
	if (air_drag_value == 0) {
 
		uint16 max_speed = v->GetDisplayMaxSpeed();
 
		/* Simplification of the method used in TTDPatch. It uses <= 10 to change more steadily from 128 to 196. */
 
		air_drag = (max_speed <= 10) ? 192 : max(2048 / max_speed, 1);
 
	} else {
 
		/* According to the specs, a value of 0x01 in the air drag property means "no air drag". */
 
		air_drag = (air_drag_value == 1) ? 0 : air_drag_value;
 
	}
 

	
 
	this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
 

	
 
	max_te *= 9800; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
 
	max_te *= GROUND_ACCELERATION; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
 
	max_te /= 256;  // Tractive effort is a [0-255] coefficient.
 
	if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) {
 
		/* Stop the vehicle if it has no power. */
 
		if (total_power == 0) this->vehstatus |= VS_STOPPED;
 

	
 
		this->gcache.cached_power = total_power;
 
		this->gcache.cached_max_te = max_te;
 
		SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
 
	}
 

	
 
	this->gcache.cached_max_track_speed = max_track_speed;
src/vehicle_type.h
Show inline comments
 
@@ -8,24 +8,26 @@
 
 */
 

	
 
/** @file vehicle_type.h Types related to vehicles. */
 

	
 
#ifndef VEHICLE_TYPE_H
 
#define VEHICLE_TYPE_H
 

	
 
#include "core/enum_type.hpp"
 

	
 
/** The type all our vehicle IDs have. */
 
typedef uint32 VehicleID;
 

	
 
static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2
 

	
 
/** Available vehicle types. */
 
enum VehicleType {
 
	VEH_BEGIN,
 

	
 
	VEH_TRAIN = VEH_BEGIN,        ///< %Train vehicle type.
 
	VEH_ROAD,                     ///< Road vehicle type.
 
	VEH_SHIP,                     ///< %Ship vehicle type.
 
	VEH_AIRCRAFT,                 ///< %Aircraft vehicle type.
 

	
 
	VEH_COMPANY_END,              ///< Last company-ownable type.
 

	
 
	VEH_EFFECT = VEH_COMPANY_END, ///< Effect vehicle type (smoke, explosions, sparks, bubbles)
0 comments (0 inline, 0 general)