anchor.diff:  
   procedure TKMNavMesh.Save(SaveStream: TKMemoryStream);
   var
  -  I,K: Integer;
  +  I: Integer;
   begin
     SaveStream.WriteA('NavMesh');
  +  SaveStream.Write(fMapX);
  +  SaveStream.Write(fMapY);
   
     SaveStream.Write(fNodeCount);
  -  for I := 0 to fNodeCount - 1 do
  -  begin
  -    SaveStream.Write(fNodes[I].Loc);
  -
  -    SaveStream.Write(Integer(Length(fNodes[I].Nearby)));
  -    for K := 0 to Length(fNodes[I].Nearby) - 1 do
  -      SaveStream.Write(fNodes[I].Nearby[K]);
  -  end;
  +  SaveStream.Write(fNodes[0], SizeOf(fNodes[0]) * fNodeCount);
   
     SaveStream.Write(fPolyCount);
  -  // In current implementation there could be just:
  -  // SaveStream.Write(fPolygons[0], SizeOf(TPolygon) * fPolyCount);
  -  // but future implementation may be changed so this will save some work
  -  for I := 0 to fPolyCount - 1 do
  -  begin
  -    SaveStream.Write(fPolygons[I].CenterPoint);
  -    SaveStream.Write(fPolygons[I].Indices, SizeOf(fPolygons[I].Indices));
  -    SaveStream.Write(fPolygons[I].NearbyCount);
  -    SaveStream.Write(fPolygons[I].Poly2PointStart);
  -    SaveStream.Write(fPolygons[I].Poly2PointCnt);
  -    SaveStream.Write(fPolygons[I].Nearby, SizeOf(fPolygons[I].Nearby));
  -    SaveStream.Write(fPolygons[I].NearbyPoints, SizeOf(fPolygons[I].NearbyPoints));
  -  end;
  +  SaveStream.Write(fPolygons[0], SizeOf(fPolygons[0]) * fPolyCount);
  +  // Maybe this code will save work in future
  +  //for I := 0 to fPolyCount - 1 do
  +  //begin
  +  //  SaveStream.Write(fPolygons[I].CenterPoint);
  +  //  SaveStream.Write(fPolygons[I].Indices, SizeOf(fPolygons[I].Indices));
  +  //  SaveStream.Write(fPolygons[I].NearbyCount);
  +  //  SaveStream.Write(fPolygons[I].Poly2PointStart);
  +  //  SaveStream.Write(fPolygons[I].Poly2PointCnt);
  +  //  SaveStream.Write(fPolygons[I].Nearby, SizeOf(fPolygons[I].Nearby));
  +  //  SaveStream.Write(fPolygons[I].NearbyPoints, SizeOf(fPolygons[I].NearbyPoints));
  +  //end;
   
     I := Length(fPoint2PolygonArr);
     SaveStream.Write( I );
  -  K := 0;
  -  if (I > 0) then
  -    K := Length(fPoint2PolygonArr[0]);
  -  SaveStream.Write( K );
  -  for I := 0 to Length(fPoint2PolygonArr) - 1 do
  -    SaveStream.Write(fPoint2PolygonArr[I,0], SizeOf(fPoint2PolygonArr[0,0]) * K );
  -
  -  I := Length(fPolygon2PointArr);
  -  SaveStream.Write( I );
  -  SaveStream.Write(fPolygon2PointArr[0], SizeOf(fPolygon2PointArr[0]) * I );
  +  SaveStream.Write(fPoint2PolygonArr[0], SizeOf(fPoint2PolygonArr[0]) * I );
  +
  +  //I := Length(fPolygon2PointArr);
  +  //SaveStream.Write( I );
  +  //SaveStream.Write(fPolygon2PointArr[0], SizeOf(fPolygon2PointArr[0]) * I );
   
     // The following does not requires save
     // fDefences
  
