(svn r3614) turn 2 do-while-loop with 2 induction variables each into canocical for loops
authortron
Sat, 18 Feb 2006 14:52:42 +0000
changeset 3034 4b1161fb9221
parent 3033 9cba043eb38f
child 3035 fbc01469d2ba
(svn r3614) turn 2 do-while-loop with 2 induction variables each into canocical for loops
ai/default/default.c
--- a/ai/default/default.c	Sat Feb 18 14:41:24 2006 +0000
+++ b/ai/default/default.c	Sat Feb 18 14:52:42 2006 +0000
@@ -159,9 +159,10 @@
 
 	EngineID i = _cargoc.ai_roadveh_start[cargo];
 	EngineID end = i + _cargoc.ai_roadveh_count[cargo];
-	const Engine* e = GetEngine(i);
-
-	do {
+
+	for (; i != end; i++) {
+		const Engine* e = GetEngine(i);
+
 		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
 			continue;
 
@@ -170,7 +171,7 @@
 			best_veh_cost = ret;
 			best_veh_index = i;
 		}
-	} while (++e, ++i != end);
+	}
 
 	return best_veh_index;
 }
@@ -183,9 +184,10 @@
 
 	EngineID i = AIRCRAFT_ENGINES_INDEX;
 	EngineID end = i + NUM_AIRCRAFT_ENGINES;
-	const Engine* e = GetEngine(i);
-
-	do {
+
+	for (; i != end; i++) {
+		const Engine* e = GetEngine(i);
+
 		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
 			continue;
 
@@ -200,7 +202,7 @@
 			best_veh_cost = ret;
 			best_veh_index = i;
 		}
-	} while (++e, ++i != end);
+	}
 
 	return best_veh_index;
 }