anchor.diff:            end;
       end;
       Assert(Result[K] <> TOO_BIG_VALUE, Format('[TileCornerTerrains] Can''t determine tile [%d:%d] terrain at Corner [%d]', [aX, aY, K]));
  +  end;
  +end;
  +
  +
  +//Get tile corners terrain kinds
  +function TKMTerrain.TileCornersTerKinds(aX, aY: Word): TKMTerrainKindsArray;
  +var
  +  K, L: Integer;
  +begin
  +  SetLength(Result, 4);
  +  for K := 0 to 3 do
  +  begin
  +    Result[K] := tkCustom;
  +    with gTerrain.Land[aY,aX] do
  +    begin
  +      if K in BaseLayer.Corners then
  +        Result[K] := TILE_CORNERS_TERRAIN_KINDS[BaseLayer.Terrain, (K + 4 - BaseLayer.Rotation) mod 4]
  +      else
  +        for L := 0 to LayersCnt - 1 do
  +          if K in Layer[L].Corners then
  +          begin
  +            Result[K] := gRes.Sprites.GetGenTerrainInfo(Layer[L].Terrain).TerKind;
  +            Break;
  +          end;
  +    end;
     end;
   end;
   
  
positive.code:   var
      Bits, BitsDiag: Byte;
    begin
      if not TileInMapCoords(X,Y) or TileHasStone(X,Y) then Exit;
  
      Bits := GetBits(X  ,Y-1)*1 +
              GetBits(X+1,Y  )*2 +
  
negative.code:       Land[Y,X].BaseLayer.Rotation := RotID[Bits];
      end;
      UpdatePassability(KMPoint(X,Y));
      AddToVisited(X,Y);
  
      //Floodfill through around tiles
      UpdateTransition(X,  Y-1, aTransitionType, aStep + 1); //  x x x
      UpdateTransition(X+1,Y,   aTransitionType, aStep + 1); //  x   x
      UpdateTransition(X,  Y+1, aTransitionType, aStep + 1); //  x x x
      UpdateTransition(X-1,Y,   aTransitionType, aStep + 1);
      UpdateTransition(X-1,Y-1, aTransitionType, aStep + 1);
      UpdateTransition(X+1,Y-1, aTransitionType, aStep + 1);
      UpdateTransition(X+1,Y+1, aTransitionType, aStep + 1);
      UpdateTransition(X-1,Y+1, aTransitionType, aStep + 1);
    end;
  
  var
  