summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorskidd13 <skidd13@openttd.org>2007-12-03 09:19:19 +0000
committerskidd13 <skidd13@openttd.org>2007-12-03 09:19:19 +0000
commit82913a21348a741eaacee6c81a57eba9a2c00250 (patch)
treeffda3073f527cfcef5eb31264655b305398d87ab /src/ai
parent1a43c6a6f6d78c1bbdebe8278ac67b6c2d5a8854 (diff)
downloadopenttd-82913a21348a741eaacee6c81a57eba9a2c00250.tar.xz
(svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/default/default.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index e0aa1ae00..d1979ed82 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -1653,13 +1653,11 @@ clear_town_stuff:;
k = 0;
// Build the rail
- for (i = 0; i != 6; i++, j >>= 1) {
- if (j & 1) {
- k = i;
- ret = DoCommand(c, railtype, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
- if (CmdFailed(ret)) return CMD_ERROR;
- total_cost.AddCost(ret);
- }
+ FOR_EACH_SET_BIT(i, j) {
+ k = i;
+ ret = DoCommand(c, railtype, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
+ if (CmdFailed(ret)) return CMD_ERROR;
+ total_cost.AddCost(ret);
}
/* signals too? */
@@ -2854,7 +2852,6 @@ static bool AiCheckRoadFinished(Player *p)
TileIndex tile;
DiagDirection dir = p->ai.cur_dir_a;
uint32 bits;
- int i;
are.dest = p->ai.cur_tile_b;
tile = TILE_MASK(p->ai.cur_tile_a + TileOffsByDiagDir(dir));
@@ -2865,7 +2862,8 @@ static bool AiCheckRoadFinished(Player *p)
are.best_dist = (uint)-1;
- for_each_bit(i, bits) {
+ uint i;
+ FOR_EACH_SET_BIT(i, bits) {
FollowTrack(tile, 0x3000 | TRANSPORT_ROAD, ROADTYPES_ROAD, (DiagDirection)_dir_by_track[i], (TPFEnumProc*)AiEnumFollowRoad, NULL, &are);
}