anchor.diff:  end;
   
   
  -function TKMTerrain.GetFieldType(const Loc: TKMPoint): TKMFieldType;
  +function TKMTerrain.GetFieldType(const aLoc: TKMPoint): TKMFieldType;
   begin
     Result := ftNone;
  -  if not TileInMapCoords(Loc.X, Loc.Y) then Exit;
  -
  -  if TileHasRoad(Loc) then
  +  if not TileInMapCoords(aLoc.X, aLoc.Y) then Exit;
  +
  +  if TileHasRoad(aLoc) then
       Result := ftRoad
     else
  -  if TileIsCornField(Loc) then
  +  if TileIsCornField(aLoc) then
       Result := ftCorn
     else
  -  if TileIsWineField(Loc) then
  +  if TileIsWineField(aLoc) then
       Result := ftWine;
   end;
   
  
positive.code: end;
  
  
  procedure TKMTerrain.UpdatePassability(const Loc: TKMPoint);
  
    procedure AddPassability(aPass: TKMTerrainPassability);
    begin
      Land[Loc.Y,Loc.X].Passability := Land^[Loc.Y,Loc.X].Passability + [aPass];
    end;
  
  var
    I, K: Integer;
    hasHousesNearTile, housesNearVertex, isBuildNoObj: Boolean;
  begin
    Assert(TileInMapCoords(Loc.X, Loc.Y)); //First of all exclude all tiles outside of actual map
  
    Land^[Loc.Y,Loc.X].Passability := [];
  
    if TileIsWalkable(Loc)
      and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
      and CheckHeightPass(Loc, hpWalking) then
      AddPassability(tpOwn);
  
    //For all passability types other than CanAll, houses and fenced houses are excluded
    if Land^[Loc.Y,Loc.X].TileLock in [tlNone, tlFenced, tlFieldWork, tlRoadWork] then
    begin
      if TileIsWalkable(Loc)
        and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
        and CheckHeightPass(Loc, hpWalking) then
        AddPassability(tpWalk);
  
      if (Land^[Loc.Y,Loc.X].TileOverlay = toRoad)
      and (tpWalk in Land^[Loc.Y,Loc.X].Passability) then //Not all roads are walkable, they must also have CanWalk passability
        AddPassability(tpWalkRoad);
  
      //Check for houses around this tile/vertex
      hasHousesNearTile := False;
      for I := -1 to 1 do
        for K := -1 to 1 do
          if TileInMapCoords(Loc.X+K, Loc.Y+I)
            and (Land^[Loc.Y+I,Loc.X+K].TileLock in [tlFenced,tlDigged,tlHouse]) then
            hasHousesNearTile := True;
  
      isBuildNoObj := False;
      if TileIsRoadable(Loc)
        and not TileIsCornField(Loc) //Can't build houses on fields
        and not TileIsWineField(Loc)
        and (Land^[Loc.Y,Loc.X].TileLock = tlNone)
        and TileInMapCoords(Loc.X, Loc.Y, 1)
        and CheckHeightPass(Loc, hpBuilding) then
      begin
        AddPassability(tpBuildNoObj);
        isBuildNoObj := True;
      end;
  
      if isBuildNoObj and not hasHousesNearTile
        and((Land[Loc.Y,Loc.X].Obj = OBJ_NONE) or (gMapElements[Land^[Loc.Y,Loc.X].Obj].CanBeRemoved)) then //Only certain objects are excluded
        AddPassability(tpBuild);
  
      if TileIsRoadable(Loc)
        and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
        and (Land^[Loc.Y,Loc.X].TileLock = tlNone)
        and (Land^[Loc.Y,Loc.X].TileOverlay <> toRoad)
        and CheckHeightPass(Loc, hpWalking) then
        AddPassability(tpMakeRoads);
  
      if ObjectIsChopableTree(Loc, [caAge1, caAge2, caAge3, caAgeFull]) then
        AddPassability(tpCutTree);
  
      if TileIsWater(Loc) then
        AddPassability(tpFish);
  
      if TileIsSand(Loc)
        and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
        //TileLock checked in outer begin/end
        and not (Land^[Loc.Y,Loc.X].TileOverlay in ROAD_LIKE_OVERLAYS)
        and not TileIsCornField(Loc)
        and not TileIsWineField(Loc)
        and CheckHeightPass(Loc, hpWalking) then //Can't crab on houses, fields and roads (can walk on fenced house so you can't kill them by placing a house on top of them)
        AddPassability(tpCrab);
  
      if TileIsSoil(Loc.X,Loc.Y)
        and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
        //TileLock checked in outer begin/end
        //Wolf are big enough to run over roads, right?
        and not TileIsCornField(Loc)
        and not TileIsWineField(Loc)
        and CheckHeightPass(Loc, hpWalking) then
        AddPassability(tpWolf);
    end;
  
    if TileIsWalkable(Loc)
      and not gMapElements[Land^[Loc.Y,Loc.X].Obj].AllBlocked
      and CheckHeightPass(Loc, hpWalking)
      and (Land^[Loc.Y,Loc.X].TileLock <> tlHouse) then
      AddPassability(tpWorker);
  
    //Check all 4 corners ter kinds around vertice 
    if VerticeIsFactorable(Loc) then
      AddPassability(tpFactor);
  
    //Check for houses around this vertice(!)
  
negative.code: 
  
  //Check if requested tile is water suitable for fish and/or sail. No waterfalls, but swamps/shallow water allowed
  function TKMTerrain.TileIsWater(const aLoc: TKMPoint): Boolean;
  begin
    Result := TileIsWater(aLoc.X, aLoc.Y);
  end;
  
  
  