anchor.diff:  begin
     SaveStream.WriteA('DefencePositions');
     SaveStream.Write(fOwner);
  +  SaveStream.Write(fCityUnderAttack);
     SaveStream.Write(fFirstLineCnt);
     SaveStream.Write(TroopFormations, SizeOf(TroopFormations));
   
  
positive.code:   if (BestIdx <> -1) then
    begin
      Result := True;
      if (Positions[BestIdx].Group = nil) then
      begin
        //New position
        Positions[BestIdx].Group := aGroup;
        if (aGroup.UnitsPerRow < TroopFormations[aGroup.GroupType].UnitsPerRow) then
          aGroup.UnitsPerRow := TroopFormations[aGroup.GroupType].UnitsPerRow;
        aGroup.OrderWalk( Positions[BestIdx].Position.Loc, True );
      end
      else
        //Append to existing position
        RestockPositionWith( Positions[BestIdx].Group, aGroup );
    end;
  end;
  
  
  procedure TKMArmyDefence.RestockPositionWith(aDefenceGroup, aGroup: TKMUnitGroup);
  var
    Needed: integer;
  begin
    Needed := TroopFormations[aDefenceGroup.GroupType].NumUnits - aDefenceGroup.Count;
    if (Needed <= 0) then
      Exit;
    if (aGroup.Count <= Needed) then
      aGroup.OrderLinkTo(aDefenceGroup, True) //Link entire group
    else
      aGroup.OrderSplitLinkTo(aDefenceGroup, Needed, True); //Link only as many units as are needed
  
    if (aDefenceGroup.UnitsPerRow < TroopFormations[aDefenceGroup.GroupType].UnitsPerRow) then
      aDefenceGroup.UnitsPerRow := TroopFormations[aDefenceGroup.GroupType].UnitsPerRow;
  end;
  
  
  //Find DefencePosition to which this Commander belongs
  //(Result could be nil if CommanderCount > PositionsCount
  function TKMArmyDefence.FindPositionOf(aGroup: TKMUnitGroup): TKMDefencePosition;
  var
    I: Integer;
  
negative.code:   GT: TGroupType;
    UGA: TKMUnitGroupArray;
  begin
    fCityUnderAttack := False;
    // Check defensive line
    for I := 0 to Length(fDefPolyFirstLine) - 1 do
    begin
  