summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-13 19:24:40 +0000
committersmatz <smatz@openttd.org>2008-02-13 19:24:40 +0000
commitfe48d0be219f2035b146c6444c92c305d9c3bedf (patch)
treeaf07b8c3ed3437ba91111379ab438956940c60bb /src/economy.cpp
parent833a00def99ecf91bce955e35b82b33e4b7d5517 (diff)
downloadopenttd-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/economy.cpp')
-rw-r--r--src/economy.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 995b63afe..dc055dd5e 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -163,11 +163,9 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
num++;
if (v->age > 730) {
/* Find the vehicle with the lowest amount of profit */
- if (min_profit_first == true) {
- min_profit = v->profit_last_year;
+ if (min_profit_first || min_profit > v->profit_last_year >> 8) {
+ min_profit = v->profit_last_year >> 8;
min_profit_first = false;
- } else if (min_profit > v->profit_last_year) {
- min_profit = v->profit_last_year;
}
}
}
@@ -1505,7 +1503,7 @@ void VehiclePayment(Vehicle *front_v)
cp->days_in_transit,
v->cargo_type);
- front_v->profit_this_year += profit;
+ front_v->profit_this_year += profit << 8;
virtual_profit += profit; // accumulate transfer profits for whole vehicle
cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet
cp->paid_for = true; // record that the cargo has been paid for to eliminate double counting
@@ -1523,7 +1521,7 @@ void VehiclePayment(Vehicle *front_v)
}
if (route_profit != 0) {
- front_v->profit_this_year += vehicle_profit;
+ front_v->profit_this_year += vehicle_profit << 8;
SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit));
if (IsLocalPlayer() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {