anchor.diff:    S.SaveToFile(aPath);
     S.Free;
   end;
  +
  +
   end.
  
positive.code: type
    THouseInfo = record
      PlanYX:THouseArea;
      DoesOrders:byte;
      BuildIcon:word;
      TabletIcon:word;
      Input:THouseRes;
      Output:THouseRes;
    end;
  
  const
    HouseInfo:array[THouseType] of THouseInfo = (
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,0,0,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //0
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,0,0,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //0
      (PlanYX:((0,0,0,0), (0,1,1,0), (1,1,1,1), (1,2,1,1)); DoesOrders:1; BuildIcon:0; TabletIcon:0), //Armor smithy
      (PlanYX:((0,0,0,0), (0,1,1,0), (0,1,1,1), (0,2,1,1)); DoesOrders:1; BuildIcon:0; TabletIcon:0), //Armor workshop
      (PlanYX:((0,0,0,0), (0,1,1,1), (0,1,1,1), (0,1,1,2)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Bakery
      (PlanYX:((1,1,1,1), (1,1,1,1), (1,1,1,1), (1,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Barracks
      (PlanYX:((0,0,0,0), (0,1,1,0), (0,1,1,1), (0,1,1,2)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Butchers
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,0), (1,2,1,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Coal mine
      (PlanYX:((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Farm
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,0), (0,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Fisher hut
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,1,2,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Gold mine
      (PlanYX:((0,0,0,0), (0,1,1,1), (1,1,1,1), (1,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Inn
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Iron mine
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Iron smithy
      (PlanYX:((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Metallurgist
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Mill
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Quarry
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Sawmill
      (PlanYX:((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //School
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,2,1,1)); DoesOrders:1; BuildIcon:0; TabletIcon:0), //Siege workshop
      (PlanYX:((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Stables
      (PlanYX:((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Store
      (PlanYX:((0,0,0,0), (0,1,1,1), (1,1,1,1), (1,1,1,2)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Swine
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Tannery
      (PlanYX:((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,2,1,1)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Town hall
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,0), (0,1,2,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Watch tower
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)); DoesOrders:1; BuildIcon:0; TabletIcon:0), //Weapon smithy
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)); DoesOrders:1; BuildIcon:0; TabletIcon:0), //Weapon workshop
      (PlanYX:((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,1,2)); DoesOrders:0; BuildIcon:0; TabletIcon:0), //Wineyard
      (PlanYX:((0,0,0,0), (0,0,0,0), (1,1,1,0), (1,1,2,0)); DoesOrders:0; BuildIcon:0; TabletIcon:0)  //Woodcutter
      ); //0
  
  const
    //1-building area //2-entrance
    HousePlanYX:array[THouseType] of THouseArea = (
      ((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,0,0,0)), //0
      ((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,0,0,0)), //0
      ((0,0,0,0), (0,1,1,0), (1,1,1,1), (1,2,1,1)), //Armor smithy
      ((0,0,0,0), (0,1,1,0), (0,1,1,1), (0,2,1,1)), //Armor workshop
      ((0,0,0,0), (0,1,1,1), (0,1,1,1), (0,1,1,2)), //Bakery
      ((1,1,1,1), (1,1,1,1), (1,1,1,1), (1,2,1,1)), //Barracks
      ((0,0,0,0), (0,1,1,0), (0,1,1,1), (0,1,1,2)), //Butchers
      ((0,0,0,0), (0,0,0,0), (1,1,1,0), (1,2,1,0)), //Coal mine
      ((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,2,1,1)), //Farm
      ((0,0,0,0), (0,0,0,0), (0,1,1,0), (0,2,1,1)), //Fisher hut
      ((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,1,2,0)), //Gold mine
      ((0,0,0,0), (0,1,1,1), (1,1,1,1), (1,2,1,1)), //Inn
      ((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,1,2,1)), //Iron mine
      ((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,1,2,1)), //Iron smithy
      ((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)), //Metallurgist
      ((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)), //Mill
      ((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)), //Quarry
      ((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)), //Sawmill
      ((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)), //School
      ((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,2,1,1)), //Siege workshop
      ((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,1,2,1)), //Stables
      ((0,0,0,0), (1,1,1,0), (1,1,1,0), (1,2,1,0)), //Store
      ((0,0,0,0), (0,1,1,1), (1,1,1,1), (1,1,1,2)), //Swine
      ((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,2,1)), //Tannery
      ((0,0,0,0), (1,1,1,1), (1,1,1,1), (1,2,1,1)), //Town hall
      ((0,0,0,0), (0,0,0,0), (0,1,1,0), (0,1,2,0)), //Watch tower
      ((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)), //Weapon smithy
      ((0,0,0,0), (0,0,0,0), (1,1,1,1), (1,2,1,1)), //Weapon workshop
      ((0,0,0,0), (0,0,0,0), (0,1,1,1), (0,1,1,2)), //Wineyard
      ((0,0,0,0), (0,0,0,0), (1,1,1,0), (1,1,2,0))  //Woodcutter
      );
  
    //Building of certain house allows player to build following houses,
    //unless they are blocked in mission script of course
  
negative.code:   Result := not (ResOutput[1] in [rt_None,rt_All,rt_Warfare]); //Exclude aggregate types
  end;
  
  
  function TKMHouseDatClass.GetResInput: THouseRes;
  begin
    Result := HouseInput_[HouseKaMOrder[fHouseType]];
  end;
  
  
  function TKMHouseDatClass.GetResOutput: THouseRes;
  begin
    Result := HouseOutput_[HouseKaMOrder[fHouseType]];
  end;
  
  
  function TKMHouseDatClass.GetTabletIcon: word;
  begin
    Result := HouseInfo[fHouseType].TabletIcon;
  end;
  
  
  function TKMHouseDatClass.IsValid: boolean;
  begin
  