Changeset - r10875:1cfbd5e0cc73
[Not reviewed]
master
0 5 0
glx - 15 years ago 2009-01-22 21:33:08
glx@openttd.org
(svn r15210) -Fix: Vehicle::GetRunningCost() was wrong for ships and aircraft
5 files changed with 15 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/aircraft.h
Show inline comments
 
@@ -104,7 +104,7 @@ struct Aircraft : public Vehicle {
 
	SpriteID GetImage(Direction direction) const;
 
	int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
 
	int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; }
 
	Money GetRunningCost() const { return AircraftVehInfo(this->engine_type)->running_cost * _price.aircraft_running; }
 
	Money GetRunningCost() const;
 
	bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
 
	void Tick();
 
	void OnNewDay();
src/aircraft_cmd.cpp
Show inline comments
 
@@ -629,6 +629,11 @@ static void CheckIfAircraftNeedsService(
 
	}
 
}
 

	
 
Money Aircraft::GetRunningCost() const
 
{
 
	return GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running;
 
}
 

	
 
void Aircraft::OnNewDay()
 
{
 
	if (!IsNormalAircraft(this)) return;
 
@@ -643,7 +648,7 @@ void Aircraft::OnNewDay()
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	CommandCost cost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 
	CommandCost cost(EXPENSES_AIRCRAFT_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1999,8 +1999,7 @@ void RoadVehicle::OnNewDay()
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
 
	CommandCost cost(EXPENSES_ROADVEH_RUN, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 
	CommandCost cost(EXPENSES_ROADVEH_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
src/ship.h
Show inline comments
 
@@ -38,7 +38,7 @@ struct Ship: public Vehicle {
 
	SpriteID GetImage(Direction direction) const;
 
	int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
 
	int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
 
	Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; }
 
	Money GetRunningCost() const;
 
	bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; }
 
	void Tick();
 
	void OnNewDay();
src/ship_cmd.cpp
Show inline comments
 
@@ -159,6 +159,11 @@ static void CheckIfShipNeedsService(Vehi
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
Money Ship::GetRunningCost() const
 
{
 
	return GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running;
 
}
 

	
 
void Ship::OnNewDay()
 
{
 
	if ((++this->day_counter & 7) == 0)
 
@@ -172,7 +177,7 @@ void Ship::OnNewDay()
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	CommandCost cost(EXPENSES_SHIP_RUN, GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 
	CommandCost cost(EXPENSES_SHIP_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
0 comments (0 inline, 0 general)