diff -r 2d983c15a049 -r 3ad9dfb5430d src/ai/default/default.cpp --- a/src/ai/default/default.cpp Tue May 20 22:05:25 2008 +0000 +++ b/src/ai/default/default.cpp Sun Jun 01 16:45:32 2008 +0000 @@ -3377,7 +3377,8 @@ AirportFTAClass::Flags flags = st->Airport()->flags; - if (!(flags & (_players_ai[p->index].build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) { + /* if airport doesn't accept our kind of plane, dismiss it */ + if (!(flags & (_players_ai[p->index].build_kind == 1 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) { continue; } @@ -3463,12 +3464,29 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, CommandCost *cost) { const AiDefaultBlockData *p; - uint i; - - for (i = 0; (p = _airport_default_block_data[i]) != NULL; i++) { - // If we are doing a helicopter service, avoid building - // airports where they can't land. - if (heli && !(GetAirport(p->attr)->flags & AirportFTAClass::HELICOPTERS)) continue; + + bool no_small = false; + + if (!heli) { + /* do not build small airport if we have large available and we are not building heli route */ + uint valid = GetValidAirports(); + for (uint i = 0; (p = _airport_default_block_data[i]) != NULL; i++) { + uint flags = GetAirport(p->attr)->flags; + if (HasBit(valid, p->attr) && (flags & AirportFTAClass::AIRPLANES) && !(flags & AirportFTAClass::SHORT_STRIP)) { + no_small = true; + break; + } + } + } + + for (uint i = 0; (p = _airport_default_block_data[i]) != NULL; i++) { + uint flags = GetAirport(p->attr)->flags; + /* If we are doing a helicopter service, avoid building airports where they can't land */ + if (heli && !(flags & AirportFTAClass::HELICOPTERS)) continue; + /* Similiar with aircraft ... */ + if (!heli && !(flags & AirportFTAClass::AIRPLANES)) continue; + /* Do not build small airport if we prefer large */ + if (no_small && (flags & AirportFTAClass::SHORT_STRIP)) continue; *cost = AiDoBuildDefaultAirportBlock(tile, p, 0); if (CmdSucceeded(*cost) && AiCheckAirportResources(tile, p, cargo))