diff options
author | tron <tron@openttd.org> | 2005-11-15 11:46:49 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-11-15 11:46:49 +0000 |
commit | 3bf8d2ccbbf75533c3578bfebde1238b7293b3ad (patch) | |
tree | 0bba4bcbec8dbc4fc490bfa7376a2ee15cd3556c | |
parent | 66d44766a7cb4f8ba61ece7ab9e932d7ba99c1d3 (diff) | |
download | openttd-3bf8d2ccbbf75533c3578bfebde1238b7293b3ad.tar.xz |
(svn r3190) Turn some loops into canonical for loop form
-rw-r--r-- | ai/default/default.c | 5 | ||||
-rw-r--r-- | disaster_cmd.c | 12 | ||||
-rw-r--r-- | settings_gui.c | 7 |
3 files changed, 10 insertions, 14 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index 845428eeb..4f4283f1a 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -1765,8 +1765,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p) } // do the following 8 times - i = 8; - do { + for (i = 0; i < 8; i++) { // check if we can build the default track aib = &p->ai.src; j = p->ai.num_build_rec; @@ -1808,7 +1807,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p) assert(r != CMD_ERROR); } } while (++aib,--j); - } while (--i); + } // check if we're done with all of them aib = &p->ai.src; diff --git a/disaster_cmd.c b/disaster_cmd.c index 1f4c72098..ff4d6712a 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -904,9 +904,9 @@ static void Disaster7_Init(void) { int index = GB(Random(), 0, 4); Industry *i; - int maxloop = 15; + uint m; - do { + for (m = 0; m < 15; m++) { FOR_ALL_INDUSTRIES(i) { if (i->xy != 0 && i->type == IT_COAL_MINE && --index < 0) { @@ -917,17 +917,17 @@ static void Disaster7_Init(void) { TileIndex tile = i->xy; TileIndexDiff step = TileOffsByDir(GB(Random(), 0, 2)); + uint n; - int count = 30; - do { + for (n = 0; n < 30; i++) { DisasterClearSquare(tile); tile = TILE_MASK(tile + step); - } while (--count); + } } return; } } - } while (--maxloop != 0); + } } static DisasterInitProc * const _disaster_initprocs[] = { diff --git a/settings_gui.c b/settings_gui.c index 3f6b520d2..433a7799d 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -1277,13 +1277,10 @@ void ShowNewgrf(void) { // little helper function to calculate _grffile_count // should be REMOVED once _grffile_count is calculated at loading - const GRFFile* c = _first_grffile; + const GRFFile* c; _grffile_count = 0; - while (c != NULL) { - _grffile_count++; - c = c->next; - } + for (c = _first_grffile; c != NULL; c = c->next) _grffile_count++; } w->vscroll.cap = 12; |