1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-30 18:09:09 +00:00

(svn r3058) The default AI may not build dual headed trains under certain circumstances.

Simplify this check by testing the rail vehicle info flags instead of passing a global variable around.
Note: This is not exactly the original behaviour, because the Lev4 was always allowed to be built, but i guess that was a glitch.
This commit is contained in:
tron
2005-10-18 07:01:00 +00:00
parent d4463b4b95
commit d4752ba0da
3 changed files with 7 additions and 25 deletions

View File

@@ -133,12 +133,16 @@ static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag, TileIndex
const RailVehicleInfo *rvi = RailVehInfo(i);
const Engine* e = GetEngine(i);
if (e->railtype != railtype || rvi->flags & RVI_WAGON
|| !HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
if (e->railtype != railtype ||
rvi->flags & RVI_WAGON ||
(rvi->flags & RVI_MULTIHEAD && flag & 1) ||
!HASBIT(e->player_avail, _current_player) ||
e->reliability < 0x8A3D) {
continue;
}
ret = DoCommandByTile(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
if (!CmdFailed(ret) && (!(_cmd_build_rail_veh_var1&1) || !(flag&1)) && ret <= money &&
if (!CmdFailed(ret) && ret <= money &&
_cmd_build_rail_veh_score >= best_veh_score) {
best_veh_score = _cmd_build_rail_veh_score;
best_veh_index = i;