anchor.diff:        Continue;
   
       //Don't check tiles farther than closest Warrior
  -    if aClosest and (W <> nil)
  -    and (KMLengthSqr(aLoc, KMPoint(K,I)) >= KMLengthSqr(aLoc, W.GetPosition)) then
  +    if aClosest and (W[0] <> nil)
  +    and (KMLengthSqr(aLoc, KMPoint(K,I)) >= KMLengthSqr(aLoc, W[0].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)
  
positive.code:   Should be optimized versus usual UnitsHitTest
    Prefer Warriors over Citizens}
  function TKMTerrain.UnitsHitTestWithinRad(aLoc: TKMPoint; MinRad, MaxRad: Single; aPlayer: TPlayerIndex; aAlliance: TAllianceType; Dir: TKMDirection; const aClosest: Boolean): Pointer;
  var
    I,K: Integer; //Counters
    LowX,LowY,HighX,HighY: Integer; //Ranges
    dX,dY: Integer;
    RequiredMaxRad: Single;
    U,C,W: TKMUnit; //CurrentUnit, BestWarrior, BestCitizen
    Warriors, Citizens: TList;
    P: TKMPoint;
  begin
    W := nil;
    C := nil;
  
    if not aClosest then
    begin
      Warriors := TList.Create;
      Citizens := TList.Create;
    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
  
negative.code:       if aClosest then
        begin
          if U is TKMUnitWarrior then
            W[0] := U
          else
            C[0] := U;
        end
        else
        begin
          if U is TKMUnitWarrior then
            Append(W, WCount, U)
          else
            Append(C, CCount, U);
        end;
    end;
  
    if aClosest then
    begin
      if W[0] <> nil then
        Result := W[0]
      else
        Result := C[0];
    end
    else
    begin
      if WCount > 0 then
        Result := W[KaMRandom(WCount)]
      else
        if CCount > 0 then
          Result := C[KaMRandom(CCount)]
        else
          Result := nil;
    end;
  end;
  
  