From 8cfe4d6a67ddbde35169adbe2ea0b1c87730ac82 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 3 Nov 2006 23:06:54 +0000 Subject: (svn r7057) -Codechange: Remove hardcoded lists of road vehicles for each cargo type in favour of just checking the cargo type of each vehicle. --- ai/default/default.c | 7 +++++-- ai/trolly/build.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'ai') 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; diff --git a/ai/trolly/build.c b/ai/trolly/build.c index ff2158395..059500dc4 100644 --- a/ai/trolly/build.c +++ b/ai/trolly/build.c @@ -232,8 +232,8 @@ EngineID AiNew_PickVehicle(Player *p) // Not supported yet return INVALID_ENGINE; } else { - EngineID start = _cargoc.ai_roadveh_start[p->ainew.cargo]; - EngineID end = start + _cargoc.ai_roadveh_count[p->ainew.cargo]; + EngineID start = ROAD_ENGINES_INDEX; + EngineID end = ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; EngineID i; // Let's check it backwards.. we simply want to best engine available.. @@ -241,6 +241,9 @@ EngineID AiNew_PickVehicle(Player *p) const Engine* e = GetEngine(i); int32 ret; + /* Skip vehicles which can't take our cargo type */ + if (RoadVehInfo(i)->cargo_type != p->ainew.cargo) continue; + // Is it availiable? // Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY if (!HASBIT(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue; -- cgit v1.2.3-70-g09d2