anchor.diff:        Continue;
   
       //Don't check tiles farther than closest Warrior
  -    if aClosest and (W<>nil) and (GetLength(KMPoint(aLoc.X,aLoc.Y),KMPoint(k,i)) >= GetLength(KMPoint(aLoc.X,aLoc.Y),W.GetPosition)) then
  +    if aClosest and (W <> nil)
  +    and (GetLength(aLoc, KMPoint(K,I)) >= GetLength(aLoc, W.GetPosition)) then
         Continue; //Since we check left-to-right we can't exit just yet (there are possible better enemies below)
   
       //In KaM archers can shoot further than sight radius (shoot further into explored areas)
       //so CheckTileRevelation is required, we can't remove it to optimise.
       //But because it will not invalidate many candidates, check it late so other checks can do their work first
  -    if (fPlayers.Player[aPlayer].FogOfWar.CheckTileRevelation(k,i,false) <> 255) then Continue;
  +    if (fPlayers.Player[aPlayer].FogOfWar.CheckTileRevelation(K,I,false) <> 255) then Continue;
   
       //This unit could be on a different tile next to KMPoint(k,i), so we cannot use that anymore.
       //There was a crash caused by VertexUsageCompatible checking (k,i) instead of U.GetPosition.
  
positive.code:     function TileIsLocked(aLoc:TKMPoint): Boolean;
      function UnitsHitTest(X,Y:word): Pointer;
      function UnitsHitTestF(aLoc: TKMPointF): Pointer;
      function UnitsHitTestWithinRad(aLoc:TKMPoint; MinRad, MaxRad:single; aPlayer:TPlayerIndex; aAlliance:TAllianceType; Dir:TKMDirection; aClosest:Boolean): Pointer;
  
      function ObjectIsChopableTree(Loc:TKMPoint; Stage: Byte): Boolean;
      function CanWalkDiagonaly(const A,B:TKMPoint): Boolean;
  
      procedure FlattenTerrain(Loc:TKMPoint; aUpdateWalkConnects: Boolean=true); overload;
      procedure FlattenTerrain(LocList:TKMPointList); overload;
  
negative.code:   end;
  
    //Scan one tile further than the maximum radius due to rounding
    LowX := Max(Round(aLoc.X-(MaxRad+1)), 1); //1.42 gets rounded to 1
    LowY := Max(Round(aLoc.Y-(MaxRad+1)), 1); //1.42 gets rounded to 1
    HighX := Min(Round(aLoc.X+(MaxRad+1)), fMapX); //1.42 gets rounded to 1
    HighY := Min(Round(aLoc.Y+(MaxRad+1)), fMapY); //1.42 gets rounded to 1
  
    for I := LowY to HighY do
    for K := LowX to HighX do
    if (Land[I,K].IsUnit <> nil) then
    begin
      //Check archer sector. If it's not within the 90 degree sector for this direction, then don't use this tile (continue)
      dX := K - aLoc.X;
      dY := I - aLoc.Y;
      case Dir of
        dir_N : if not ((Abs(dX) <= -dY) and (dY < 0)) then Continue;
        dir_NE: if not ((dX > 0)         and (dY < 0)) then Continue;
        dir_E:  if not ((dX > 0) and (Abs(dY) <= dX))  then Continue;
        dir_SE: if not ((dX > 0)         and (dY > 0)) then Continue;
        dir_S : if not ((Abs(dX) <= dY)  and (dY > 0)) then Continue;
        dir_SW: if not ((dX < 0)         and (dY > 0)) then Continue;
        dir_W:  if not ((dX < 0) and (Abs(dY) <= -dX)) then Continue;
        dir_NW: if not ((dX < 0)         and (dY < 0)) then Continue;
      end;
  
      U := Land[I,K].IsUnit;
  
      //Alliance is the check that will invalidate most candidates, so do it early on
      if (U = nil)
  