anchor.diff:      fDoor:TKMPoint;
       fStreet:TKMPoint;
       fHasStarted:boolean;
  +    fPushedUnit: TKMUnit;
       fWaitingForPush:boolean;
       fUsedDoorway:boolean;
       procedure IncDoorway;
       procedure DecDoorway;
       function FindBestExit(aLoc: TKMPoint): TBestExit;
  -    function ValidTileToGo(aLocX, aLocY:word; aUnit:TKMUnit):boolean; //using X,Y looks more clear
  +    function TileIsFree(X,Y: Word): Boolean;
  +    function TileHasIdleUnit(X,Y: Word): TKMUnit;
       procedure WalkIn;
       procedure WalkOut;
     public
  
positive.code:     SaveStream.Write(fUnit.ID) //Store ID, then substitute it with reference on SyncLoad
    else
      SaveStream.Write(Integer(0));
    SaveStream.Write(fDirection, SizeOf(fDirection));
    SaveStream.Write(fDoor);
    SaveStream.Write(fStreet);
  
negative.code: //Attempt to find a tile below the door (on the street) we can walk to
  //We can push idle units away. Check center first
  function TUnitActionGoInOut.FindBestExit(aLoc: TKMPoint): TBestExit;
  var
    U: TKMUnit;
  begin
    if TileIsFree(aLoc.X, aLoc.Y) then
      Result := be_Center
    else
    if TileIsFree(aLoc.X-1, aLoc.Y) then
      Result := be_Left
    else
    if TileIsFree(aLoc.X+1, aLoc.Y) then
      Result := be_Right
    else
    begin
      //U could be nil if tile is unwalkable for some reason
      U := TileHasIdleUnit(aLoc.X, aLoc.Y);
      if U <> nil then
        Result := be_Center
      else
      begin
        U := TileHasIdleUnit(aLoc.X-1, aLoc.Y);
        if U <> nil then
          Result := be_Left
        else
        begin
          U := TileHasIdleUnit(aLoc.X+1, aLoc.Y);
          if U <> nil then
            Result := be_Right
          else
            Result := be_None;
        end;
      end;
  
      if U <> nil then
      begin
        fPushedUnit := U.GetUnitPointer;
        fPushedUnit.SetActionWalkPushed(fTerrain.GetOutOfTheWay(U.GetPosition, KMPoint(0,0), CanWalk));
      end;
    end;
  end;
  
  
  function TUnitActionGoInOut.TileIsFree(X,Y: Word): Boolean; 
  begin
    Result := fTerrain.TileInMapCoords(X,Y)
          and (fTerrain.CheckPassability(KMPoint(X,Y), fUnit.GetDesiredPassability))
          and (fTerrain.CanWalkDiagonaly(fUnit.GetPosition, KMPoint(X,Y)))
          and (fTerrain.Land[Y,X].IsUnit = nil);
  end;
  
  
  //Check that tile is walkable and there's no unit blocking it or that unit can be pushed away
  function TUnitActionGoInOut.TileHasIdleUnit(X,Y: Word): TKMUnit;
  var U: TKMUnit;
  begin
    Result := nil;
  
    if fTerrain.TileInMapCoords(X,Y)
    and (fTerrain.CheckPassability(KMPoint(X,Y), fUnit.GetDesiredPassability))
    and (fTerrain.CanWalkDiagonaly(fUnit.GetPosition, KMPoint(X,Y)))
    and (fTerrain.Land[Y,X].IsUnit <> nil) then //If there's some unit we need to do a better check on him
    begin
      U := fTerrain.UnitsHitTest(X,Y); //Let's see who is standing there
  
      //Check that the unit is idling, so that we can push it away
      if (U <> nil)
      and (U.GetUnitAction is TUnitActionStay)
      and not TUnitActionStay(U.GetUnitAction).Locked then
        Result := U;
    end;
  end;
  
  