anchor.diff:    Result := 0;
     aIdx := (aPL*fPolygons + aIdx) shl 2;
     for GT := Low(TGroupType) to High(TGroupType) do
  -    Result := Result + fPresence[aIdx + Byte(GT)];
  +    Result := Min(High(Word), Result + fPresence[aIdx + Byte(GT)]);
   end;
   
   
  
positive.code: end;
  
  
  function TKMInfluences.GetOwnershipFromPoint(const aPL: TKMHandIndex; aY, aX: Word): Byte;
  var
    POM: Word;
  begin
    POM := fNavMesh.FindClosestPolygon(KMPoint(aX,aY));
    Result := GetOwnership(aPL, POM);
  end;
  
  
  procedure TKMInfluences.SetOwnershipFromPoint(const aPL: TKMHandIndex; aY, aX: Word; const aOwnership: Byte);
  begin
    aX := fNavMesh.FindClosestPolygon(KMPoint(aX,aY));
    SetOwnership(aPL, aX, aOwnership);
  end;
  
  
  function TKMInfluences.GetBestOwner(aX,aY: Word): TKMHandIndex;
  begin
    aX := fNavMesh.FindClosestPolygon(KMPoint(aX,aY));
    Result := GetBestOwner(aX);
  end;
  
  
  
negative.code: begin
    aIdx := ((aPL*fPolygons + aIdx) shl 2) + Byte(aGT);
    fPresence[aIdx] := fPresence[aIdx] + aPresence;
  end;
  
  
  function TKMInfluences.GetEnemyGroupPresence(const aPL: TKMHandIndex; const aIdx: Word; const aGT: TGroupType): Word;
  var
    PL: TKMHandIndex;
  begin
    Result := 0;
    for PL := 0 to gHands.Count - 1 do
      if gHands[PL].Enabled AND (gHands[aPL].Alliances[PL] = at_Enemy) then
        Result := Result + Presence[PL, aIdx, aGT];
  end;
  
  
  procedure TKMInfluences.UpdateMilitaryPresence(const aPL: TKMHandIndex);
  const
    EACH_X_MEMBER_COEF = 10;
    MAX_DISTANCE = 20;
  var
    I, K, Cnt: Integer;
    GT: TGroupType;
  