summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-20 20:18:19 +0000
committerrubidium <rubidium@openttd.org>2012-01-20 20:18:19 +0000
commit70c7fbd90eb0ace75d759725ba4d0085283f152c (patch)
treef807e537b9e78dff6442d4ec2a472217e84157d4 /src/economy.cpp
parent15331fa03c5bd87c54ea51e57a9738e867f6bc2e (diff)
downloadopenttd-70c7fbd90eb0ace75d759725ba4d0085283f152c.tar.xz
(svn r23826) -Fix [FS#4972]: the detailed performance rating window showed the cargo count of the current quarter instead of the last quarter like the tooltip says
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 01fd5b4a4..33dfec3cc 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -214,27 +214,21 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
/* Generate score depending on amount of transported cargo */
{
- const CompanyEconomyEntry *cee;
- int numec;
- uint32 total_delivered;
-
- numec = min(c->num_valid_stat_ent, 4);
+ int numec = min(c->num_valid_stat_ent, 4);
if (numec != 0) {
- cee = c->old_economy;
- total_delivered = 0;
+ const CompanyEconomyEntry *cee = c->old_economy;
+ OverflowSafeInt64 total_delivered = 0;
do {
- total_delivered += cee->delivered_cargo;
+ total_delivered += cee->delivered_cargo.GetSum<OverflowSafeInt64>();
} while (++cee, --numec);
- _score_part[owner][SCORE_DELIVERED] = total_delivered;
+ _score_part[owner][SCORE_DELIVERED] = ClampToI32(total_delivered);
}
}
/* Generate score for variety of cargo */
{
- uint num = CountBits(c->cargo_types);
- _score_part[owner][SCORE_CARGO] = num;
- if (update) c->cargo_types = 0;
+ _score_part[owner][SCORE_CARGO] = c->old_economy->delivered_cargo.GetCount();
}
/* Generate score for company's money */
@@ -1007,8 +1001,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
}
/* Update company statistics */
- company->cur_economy.delivered_cargo += accepted;
- if (accepted > 0) SetBit(company->cargo_types, cargo_type);
+ company->cur_economy.delivered_cargo[cargo_type] += accepted;
/* Increase town's counter for town effects */
const CargoSpec *cs = CargoSpec::Get(cargo_type);