summaryrefslogtreecommitdiff
path: root/ai/default/default.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-03 23:06:54 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-03 23:06:54 +0000
commite10ba5fdc5b0d317979291f9994fda0453cc13e9 (patch)
treebbeb158718e6311e12e482d43ddb9114a924372a /ai/default/default.c
parent6b44b88e9f8ed979b038091d2694a49070e2ef62 (diff)
downloadopenttd-e10ba5fdc5b0d317979291f9994fda0453cc13e9.tar.xz
(svn r7057) -Codechange: Remove hardcoded lists of road vehicles for each cargo type in favour of just checking the cargo type of each vehicle.
Diffstat (limited to 'ai/default/default.c')
-rw-r--r--ai/default/default.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index b78abb5ac..6794d9f26 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -163,8 +163,8 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex til
{
EngineID best_veh_index = INVALID_ENGINE;
int32 best_veh_cost = 0;
- EngineID i = _cargoc.ai_roadveh_start[cargo];
- EngineID end = i + _cargoc.ai_roadveh_count[cargo];
+ EngineID i = ROAD_ENGINES_INDEX;
+ EngineID end = i + NUM_ROAD_ENGINES;
for (; i != end; i++) {
const Engine* e = GetEngine(i);
@@ -174,6 +174,9 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex til
continue;
}
+ /* Skip vehicles which can't take our cargo type */
+ if (RoadVehInfo(i)->cargo_type != cargo) continue;
+
ret = DoCommand(tile, i, 0, 0, CMD_BUILD_ROAD_VEH);
if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
best_veh_cost = ret;