diff options
author | peter1138 <peter1138@openttd.org> | 2008-01-23 13:20:51 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-01-23 13:20:51 +0000 |
commit | 9515328962991b1992310ac29f312f5774ac1eaf (patch) | |
tree | 6d12d48aac0eca6ada4ebf4bbf95154cb4ac247e /src/ai/trolly | |
parent | a31ebdb2be267edced3b1fdc3a01034f2fa2d2bb (diff) | |
download | openttd-9515328962991b1992310ac29f312f5774ac1eaf.tar.xz |
(svn r11959) -Codechange: Use macro to loop for specific engine types instead of using specific indexes each time.
-Codechange: Minor scope changes in said loops.
Diffstat (limited to 'src/ai/trolly')
-rw-r--r-- | src/ai/trolly/build.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index 714d80ab8..329c54d34 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -234,16 +234,12 @@ EngineID AiNew_PickVehicle(Player *p) } else { EngineID best_veh_index = INVALID_ENGINE; int32 best_veh_rating = 0; - EngineID start = ROAD_ENGINES_INDEX; - EngineID end = ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; EngineID i; /* Loop through all road vehicles */ - for (i = start; i != end; i++) { + FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) { const RoadVehicleInfo *rvi = RoadVehInfo(i); const Engine* e = GetEngine(i); - int32 rating; - CommandCost ret; /* Skip vehicles which can't take our cargo type */ if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue; @@ -256,11 +252,11 @@ EngineID AiNew_PickVehicle(Player *p) if (!HasBit(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue; /* Rate and compare the engine by speed & capacity */ - rating = rvi->max_speed * rvi->capacity; + int rating = rvi->max_speed * rvi->capacity; if (rating <= best_veh_rating) continue; // Can we build it? - ret = AI_DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH); + CommandCost ret = AI_DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH); if (CmdFailed(ret)) continue; best_veh_rating = rating; |