(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
authorrubidium
Mon, 04 Dec 2006 13:46:03 +0000
changeset 5235 2313d53f426a
parent 5234 980aa61260aa
child 5236 4c1289d5e45a
(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
graph_gui.c
main_gui.c
order_gui.c
window.c
--- a/graph_gui.c	Mon Dec 04 13:45:20 2006 +0000
+++ b/graph_gui.c	Mon Dec 04 13:46:03 2006 +0000
@@ -224,9 +224,9 @@
 
 	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 @@
 {
 	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;
 	}
--- a/main_gui.c	Mon Dec 04 13:45:20 2006 +0000
+++ b/main_gui.c	Mon Dec 04 13:46:03 2006 +0000
@@ -1303,8 +1303,8 @@
 		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 @@
 		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);
--- a/order_gui.c	Mon Dec 04 13:45:20 2006 +0000
+++ b/order_gui.c	Mon Dec 04 13:46:03 2006 +0000
@@ -552,8 +552,8 @@
 
 	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);
--- a/window.c	Mon Dec 04 13:45:20 2006 +0000
+++ b/window.c	Mon Dec 04 13:46:03 2006 +0000
@@ -66,10 +66,9 @@
 
 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);