anchor.diff:      Node := Node.Next;
     end;
   end; *)
  +
  +function TTileMap.AllocateHeuristedNode(X, Y: NativeInt): PCPFNode;
  +var
  +  Cell: PCPFCell;
  +  Node, Right: PCPFNode;
  +  NodeInfo: NativeUInt;
  +  Mask: NativeInt;
  +  SortValue: Cardinal;
  +
  +  {$ifdef LARGEINT}
  +    NodeBuffers: PCPFNodeBuffers;
  +  {$endif}
  +begin
  +  Cell := @FInfo.CellArray[FInfo.MapWidth * Y + X];
  +
  +  {$ifdef LARGEINT}
  +  NodeBuffers := Pointer(@FInfo.NodeAllocator.Buffers);
  +  {$endif}
  +
  +  NodeInfo := Cell.NodePtr;
  +  if (NodeInfo and NODEPTR_FLAG_HEURISTED = 0) then
  +  begin
  +    if (NodeInfo and NODEPTR_FLAG_ALLOCATED = 0) then
  +    begin
  +      // allocate new node
  +      Node := FInfo.NodeAllocator.NewNode;
  +      Node.NodeInfo := NodeInfo;
  +      {$ifdef LARGEINT}
  +        Cell.NodePtr := NativeUInt(NativeInt(Node) + FInfo.NodeAllocator.LargeModifier +
  +          (NODEPTR_FLAG_HEURISTED + NODEPTR_FLAG_ALLOCATED));
  +      {$else}
  +        Cell.NodePtr := NativeUInt(Node) + (NODEPTR_FLAG_HEURISTED + NODEPTR_FLAG_ALLOCATED);
  +      {$endif}
  +      Cardinal(Node.Coordinates) := Y + (X shl 16);
  +
  +      // set next allocable node
  +      if (Node <> FInfo.NodeAllocator.NewNodeLimit) then
  +      begin
  +        Inc(Node);
  +        FInfo.NodeAllocator.NewNode := Node;
  +        Dec(Node);
  +      end else
  +      begin
  +        GrowNodeAllocator(FInfo);
  +      end;
  +    end else
  +    begin
  +      // take allocated node, mark as heuristed
  +      {$ifdef LARGEINT}
  +        Node := Pointer(
  +          (NodeBuffers[NodeInfo shr LARGE_NODEPTR_OFFSET]) +
  +          (NodeInfo and NODEPTR_CLEAN_MASK) );
  +        Cell.NodePtr := NodeInfo + NODEPTR_FLAG_HEURISTED;
  +      {$else}
  +        Node := Pointer(NodeInfo and NODEPTR_CLEAN_MASK);
  +        Cell.NodePtr := Cardinal(Node) + (NODEPTR_FLAG_HEURISTED + NODEPTR_FLAG_ALLOCATED);
  +      {$endif}
  +    end;
  +
  +    // heuristics data
  +    // (dX, dY) = Node.Coordinates - FInfo.FinishPoint;
  +    Mask := Cardinal(FInfo.FinishPoint);
  +    Y := Y - Word(Mask);
  +    X := X - (Mask shr 16);
  +
  +    // Way
  +    Mask := 2*Byte(Y > 0) + (Y shr HIGH_NATIVE_BIT);
  +    Mask := Mask * 3;
  +    Mask := Mask + 2*Byte(X > 0);
  +    Mask := Mask - 1 + (X shr {$ifdef CPUX86}31{$else}HIGH_NATIVE_BIT{$endif}); // Delphi compiler optimization bug
  +    Node.NodeInfo := Node.NodeInfo or Cardinal(Mask shl 3);
  +
  +    // Y := Abs(dY)
  +    Mask := -(Y shr HIGH_NATIVE_BIT);
  +    Y := Y xor Mask;
  +    Dec(Y, Mask);
  +
  +    // X := Abs(dX)
  +    Mask := -(X shr HIGH_NATIVE_BIT);
  +    X := X xor Mask;
  +    Dec(X, Mask);
  +
  +    // calculate
  +    Node.SortValue := SORTVALUE_LIMIT;
  +    if (FKind <> mkHexagonal) then
  +    begin
  +      if (X <= Y) then
  +      begin
  +        Node.Path := SORTVALUE_LIMIT -
  +           Cardinal(X * FInfo.HeuristicsDiagonal + (Y - X) * FInfo.HeuristicsLine);
  +      end else
  +      begin
  +        Node.Path := SORTVALUE_LIMIT -
  +           Cardinal(Y * FInfo.HeuristicsDiagonal + (X - Y) * FInfo.HeuristicsLine);
  +      end;
  +    end else
  +    begin
  +      X := X - ((Mask xor PNativeInt(@FInfo.FinishPoint)^) and Y and 1) - (Y shr 1);
  +      Node.Path := SORTVALUE_LIMIT -
  +         Cardinal(FInfo.HeuristicsLine * (Y + (X and ((X shr HIGH_NATIVE_BIT) - 1))));
  +    end;
  +  end else
  +  begin
  +    {$ifdef LARGEINT}
  +      Node := Pointer(
  +        (NodeBuffers[NodeInfo shr LARGE_NODEPTR_OFFSET]) +
  +        (NodeInfo and NODEPTR_CLEAN_MASK) );
  +    {$else}
  +      Node := Pointer(NodeInfo and NODEPTR_CLEAN_MASK);
  +    {$endif}
  +
  +    // already in heuristed pool case
  +    SortValue := Node.SortValue;
  +    if (SortValue < NATTANABLE_LENGTH_LIMIT) then
  +    begin
  +      Result := Node;
  +      Exit;
  +    end;
  +
  +    // clear sort value
  +    Node.Path := SORTVALUE_LIMIT - (SortValue - Node.Path);
  +    Node.SortValue := SORTVALUE_LIMIT;
  +  end;
  +
  +  // add to heuristed pool
  +  Right := FNodes.HeuristedPool.First.Next;
  +  Node.Next := Right;
  +  Right.Prev := Node;
  +  FNodes.HeuristedPool.First.Next := Node;
  +
  +  // result
  +  Result := Node;
  +end;
   
   function TTileMap.ActualizeWeights(Weights: PCPFWeightsInfo; Compare: Boolean): Boolean;
   label
  
positive.code:   {$endif}
    {$if Defined(DEBUG) and not Defined(CPFLIB)}
  
    // anti hint
    TTileMapPtr(nil).FlushHeuristedNodes(TCPFStart(nil^), TCPFNode(nil^));
    TTileMapPtr(nil).CalculateHeuristics(PPoint(nil)^, PPoint(nil)^);
    TTileMapPtr(nil).AddHeuristedNodes(nil, nil);
    {$ifend}
  
  
negative.code:       end;
      end;
  
      function AllocateHeuristedNode(X, Y: NativeInt): PCPFNode;
      function ActualizeWeights(Weights: PCPFWeightsInfo; Compare: Boolean): Boolean;
      function ActualizeStarts(Points: PPoint; Count: NativeUInt; Compare: Boolean): Boolean;
      function ActualizeExcludes(Points: PPoint; Count: NativeUInt; Compare: Boolean): Boolean;
  