1
0
Fork 0

(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

release/0.5
rubidium 2006-12-04 13:46:03 +00:00
parent 11474c26d7
commit 756d6a6efb
4 changed files with 14 additions and 15 deletions

View File

@ -224,9 +224,9 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e)
switch (e->event) { switch (e->event) {
case WE_CREATE: { case WE_CREATE: {
int i; uint i;
for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { for (i = 3; i < w->widget_count; i++) {
if (!HASBIT(_legend_excludebits, i)) LowerWindowWidget(w, i + 3); if (!HASBIT(_legend_excludebits, i - 3)) LowerWindowWidget(w, i);
} }
break; break;
} }
@ -705,9 +705,9 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
{ {
switch (e->event) { switch (e->event) {
case WE_CREATE: { case WE_CREATE: {
int i; uint i;
for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) { for (i = 3; i < w->widget_count; i++) {
if (!HASBIT(_legend_cargobits, i)) LowerWindowWidget(w, i + 3); if (!HASBIT(_legend_cargobits, i - 3)) LowerWindowWidget(w, i);
} }
break; break;
} }

View File

@ -1303,8 +1303,8 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
break; break;
case WE_TIMEOUT: { case WE_TIMEOUT: {
int i; uint i;
for (i = 0; w->widget[i].type != WWT_LAST; i++) { for (i = 0; i < w->widget_count; i++) {
if (IsWindowWidgetLowered(w, i)) { if (IsWindowWidgetLowered(w, i)) {
RaiseWindowWidget(w, i); RaiseWindowWidget(w, i);
InvalidateWidget(w, i); InvalidateWidget(w, i);
@ -1848,8 +1848,8 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
break; break;
case WE_TIMEOUT: { case WE_TIMEOUT: {
int i; uint i;
for (i = 2; w->widget[i].type != WWT_LAST; i++) { for (i = 2; i < w->widget_count; i++) {
if (IsWindowWidgetLowered(w, i)) { if (IsWindowWidgetLowered(w, i)) {
RaiseWindowWidget(w, i); RaiseWindowWidget(w, i);
InvalidateWidget(w, i); InvalidateWidget(w, i);

View File

@ -552,8 +552,8 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
case WE_TIMEOUT: { // handle button unclick ourselves... case WE_TIMEOUT: { // handle button unclick ourselves...
// unclick all buttons except for the 'goto' button (7), which is 'persistent' // unclick all buttons except for the 'goto' button (7), which is 'persistent'
int i; uint i;
for (i = 0; w->widget[i].type != WWT_LAST; i++) { for (i = 0; i < w->widget_count; i++) {
if (IsWindowWidgetLowered(w, i) && i != 7) { if (IsWindowWidgetLowered(w, i) && i != 7) {
RaiseWindowWidget(w, i); RaiseWindowWidget(w, i);
InvalidateWidget(w, i); InvalidateWidget(w, i);

View File

@ -66,10 +66,9 @@ void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widget
void RaiseWindowButtons(Window *w) void RaiseWindowButtons(Window *w)
{ {
const Widget *wi = w->widget; uint i;
uint i = 0;
for (i = 0; wi->type != WWT_LAST; i++, wi++) { for (i = 0; i < w->widget_count; i++) {
if (IsWindowWidgetLowered(w, i)) { if (IsWindowWidgetLowered(w, i)) {
RaiseWindowWidget(w, i); RaiseWindowWidget(w, i);
InvalidateWidget(w, i); InvalidateWidget(w, i);