diff options
author | smatz <smatz@openttd.org> | 2008-02-13 19:24:40 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-02-13 19:24:40 +0000 |
commit | fe48d0be219f2035b146c6444c92c305d9c3bedf (patch) | |
tree | af07b8c3ed3437ba91111379ab438956940c60bb /src/aircraft_cmd.cpp | |
parent | 833a00def99ecf91bce955e35b82b33e4b7d5517 (diff) | |
download | openttd-fe48d0be219f2035b146c6444c92c305d9c3bedf.tar.xz |
(svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
-Fix [FS#1739]: vehicle profit is now counted with 8bit fract, so it is now shown properly in the vehicle details window
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r-- | src/aircraft_cmd.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index cdad840ab..494b041f2 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -321,6 +321,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) u->z_pos = GetSlopeZ(x, y); v->z_pos = u->z_pos + 1; + v->running_ticks = 0; + // u->delta_x = u->delta_y = 0; v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; @@ -735,11 +737,12 @@ void Aircraft::OnNewDay() AgeVehicle(this); CheckIfAircraftNeedsService(this); - if (this->vehstatus & VS_STOPPED) return; + if (this->running_ticks == 0) return; - CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running / 364); + CommandCost cost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running * this->running_ticks / (364 * DAY_TICKS)); - this->profit_this_year -= cost.GetCost() >> 8; + this->profit_this_year -= cost.GetCost(); + this->running_ticks = 0; SubtractMoneyFromPlayerFract(this->owner, cost); @@ -2146,6 +2149,8 @@ void Aircraft::Tick() { if (!IsNormalAircraft(this)) return; + if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++; + if (this->subtype == AIR_HELICOPTER) HelicopterTickHandler(this); AgeAircraftCargo(this); |