Mercurial > hg > openttd
comparison src/graph_gui.cpp @ 7520:1903ce8b07b4 draft
(svn r11039) -Fix [FS#1191]: underflow that caused overflows in the performance rating calculation.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 02 Sep 2007 20:41:46 +0000 |
parents | 549c757023fc |
children | b66a3cb83e69 |
comparison
equal
deleted
inserted
replaced
7519:f3ee476ce6ec | 7520:1903ce8b07b4 |
---|---|
1004 /* Draw the score */ | 1004 /* Draw the score */ |
1005 SetDParam(0, score); | 1005 SetDParam(0, score); |
1006 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0); | 1006 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0); |
1007 | 1007 |
1008 /* Calculate the %-bar */ | 1008 /* Calculate the %-bar */ |
1009 if (val > needed) { | 1009 x = clamp(val, 0, needed) * 50 / needed; |
1010 x = 50; | |
1011 } else if (val == 0) { | |
1012 x = 0; | |
1013 } else { | |
1014 x = val * 50 / needed; | |
1015 } | |
1016 | 1010 |
1017 /* SCORE_LOAN is inversed */ | 1011 /* SCORE_LOAN is inversed */ |
1018 if (val < 0 && i == SCORE_LOAN) x = 0; | 1012 if (val < 0 && i == SCORE_LOAN) x = 0; |
1019 | 1013 |
1020 /* Draw the bar */ | 1014 /* Draw the bar */ |
1021 if (x != 0) GfxFillRect(112, y - 2, 112 + x, y + 10, color_done); | 1015 if (x != 0) GfxFillRect(112, y - 2, 112 + x, y + 10, color_done); |
1022 if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone); | 1016 if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone); |
1023 | 1017 |
1024 /* Calculate the % */ | 1018 /* Calculate the % */ |
1025 x = (val <= needed) ? val * 100 / needed : 100; | 1019 x = clamp(val, 0, needed) * 100 / needed; |
1026 | 1020 |
1027 /* SCORE_LOAN is inversed */ | 1021 /* SCORE_LOAN is inversed */ |
1028 if (val < 0 && i == SCORE_LOAN) x = 0; | 1022 if (val < 0 && i == SCORE_LOAN) x = 0; |
1029 | 1023 |
1030 /* Draw it */ | 1024 /* Draw it */ |