Changeset - r11171:0ec43fa9bbfe
[Not reviewed]
master
0 3 0
rubidium - 16 years ago 2009-02-19 09:45:44
rubidium@openttd.org
(svn r15521) -Codechange: add helper function to get the display tractive effort of a vehicle.
3 files changed with 19 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -512,11 +512,10 @@ static int DrawRailWagonPurchaseInfo(int
 
static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	uint weight = e->GetDisplayWeight();
 

	
 
	/* Purchase Cost - Engine weight */
 
	SetDParam(0, e->GetCost());
 
	SetDParam(1, weight);
 
	SetDParam(1, e->GetDisplayWeight());
 
	DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING);
 
	y += 10;
 

	
 
@@ -528,7 +527,7 @@ static int DrawRailEnginePurchaseInfo(in
 

	
 
	/* Max tractive effort - not applicable if old acceleration or maglev */
 
	if (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && rvi->railtype != RAILTYPE_MAGLEV) {
 
		SetDParam(0, (weight * 10 * GetEngineProperty(engine_number, 0x1F, rvi->tractive_effort)) / 256);
 
		SetDParam(0, e->GetDisplayMaxTractiveEffort());
 
		DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, TC_FROMSTRING);
 
		y += 10;
 
	}
src/engine.cpp
Show inline comments
 
@@ -204,6 +204,22 @@ uint Engine::GetDisplayWeight() const
 
	}
 
}
 

	
 
/**
 
 * Returns the tractive effort 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
 
{
 
	/* Currently only trains have 'tractive effort' */
 
	switch (this->type) {
 
		case VEH_TRAIN:
 
			return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, 0x1F, this->u.rail.tractive_effort)) / 256;
 

	
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
/** Sets cached values in Company::num_vehicles and Group::num_vehicles
 
 */
 
void SetCachedEngineCounts()
src/engine_base.h
Show inline comments
 
@@ -55,6 +55,7 @@ struct Engine : PoolItem<Engine, EngineI
 
	uint GetDisplayMaxSpeed() const;
 
	uint GetPower() const;
 
	uint GetDisplayWeight() const;
 
	uint GetDisplayMaxTractiveEffort() const;
 
};
 

	
 
static inline bool IsEngineIndex(uint index)
0 comments (0 inline, 0 general)