/* method 1 */
// for (local tile = 0; tile <= AIMap.GetMapSize(); tile++) {
// if (!AIMap.IsValidTile(tile)) continue;
// local dist = AITile.GetDistanceSquareToTile(tile, airport1_tile);
// local fake = WrightAI.DistanceRealFake(tile, airport1_tile);
// if (dist <= max_dist && dist >= min_dist && fake <= fakedist * 11 / 10) {
// tileList.AddItem(tile, dist);
// AISign.BuildSign(tile, ("" + dist + ""));
// }
// }
// if (tileList.Count() == 0) {
// //continue;
// AILog.Info("tileList.Count() is 0");
// }
// local closestTownscopy = AIList();
// closestTownscopy.AddList(closestTowns);
// for (local town = closestTownscopy.Begin(); closestTownscopy.HasNext(); town = closestTownscopy.Next()) {
// if (!tileList.HasItem(AITown.GetLocation(town))) {
// closestTowns.RemoveItem(town);
// }
// }
/* method 2 */
local closestTownscopy = AIList();
closestTownscopy.AddList(closestTowns);
for (local town = closestTownscopy.Begin(); closestTownscopy.HasNext(); town = closestTownscopy.Next()) {
local dist = AITile.GetDistanceSquareToTile(AITown.GetLocation(town), airport1_tile);
local fake = WrightAI.DistanceRealFake(AITown.GetLocation(town), airport1_tile);
if (!(dist <= max_dist && dist >= min_dist && fake <= fakedist * 11 / 10)) {
closestTowns.RemoveItem(town);
}
}
AILog.Info("There are " + closestTowns.Count() + " towns near " + AITown.GetName(AITile.GetClosestTown(airport1_tile)));
closestTowns.KeepTop(10);
}