/* 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();
for (local tile = tileList.Begin(); tileList.HasNext(); tile = tileList.Next()) {
local closest_town = AITile.GetClosestTown(tile);
if (closestTowns.HasItem(closest_town)) {
closestTownscopy.AddItem(town);
}
}
closestTowns.Clear();
closestTowns.AddList(closestTownscopy);
/* 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);
// }
// }