Mercurial > hg > openttd
changeset 4760:d28839f12cf5 draft
(svn r6674) -Fix r6631: two loops had incorrect behaviour (out of bound access in widget arrays)
author | glx <glx@openttd.org> |
---|---|
date | Fri, 06 Oct 2006 23:17:04 +0000 |
parents | 7eef5a2e8028 |
children | 1bafc336460b |
files | graph_gui.c |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graph_gui.c +++ b/graph_gui.c @@ -224,10 +224,9 @@ switch (e->event) { case WE_CREATE: { - uint include_bits = ~_legend_excludebits; int i; - for (i = 0; include_bits != 0; i++, include_bits >>= 1) { - if (HASBIT(include_bits, 0)) LowerWindowWidget(w, i + 3); + for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { + if (!HASBIT(_legend_excludebits, i)) LowerWindowWidget(w, i + 3); } break; } @@ -706,10 +705,9 @@ { switch (e->event) { case WE_CREATE: { - uint to_select = ~_legend_cargobits; int i; - for (i = 0; to_select != 0; i++, to_select >>= 1) { - if (HASBIT(to_select, 0)) LowerWindowWidget(w, i + 3); + for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { + if (!HASBIT(_legend_cargobits, i)) LowerWindowWidget(w, i + 3); } break; }