diff options
author | rubidium <rubidium@openttd.org> | 2006-12-04 13:46:03 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-04 13:46:03 +0000 |
commit | 756d6a6efb64d0025e24fc4ea98b37d93d17868c (patch) | |
tree | ff3ed6156af7a65ae49ead114c7f736d5826790b | |
parent | 11474c26d7ebf2973081f15d7f8a4c445262f0bc (diff) | |
download | openttd-756d6a6efb64d0025e24fc4ea98b37d93d17868c.tar.xz |
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
-rw-r--r-- | graph_gui.c | 12 | ||||
-rw-r--r-- | main_gui.c | 8 | ||||
-rw-r--r-- | order_gui.c | 4 | ||||
-rw-r--r-- | window.c | 5 |
4 files changed, 14 insertions, 15 deletions
diff --git a/graph_gui.c b/graph_gui.c index fde5f50bc..eedeb949d 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -224,9 +224,9 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e) switch (e->event) { case WE_CREATE: { - int i; - for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { - if (!HASBIT(_legend_excludebits, i)) LowerWindowWidget(w, i + 3); + uint i; + for (i = 3; i < w->widget_count; i++) { + if (!HASBIT(_legend_excludebits, i - 3)) LowerWindowWidget(w, i); } break; } @@ -705,9 +705,9 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e) { switch (e->event) { case WE_CREATE: { - int i; - for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { - if (!HASBIT(_legend_cargobits, i)) LowerWindowWidget(w, i + 3); + uint i; + for (i = 3; i < w->widget_count; i++) { + if (!HASBIT(_legend_cargobits, i - 3)) LowerWindowWidget(w, i); } break; } diff --git a/main_gui.c b/main_gui.c index 8ecd7c988..9f6a6042c 100644 --- a/main_gui.c +++ b/main_gui.c @@ -1303,8 +1303,8 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) break; case WE_TIMEOUT: { - int i; - for (i = 0; w->widget[i].type != WWT_LAST; i++) { + uint i; + for (i = 0; i < w->widget_count; i++) { if (IsWindowWidgetLowered(w, i)) { RaiseWindowWidget(w, i); InvalidateWidget(w, i); @@ -1848,8 +1848,8 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) break; case WE_TIMEOUT: { - int i; - for (i = 2; w->widget[i].type != WWT_LAST; i++) { + uint i; + for (i = 2; i < w->widget_count; i++) { if (IsWindowWidgetLowered(w, i)) { RaiseWindowWidget(w, i); InvalidateWidget(w, i); diff --git a/order_gui.c b/order_gui.c index 52061507e..0232fc49c 100644 --- a/order_gui.c +++ b/order_gui.c @@ -552,8 +552,8 @@ static void OrdersWndProc(Window *w, WindowEvent *e) case WE_TIMEOUT: { // handle button unclick ourselves... // unclick all buttons except for the 'goto' button (7), which is 'persistent' - int i; - for (i = 0; w->widget[i].type != WWT_LAST; i++) { + uint i; + for (i = 0; i < w->widget_count; i++) { if (IsWindowWidgetLowered(w, i) && i != 7) { RaiseWindowWidget(w, i); InvalidateWidget(w, i); @@ -66,10 +66,9 @@ void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widget void RaiseWindowButtons(Window *w) { - const Widget *wi = w->widget; - uint i = 0; + uint i; - for (i = 0; wi->type != WWT_LAST; i++, wi++) { + for (i = 0; i < w->widget_count; i++) { if (IsWindowWidgetLowered(w, i)) { RaiseWindowWidget(w, i); InvalidateWidget(w, i); |