mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r15210) -Fix: Vehicle::GetRunningCost() was wrong for ships and aircraft
This commit is contained in:
parent
b2d0e14848
commit
c5f0fe7c40
@ -104,7 +104,7 @@ struct Aircraft : public Vehicle {
|
|||||||
SpriteID GetImage(Direction direction) const;
|
SpriteID GetImage(Direction direction) const;
|
||||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
|
||||||
int GetDisplayMaxSpeed() const { return this->max_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); }
|
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
|
||||||
void Tick();
|
void Tick();
|
||||||
void OnNewDay();
|
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()
|
void Aircraft::OnNewDay()
|
||||||
{
|
{
|
||||||
if (!IsNormalAircraft(this)) return;
|
if (!IsNormalAircraft(this)) return;
|
||||||
@ -643,7 +648,7 @@ void Aircraft::OnNewDay()
|
|||||||
|
|
||||||
if (this->running_ticks == 0) return;
|
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->profit_this_year -= cost.GetCost();
|
||||||
this->running_ticks = 0;
|
this->running_ticks = 0;
|
||||||
|
@ -1999,8 +1999,7 @@ void RoadVehicle::OnNewDay()
|
|||||||
|
|
||||||
if (this->running_ticks == 0) return;
|
if (this->running_ticks == 0) return;
|
||||||
|
|
||||||
const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
|
CommandCost cost(EXPENSES_ROADVEH_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
|
||||||
CommandCost cost(EXPENSES_ROADVEH_RUN, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS));
|
|
||||||
|
|
||||||
this->profit_this_year -= cost.GetCost();
|
this->profit_this_year -= cost.GetCost();
|
||||||
this->running_ticks = 0;
|
this->running_ticks = 0;
|
||||||
|
@ -38,7 +38,7 @@ struct Ship: public Vehicle {
|
|||||||
SpriteID GetImage(Direction direction) const;
|
SpriteID GetImage(Direction direction) const;
|
||||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
||||||
int GetDisplayMaxSpeed() const { return this->max_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; }
|
bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; }
|
||||||
void Tick();
|
void Tick();
|
||||||
void OnNewDay();
|
void OnNewDay();
|
||||||
|
@ -159,6 +159,11 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
|||||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
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()
|
void Ship::OnNewDay()
|
||||||
{
|
{
|
||||||
if ((++this->day_counter & 7) == 0)
|
if ((++this->day_counter & 7) == 0)
|
||||||
@ -172,7 +177,7 @@ void Ship::OnNewDay()
|
|||||||
|
|
||||||
if (this->running_ticks == 0) return;
|
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->profit_this_year -= cost.GetCost();
|
||||||
this->running_ticks = 0;
|
this->running_ticks = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user