mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r11039) -Fix [FS#1191]: underflow that caused overflows in the performance rating calculation.
This commit is contained in:
parent
d396b0c556
commit
b1effc466e
@ -217,10 +217,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
|||||||
/* Skip the total */
|
/* Skip the total */
|
||||||
if (i == SCORE_TOTAL) continue;
|
if (i == SCORE_TOTAL) continue;
|
||||||
/* Check the score */
|
/* Check the score */
|
||||||
s = (_score_part[owner][i] >= _score_info[i].needed) ?
|
s = clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _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;
|
|
||||||
score += s;
|
score += s;
|
||||||
total_score += _score_info[i].score;
|
total_score += _score_info[i].score;
|
||||||
}
|
}
|
||||||
|
@ -1006,13 +1006,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
|
|||||||
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
|
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
|
||||||
|
|
||||||
/* Calculate the %-bar */
|
/* Calculate the %-bar */
|
||||||
if (val > needed) {
|
x = clamp(val, 0, needed) * 50 / needed;
|
||||||
x = 50;
|
|
||||||
} else if (val == 0) {
|
|
||||||
x = 0;
|
|
||||||
} else {
|
|
||||||
x = val * 50 / needed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SCORE_LOAN is inversed */
|
/* SCORE_LOAN is inversed */
|
||||||
if (val < 0 && i == SCORE_LOAN) x = 0;
|
if (val < 0 && i == SCORE_LOAN) x = 0;
|
||||||
@ -1022,7 +1016,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
|
|||||||
if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
|
if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
|
||||||
|
|
||||||
/* Calculate the % */
|
/* Calculate the % */
|
||||||
x = (val <= needed) ? val * 100 / needed : 100;
|
x = clamp(val, 0, needed) * 100 / needed;
|
||||||
|
|
||||||
/* SCORE_LOAN is inversed */
|
/* SCORE_LOAN is inversed */
|
||||||
if (val < 0 && i == SCORE_LOAN) x = 0;
|
if (val < 0 && i == SCORE_LOAN) x = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user