(svn r15210) -Fix: Vehicle::GetRunningCost() was wrong for ships and aircraft

pull/155/head
glx 16 years ago
parent 4ce7be6490
commit 12c89708cb

@ -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();

@ -629,6 +629,11 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
}
}
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;

@ -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;

@ -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();

@ -159,6 +159,11 @@ static void CheckIfShipNeedsService(Vehicle *v)
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;

Loading…
Cancel
Save