diff options
author | glx <glx@openttd.org> | 2008-05-05 21:09:03 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2008-05-05 21:09:03 +0000 |
commit | 1050f07ed13b98b4742cb77284480a49cefd90e6 (patch) | |
tree | 831d4a0cc0af58ed297a4a8570fc066eeacb0d9d | |
parent | 22aa011b5773689fa2bfba1c35488c42d4be0d28 (diff) | |
download | openttd-1050f07ed13b98b4742cb77284480a49cefd90e6.tar.xz |
(svn r12959) -Fix: don't assume no production when the first produced cargo is invalid in industries directory
-rw-r--r-- | src/industry_gui.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 3070dd1f8..188c3e155 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -796,31 +796,35 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) DrawWindowWidgets(w); DrawSortButtonState(w, IDW_SORTBYNAME + (_industry_sort_order >> 1), _industry_sort_order & 1 ? SBS_DOWN : SBS_UP); - uint p = w->vscroll.pos; + uint pos = w->vscroll.pos; int n = 0; - while (p < _num_industry_sort) { - const Industry* i = _industry_sort[p]; + while (pos < _num_industry_sort) { + const Industry* i = _industry_sort[pos]; + byte p = 0; - SetDParam(0, i->index); - if (i->produced_cargo[0] != CT_INVALID) { - SetDParam(1, i->produced_cargo[0]); - SetDParam(2, i->last_month_production[0]); + /* Industry name */ + SetDParam(p++, i->index); - if (i->produced_cargo[1] != CT_INVALID) { - SetDParam(3, i->produced_cargo[1]); - SetDParam(4, i->last_month_production[1]); - SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8); - SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8); - DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, TC_FROMSTRING); - } else { - SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8); - DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, TC_FROMSTRING); - } - } else { - DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, TC_FROMSTRING); + /* Industry productions */ + for (byte j = 0; j < lengthof(i->produced_cargo); j++) { + if (i->produced_cargo[j] == CT_INVALID) continue; + SetDParam(p++, i->produced_cargo[j]); + SetDParam(p++, i->last_month_production[j]); } - p++; + + /* Transported productions */ + for (byte j = 0; j < lengthof(i->produced_cargo); j++) { + if (i->produced_cargo[j] == CT_INVALID) continue; + SetDParam(p++, i->last_month_pct_transported[j] * 100 >> 8); + } + + /* Drawing the right string */ + StringID str = STR_INDUSTRYDIR_ITEM_NOPROD; + if (p != 1) str = (p == 4) ? STR_INDUSTRYDIR_ITEM : STR_INDUSTRYDIR_ITEM_TWO; + DrawString(4, 28 + n * 10, str, TC_FROMSTRING); + + pos++; if (++n == w->vscroll.cap) break; } } break; |