summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-02 20:41:46 +0000
committerrubidium <rubidium@openttd.org>2007-09-02 20:41:46 +0000
commitb1effc466eac33997567e2f2e68812afb1c0a7f6 (patch)
treee63e7fae0c819a5ffcf9150bc1fd58d6048144c9 /src/economy.cpp
parentd396b0c55695414d7ab3d3ddcbe33ecdd4d7f6fa (diff)
downloadopenttd-b1effc466eac33997567e2f2e68812afb1c0a7f6.tar.xz
(svn r11039) -Fix [FS#1191]: underflow that caused overflows in the performance rating calculation.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index a9b0d9229..8c5be601c 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -217,10 +217,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Skip the total */
if (i == SCORE_TOTAL) continue;
/* Check the score */
- s = (_score_part[owner][i] >= _score_info[i].needed) ?
- _score_info[i].score :
- _score_part[owner][i] * _score_info[i].score / _score_info[i].needed;
- if (s < 0) s = 0;
+ s = clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
score += s;
total_score += _score_info[i].score;
}