anchor.diff:              if TestTile.TerType <> centerTile.TerType then
               begin
                 TestTile.TerType:=centerTile.TerType;
  +              FOutQueue.Delete(TestTile);
                 FOutQueue.Insert(TestTile);
   
  -              invalid := GetInvalidTiles(TestTile);
  -
  -              nativeTilesCntNorm:=ifthen(invalid.NativeTiles.IsEmpty, MaxInt, invalid.NativeTiles.Size);
  -
  -              if (nativeTilesCntNorm > invalidNativeTilesCnt)
  -                or ((nativeTilesCntNorm = invalidNativeTilesCnt) and (SizeInt(invalid.ForeignTiles.Size) < invalidForeignTilesCnt) ) then
  +              testTiles := GetInvalidTiles(TestTile);
  +
  +              nativeTilesCntNorm:=ifthen(testTiles.NativeTiles.IsEmpty, MaxInt, testTiles.NativeTiles.Size);
  +
  +    					putSuitableTile  := false;
  +    					addToSuitableTiles := false;
  +
  +              if testTiles.centerPosValid then
                 begin
  -                invalidNativeTilesCnt := nativeTilesCntNorm;
  -                invalidForeignTilesCnt:=invalid.ForeignTiles.Size;
  +                if not centerPosValid then
  +                begin
  +                  centerPosValid := true;
  +                  putSuitableTile := true;
  +                end
  +                else
  +                begin
  +                  if testTiles.ForeignTiles.Size < invalidForeignTilesCnt then
  +                  begin
  +                    putSuitableTile := true;
  +                  end
  +                  else
  +                  begin
  +                    addToSuitableTiles := true;
  +                  end;
  +                end;
  +              end
  +              else if not centerPosValid then
  +              begin
  +                 if (nativeTilesCntNorm > invalidNativeTilesCnt)
  +                   or ((nativeTilesCntNorm = invalidNativeTilesCnt) and (tiles.ForeignTiles.Size < invalidForeignTilesCnt)) then
  +                 begin
  +                   putSuitableTile := true;
  +                 end
  +                 else if (nativeTilesCntNorm = invalidNativeTilesCnt) and (tiles.ForeignTiles.Size = invalidForeignTilesCnt) then
  +                 begin
  +                   addToSuitableTiles := true;
  +                 end;
  +              end;
  +
  +              if putSuitableTile then
  +              begin
  +                invalidNativeTilesCnt:=nativeTilesCntNorm;
  +                invalidForeignTilesCnt:=tiles.ForeignTiles.Size;
                   SuitableTiles.Free;
                   SuitableTiles := TTileSet.Create;
  -
  -                SuitableTiles.Insert(TestTile);
  -
  -              end
  -              else if (nativeTilesCntNorm = invalidNativeTilesCnt) and (SizeInt(invalid.ForeignTiles.Size) = invalidForeignTilesCnt) then
  +                addToSuitableTiles := true;
  +              end;
  +
  +              if addToSuitableTiles then
                 begin
                   SuitableTiles.Insert(TestTile);
                 end;
   
  -              invalid.Free;
  +              FreeAndNil(testTiles);
                 FOutQueue.Delete(TestTile);
               end;
             end;
           end;
   
  -        tileRequiresValidation := invalidForeignTilesCnt > 0;
  -
           if SuitableTiles.Size = 1 then
           begin
  -          UpdateTerrain(SuitableTiles.NMin^.Data, tileRequiresValidation);
  +          UpdateTerrain(SuitableTiles.NMin^.Data);
           end
           else
           begin
  
positive.code:   TInvalidTiles = class
    public
      ForeignTiles, NativeTiles: TTileSet;
      constructor Create();
      destructor Destroy; override;
  
  
negative.code:   invalidForeignTilesCnt,invalidNativeTilesCnt,nativeTilesCntNorm: Integer;
    j: Integer;
  
    centerPosValid, addToSuitableTiles, putSuitableTile: Boolean;
  
    currentCoord: TMapCoord;
    delta: TMapCoord;
    testTiles: TInvalidTiles;
  
  begin
     while not FInQueue.IsEmpty do
     begin
  