anchor.diff:  {Find closest harvestable deposit of Stone}
   {Return walkable tile below Stone deposit}
   function TTerrain.FindStone(aPosition:TKMPoint; aRadius:integer; aAvoidLoc:TKMPoint; out StonePoint: TKMPointDir):Boolean;
  -const Ins=2; //2..Map-2
  +const Ins=2; //2..Map-2, so that map edges keep the Stone? Could be 1 if we want to
   var i,k:integer; List:TKMPointDirList;
   begin
     List := TKMPointDirList.Create;
  
positive.code: end;
  
  
  {Take 4 neighbour heights and approach it}
  //@Lewin: I don't like approach we use - flatten the tile without note of neighbour tiles
  //Instead we might want to interpolate between surrounding 8 vertices (X and Y, no diagonals)
  //Also it should be FlattenTerrain duty to preserve walkability if there are units standing
  //@Krom: I agree with both of those. I've done the second one, maybe you can do the first? :) (I'm not 100% sure what you meant)
  procedure TTerrain.FlattenTerrain(Loc:TKMPoint; aRebuildWalkConnects:boolean=true);
  
    procedure EnsureWalkable(aX,aY:integer);
    var WasWalkable:boolean;
    begin
      //Check if tile occupied by Unit was walkable in previous state and now is unwalkable due to Height change
      //We should try restore walkability at least by flattening terrain, otherwise it's different and more serious error
      WasWalkable := (Land[aY,aX].IsUnit <> nil) and CheckPassability(KMPoint(aX,aY),CanWalk) and not CheckHeightPass(KMPoint(aX,aY),CanWalk);
      if WasWalkable and (fGame.GameState <> gsEditor) then //Allow units to become "stuck" in the map editor, as height changing is allowed anywhere
        //This recursive call should be garanteed to exit, as eventually the terrain will be flat enough.
        FlattenTerrain(KMPoint(aX,aY),false); //No need to rebuild the walk connect each time, it will be done at the end
    end;
  
  var TempH:byte; i,k: integer;
  begin
    TempH:=(
      Land[Loc.Y,Loc.X].Height+
      Land[Loc.Y+1,Loc.X].Height+
      Land[Loc.Y,Loc.X+1].Height+
      Land[Loc.Y+1,Loc.X+1].Height
    )div 4;
    if CheckPassability(KMPoint(Loc.X,Loc.Y),CanElevate) then
    Land[Loc.Y,Loc.X].Height:=mix(Land[Loc.Y,Loc.X].Height,TempH,0.5);
    if CheckPassability(KMPoint(Loc.X,Loc.Y+1),CanElevate) then
    Land[Loc.Y+1,Loc.X].Height:=mix(Land[Loc.Y+1,Loc.X].Height,TempH,0.5);
    if CheckPassability(KMPoint(Loc.X+1,Loc.Y),CanElevate) then
    Land[Loc.Y,Loc.X+1].Height:=mix(Land[Loc.Y,Loc.X+1].Height,TempH,0.5);
    if CheckPassability(KMPoint(Loc.X+1,Loc.Y+1),CanElevate) then
    Land[Loc.Y+1,Loc.X+1].Height:=mix(Land[Loc.Y+1,Loc.X+1].Height,TempH,0.5);
  
    //All 9 tiles around and including this one could have become unwalkable and made a unit stuck, so check them all
    for i:=-1 to 1 do
      for k:=-1 to 1 do
        EnsureWalkable(Loc.X+i,Loc.Y+k);
  
    RebuildLighting(Loc.X-2,Loc.X+3,Loc.Y-2,Loc.Y+3);
    RecalculatePassabilityAround(Loc); //Changing height will affect the cells around this one
  
negative.code: 
      //We UpdateTransition when the stone becomes grass, Bits can never = 15
      //The tile in center is fully mined and one below has Stoncutter on it,
      //hence there cant be any tile surrounded by stones from all sides
      Assert(Bits < 15);
      Land[Y,X].Terrain  := TileID[Bits];
      Land[Y,X].Rotation := RotID[Bits];
  