positive.code:       NearbyPoints: array [0..2] of TKMPoint; // Center points
      end;
  
    TNodeArray = array of TNode;
    TPolygonArray = array of TPolygon;
  
    //NavMesh is used to acess the map on a higher level than tiles
    //terrain is represented as a mesh interconnected polygons
    TKMNavMesh = class
    private
      //Keep a copy of these temp arrays for debug rendering
      fRawOutlines: TKMShapesArray;
      fSimpleOutlines: TKMShapesArray;
      fRawMesh: TKMTriMesh;
  
      //Working data
      fNodeCount: Integer;
      fPolyCount: Integer;
      fNodes: TNodeArray;               // Nodes
      fPolygons: TPolygonArray;         // Polygons
      fPoint2PolygonArr: TKMWord2Array; // KMPoint -> Polygon index
      fPolygon2PointArr: TKMPointArray; // Polygon index -> KMPoint
  
  
      fDefences: TForwardFF; //Defences class
      fPathfinding: TNavMeshPathFinding; // NavMesh Pathfinding
      fPositioning: TNavMeshFloodPositioning; // NavMesh Positioning
  
      //Building the navmesh from terrain
      //Process involves many steps executed in a functional way
      procedure GenerateTileOutline(out aTileOutlines: TKMShapesArray);
      procedure TriangulateOutlines;
      procedure AssembleNavMesh;
      procedure InitConnectivity;
      function FindClosestPolygon(aP: TKMPoint): Word;
      procedure TieUpTilesWithPolygons();
      procedure TieUpPolygonsWithTiles();
  
      function GetPolygonFromPoint(const aPoint: TKMPoint): Word;
    public
      constructor Create();
      destructor Destroy(); override;
      procedure Save(SaveStream: TKMemoryStream);
      procedure Load(LoadStream: TKMemoryStream);
  
      property Point2Polygon: TKMWord2Array read fPoint2PolygonArr;
      property KMPoint2Polygon[const aPoint: TKMPoint]: Word read GetPolygonFromPoint;
      property Polygon2Point: TKMPointArray read fPolygon2PointArr;
      property Polygons: TPolygonArray read fPolygons;
      property Nodes: TNodeArray read fNodes;
      property Defences: TForwardFF read fDefences write fDefences;
      property Pathfinding: TNavMeshPathFinding read fPathfinding write fPathfinding;
      property Positioning: TNavMeshFloodPositioning read fPositioning write fPositioning;
  
      procedure AfterMissionInit();
      //procedure GetDefenceOutline(aOwner: TKMHandIndex; out aOutline1, aOutline2: TKMWeightSegments);
  
      procedure UpdateState(aTick: Cardinal);
      procedure Paint(const aRect: TKMRect);
    end;
  
  const
    // Constants in KM_PolySimplify must be also changed!!!
    NAVMESH_SUPPORT_DENSITY = 7; // Density of NavMesh
    NAVMESH_EDGE_POINTS_TOLERANCE = 1; // Shape edges (points) closer than this will be skipped (SHOULD be equal to 1)
    NAVMESH_SUPPORT_POINTS_TOLERANCE = 4; // Grid points closer than this will be skipped (+- 0.5 * NAVMESH_SUPPORT_DENSITY)
  
  
  implementation
  
negative.code: interface
  uses
    KM_PolySimplify,
    KM_CommonClasses, KM_CommonTypes, KM_Defaults, KM_Points, Contnrs,
    KM_NavMeshDefences,
    KromUtils, KM_CommonUtils,
    KM_NavMeshFloodPositioning, KM_NavMeshPathFinding;// TimeGet
  
  
  type
  
    TKMNavMeshByteArray = array[-1..257,-1..257] of Byte;
    TKMNavMeshWordArray = array[-1..257,-1..257] of Word;
  
    // Borders
    TKMBord = record
      Node, Prev, Next, NextY: Word;
    end;
    TKMBordInfo = record
      Count: Word;
      Borders: array[0..6000] of TKMBord;
    end;
  
    // PolyLines
    PPolyLine = ^TKMPolyLine;
    TKMPolyLine = record
      Node,Polygon: Word;
      Next: PPolyLine;
    end;
    PPolyLines = ^TKMPolyLines;
    TKMPolyLines = record
    	LeftEdge, RightEdge, FutureLeftEdge, FutureRightEdge: Word;
      FirstLine, LastLine: PPolyLine;
    end;
  
  
    TDebugLines = record // Only for debug
      Count: Word;
      Lines: array[0..15000] of record
        P1,P2: TKMPoint;
      end;
    end;
  
    TPolygon = record
        CenterPoint: TKMPoint;
  