summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-01-06 22:16:17 +0000
committertruelight <truelight@openttd.org>2006-01-06 22:16:17 +0000
commit4cda74cb31953af0ff747430225199770c98a4ef (patch)
treef6d50d5d4966d35314b2f71c0373c3b1362ed2e9
parentefd3d4210779d54a1434d71e08fa26b03478ef18 (diff)
downloadopenttd-4cda74cb31953af0ff747430225199770c98a4ef.tar.xz
(svn r3377) -Fix: [ FS#24 ] Min. profit in detail performance rating gave you full points if you had no vehicles, and was limited to 20k. Solved both. (Partly based on Graphite his patch)
-rw-r--r--economy.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/economy.c b/economy.c
index 2cdedccc0..725b33c35 100644
--- a/economy.c
+++ b/economy.c
@@ -124,25 +124,31 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Count vehicles */
{
Vehicle *v;
- int32 min_profit = _score_info[SCORE_MIN_PROFIT].needed;
+ int32 min_profit = 0;
+ bool min_profit_first = true;
uint num = 0;
FOR_ALL_VEHICLES(v) {
if (v->owner != owner)
continue;
if ((v->type == VEH_Train && IsFrontEngine(v)) ||
- v->type == VEH_Road ||
- (v->type == VEH_Aircraft && v->subtype<=2) ||
- v->type == VEH_Ship) {
+ v->type == VEH_Road ||
+ (v->type == VEH_Aircraft && v->subtype <= 2) ||
+ v->type == VEH_Ship) {
num++;
if (v->age > 730) {
- if (min_profit > v->profit_last_year)
+ /* Find the vehicle with the lowest amount of profit */
+ if (min_profit_first == true) {
+ min_profit = v->profit_last_year;
+ min_profit_first = false;
+ } else if (min_profit > v->profit_last_year)
min_profit = v->profit_last_year;
}
}
}
_score_part[owner][SCORE_VEHICLES] = num;
+ /* Don't allow negative min_profit to show */
if (min_profit > 0)
_score_part[owner][SCORE_MIN_PROFIT] = min_profit;
}