diff options
author | glx <glx@openttd.org> | 2009-01-22 21:33:08 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2009-01-22 21:33:08 +0000 |
commit | c5f0fe7c4074fc61dd54b756d2835fcf90ceaf05 (patch) | |
tree | 593969317bbdfd30857464beb43cbc118db5897d | |
parent | b2d0e14848816c8004055824f192abdaedcc0fbf (diff) | |
download | openttd-c5f0fe7c4074fc61dd54b756d2835fcf90ceaf05.tar.xz |
(svn r15210) -Fix: Vehicle::GetRunningCost() was wrong for ships and aircraft
-rw-r--r-- | src/aircraft.h | 2 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 7 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 3 | ||||
-rw-r--r-- | src/ship.h | 2 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 7 |
5 files changed, 15 insertions, 6 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index faf888f88..2f50517df 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -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(); diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index f901306f5..2effe517a 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 10a85cc04..914f8e2d8 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -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; diff --git a/src/ship.h b/src/ship.h index 79ab4c156..831a692dd 100644 --- a/src/ship.h +++ b/src/ship.h @@ -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(); diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index ca400db87..45361fc96 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -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; |