mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r3198) Rewrite the company league drawing routine for better readability
This commit is contained in:
parent
67dcf1ffd8
commit
839cb586a7
64
graph_gui.c
64
graph_gui.c
@ -813,48 +813,44 @@ static inline StringID GetPerformanceTitleFromValue(uint value)
|
|||||||
return _performance_titles[minu(value, 1000) >> 6];
|
return _performance_titles[minu(value, 1000) >> 6];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CDECL _perf_hist_comp(const void *elem1, const void *elem2 ) {
|
static int CDECL PerfHistComp(const void* elem1, const void* elem2)
|
||||||
const Player *p1 = *(const Player* const *)elem1;
|
{
|
||||||
const Player *p2 = *(const Player* const *)elem2;
|
const Player* p1 = *(const Player* const*)elem1;
|
||||||
int32 v = p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
|
const Player* p2 = *(const Player* const*)elem2;
|
||||||
return (v!=0) | (v >> (sizeof(int32)*8-1));
|
|
||||||
|
return p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
|
static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
const Player* p;
|
const Player* plist[MAX_PLAYERS];
|
||||||
Player const *plist[MAX_PLAYERS];
|
const Player* p;
|
||||||
uint pl_num;
|
uint pl_num;
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
pl_num=0;
|
pl_num = 0;
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p;
|
||||||
if (p->is_active)
|
|
||||||
plist[pl_num++] = p;
|
qsort(plist, pl_num, sizeof(*plist), PerfHistComp);
|
||||||
|
|
||||||
|
for (i = 0; i != pl_num; i++) {
|
||||||
|
p = plist[i];
|
||||||
|
SetDParam(0, i + STR_01AC_1ST);
|
||||||
|
SetDParam(1, p->name_1);
|
||||||
|
SetDParam(2, p->name_2);
|
||||||
|
SetDParam(3, GetPlayerNameString(p->index, 4));
|
||||||
|
SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
|
||||||
|
|
||||||
|
DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0);
|
||||||
|
DrawPlayerIcon(p->index, 27, 16 + i * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
assert(pl_num > 0);
|
|
||||||
|
|
||||||
qsort((void*)plist, pl_num, sizeof(Player*), _perf_hist_comp);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
SetDParam(0, i + STR_01AC_1ST);
|
|
||||||
p = plist[i];
|
|
||||||
SetDParam(1, p->name_1);
|
|
||||||
SetDParam(2, p->name_2);
|
|
||||||
SetDParam(3, GetPlayerNameString(p->index, 4));
|
|
||||||
SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
|
|
||||||
|
|
||||||
DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0);
|
|
||||||
DrawPlayerIcon(p->index, 27, 16 + i * 10);
|
|
||||||
} while (++i != pl_num);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user