//
// country.script
//

// _country_GetSIDByID
//
procedure _country_GetSIDByID(id : Integer; var sid : String);
begin
   case id of
      -2 : sid := 'spe';
      0 : sid := 'aus';
      1 : sid := 'fra';
      2 : sid := 'eng';
      3 : sid := 'spa';
      4 : sid := 'rus';
      5 : sid := 'ukr';
      6 : sid := 'pol';
      7 : sid := 'swe';
      8 : sid := 'pru';
      9 : sid := 'ven';
      10 : sid := 'tur';
      11 : sid := 'alg';
      12 : sid := 'mis';
      13 : sid := 'net';
      14 : sid := 'den';
      15 : sid := 'por';
      16 : sid := 'pie';
      17 : sid := 'sax';
      18 : sid := 'bav';
      19 : sid := 'hun';
      20 : sid := 'swi';
      21 : sid := 'sco';
      22 : sid := 'tat';
      23 : sid := 'lit';
      else
      begin
         sid := '';
         ErrorLog('_country_GetSIDByID : unknown nation index');
      end;
   end;
end;

// _country_GetIDBySID
//
function _country_GetIDBySID(var sid : String) : Integer;
begin
   var id : Integer;
   case sid of
      'spe' : id := -2;
      'aus' : id := 0;
      'fra' : id := 1;
      'eng' : id := 2;
      'spa' : id := 3;
      'rus' : id := 4;
      'ukr' : id := 5;
      'pol' : id := 6;
      'swe' : id := 7;
      'pru' : id := 8;
      'ven' : id := 9;
      'tur' : id := 10;
      'alg' : id := 11;
      'mis' : id := 12;
      'net' : id := 13;
      'den' : id := 14;
      'por' : id := 15;
      'pie' : id := 16;
      'sax' : id := 17;
      'bav' : id := 18;
      'hun' : id := 19;
      'swi' : id := 20;
      'sco' : id := 21;
      'tat' : id := 22;
      'lit' : id := 23;
      else
      ErrorLog('_country_GetSIDByID : unknown nation index');
   end;
   Result := id;
end;

// _country_IDToBoolean
//
procedure _country_IDToBoolean(cid : Integer; var aus, fra, eng, spa, rus, ukr, pol, swe, pru, ven, tur, alg, mis, net, den, por, pie, sax, bav, hun, swi, sco, tat, lit : Boolean);
begin
   const _aus = 0;
   const _fra = 1;
   const _eng = 2;
   const _spa = 3;
   const _rus = 4;
   const _ukr = 5;
   const _pol = 6;
   const _swe = 7;
   const _pru = 8;
   const _ven = 9;
   const _tur = 10;
   const _alg = 11;
   const _mis = 12;
   const _net = 13;
   const _den = 14;
   const _por = 15;
   const _pie = 16;
   const _sax = 17;
   const _bav = 18;
   const _hun = 19;
   const _swi = 20;
   const _sco = 21;
   const _tat = 22;
   const _lit = 23;
   case cid of
      _aus : aus := True;
      _fra : fra := True;
      _eng : eng := True;
      _spa : spa := True;
      _rus : rus := True;
      _ukr : ukr := True;
      _pol : pol := True;
      _swe : swe := True;
      _pru : pru := True;
      _ven : ven := True;
      _tur : tur := True;
      _alg : alg := True;
      _mis : mis := True;
      _net : net := True;
      _den : den := True;
      _por : por := True;
      _pie : pie := True;
      _sax : sax := True;
      _bav : bav := True;
      _hun : hun := True;
      _swi : swi := True;
      _sco : sco := True;
      _tat : tat := True;
      _lit : lit := True;
   end;
end;

// _country_GetUnitSIDMaskBySID
//
procedure _country_GetUnitSIDMaskBySID(var sid : String; cid : Integer; var sidmask : String);
begin
   sidmask := '';
   var tmp : String = SubStr(sid, StrLength(sid)-2, 3);
   var tmpscid : String = '%nat%';
   case tmp of
      'mil', 'por', 'tow', 'wwa', 'swa', 'sto', 'mar', 'gol', 'iro', 'coa' : tmpscid := '%com%';
      'blg', 'blg2' : tmpscid := '%mis%';
   end;
   sidmask := tmpscid+tmp;
end;

// _country_GetUnitSIDBySIDMask
//
procedure _country_GetUnitSIDBySIDMask(var sidmask : String; cid : Integer; var sid : String);
begin
   sid := '';
   var tmp : String = SubStr(sidmask, StrLength(sidmask)-2, 3);
   var csid : String;
   _country_GetSIDByID(cid, csid);
   if (StrExists(sidmask, '%nat%')) then
   tmp := csid+tmp
   else
   if (StrExists(sidmask, '%com%')) then
   begin
      var csid, tmpcsid : String;
      _country_GetSIDByID(cid, csid);
      tmpcsid := 'eur';
      case tmp of
         'por' : begin
            case csid of
               'ukr' : tmpcsid := 'ukr';
               'rus' : tmpcsid := 'rus';
               'tur', 'alg' : tmpcsid := 'tur';
               'por' : tmpcsid := 'por';
            end;
         end;
         'mil', 'tow', 'swa' : begin
            case csid of
               'rus', 'ukr' : tmpcsid := 'rus';
               'tur', 'alg' : tmpcsid := 'tur';
            end;
         end;
         'wwa' : begin
            tmpcsid := 'ukr';
         end;
         'sto' : begin
            case csid of
               'tur', 'alg' : tmpcsid := 'tur';
               'rus', 'ukr' : tmpcsid := 'rus';
               'spa', 'por' : tmpcsid := 'spa';
            end;
         end;
         'mar' : begin
            case csid of
               'rus', 'ukr' : tmpcsid := 'rus';
               'tur', 'alg' : tmpcsid := 'tur';
               'spa', 'por' : tmpcsid := 'spa';
            end;
         end;
         'blg', 'blg2' : begin
            tmpcsid := 'mis';
         end;
         //'gol', 'iro', 'coa' : tmpcsid := 'eur';
      end;
      tmp := tmpcsid+tmp;
   end;
   sid := tmp;
end;

// _country_AddEnabled
//
procedure _country_AddEnabled(var country : TCountry; var sid : String);
begin
   var i : Integer;
   for i:=0 to gc_country_maxmembers-1 do
   begin
      if ((country.enabled[i]=sid) or (country.enabled[i]='')) then
      begin
         country.enabled[i] := sid;
         break;
      end;
   end;
end;

// _country_GetEnabledIndexBySID
//
function _country_GetEnabledIndexBySID(cid : Integer; var sid : String) : Integer;
begin
   Result := -1;
   var i : Integer;
   for i:=0 to gc_country_maxmembers-1 do
   begin
      if (gCountry[cid].enabled[i]=sid) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_AddMemberEditorPlace
//
procedure _country_AddMemberEditorPlace(var country : TCountry; var sid : String; category, priority : Integer);
begin
   var ind : Integer = -1;
   var i : Integer;
   for i:=0 to gc_country_maxmembers-1 do
   begin
      if (country.editorplace[category][i].sid='') then
      begin
         ind := i;
         break;
      end;
   end;
   if (ind<>-1) then
   begin
      country.editorplace[category][ind].sid := sid;
      country.editorplace[category][ind].priority := priority;
   end
   else
   ErrorLog('_country_AddMemberEditorPlace : ind=-1');
end;

// _country_AddMember
//
procedure _country_AddMember(var country : TCountry; const sid : String; var ind : Integer; enabled : Boolean; category, priority, airole : Integer);
begin
   if (ind>=gc_country_maxmembers) then
   ErrorLog('_country_AddMember : country.members[out of bounds]');
   country.members[ind] := sid;
   country.membersairole[ind] := airole;
   if (enabled) then
   _country_AddEnabled(country, country.members[ind]);
   if (category<>gc_country_editorplace_category_none) then
   _country_AddMemberEditorPlace(country, country.members[ind], category, priority);
   ind := ind+1;
end;

// _country_IsCountryMember
//
function _country_IsCountryMember(cid : Integer; const sid : String) : Boolean;
begin
   Result := False;
   if (sid<>'') then
   begin
      var i : Integer;
      for i:=0 to gc_country_maxmembers-1 do
      begin
         if (gCountry[cid].members[i]=sid) then
         begin
            Result := True;
            break;
         end;
      end;
   end;
end;

// _country_GetMemberIDByAIRole
//
function _country_GetMemberIDByAIRole(incid, airole : Integer) : Integer;
begin
   Result := -1;
   var i : Integer;
   for i:=0 to gc_country_maxmembers do
   begin
      if (gObjProp[incid][i].airole=airole) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_GetUpgradeIndexByUpgradeID
//
function _country_GetUpgradeIndexByUpgradeID(cid : Integer; const upgradeid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := 0;
   if (upgradeid<>'') then
   begin
      var i : Integer;
      for i:=0 to gc_country_maxupgradecount-1 do
      begin
         if ((gCountry[cid].upgrade[i].id=upgradeid) or ((bAddIfNotExist) and (gCountry[cid].upgrade[i].id=''))) then
         begin
            Result := i;
            break;
         end;
      end;
   end
   else
   Log('_country_GetUpgradeIndexByUpgradeID : upgradeid="');
end;

// _country_GetUpgradeSIDByUpgradeID
//
procedure _country_GetUpgradeSIDByUpgradeID(cid : Integer; upgradeid : Integer; var upgradesid : String);
begin
   upgradesid := gCountry[cid].upgrade[upgradeid].id;
end;

// _country_GetUpgradeIndexByUpgradeType
//
function _country_GetUpgradeIndexByUpgradeType(cid, itype : Integer) : Integer;
begin
   Result := 0;
   var i : Integer;
   for i:=0 to gc_country_maxupgradecount-1 do
   begin
      if (gCountry[cid].upgrade[i].itype=itype) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_IsCountryUpgrade
//
function _country_IsCountryUpgrade(cid : Integer; const upgsid : String) : Boolean;
begin
   Result := (_country_GetUpgradeIndexByUpgradeID(cid, upgsid, False)>0);
end;

// _country_GetFixedProduceIndexBySID
//
function _country_GetFixedProduceIndexBySID(cid : Integer; var sid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := -1;
   if (_country_IsCountryMember(cid, sid)) then
   begin
      var i : Integer;
      for i:=0 to gc_country_maxfixedproduce-1 do
      begin
         if ((gCountry[cid].fixedproduce[i].id=sid) or ((bAddIfNotExist) and (gCountry[cid].fixedproduce[i].id=''))) then
         begin
            Result := i;
            break;
         end;
      end;
   end;
end;

// _country_GetFixedProduceBuildIndexBySID
//
function _country_GetFixedProduceBuildIndexBySID(cid : Integer; fixedproduceind : Integer; var sid : String) : Integer;
begin
   Result := -1;
   if (_country_IsCountryMember(cid, sid)) then
   begin
      var i : Integer;
      for i:=0 to gc_country_fixedproduce_maxcount-1 do
      begin
         if (gCountry[cid].fixedproduce[fixedproduceind].build[i].id=sid) then
         begin
            Result := i;
            break;
         end;
      end;
   end;
end;

// _country_AddFixedProduce
//
procedure _country_AddFixedProduce(var country : TCountry; fixedproduceind : Integer; const sid, id : String; x, y : Integer; var ind : Integer);
begin
   if (_country_IsCountryMember(country.id, sid)) then
   begin
      country.fixedproduce[fixedproduceind].id := sid;
      country.fixedproduce[fixedproduceind].build[ind].id := id;
      country.fixedproduce[fixedproduceind].build[ind].x := x;
      country.fixedproduce[fixedproduceind].build[ind].y := y;
      ind := ind+1;
   end;
end;

// _country_GetAccessControlIndexBySID
//
function _country_GetAccessControlIndexBySID(cid : Integer; const sid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := -1;
   if (_country_IsCountryMember(cid, sid)) or (_country_IsCountryUpgrade(cid, sid)) then
   begin
      var i : Integer;
      for i:=0 to gc_country_maxaccesscontrol-1 do
      begin
         if ((gCountry[cid].accesscontrol[i].id=sid) or ((bAddIfNotExist) and (gCountry[cid].accesscontrol[i].id=''))) then
         begin
            Result := i;
            break;
         end;
      end;
   end;
end;

// _country_AddAccessControl
//
procedure _country_AddAccessControl(var country : TCountry; accesscontrolind : Integer; const sid, id : String; var ind : Integer);
begin
   if ((_country_IsCountryMember(country.id, sid)) or (_country_IsCountryUpgrade(country.id, sid))) { and ((_country_IsCountryMember(country.id, id)) or (_country_IsCountryUpgrade(country.id, id))) } then
   begin
      country.accesscontrol[accesscontrolind].id := sid;
      country.accesscontrol[accesscontrolind].req[ind] := id;
      ind := ind+1;
   end;
end;

// _country_AddFixedProduceWithAccessControl
//
procedure _country_AddFixedProduceWithAccessControl(var country : TCountry; fixedproduceind : Integer; const sid, id : String; x, y : Integer; var ind : Integer; const req0, req1, req2{, req3, req4, req5, req6, req7} : String);
begin
   if (_country_IsCountryMember(country.id, sid)) and (_country_IsCountryMember(country.id, id)) then
   begin
      _country_AddFixedProduce(country, fixedproduceind, sid, id, x, y, ind);
      var accessind : Integer;
      var accesscontrolind : Integer = _country_GetAccessControlIndexBySID(country.id, id, True);
      if (accesscontrolind<>-1) then
      begin
         if (req0<>'') then _country_AddAccessControl(country, accesscontrolind, id, req0, accessind);
         if (req1<>'') then _country_AddAccessControl(country, accesscontrolind, id, req1, accessind);
         if (req2<>'') then _country_AddAccessControl(country, accesscontrolind, id, req2, accessind);
         //if (req3<>'') then _country_AddAccessControl(country, accesscontrolind, id, req3, accessind);
         //if (req4<>'') then _country_AddAccessControl(country, accesscontrolind, id, req4, accessind);
         //if (req5<>'') then _country_AddAccessControl(country, accesscontrolind, id, req5, accessind);
         //if (req6<>'') then _country_AddAccessControl(country, accesscontrolind, id, req6, accessind);
         //if (req7<>'') then _country_AddAccessControl(country, accesscontrolind, id, req7, accessind);
      end;
   end;
end;

// _country_GetUnitLockIndexBySID
//
function _country_GetUnitLockIndexBySID(cid : Integer; var sid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := -1;
   if (_country_IsCountryMember(cid, sid)) then
   begin
      var i : Integer;
      for i:=0 to gc_country_maxunitlock-1 do
      begin
         if ((gCountry[cid].unitlock[i].id=sid) or ((bAddIfNotExist) and (gCountry[cid].unitlock[i].id=''))) then
         begin
            Result := i;
            break;
         end;
      end;
   end;
end;

// _country_AddUnitLock
//
procedure _country_AddUnitLock(var country : TCountry; unitlockind : Integer; var sid, lockid : String; count : Integer; var ind : Integer);
begin
   if (_country_IsCountryMember(country.id, sid)) and (_country_IsCountryMember(country.id, lockid)) then
   begin
      country.unitlock[unitlockind].id := sid;
      country.unitlock[unitlockind].lockid := lockid;
      country.unitlock[unitlockind].count := count;
      ind := ind+1;
   end;
end;

// _country_GetUpgradePlaceIndexBySID
//
function _country_GetUpgradePlaceIndexBySID(cid : Integer; var sid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := -1;
   var i : Integer;
   for i:=0 to gc_country_maxupgradeplace-1 do
   begin
      if ((gCountry[cid].upgradeplace[i].id=sid) or ((bAddIfNotExist) and (gCountry[cid].upgradeplace[i].id=''))) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_AddUpgradeToUpgradePlace
//
procedure _country_AddUpgradeToUpgradePlace(var upgradeplace : TCountryUpgradePlace; const sid, upgid : String);
begin
   upgradeplace.id := sid;
   var i : Integer;
   for i:=0 to gc_country_upgradeplace_maxcount-1 do
   begin
      if (upgradeplace.upgrade[i]=upgid) then
      ErrorLog('_country_AddUpgradeToUpgradePlace : dublicate = '+upgid);
      if (upgradeplace.upgrade[i]='') then
      begin
         upgradeplace.upgrade[i] := upgid;
         break;
      end;
   end;
end;

// _country_ModifyUpgrade
//
procedure _country_ModifyUpgrade(var country : TCountry;upgind : Integer; value : Integer; food, wood, stone, gold, iron, coal : Integer);
begin
   if (value<>-1) then
   country.upgrade[upgind].value := value;
   if (food<>-1) then
   country.upgrade[upgind].price[gc_resource_type_food] := food;
   if (wood<>-1) then
   country.upgrade[upgind].price[gc_resource_type_wood] := wood;
   if (stone<>-1) then
   country.upgrade[upgind].price[gc_resource_type_stone] := stone;
   if (gold<>-1) then
   country.upgrade[upgind].price[gc_resource_type_gold] := gold;
   if (iron<>-1) then
   country.upgrade[upgind].price[gc_resource_type_iron] := iron;
   if (coal<>-1) then
   country.upgrade[upgind].price[gc_resource_type_coal] := coal;
end;

// _country_SetUpgradeExt
//
procedure _country_SetUpgrade(var country : TCountry; upgind : Integer; const upgid : String; level, tooltiptype, itype, value : Integer; enabled : Boolean; time, x, y : Integer; food, wood, stone, gold, iron, coal : Integer; iarr1p0, iarr1p1, iarr1p2 : Integer; const sarr2p0, sarr2p1, sarr2p2, sarr2p3, sarr2p4, sarr2p5, sarr2p6, sarr2p7, sarr2p8, sarr2p9 : String);
begin
   country.upgrade[upgind].id := upgid;
   country.upgrade[upgind].enabled := enabled;
   country.upgrade[upgind].level := level;
   country.upgrade[upgind].itype := itype;
   country.upgrade[upgind].value := value;
   country.upgrade[upgind].price[gc_resource_type_food] := food;
   country.upgrade[upgind].price[gc_resource_type_wood] := wood;
   country.upgrade[upgind].price[gc_resource_type_stone] := stone;
   country.upgrade[upgind].price[gc_resource_type_gold] := gold;
   country.upgrade[upgind].price[gc_resource_type_iron] := iron;
   country.upgrade[upgind].price[gc_resource_type_coal] := coal;
   country.upgrade[upgind].time := _misc_FramesToTime(time);
   country.upgrade[upgind].x := x;
   country.upgrade[upgind].y := y;
   country.upgrade[upgind].tooltiptype := tooltiptype;
   country.upgrade[upgind].bindividual := False;
   country.upgrade[upgind].iarrparam1[0] := iarr1p0;
   country.upgrade[upgind].iarrparam1[1] := iarr1p1;
   country.upgrade[upgind].iarrparam1[2] := iarr1p2;
   country.upgrade[upgind].sarrparam2[0] := sarr2p0;
   country.upgrade[upgind].sarrparam2[1] := sarr2p1;
   country.upgrade[upgind].sarrparam2[2] := sarr2p2;
   country.upgrade[upgind].sarrparam2[3] := sarr2p3;
   country.upgrade[upgind].sarrparam2[4] := sarr2p4;
   country.upgrade[upgind].sarrparam2[5] := sarr2p5;
   country.upgrade[upgind].sarrparam2[6] := sarr2p6;
   country.upgrade[upgind].sarrparam2[7] := sarr2p7;
   country.upgrade[upgind].sarrparam2[8] := sarr2p8;
   country.upgrade[upgind].sarrparam2[9] := sarr2p9;
end;

// _country_AddUpgrade
//
procedure _country_AddUpgrade(var country : TCountry; const upgid : String; level, tooltiptype, itype, value : Integer; enabled : Boolean; time, x, y : Integer; var ind : Integer; food, wood, stone, gold, iron, coal : Integer; bAddIfNotExist : Boolean; iarr1p0, iarr1p1, iarr1p2 : Integer; const sarr2p0, sarr2p1, sarr2p2, sarr2p3, sarr2p4, sarr2p5, sarr2p6, sarr2p7, sarr2p8, sarr2p9 : String);
begin
   var upgind : Integer = _country_GetUpgradeIndexByUpgradeID(country.id, upgid, bAddIfNotExist);
   if (upgind>=0) then
   begin
      _country_SetUpgrade(country, upgind, upgid, level, tooltiptype, itype, value, enabled, time, x, y, food, wood, stone, gold, iron, coal, iarr1p0, iarr1p1, iarr1p2, sarr2p0, sarr2p1, sarr2p2, sarr2p3, sarr2p4, sarr2p5, sarr2p6, sarr2p7, sarr2p8, sarr2p9);
      
      var s1, s2, s3, s4 : String;
      _misc_GetDelimiterString(upgid, gc_gui_dotchar, s1, s2, s3, s4);
      var sid : String = s1;
      
      const bAddIfNotExist = True;
      var upgplaceind : Integer = _country_GetUpgradePlaceIndexBySID(country.id, sid, bAddIfNotExist);
      _country_AddUpgradeToUpgradePlace(country.upgradeplace[upgplaceind], sid, upgid);
      ind := ind+1;
   end;
end;

// _country_AddUpgradeSArrParam2MemberIfExists
//
procedure _country_AddUpgradeSArrParam2MemberIfExists(var country : TCountry; upgind : Integer; const sid : String);
begin
   if (_country_IsCountryMember(country.id, sid)) then
   begin
      var i : Integer;
      for i:=0 to gc_upgrade_maxarrparam2count-1 do
      begin
         if (country.upgrade[upgind].sarrparam2[i]='') or (country.upgrade[upgind].sarrparam2[i]='sid') then
         begin
            country.upgrade[upgind].sarrparam2[i] := sid;
            break;
         end;
         if (i=gc_upgrade_maxarrparam2count-1) then
         ErrorLog('_country_AddUpgradeSArrParam2MemberIfExists : array is near out of range');
      end;
   end;
end;

// _country_AddUpgradeWithAccessControl
//
procedure _country_AddUpgradeWithAccessControl(var country : TCountry; const upgid : String; level, tooltiptype, itype, value : Integer; enabled : Boolean; time, x, y : Integer; var ind : Integer; food, wood, stone, gold, iron, coal : Integer; bAddIfNotExist : Boolean; iarr1p0, iarr1p1, iarr1p2 : Integer; const sarr2p0, sarr2p1, sarr2p2, sarr2p3, sarr2p4, sarr2p5, sarr2p6, sarr2p7, sarr2p8, sarr2p9 : String; bAccessControl : Boolean; const req0, req1, req2, req3, req4, req5, req6, req7 : String);
begin
   var tupgid : String = upgid;
   _country_AddUpgrade(country, tupgid, level, tooltiptype, itype, value, enabled, time, x, y, ind, food, wood, stone, gold, iron, coal, bAddIfNotExist, iarr1p0, iarr1p1, iarr1p2, sarr2p0, sarr2p1, sarr2p2, sarr2p3, sarr2p4, sarr2p5, sarr2p6, sarr2p7, sarr2p8, sarr2p9);
   var accessind : Integer;
   var accesscontrolind : Integer = _country_GetAccessControlIndexBySID(country.id, tupgid, True);
   if (accesscontrolind<>-1) then
   begin
      if (req0<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req0, accessind);
      if (req1<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req1, accessind);
      if (req2<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req2, accessind);
      if (req3<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req3, accessind);
      if (req4<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req4, accessind);
      if (req5<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req5, accessind);
      if (req6<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req6, accessind);
      if (req7<>'') then _country_AddAccessControl(country, accesscontrolind, tupgid, req7, accessind);
   end;
end;

// _country_AddUpgradeLink
//
procedure _country_AddUpgradeLink(var country : TCountry; const upgid1, upgid2 : String; var ind : Integer);
begin
   country.upgradelinks[ind][0] := upgid1;
   country.upgradelinks[ind][1] := upgid2;
   ind := ind+1;
end;

// _country_AddUpgradeLinkRange
//
procedure _country_AddUpgradeLinkRange(var country : TCountry; const upgidbasis : String; minLevel, maxLevel : Integer; var ind : Integer);
begin
   var i : Integer;
   for i:=minLevel to maxLevel-1 do
   _country_AddUpgradeLink(country, upgidbasis+IntToStr(i), upgidbasis+IntToStr(i+1), ind);
end;

// _country_GetPrivateUpgradeIndexBySID
//
function _country_GetPrivateUpgradeIndexBySID(cid : Integer; const sid : String; bAddIfNotExist : Boolean) : Integer;
begin
   Result := -1;
   var i : Integer;
   for i:=0 to gc_country_maxprivatcount-1 do
   begin
      if ((gCountry[cid].upgradeprivate[i]=sid) or ((bAddIfNotExist) and (gCountry[cid].upgradeprivate[i]=''))) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_AddPrivateUpgrade
//
procedure _country_AddPrivateUpgrade(var country : TCountry; const sid : String; var ind : Integer);
begin
   country.upgradeprivate[ind] := sid;
   ind := ind+1;
end;

// _country_GetUpgradeCostBySID
//
function _country_GetUpgradeCostBySID(cid : Integer; var upgsid : String; var food, wood, stone, gold, iron, coal : Integer) : Integer;
begin
   var upgid : Integer = _country_GetUpgradeIndexByUpgradeID(cid, upgsid, False);
   if (upgid>0) then
   begin
      var i : Integer;
      for i:=0 to gc_ResCount-1 do
      case i of
         gc_resource_type_food : food := gCountry[cid].upgrade[upgid].price[i];
         gc_resource_type_wood : wood := gCountry[cid].upgrade[upgid].price[i];
         gc_resource_type_stone : stone := gCountry[cid].upgrade[upgid].price[i];
         gc_resource_type_gold : gold := gCountry[cid].upgrade[upgid].price[i];
         gc_resource_type_iron : iron := gCountry[cid].upgrade[upgid].price[i];
         gc_resource_type_coal : coal := gCountry[cid].upgrade[upgid].price[i];
      end;
   end
   else
   ErrorLog('_country_GetUpgradeCostBySID : Unknown upgid');
end;

// _country_InitUnitsUpgrades
//
procedure _country_InitUnitsUpgrades(var country : TCountry; var ind, linkind : Integer);
begin
   const bAddIfNotExist = True;
   const cTrue = True; // for better formating and reading
   const ctypeDamagePike = 0;
   const ctypeDamageSword = 1;
   const ctypeDamageBullet = 2;
   const ctypeProtection = 3;
   const ctypeProtectionOnlyPikeArrow = 4;
   const ctypeProtectionOnlySword = 5;
   const ctypeDamageArrow = 6;
   
   var csid : String = country.sid;
   var cid : Integer = _country_GetIDBySID(csid);
   const _aus = 0;
   const _fra = 1;
   const _eng = 2;
   const _spa = 3;
   const _rus = 4;
   const _ukr = 5;
   const _pol = 6;
   const _swe = 7;
   const _pru = 8;
   const _ven = 9;
   const _tur = 10;
   const _alg = 11;
   const _mis = 12;
   const _net = 13;
   const _den = 14;
   const _por = 15;
   const _pie = 16;
   const _sax = 17;
   const _bav = 18;
   const _hun = 19;
   const _swi = 20;
   const _sco = 21;
   const _tat = 22;
   const _lit = 23;
   
   var aus, fra, eng, spa, rus, ukr, pol, swe, pru, ven, tur, alg, mis, net, den, por, pie, sax, bav, hun, swi, sco, tat, lit : Boolean;
   _country_IDToBoolean(cid, aus, fra, eng, spa, rus, ukr, pol, swe, pru, ven, tur, alg, mis, net, den, por, pie, sax, bav, hun, swi, sco, tat, lit);
   
   type TUpgStruct = class
      place, member : String;
      req : array [0..5] of String;
      value : array [0..5] of Integer;
      food : array [0..5] of Integer;
      wood : array [0..5] of Integer;
      stone : array [0..5] of Integer;
      gold : array [0..5] of Integer;
      iron : array [0..5] of Integer;
      coal : array [0..5] of Integer;
   end;
   procedure ResetUpgStruct(var upgstruct : TUpgStruct);
   begin
      upgstruct.place := '';
      upgstruct.member := '';
      var i : Integer;
      for i:=0 to 5 do
      begin
         upgstruct.req[i] := '';
         upgstruct.value[i] := 0;
         upgstruct.food[i] := 0;
         upgstruct.wood[i] := 0;
         upgstruct.stone[i] := 0;
         upgstruct.gold[i] := 0;
         upgstruct.iron[i] := 0;
         upgstruct.coal[i] := 0;
      end;
   end;
   procedure SetUpgStructFoodGold(var upgstruct : TUpgStruct; var place, member : String; value0, food0, gold0 : Integer; b0 : Boolean; value1, food1, gold1 : Integer; b1 : Boolean; value2, food2, gold2 : Integer; b2 : Boolean; value3, food3, gold3 : Integer; b3 : Boolean; value4, food4, gold4 : Integer; b4 : Boolean; value5, food5, gold5 : Integer; const req0, req1 : String);
   begin
      ResetUpgStruct(upgstruct);
      upgstruct.place := place;
      upgstruct.member := member;
      upgstruct.req[0] := req0; upgstruct.req[1] := req1;
      upgstruct.value[0] := value0; upgstruct.value[1] := value1; upgstruct.value[2] := value2; upgstruct.value[3] := value3; upgstruct.value[4] := value4; upgstruct.value[5] := value5;
      upgstruct.food[0] := food0; upgstruct.food[1] := food1; upgstruct.food[2] := food2; upgstruct.food[3] := food3; upgstruct.food[4] := food4; upgstruct.food[5] := food5;
      upgstruct.gold[0] := gold0; upgstruct.gold[1] := gold1; upgstruct.gold[2] := gold2; upgstruct.gold[3] := gold3; upgstruct.gold[4] := gold4; upgstruct.gold[5] := gold5;
   end;
   procedure SetUpgStructFoodGoldIron(var upgstruct : TUpgStruct; var place, member : String; value0, food0, gold0, iron0 : Integer; b0 : Boolean; value1, food1, gold1, iron1 : Integer; b1 : Boolean; value2, food2, gold2, iron2 : Integer; b2 : Boolean; value3, food3, gold3, iron3 : Integer; b3 : Boolean; value4, food4, gold4, iron4 : Integer; b4 : Boolean; value5, food5, gold5, iron5 : Integer; const req0, req1 : String);
   begin
      ResetUpgStruct(upgstruct);
      SetUpgStructFoodGold(upgstruct, place, member, value0, food0, gold0, b0, value1, food1, gold1, b1, value2, food2, gold2, b2, value3, food3, gold3, b3, value4, food4, gold4, b4, value5, food5, gold5, req0, req1);
      upgstruct.iron[0] := iron0; upgstruct.iron[1] := iron1; upgstruct.iron[2] := iron2; upgstruct.iron[3] := iron3; upgstruct.iron[4] := iron4; upgstruct.iron[5] := iron5;
   end;
   procedure SetUpgStructFoodGoldIronCoal(var upgstruct : TUpgStruct; var place, member : String; value0, food0, gold0, iron0, coal0 : Integer; b0 : Boolean; value1, food1, gold1, iron1, coal1 : Integer; b1 : Boolean; value2, food2, gold2, iron2, coal2 : Integer; b2 : Boolean; value3, food3, gold3, iron3, coal3 : Integer; b3 : Boolean; value4, food4, gold4, iron4, coal4 : Integer; b4 : Boolean; value5, food5, gold5, iron5, coal5 : Integer; const req0, req1 : String);
   begin
      ResetUpgStruct(upgstruct);
      SetUpgStructFoodGold(upgstruct, place, member, value0, food0, gold0, b0, value1, food1, gold1, b1, value2, food2, gold2, b2, value3, food3, gold3, b3, value4, food4, gold4, b4, value5, food5, gold5, req0, req1);
      upgstruct.iron[0] := iron0; upgstruct.iron[1] := iron1; upgstruct.iron[2] := iron2; upgstruct.iron[3] := iron3; upgstruct.iron[4] := iron4; upgstruct.iron[5] := iron5;
      upgstruct.coal[0] := coal0; upgstruct.coal[1] := coal1; upgstruct.coal[2] := coal2; upgstruct.coal[3] := coal3; upgstruct.coal[4] := coal4; upgstruct.coal[5] := coal5;
   end;
   procedure AddUpgradePack(var country : TCountry; upgstruct : TUpgStruct; upgradetype, tooltiptype, x, y : Integer; bEnabled : Boolean; var ind, linkind : Integer);
   begin
      var j : Integer;
      for j:=0 to 5 do
      begin
         if (upgstruct.value[j]<>0) then
         begin
            var iupgtype : Integer = gc_upg_type_none;
            var iupgtype2 : Integer = 1;
            var iparam1, iparam2, iparam3 : Integer;
            case upgradetype of
               ctypeDamagePike : begin
                  iupgtype := gc_upg_type_damage;
                  iparam1 := gc_obj_weapon_kind_pike;
               end;
               ctypeDamageSword : begin
                  iupgtype := gc_upg_type_damage;
                  iparam1 := gc_obj_weapon_kind_sword;
               end;
               ctypeDamageBullet : begin
                  iupgtype := gc_upg_type_damage;
                  iparam1 := gc_obj_weapon_kind_bullet;
               end;
               ctypeDamageArrow : begin
                  iupgtype := gc_upg_type_damage;
                  iparam1 := gc_obj_weapon_kind_arrow;
               end;
               ctypeProtection : begin
                  iupgtype := gc_upg_type_protection;
                  iparam1 := gc_obj_weapon_kind_pike;
                  iparam2 := gc_obj_weapon_kind_sword;
                  iparam3 := gc_obj_weapon_kind_arrow;
                  iupgtype2 := 2;
               end;
               ctypeProtectionOnlyPikeArrow : begin
                  iupgtype := gc_upg_type_protection;
                  iparam1 := gc_obj_weapon_kind_pike;
                  iparam3 := gc_obj_weapon_kind_arrow;
                  iupgtype2 := 2;
               end;
               ctypeProtectionOnlySword : begin
                  iupgtype := gc_upg_type_protection;
                  iparam2 := gc_obj_weapon_kind_sword;
                  iupgtype2 := 2;
               end;
               else
               ErrorLog('AddUpgradePack : Unknown type');
            end;
            _country_AddUpgradeWithAccessControl(country, upgstruct.place+'.'+upgstruct.member+'.'+IntToStr(iupgtype2)+'.'+IntToStr(j+1), j+2, tooltiptype, iupgtype, upgstruct.value[j], (j=0) and bEnabled, 500, x, y, ind, upgstruct.food[j], upgstruct.wood[j], upgstruct.stone[j], upgstruct.gold[j], upgstruct.iron[j], upgstruct.coal[j], bAddIfNotExist, iparam1, iparam2, iparam3, upgstruct.member, '', '', '', '', '', '', '', '', '', True, upgstruct.req[0], upgstruct.req[1], upgstruct.req[2], upgstruct.req[3], upgstruct.req[4], upgstruct.req[5], '', '');
            if (j<5) and (upgstruct.value[j+1]<>0) then
            _country_AddUpgradeLink(country, upgstruct.place+'.'+upgstruct.member+'.'+IntToStr(iupgtype2)+'.'+IntToStr(j+1), upgstruct.place+'.'+upgstruct.member+'.'+IntToStr(iupgtype2)+'.'+IntToStr(j+2), linkind);
         end;
      end;
   end;
   
   var upgstruct : TUpgStruct;
   var upgplace, member : String;
   var bhave18century : Boolean = (not ukr) and (not tur) and (not alg) {and (not sco)}; // remove sco cause of index broke can accure
   var blacksmith : String = csid+'bla';
   var academy : String = csid+'aca';
   var century18 : String = csid+'cen'+'.1'; // name is static, used in apply map settings procedure

   // barracks
   upgplace := csid+'bar';
   case cid of
      _rus : member := 'pikemanrus';
      _ukr : member := '';
      _pol : member := 'pikemanpol';
      _tur : member := 'pikemantur';
      _alg : member := 'pikemantur';
      _sco : member := 'pikemansco';
      _por : member := 'pikemanpor';
      //_spa : member := 'pikemanspa'; // add spa default pikeman here to prevent index problems, add new upgrades at the en_d.
      _swi : member := 'pikemanswi';
      else
      member := 'pikeman';
   end;
   if (member<>'') then
   begin
      var bEnabled : Boolean = (cid<>_spa);
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 25, True, 2, 1400, 325, True, 2, 4600, 650, True, 1, 6200, 1650, True, 2, 15300, 2075, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1250, 310, True, 2, 3900, 650, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pik_rus
         _ukr : ;
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 50, True, 1, 1400, 100, True, 1, 3200, 450, True, 2, 8200, 2220, True, 2, 15030, 1800, True, 0, 0, 0, blacksmith, ''); // Pikiner_polan
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 90, True, 2, 300, 450, True, 2, 4600, 300, True, 1, 9200, 1250, True, 2, 14030, 2600, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3600, 450, True, 2, 1300, 300, True, 2, 200, 50, True, 1, 6800, 1950, True, 2, 15030, 2300, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 200, 50, True, 2, 600, 300, True, 2, 1200, 450, True, 2, 2200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 200, 50, True, 2, 600, 300, True, 2, 1200, 450, True, 2, 2200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_turki
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3600, 450, True, 2, 1300, 300, True, 2, 200, 50, True, 1, 6800, 1950, True, 2, 15030, 2300, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 700, 400, True, 2, 3100, 250, True, 1, 6700, 1950, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3600, 450, True, 2, 1300, 300, True, 2, 200, 50, True, 1, 6800, 1950, True, 2, 15030, 2300, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 90, True, 2, 300, 450, True, 2, 4600, 300, True, 1, 9200, 1250, True, 2, 14030, 2600, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 250, 70, True, 2, 750, 210, True, 3, 2800, 790, True, 1, 6000, 750, True, 2, 10800, 1350, True, 0, 0, 0, blacksmith, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3600, 450, True, 1, 1300, 300, True, 2, 200, 50, True, 1, 6800, 1950, True, 2, 15030, 2300, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 90, True, 2, 300, 450, True, 2, 4600, 300, True, 1, 9200, 1250, True, 2, 14030, 2600, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 2, 16030, 2000, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 200, 50, True, 3, 1300, 300, True, 2, 3600, 450, True, 1, 7200, 1850, True, 1, 16030, 2000, True, 0, 0, 0, blacksmith, '');
      end;
      AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 0, 1, bEnabled, ind, linkind);
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 350, 90, True, 1, 1000, 135, True, 2, 4200, 500, True, 1, 11075, 310, True, 1, 15050, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 990, 50, True, 1, 200, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 17010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pik_rus
         _ukr : ;
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 250, 75, True, 1, 800, 150, True, 2, 3500, 225, True, 2, 9005, 407, True, 4, 19010, 2975, True, 0, 0, 0, blacksmith, ''); // Pikiner_polan
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 350, 50, True, 1, 700, 275, True, 2, 2500, 200, True, 1, 13005, 997, True, 1, 16010, 2550, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 175, 40, True, 1, 990, 275, True, 2, 4700, 280, True, 1, 9505, 707, True, 1, 17510, 2950, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 2, 900, 175, True, 3, 4500, 300, True, 1, 9005, 507, True, 2, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 2, 900, 175, True, 3, 4500, 300, True, 1, 9005, 507, True, 2, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_turki
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 175, 40, True, 1, 990, 275, True, 2, 4700, 280, True, 1, 9005, 707, True, 1, 17510, 2950, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 250, 150, True, 1, 800, 275, True, 2, 4200, 100, True, 1, 9305, 707, True, 1, 17890, 2850, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 350, 50, True, 1, 700, 275, True, 2, 2500, 200, True, 1, 13005, 997, True, 1, 16010, 2550, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 175, 40, True, 1, 990, 275, True, 2, 4700, 280, True, 1, 9505, 707, True, 1, 17510, 2950, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 60, True, 2, 450, 180, True, 3, 1690, 675, True, 1, 4500, 600, True, 2, 8100, 1080, True, 0, 0, 0, blacksmith, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 350, 50, True, 1, 700, 275, True, 2, 2500, 200, True, 1, 13005, 997, True, 2, 16010, 2550, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 175, 40, True, 1, 990, 275, True, 2, 4700, 280, True, 1, 9505, 707, True, 1, 17510, 2950, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, ''); // Pikiner_evro
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 150, 50, True, 2, 900, 175, True, 1, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 0, 0, 0, blacksmith, '');
      end;
      
      var tmptype : Integer = ctypeProtection;
      //poland pikeman is default now
      {if (pol) then // poland pikeman got unique, upgrade mechanic. he upgrade protection from pike and arrow. and only last upgrade, improve protection from sword
      tmptype := ctypeProtectionOnlyPikeArrow;}
      AddUpgradePack(country, upgstruct, tmptype, gc_upg_tooltiptype_infdef, 0, 2, bEnabled, ind, linkind);
   end;
   
   case cid of
      _aus : member := 'roundshier';
      _tur : member := 'lightinfantry';
      _alg : member := 'lightinfantry';
      else
      member := '';
   end;
   if (member<>'') then
   begin
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 1500, 200, True, 2, 1300, 325, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Rundashir_Avstria
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 50, True, 1, 1100, 200, True, 1 1300, 325, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Pehota_turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 50, True, 1, 1100, 200, True, 1, 1300, 325, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Pehota_turki
      end;
      AddUpgradePack(country, upgstruct, ctypeDamageSword, gc_upg_tooltiptype_infdmg, 1, 1, True, ind, linkind);
      case cid of
         _aus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 70, 120, True, 2, 4360, 150, 320, True, 2, 506, 250, 420, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, blacksmith, ''); // Rundashir_Avstria
         _tur : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 70, 120, True, 1, 6360, 150, 320, True, 2, 506, 250, 420, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, blacksmith, ''); // Pehota_turki
         _alg : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 70, 120, True, 1, 6360, 150, 320, True, 2, 506, 250, 420, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, blacksmith, ''); // Pehota_turki
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 1, 2, True, ind, linkind);
   end;
   
   case cid of
      _aus : member := 'musketeeraus';
      _spa : member := 'musketeerspa';
      _rus : member := 'strelet';
      _ukr : member := 'serdiuk';
      _pol : member := 'musketeerpol';
      _tur : member := 'jannisary';
      _alg : member := '';
      _net : member := 'musketeernet';
      _sco : member := 'musketeersco';
      _hun : member := 'gauduk';
      else
      member := 'musketeer';
   end;
   if (member<>'') then
   begin
      var posx : Integer = 2;
      if (cid=_ukr) then
      posx := 0;
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_avstr
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 100, 50, True, 1, 3000, 500, True, 2, 2500, 750, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1900, 150, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Strelec_Spain
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Strelec
         //_ukr : SetUpgStructFoodGoldIronCoal(upgstruct, upgplace, member, 2, 22000, 800, 0, 0, True, 3, 32400, 5800, 0, 0, True, 4, 42010, 6800, 0, 0, True, 5, 52300, 1800, 7400, 0, True, 6, 45000, 300, 14500, 0, True, 10, 62400, 0, 0, 39200, blacksmith, ''); // Kozacki_Strelec
         _ukr : SetUpgStructFoodGoldIronCoal(upgstruct, upgplace, member, 2, 5400, 350, 0, 0, True, 2, 22000, 800, 0, 0, True, 2, 32400, 5800, 0, 0, True, 2, 42010, 6800, 0, 0, True, 2, 52300, 1800, 7400, 0, True, 0, 0, 0, 0, 0, blacksmith, ''); // C3 changes (remove last upg to damage and protection
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 125, True, 1, 1250, 275, True, 2, 2500, 650, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_polsha
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 200, True, 1, 2000, 200, True, 2, 100, 200, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Ianithar
         _alg : ;
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 200, True, 1, 2000, 200, True, 2, 100, 200, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2500, 200, True, 1, 1500, 400, True, 2, 500, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 200, True, 1, 2000, 200, True, 2, 100, 200, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_ev
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 125, True, 1, 1250, 275, True, 2, 2500, 650, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Mushketer_polsha
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); //
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 1, 1000, 300, True, 2, 500, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); //
      end;
      AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, posx, 1, True, ind, linkind);
      case cid of
         _aus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 1, 405, 150, 200, True, 1, 1570, 100, 350, True, 1, 1556, 550, 100, True, 1, 1060, 850, 400, True, 1, 3700, 750, 700, blacksmith, ''); // Mushketer_avstr
         _fra : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 75, 200, True, 2, 705, 250, 250, True, 2, 2560, 300, 450, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 650, 700, blacksmith, ''); // Mushketer_ev
         _eng : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 220, 50, 100, True, 2, 505, 140, 200, True, 2, 1670, 100, 350, True, 1, 1000, 920, 100, True, 2, 1060, 700, 400, True, 2, 3900, 550, 700, blacksmith, ''); // Mushketer_ev
         _spa : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 1, 405, 150, 200, True, 1, 1570, 100, 350, True, 1, 1556, 550, 100, True, 1, 1060, 850, 400, True, 1, 3700, 650, 700, blacksmith, ''); // Strelec_Spain
         _rus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 3, 170, 50, 100, True, 3, 405, 150, 200, True, 2, 1570, 100, 350, True, 2, 1556, 550, 100, True, 1, 1060, 850, 400, True, 1, 3700, 650, 700, blacksmith, ''); // Strelec
         //_ukr : SetUpgStructFoodGoldIronCoal(upgstruct, upgplace, member, 1, 3706, 0, 2350, 0, True, 2, 12060, 0, 7850, 0, True, 2, 36706, 0, 14000, 0, True, 1, 36706, 0, 22350, 0, True, 2, 37060, 0, 34350, 0, True, 0, 0, 0, 0, 0, blacksmith, ''); // C3 changes (remove last upg to damage and protection
         _ukr : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 40, True, 2, 600, 120, True, 2, 1500, 300, True, 1, 3500, 450, True, 2, 8100, 210, True, 0, 0, 0, blacksmith, ''); // C3 changes (remove last upg to damage and protection
         _pol : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 125, 150, 100, True, 1, 375, 100, 200, True, 2, 1570, 300, 450, True, 1, 2556, 350, 400, True, 1, 3060, 650, 100, True, 2, 2700, 750, 600, blacksmith, ''); // Mushketer_polsha
         _swe : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 450, 550, 300, True, 2, 405, 150, 20, True, 2, 1570, 100, 290, True, 1, 1956, 450, 700, True, 2, 1660, 650, 400, True, 2, 2700, 650, 100, blacksmith, ''); // Mushketer_ev
         _pru : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _ven : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _tur : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 4700, 450, 700, blacksmith, ''); // Ianithar
         _alg : ;
         _den : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _net : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 1, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 1, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _bav : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 450, 550, 300, True, 2, 405, 150, 20, True, 2, 1570, 100, 290, True, 1, 1956, 450, 700, True, 2, 1660, 550, 400, True, 2, 2700, 750, 100, blacksmith, ''); // Mushketer_ev
         _sax : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _sco : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 250, 30, 0, True, 1, 500, 400, 60, True, 2, 875, 225, 0, True, 1, 4200, 240, 0, True, 1, 6300, 360, 0, True, 2, 13125, 750, 0, blacksmith, '');
         _por : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 450, 550, 300, True, 2, 405, 150, 20, True, 2, 1570, 100, 290, True, 1, 1956, 450, 700, True, 2, 1660, 550, 400, True, 2, 2700, 850, 100, blacksmith, ''); // Mushketer_ev
         _hun : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 125, 150, 100, True, 1, 375, 100, 200, True, 2, 1570, 300, 450, True, 1, 2556, 350, 400, True, 1, 2060, 450, 100, True, 2, 2700, 950, 600, blacksmith, ''); // Mushketer_polsha
         _pie : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
         _swi : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 170, 50, 100, True, 2, 405, 150, 200, True, 2, 1570, 100, 350, True, 1, 1556, 550, 100, True, 2, 1060, 850, 400, True, 2, 3700, 450, 700, blacksmith, ''); // Mushketer_ev
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, posx, 2, True, ind, linkind);
   end;
   
   case cid of
      _rus : member := 'drummerrus';
      _ukr : member := '';
      _tur : member := 'drummertur';
      _alg : member := 'drummertur';
      _sco : member := 'bagpiper';
      else
      member := 'drummer';
   end;
   if (member<>'') then
   begin
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 500, 75, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 670, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_1
         _ukr : ;
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 405, 250, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 905, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_Turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_Turki
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 845, 95, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 905, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 905, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik_ev1
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 500, 75, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); //
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 670, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); //
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_drummerdef, 4, 2, True, ind, linkind);
   end;
   
   case cid of
      _rus : member := 'officerrus';
      _ukr : member := '';
      _tur : member := 'officertur';
      _alg : member := 'officertur';
      _sco : member := 'officersco';
      else
      member := 'officer';
   end;
   if (member<>'') then
   begin
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 100, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 200, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 250, 75, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 100, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 100, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Russki_Komandir
         _ukr : ;
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 50, 150, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 800, 150, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 150, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 100, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_turki
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 150, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 500, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 800, 150, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 150, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 250, 75, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 800, 150, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 150, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 100, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 200, 25, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
      end;
      AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 5, 1, True, ind, linkind);
      country.upgrade[ind-1].time := 46.875;
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1850, 450, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1950, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 425, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1850, 450, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 1850, 450, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Russki_Komandir
         _ukr : ;
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1550, 650, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1050, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 395, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1450, 450, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_turki
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_turki
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 395, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1550, 475, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1050, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 395, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 1550, 425, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1050, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 395, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1050, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1650, 395, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Officer_evro
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 5, 2, True, ind, linkind);
      country.upgrade[ind-1].time := 46.875;
   end;

   // barracks 18 century
   if (bhave18century) then
   begin
      upgplace := csid+'ba2';
      case cid of
         _swe : member := 'pikeman18swe';
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _sco : member := '';
         else
         member := 'pikeman18';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 2, 8000, 1200, True, 2, 20000, 2500, True, 2, 32000, 2800, True, 2, 32000, 3800, True, 2, 40500, 4800, blacksmith, ''); // Pik_evro_rus
         end;
         AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 0, 1, True, ind, linkind);
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1500, 500, True, 3, 7000, 1500, True, 2, 37000, 2000, True, 3, 37000, 5500, True, 2, 37000, 5500, True, 3, 64600, 5500, blacksmith, '');
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 0, 2, True, ind, linkind);
      end;
      
      if (cid=_sco) then
      begin
         member := 'swordsmansco';
         SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 450, 110, True, 3, 900, 220, True, 4, 3350, 850, True, 5, 14400, 2060, True, 6, 37800, 4525, True, 10, 90000, 8000, blacksmith, '');
         AddUpgradePack(country, upgstruct, ctypeDamageSword, gc_upg_tooltiptype_infdmg, 0, 1, True, ind, linkind);
         SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 75, 0, True, 2, 700, 225, 0, True, 2, 2500, 560, 0, True, 2, 7750, 1125, 0, True, 3, 15800, 1800, 0, True, 5, 36125, 3350, 0, blacksmith, '');
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 0, 2, True, ind, linkind)
      end;
      
      case cid of
         _ukr : member := '';
         _pru : member := 'musketeer18pru';
         _tur : member := '';
         _alg : member := '';
         _den : member := 'musketeer18den';
         _bav : member := 'musketeer18bav';
         _sax : member := 'musketeer18sax';
         _sco : member := '';
         else
         member := 'musketeer18';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 200, True, 1, 2000, 400, True, 2, 1200, 1800, True, 2, 3300, 100, True, 3, 1100, 200, True, 3, 5500, 2100, blacksmith, ''); // Mushketer
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1100, 750, True, 1, 1670, 850, True, 2, 1900, 200, True, 2, 2340, 1800, True, 3, 3000, 900, True, 3, 3500, 700, blacksmith, ''); // Mushketer
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 100, True, 1, 2500, 200, True, 2, 1000, 300, True, 2, 3500, 400, True, 3, 2000, 3800, True, 3, 3500, 600, blacksmith, ''); // Mushketer
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 9000, 200, True, 1, 600, 200, True, 2, 4000, 100, True, 2, 500, 2100, True, 3, 3000, 200, True, 3, 3500, 1400, blacksmith, ''); // Mushketer
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 700, True, 1, 1600, 800, True, 2, 2500, 900, True, 2, 2000, 600, True, 3, 3500, 1000, True, 3, 3000, 800, blacksmith, ''); // Mushketer_PR
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 700, True, 1, 1600, 800, True, 1, 2500, 900, True, 1, 2000, 600, True, 1, 3500, 1000, True, 1, 3000, 800, blacksmith, ''); // Mushketer_DA
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 100, True, 1, 1600, 200, True, 2, 1500, 300, True, 2, 3100, 2600, True, 3, 2900, 200, True, 3, 3200, 1400, blacksmith, ''); // Mushketer
            //_bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 900, 700, True, 3, 1600, 800, True, 4, 2500, 900, True, 5, 2000, 600, True, 6, 3500, 1000, True, 10, 3000, 800, blacksmith, '');
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 700, True, 1, 1600, 800, True, 1, 2500, 900, True, 1, 2000, 600, True, 1, 3500, 1000, True, 1, 3000, 800, blacksmith, '');
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 9000, 200, True, 2, 600, 200, True, 2, 4000, 100, True, 1, 500, 2100, True, 2, 3000, 200, True, 2, 3500, 1400, blacksmith, '');
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 800, True, 1, 1500, 800, True, 2, 2000, 800, True, 2, 2500, 800, True, 3, 3000, 800, True, 3, 3500, 800, blacksmith, ''); // Mushketer
         end;
         AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 2, 1, True, ind, linkind);
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3500, 370, True, 2, 35030, 1050, True, 2, 11706, 4300, True, 1, 36700, 4450, True, 2, 30160, 1550, True, 2, 33600, 1150, blacksmith, ''); // Mushketer
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3750, 370, True, 2, 10020, 1450, True, 2, 34200, 3850, True, 1, 35000, 2350, True, 2, 31250, 3350, True, 2, 30570, 1450, blacksmith, ''); // Mushketer
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 5706, 350, True, 2, 9030, 4350, True, 2, 32706, 1000, True, 1, 39556, 2350, True, 2, 27060, 3350, True, 2, 40600, 1550, blacksmith, ''); // Mushketer
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 5706, 750, True, 2, 9030, 1050, True, 2, 32706, 2900, True, 1, 39556, 5450, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3500, 350, True, 2, 11230, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer_PR
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3500, 350, True, 1, 11230, 1350, True, 1, 35706, 4000, True, 2, 36556, 4350, True, 2, 30060, 1350, True, 3, 37600, 1350, blacksmith, ''); // Mushketer_DA
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3906, 350, True, 2, 9030, 1150, True, 2, 37706, 4200, True, 1, 32556, 3350, True, 2, 34060, 2350, True, 2, 36500, 1550, blacksmith, ''); // Mushketer
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3500, 350, True, 1, 11230, 1350, True, 1, 35706, 4000, True, 2, 36556, 4350, True, 2, 30060, 1350, True, 3, 37600, 1350, blacksmith, '');
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 5706, 750, True, 2, 9030, 1050, True, 2, 32706, 2900, True, 1, 39556, 5450, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, '');
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 2, 35706, 4000, True, 1, 36556, 4350, True, 2, 30060, 1350, True, 2, 37600, 1350, blacksmith, ''); // Mushketer
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 2, 2, True, ind, linkind);
      end;
      
      case cid of
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _pru : member := 'grenadierpru';
         _den : member := 'grenadierden';
         _bav : member := 'grenadierbav';
         _sax : member := 'grenadiersax';
         _sco : member := '';
         _hun : member := 'grenadierhun';
         else
         member := 'grenadier';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1800, 800, True, 3, 11200, 1750, True, 4, 33000, 2900, True, 5, 42000, 4800, True, 6, 52000, 3800, True, 1500, 64010, 15200, blacksmith, ''); // Grenader
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 1300, True, 3, 10000, 1900, True, 4, 22000, 2900, True, 5, 52000, 3700, True, 6, 52000, 4800, True, 1500, 60000, 16000, blacksmith, ''); // Grenader
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 3000, 800, True, 3, 11000, 1800, True, 4, 31000, 2800, True, 5, 43000, 3800, True, 6, 62000, 4800, True, 1500, 52000, 15800, blacksmith, ''); // Grenader
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 800, True, 3, 13000, 1800, True, 4, 25000, 1800, True, 5, 49000, 4800, True, 6, 54000, 5800, True, 1500, 60000, 14590, blacksmith, ''); // Grenader
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 800, True, 3, 13000, 2800, True, 4, 32000, 1800, True, 5, 52000, 4800, True, 6, 42000, 3800, True, 1500, 64000, 14800, blacksmith, ''); // Grenader
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 3, 1000, 800, True, 4, 13000, 2800, True, 4, 32000, 1800, True, 4, 52000, 4800, True, 5, 42000, 3800, True, 1500, 64000, 14800, blacksmith, ''); // Grenader
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 800, True, 3, 13000, 2800, True, 4, 32000, 1800, True, 5, 52000, 4800, True, 6, 42000, 3800, True, 1500, 64000, 14800, blacksmith, '');
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 800, True, 3, 13000, 1800, True, 4, 25000, 1800, True, 5, 49000, 4800, True, 6, 54000, 5800, True, 1500, 60000, 14590, blacksmith, '');
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 6, 1000, 800, True, 5, 13000, 1800, True, 4, 25000, 1800, True, 3, 49000, 4800, True, 2, 54000, 5800, True, 1500, 60000, 14590, blacksmith, '');
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 800, True, 3, 12000, 1800, True, 4, 32000, 2800, True, 5, 42000, 3800, True, 6, 52000, 4800, True, 1500, 62000, 15800, blacksmith, ''); // Grenader
         end;
         AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 3, 1, True, ind, linkind);
         // make last attack upgrade to increase grenade damage
         country.upgrade[ind-1].tooltiptype := gc_upg_tooltiptype_grenadedmg;
         country.upgrade[ind-1].iarrparam1[0] := gc_obj_weapon_kind_mortarball;
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3506, 220, True, 2, 11250, 1450, True, 3, 37200, 3300, True, 1, 40400, 3050, True, 2, 22060, 350, True, 3, 63900, 2350, blacksmith, ''); // Grenader
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3250, 450, True, 2, 11030, 1350, True, 3, 36200, 2500, True, 1, 16600, 3650, True, 2, 60060, 1050, True, 3, 64000, 1650, blacksmith, ''); // Grenader
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 4506, 750, True, 2, 10130, 950, True, 3, 25706, 500, True, 1, 46556, 1350, True, 2, 50060, 6050, True, 3, 44000, 1650, blacksmith, ''); // Grenader
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 7705, 350, True, 2, 7030, 1350, True, 3, 21706, 1000, True, 1, 22556, 5350, True, 2, 30060, 1750, True, 3, 62000, 950, blacksmith, ''); // Grenader
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3205, 375, True, 2, 11030, 4350, True, 3, 36206, 500, True, 1, 34950, 1350, True, 2, 30060, 2150, True, 3, 64000, 2550, blacksmith, ''); // Grenader
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 3205, 375, True, 3, 11030, 4350, True, 3, 36206, 500, True, 2, 34950, 1350, True, 1, 30060, 2150, True, 1, 64000, 2550, blacksmith, ''); // Grenader
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3205, 375, True, 2, 11030, 4350, True, 3, 36206, 500, True, 1, 34950, 1350, True, 2, 30060, 2150, True, 3, 64000, 2550, blacksmith, '');
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 7705, 350, True, 2, 7030, 1350, True, 2, 21706, 1000, True, 2, 22556, 5350, True, 2, 30060, 1750, True, 2, 62000, 950, blacksmith, '');
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 7705, 350, True, 2, 7030, 1350, True, 2, 21706, 1000, True, 2, 22556, 5350, True, 2, 30060, 1750, True, 2, 62000, 950, blacksmith, '');
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 11030, 1350, True, 3, 35706, 3000, True, 1, 36556, 3350, True, 2, 30060, 1350, True, 3, 64000, 1350, blacksmith, ''); // Grenader
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 3, 2, True, ind, linkind);
      end;
      
      case cid of
         _eng : member := 'bagpiper';
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _sco : member := '';
         else
         member := 'drummer18';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 805, 65, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 10, 555, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Volinshik
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 205, 150, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 900, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 900, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 450, 75, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 900, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 205, 90, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 900, 45, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 15, 706, 50, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Barabanshik
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_drummerdef, 4, 2, True, ind, linkind);
      end;
      
      case cid of
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _sco : member := '';
         else
         member := 'officer18';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1200, 700, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 800, 950, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 2000, 200, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 200, 910, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1200, 750, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1200, 750, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 900, 775, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 200, 910, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1200, 750, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 200, 910, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1200, 750, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 1000, 800, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
         end;
         AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 5, 1, True, ind, linkind);
         country.upgrade[ind-1].time := 46.875;
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 2105, 450, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 2105, 300, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 605, 950, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 305, 950, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1500, 375, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1500, 375, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1606, 650, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 305, 950, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1500, 375, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 305, 950, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1500, 375, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 1706, 350, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, academy, ''); // Oficer_rusevr2
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 5, 2, True, ind, linkind);
         country.upgrade[ind-1].time := 46.875;
      end;
   end;
   
   // stables
   upgplace := csid+'sta';
   case cid of
      _rus : member := 'vityaz';
      _ukr : member := '';
      _pol : member := '';
      _swe : member := 'reiterswe';
      _tur : member := '';
      _alg : member := '';
      _sco : member := '';
      else
      member := 'reiter';
   end;
   if (member<>'') then
   begin
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7500, 1800, blacksmith, ''); // Konni_Ricar
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 100, True, 2, 500, 280, True, 1, 4400, 220, True, 1, 3050, 320, True, 1, 2030, 800, True, 1, 7000, 1600, blacksmith, ''); // Konni_Ricar
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 400, 50, True, 2, 1000, 270, True, 1, 4400, 180, True, 1, 2750, 420, True, 1, 2530, 600, True, 1, 7500, 1700, blacksmith, ''); // Konni_Ricar
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Konni_Ricar
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Tiagoli_koval_rus
         _ukr : ;
         _pol : ;
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Reitar_Shwec
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 800, 100, True, 2, 800, 220, True, 1, 2400, 380, True, 1, 4250, 220, True, 1, 4030, 900, True, 1, 6000, 1600, blacksmith, ''); // Konni_Ricar
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Konni_Ricar
         _tur : ;
         _alg : ;
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 800, 100, True, 2, 800, 220, True, 1, 2400, 380, True, 1, 4250, 220, True, 1, 4030, 900, True, 1, 6000, 1600, blacksmith, ''); // Konni_Ricar
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4600, 280, True, 1, 2050, 220, True, 1, 3530, 500, True, 1, 6500, 1900, blacksmith, ''); // Konni_Ricar
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 800, 220, True, 1, 2400, 380, True, 1, 4250, 220, True, 1, 4030, 900, True, 1, 6000, 1600, blacksmith, ''); // Konni_Ricar
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, '');
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 800, 220, True, 1, 2400, 380, True, 1, 4250, 220, True, 1, 4030, 900, True, 1, 6000, 1600, blacksmith, ''); // Konni_Ricar
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, '');
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Konni_Ricar
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, ''); // Konni_Ricar
      end;
      AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 0, 1, True, ind, linkind);
      var i : Integer;
      for i:=1 to 6 do
      country.upgrade[ind-i].time := 23.4375;
      case cid of
         _aus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Konni_Ricar
         _fra : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 600, 135, 400, True, 3, 200, 200, 300, True, 3, 800, 100, 560, True, 2, 3200, 300, 300, True, 1, 1600, 350, 650, True, 1, 15700, 1000, 5000, blacksmith, ''); // Konni_Ricar
         _eng : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 500, 35, 200, True, 3, 300, 200, 500, True, 3, 950, 200, 620, True, 2, 1450, 300, 540, True, 1, 6200, 550, 600, True, 1, 12000, 720, 3730, blacksmith, ''); // Konni_Ricar
         _spa : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Konni_Ricar
         _rus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Tiagoli_koval_rus
         _ukr : ;
         _pol : ;
         _swe : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 300, True, 1, 600, 100, 400, True, 2, 800, 200, 560, True, 2, 1600, 300, 640, True, 3, 3200, 350, 300, True, 2, 16000, 1000, 5000, blacksmith, ''); // Reitar_Shwec
         _pru : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 400, True, 3, 600, 100, 300, True, 3, 800, 200, 560, True, 2, 1600, 300, 340, True, 1, 2200, 350, 600, True, 1, 17000, 950, 5200, blacksmith, ''); // Konni_Ricar
         _ven : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Konni_Ricar
         _tur : ;
         _alg : ;
         _den : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 400, True, 3, 600, 100, 300, True, 3, 800, 200, 560, True, 2, 1600, 300, 340, True, 1, 2200, 350, 600, True, 1, 17000, 950, 5200, blacksmith, ''); // Konni_Ricar
         _net : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 250, 55, 300, True, 3, 550, 200, 400, True, 3, 600, 100, 560, True, 2, 1800, 500, 640, True, 1, 5200, 250, 300, True, 1, 14000, 990, 5000, blacksmith, ''); // Konni_Ricar
         _bav : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 400, True, 3, 600, 100, 300, True, 3, 800, 200, 560, True, 2, 1600, 300, 340, True, 1, 2200, 350, 600, True, 1, 17000, 950, 5200, blacksmith, ''); // Konni_Ricar
         _sax : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, '');
         _por : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 400, True, 3, 600, 100, 300, True, 3, 800, 200, 560, True, 2, 1600, 300, 340, True, 1, 2200, 350, 600, True, 1, 17000, 950, 5200, blacksmith, ''); // Konni_Ricar
         _hun : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, '');
         _pie : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Konni_Ricar
         _swi : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 300, True, 3, 600, 100, 400, True, 3, 800, 200, 560, True, 2, 1600, 300, 640, True, 1, 3200, 350, 300, True, 1, 16000, 1000, 5000, blacksmith, ''); // Konni_Ricar
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 0, 2, True, ind, linkind);
      for i:=1 to 6 do
      country.upgrade[ind-i].time := 7.8125;
   end;

   case cid of
      _rus : member := 'cossackdon';
      _ukr : member := 'cossackregister';
      _pol : member := 'reiterpol';
      _tur : member := 'spakh';
      _alg : member := 'mameluke';
      _sco : member := 'lancersco';
      else
      member := '';
   end;
   if (member<>'') then
   begin
      var posx : Integer = 2;
      if (cid=_pol) then
      posx := 1
      else
      if (cid=_tur) or (cid=_alg) then
      posx := 0;
      //var cUpgType : Integer = _misc_SwitchInt(ctypeDamagePike, ctypeDamageSword, (cid=_pol));
      case cid of
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 1, 5000, 800, True, 2, 10000, 1200, True, 2, 20000, 1300, True, 3, 30000, 4000, True, 3, 20000, 5000, blacksmith, ''); // Tiagoli_kozak
         _ukr : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 3000, True, 2, 2000, 2000, True, 2, 7100, 8000, True, 2, 2250, 2000, True, 2, 3030, 5000, True, 1, 7000, 18000, blacksmith, ''); // Kozak_pikiner
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 1, 5000, 800, True, 1, 10000, 800, True, 2, 20000, 950, True, 2, 30000, 300, True, 3, 20000, 1500, blacksmith, ''); // Reitor_Polsha

         ////_tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 3000, True, 2, 2000, 2000, True, 3, 7100, 8000, True, 1, 2250, 2000, True, 1, 3030, 5000, True, 1, 7000, 18000, blacksmith, ''); // TUrkey_pikiner
         ////_alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 3000, True, 1, 2000, 2000, True, 1, 7100, 8000, True, 2, 2250, 2000, True, 2, 3030, 5000, True, 3, 7000, 18000, blacksmith, ''); // Mameluk
         //  _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 500, True, 1, 2000, 1000, True, 2, 7100, 1500, True, 1, 2250, 2000, True, 1, 3030, 2500, True, 1, 7000, 3000, blacksmith, ''); // TUrkey_pikiner
         //  _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 500, True, 1, 2000, 1000, True, 1, 7100, 1500, True, 1, 2250, 2000, True, 1, 3030, 2500, True, 2, 7000, 3000, blacksmith, ''); // Mameluk

         _tur : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 500, True, 1, 2000, 2000, True, 2, 7100, 3500, True, 1, 2250, 5000, True, 1, 3030, 6500, True, 1, 7000, 8000, blacksmith, ''); // TUrkey_pikiner
         _alg : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 500, True, 1, 2000, 2000, True, 1, 7100, 3500, True, 1, 2250, 5000, True, 1, 3030, 6500, True, 2, 7000, 8000, blacksmith, ''); // Mameluk
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 3000, True, 1, 2000, 2000, True, 2, 7100, 8000, True, 1, 2250, 2000, True, 2, 3030, 5000, True, 3, 7000, 18000, blacksmith, '');
      end;
      //restored upgrades, only wingedhussar and hackapell has pikes
      var cUpgType : Integer = ctypeDamagePike;
      if (cid=_pol) then cUpgType := ctypeDamageSword;
      AddUpgradePack(country, upgstruct, cUpgType, gc_upg_tooltiptype_infdmg, posx, 1, True, ind, linkind);
      case cid of
         _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 1350, True, 1, 1500, 2100, True, 1, 5000, 3300, True, 1, 10500, 4400, True, 2, 12600, 5500, True, 2, 40000, 6000, blacksmith, ''); // Tiagoli_kozak
         _ukr : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 3000, True, 2, 2000, 100, 5000, True, 2, 65000, 200, 10000, True, 2, 65000, 300, 4000, True, 2, 65000, 350, 20000, True, 2, 65000, 1000, 30000, blacksmith, ''); // Kozak_pikiner
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 900, True, 1, 1500, 850, True, 1, 5000, 950, True, 2, 10500, 400, True, 2, 12600, 1500, True, 3, 40000, 9000, blacksmith, ''); // Reitor_Polsha

         ////_tur : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 3000, True, 1, 2000, 100, 5000, True, 2, 44930, 200, 10000, True, 3, 44930, 300, 4000, True, 2, 44930, 350, 20000, True, 1, 44930, 1000, 30000, blacksmith, ''); // TUrkey_pikiner
         ////_alg : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 3000, True, 2, 2000, 100, 5000, True, 3, 44930, 200, 10000, True, 3, 44930, 300, 4000, True, 2, 44930, 350, 20000, True, 1, 44930, 1000, 30000, blacksmith, ''); // Mameluk
         //  _tur : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 500, True, 1, 2000, 100, 500, True, 2, 4200, 200, 2000, True, 3, 8900, 300, 3000, True, 2, 11200, 350, 4000, True, 1, 12500, 1000, 5000, blacksmith, ''); // TUrkey_pikiner
         //  _alg : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 500, True, 2, 2000, 100, 500, True, 3, 4200, 200, 2000, True, 3, 8900, 300, 3000, True, 2, 11200, 350, 4000, True, 1, 12500, 1000, 5000, blacksmith, ''); // Mameluk

         _tur : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 1000, True, 1, 2000, 100, 1000, True, 2, 40000, 200, 4000, True, 3, 40000, 300, 6000, True, 2, 40000, 350, 8000, True, 1, 40000, 1000, 10000, blacksmith, ''); // TUrkey_pikiner
         _alg : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 1000, True, 2, 2000, 100, 1000, True, 3, 40000, 200, 4000, True, 3, 40000, 300, 6000, True, 2, 40000, 350, 8000, True, 1, 40000, 1000, 10000, blacksmith, ''); // Mameluk
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 4000, 1350, True, 1, 3500, 2100, True, 2, 8000, 3300, True, 3, 14500, 4400, True, 3, 22600, 5500, True, 2, 30000, 6000, blacksmith, ''); // Tiagoli_kozak
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, posx, 2, True, ind, linkind);
   end;
   
   case cid of
      _rus : member := '';
      _ukr : member := '';
      _tur : member := '';
      _alg : member := '';
      _pol : member := 'dragoonpol';
      _sco : member := '';
      else
      member := 'dragoon';
   end;
   if (member<>'') then
   begin
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 400, 150, True, 1, 800, 200, True, 2, 300, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _rus : ;
         _ukr : ;
         //_pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 700, 250, True, 2, 500, 200, True, 3, 700, 240, True, 1, 1200, 900, True, 1, 1800, 800, True, 3, 850, 650, blacksmith, ''); // Dragun
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 500, 200, True, 2, 700, 240, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, '');
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 500, 100, True, 2, 900, 640, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _tur : ;
         _alg : ;
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 500, 100, True, 2, 900, 640, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 600, 100, True, 2, 800, 540, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 500, 100, True, 2, 900, 640, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 700, 250, True, 1, 500, 100, True, 2, 900, 640, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 150, True, 1, 700, 200, True, 2, 900, 340, True, 1, 0, 0, True, 1, 0, 0, True, 3, 0, 0, blacksmith, ''); // Dragun
      end;
      var bEnabled : Boolean = True; //(cid<>_pol);
      AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, 2, 1, bEnabled, ind, linkind);
      // disabling upgrades past 4th one
      var i, j : Integer;
      for i:=0 to gc_country_maxupgradecount-1 do
      begin
         for j:=0 to gc_country_upgradelinks_maxcount-1 do
         begin
            if StrExists(country.upgradelinks[i, 0], 'sta.dragoon.1.3') or StrExists(country.upgradelinks[i, 0], 'sta.dragoonpol.1.3') then
            country.upgradelinks[i, 1]:='';
         end;
      end;

      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 5000, blacksmith, ''); // Dragun
         _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 5000, blacksmith, ''); // Dragun
         _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1300, 250, True, 2, 5200, 650, True, 2, 2000, 1450, True, 1, 6000, 100, True, 2, 1000, 3250, True, 2, 7001, 4400, blacksmith, ''); // Dragun
         _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _rus : ;
         _ukr : ;
         //_pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 3, 6200, 1150, True, 3, 5400, 2150, True, 1, 2000, 1200, True, 1, 3000, 4250, True, 6, 5001, 8101, blacksmith, ''); // Dragun
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 1, 6200, 550, True, 1, 5400, 1150, True, 1, 2000, 800, True, 2, 3000, 2250, True, 2, 5001, 6100, blacksmith, '');
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 650, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 250, True, 2, 6300, 850, True, 2, 4600, 1350, True, 1, 2500, 750, True, 2, 800, 2750, True, 2, 2001, 7200, blacksmith, ''); // Dragun
         _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _tur : ;
         _alg : ;
         _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 250, True, 2, 6300, 850, True, 2, 4600, 1350, True, 1, 2500, 750, True, 2, 800, 2750, True, 2, 2001, 8200, blacksmith, ''); // Dragun
         _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 400, 250, True, 2, 7600, 550, True, 2, 4000, 950, True, 1, 4000, 900, True, 2, 4000, 2150, True, 2, 3001, 6200, blacksmith, ''); // Dragun
         _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 250, True, 2, 6300, 850, True, 2, 4600, 1350, True, 1, 2500, 750, True, 2, 800, 2750, True, 2, 2001, 8200, blacksmith, ''); // Dragun
         _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 600, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 250, True, 2, 6300, 850, True, 2, 4600, 1350, True, 1, 2500, 700, True, 2, 800, 2750, True, 2, 2001, 8200, blacksmith, ''); // Dragun
         _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
         _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 150, True, 2, 6600, 750, True, 2, 5000, 1250, True, 1, 3000, 700, True, 2, 1000, 2350, True, 2, 6001, 6000, blacksmith, ''); // Dragun
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 2, 2, bEnabled, ind, linkind);
   end;
   
   // cavalry 18 century
   if (bhave18century) then
   begin
      case cid of
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _sco : member := '';
         _sax : member := 'guardcavalrysax';
         else
         member := 'cuirassier';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 32000, 600, True, 1, 12000, 2200, True, 1, 62000, 1300, True, 2, 57000, 3150, True, 2, 61055, 8100, True, 3, 47150, 4020, blacksmith, century18); // Kirasir
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 10000, 900, True, 1, 34000, 1000, True, 1, 42000, 3200, True, 2, 61000, 3150, True, 2, 47055, 4100, True, 3, 59050, 11020, blacksmith, century18); // Kirasir
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 11000, 1600, True, 1, 33000, 300, True, 1, 64000, 3200, True, 2, 59000, 2150, True, 2, 52055, 5100, True, 3, 54050, 7020, blacksmith, century18); // Kirasir
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 10000, 200, True, 1, 34000, 1700, True, 1, 64000, 2100, True, 2, 58000, 4150, True, 2, 59055, 3100, True, 3, 47050, 8150, blacksmith, century18); // Kirasir
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 10000, 200, True, 1, 34000, 1700, True, 1, 64000, 2100, True, 2, 58000, 4150, True, 2, 59055, 3100, True, 3, 47050, 8150, blacksmith, century18); // Kirasir
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 32000, 600, True, 1, 12000, 1300, True, 1, 64000, 2200, True, 2, 58000, 3150, True, 2, 59055, 4100, True, 3, 47050, 8050, blacksmith, century18); // Kirasir
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 11000, 1600, True, 1, 33000, 300, True, 1, 64000, 3200, True, 2, 59000, 2150, True, 2, 52055, 5100, True, 3, 54050, 7020, blacksmith, century18); // Kirasir
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 10000, 200, True, 2, 34000, 1700, True, 3, 64000, 2100, True, 1, 58000, 4150, True, 1, 59055, 3100, True, 1, 47050, 8150, blacksmith, century18); // Kirasir
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 11000, 1600, True, 1, 33000, 300, True, 1, 64000, 3200, True, 2, 59000, 2150, True, 2, 52055, 5100, True, 3, 54050, 7020, blacksmith, century18); // Kirasir
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 10000, 200, True, 1, 34000, 1700, True, 1, 64000, 2100, True, 2, 58000, 4150, True, 2, 59055, 3100, True, 3, 47050, 8150, blacksmith, century18); // Kirasir
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 12000, 600, True, 1, 32000, 1300, True, 1, 62000, 2200, True, 2, 61000, 3150, True, 2, 57055, 4100, True, 3, 49050, 8020, blacksmith, century18); // Kirasir
         end;
         AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 3, 1, True, ind, linkind);
         case cid of
            _aus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _fra : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1520, 750, 1000, True, 3, 3200, 350, 1950, True, 3, 7600, 300, 3110, True, 2, 6200, 6200, 100, True, 1, 11700, 4450, 7000, True, 1, 9700, 3244, 5060, blacksmith, century18); // Kirasir
            _eng : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1260, 350, 200, True, 3, 3500, 750, 2800, True, 3, 2600, 900, 2930, True, 2, 12700, 5600, 200, True, 1, 5700, 1350, 7000, True, 1, 12700, 5424, 5060, blacksmith, century18); // Kirasir
            _spa : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _rus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _ukr : ;
            _pol : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _swe : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 2505, 350, 1000, True, 3, 2000, 300, 2000, True, 3, 5600, 750, 3030, True, 2, 10700, 6100, 100, True, 1, 8100, 2150, 5000, True, 1, 9200, 4900, 7060, blacksmith, century18); // Kirasir
            _pru : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1520, 450, 1000, True, 3, 7000, 750, 2000, True, 3, 3600, 3300, 3050, True, 2, 8700, 3200, 200, True, 1, 8700, 2650, 4300, True, 1, 11200, 4700, 6760, blacksmith, century18); // Kirasir
            _ven : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1520, 450, 1000, True, 3, 7000, 750, 2000, True, 3, 3600, 3300, 3050, True, 2, 8700, 3200, 200, True, 1, 8700, 2650, 4300, True, 1, 11200, 4700, 6760, blacksmith, century18); // Kirasir
            _net : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1250, 450, 1000, True, 3, 2500, 650, 2000, True, 3, 4600, 200, 3050, True, 2, 11700, 6100, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _bav : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 2505, 350, 1000, True, 3, 2000, 300, 2000, True, 3, 5600, 750, 3030, True, 2, 10700, 6100, 100, True, 1, 8100, 2150, 5000, True, 1, 9200, 4900, 7060, blacksmith, century18); // Kirasir
            _sax : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1520, 450, 1000, True, 2, 7000, 750, 2000, True, 3, 3600, 3300, 3050, True, 3, 8700, 3200, 200, True, 1, 8700, 2650, 4300, True, 1, 11200, 4700, 6760, blacksmith, century18); // Kirasir
            _por : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 2505, 350, 1000, True, 3, 2000, 300, 2000, True, 3, 5600, 750, 3030, True, 2, 10700, 6100, 100, True, 1, 8100, 2150, 5000, True, 1, 9200, 4900, 7060, blacksmith, century18); // Kirasir
            _hun : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1520, 450, 1000, True, 3, 7000, 750, 2000, True, 3, 3600, 3300, 3050, True, 2, 8700, 3200, 200, True, 1, 8700, 2650, 4300, True, 1, 11200, 4700, 6760, blacksmith, century18); // Kirasir
            _pie : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
            _swi : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 1760, 350, 1000, True, 3, 3000, 750, 2000, True, 3, 7600, 300, 3030, True, 2, 8700, 6200, 100, True, 1, 8700, 2350, 5000, True, 1, 9700, 4444, 7060, blacksmith, century18); // Kirasir
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 3, 2, True, ind, linkind);
      end;
      
      case cid of
         _ukr : member := '';
         _pru : member := 'hussarpru';
         _hun : member := '';
         _tur : member := '';
         _alg : member := '';
         _sco : member := '';
         _swi : member := 'hussarswi';
         else
         member := 'hussar';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _fra : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 800, 200, True, 2, 0, 4800, 2800, True, 3, 25200, 0, 2500, True, 4, 27000, 0, 2500, True, 1, 46200, 0, 4300, True, 1, 21000, 0, 5200, blacksmith, century18); // Gusar_evro
            _eng : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1200, 400, True, 2, 0, 3800, 2000, True, 3, 10200, 0, 3000, True, 4, 42000, 0, 2000, True, 1, 49200, 0, 6500, True, 1, 14000, 0, 2000, blacksmith, century18); // Gusar_evro
            _spa : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _rus : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _ukr : ;
            _pol : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _swe : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1200, 1500, True, 2, 0, 4400, 1500, True, 3, 10200, 0, 1500, True, 4, 42000, 0, 3500, True, 1, 29200, 0, 5500, True, 1, 40000, 0, 4400, blacksmith, century18); // Gusar_evro
            _pru : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 2800, 1600, True, 1, 0, 2800, 1400, True, 2, 10200, 0, 3000, True, 2, 42000, 0, 2000, True, 3, 29200, 0, 5500, True, 3, 40000, 0, 4000, blacksmith, century18); // Gusar_NEW
            _ven : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 2800, 1600, True, 2, 0, 2800, 1400, True, 3, 10200, 0, 4000, True, 4, 42000, 0, 2000, True, 1, 29200, 0, 5500, True, 1, 40000, 0, 4000, blacksmith, century18); // Gusar_NEW
            _net : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 3000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _bav : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 3000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _sax : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1200, 1500, True, 2, 0, 4400, 1500, True, 3, 10200, 0, 2500, True, 4, 42000, 0, 3500, True, 1, 29200, 0, 5500, True, 1, 40000, 0, 4400, blacksmith, century18); // Gusar_evro
            _por : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 3000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _hun : ;
            _pie : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 0, 1800, 1000, True, 2, 0, 3800, 2000, True, 3, 20200, 0, 2000, True, 4, 32000, 0, 3000, True, 1, 49200, 0, 3500, True, 1, 20000, 0, 6000, blacksmith, century18); // Gusar_evro
            _swi : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 0, 2800, 1600, True, 2, 0, 2800, 1400, True, 2, 10200, 0, 3000, True, 2, 42000, 0, 2000, True, 2, 29200, 0, 5500, True, 2, 40000, 0, 4000, blacksmith, century18); //
         end;
         AddUpgradePack(country, upgstruct, ctypeDamageSword, gc_upg_tooltiptype_infdmg, 4, 1, True, ind, linkind);
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 1350, True, 1, 2900, 2350, True, 1, 4600, 5350, True, 2, 4000, 8350, True, 2, 7000, 15350, True, 3, 51000, 20150, blacksmith, century18); // Gusar_evro
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1550, 1150, True, 1, 2150, 2550, True, 1, 5600, 4350, True, 2, 4000, 9350, True, 2, 9000, 13200, True, 2, 52000, 19850, blacksmith, century18); // Gusar_evro
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 350, True, 1, 3900, 3350, True, 1, 1100, 5350, True, 2, 7800, 8350, True, 2, 1700, 17350, True, 3, 55200, 17150, blacksmith, century18); // Gusar_evro
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 1250, True, 1, 3200, 2450, True, 1, 3600, 3350, True, 2, 6000, 10350, True, 2, 9000, 13350, True, 3, 48000, 22150, blacksmith, century18); // Gusar_NEW
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 1250, True, 1, 3200, 2450, True, 1, 3600, 3350, True, 2, 6000, 10350, True, 2, 9000, 13350, True, 3, 48000, 22150, blacksmith, century18); // Gusar_NEW
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 350, True, 1, 3900, 3350, True, 1, 1100, 5350, True, 2, 7800, 8350, True, 2, 1700, 17350, True, 3, 55200, 17150, blacksmith, century18); // Gusar_evro
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _hun : ;
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1760, 1350, True, 1, 1900, 2350, True, 1, 1600, 5350, True, 2, 8000, 8350, True, 2, 2000, 15350, True, 3, 56000, 20150, blacksmith, century18); // Gusar_evro
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 1250, True, 2, 3200, 2450, True, 2, 3600, 3350, True, 1, 6000, 10350, True, 2, 9000, 13350, True, 2, 48000, 22150, blacksmith, century18); //
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 4, 2, True, ind, linkind);
      end;
      
      case cid of
         _fra : member := 'dragoon18fra';
         _ukr : member := '';
         _tur : member := '';
         _alg : member := '';
         _net : member := 'dragoon18net';
         _sco : member := '';
         _hun : member := 'lightcavalry';
         _pie : member := 'dragoon18pie';
         else
         member := 'dragoon18';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_France
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 1000, 200, True, 2, 10200, 250, True, 4, 15200, 200, True, 2, 19850, 280, True, 2, 32000, 1180, True, 4, 32000, 980, blacksmith, century18); // Dragun_18
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 4500, 200, True, 2, 5500, 250, True, 4, 22000, 500, True, 2, 13000, 480, True, 2, 42000, 780, True, 4, 32000, 680, blacksmith, century18); // Dragun_18
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 4500, 200, True, 2, 5500, 250, True, 4, 22000, 500, True, 2, 13000, 480, True, 2, 42000, 780, True, 4, 32000, 680, blacksmith, century18); // Dragun_18
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 100, True, 2, 9000, 350, True, 3, 12000, 400, True, 1, 23000, 580, True, 2, 32000, 680, True, 3, 42000, 780, blacksmith, century18); // Dragun_18
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 4500, 200, True, 2, 5500, 250, True, 4, 22000, 500, True, 2, 13000, 480, True, 2, 42000, 780, True, 4, 32000, 680, blacksmith, century18); // Dragun_18
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 4500, 200, True, 2, 5500, 250, True, 3, 22000, 500, True, 1, 13000, 480, True, 1, 42000, 780, True, 2, 32000, 680, blacksmith, century18); // Dragun_18
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); //
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 2000, 100, True, 2, 9000, 350, True, 4, 12000, 400, True, 2, 23000, 580, True, 2, 32000, 680, True, 4, 42000, 780, blacksmith, century18); // Dragun_18
         end;
         AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, 5, 1, True, ind, linkind);
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 2, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 2, 21760, 9350, blacksmith, century18); // Dragun_France
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 250, 999, True, 1, 1360, 1250, True, 2, 17600, 2150, True, 1, 15600, 5350, True, 2, 19600, 3350, True, 3, 25760, 8350, blacksmith, century18); // Dragun_18
            _spa : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
            _rus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
            _ukr : ;
            _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
            _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 260, 935, True, 1, 1460, 1150, True, 2, 12600, 3350, True, 1, 19600, 2350, True, 2, 12600, 7350, True, 3, 26760, 7350, blacksmith, century18); // Dragun_18
            _pru : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 750, 935, True, 1, 1260, 1150, True, 2, 10600, 2350, True, 1, 22600, 6350, True, 2, 19600, 4350, True, 3, 15760, 9350, blacksmith, century18); // Dragun_18
            _ven : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
            _tur : ;
            _alg : ;
            _den : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 750, 935, True, 1, 1260, 1150, True, 2, 10600, 2350, True, 1, 22600, 5350, True, 2, 19600, 3350, True, 3, 15760, 9350, blacksmith, century18); // Dragun_18
            _net : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 2, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 4350, True, 2, 19600, 5350, True, 2, 21760, 8350, blacksmith, century18); // Dragun_18
            _bav : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 260, 935, True, 1, 1460, 1150, True, 2, 12600, 3350, True, 1, 19600, 3350, True, 2, 12600, 7350, True, 3, 26760, 7350, blacksmith, century18); // Dragun_18
            _sax : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 750, 935, True, 1, 1260, 1150, True, 2, 10600, 2350, True, 1, 22600, 5350, True, 2, 19600, 3350, True, 3, 15760, 9350, blacksmith, century18); // Dragun_18
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 260, 935, True, 1, 1460, 1150, True, 2, 12600, 3350, True, 1, 19600, 3350, True, 2, 12600, 7350, True, 3, 26760, 6350, blacksmith, century18); // Dragun_18
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 750, 935, True, 1, 1260, 1150, True, 2, 10600, 2350, True, 1, 22600, 5350, True, 1, 19600, 3350, True, 2, 15760, 9350, blacksmith, century18); // Dragun_18
            _pie : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 4350, True, 1, 19600, 5350, True, 2, 21760, 8350, blacksmith, century18); // Dragun_18
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 760, 935, True, 1, 1260, 1150, True, 2, 15600, 2350, True, 1, 17600, 3350, True, 2, 19600, 5350, True, 3, 21760, 9350, blacksmith, century18); // Dragun_18
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 5, 2, True, ind, linkind);
      end;
   end;
   
   // barrack 18 century unique units
   if (bhave18century) then
   begin
      upgplace := csid+'ba2';
      case cid of
         _aus : member := 'pandur';
         _fra : member := 'chasseur';
         _eng : member := 'highlander';
         _hun : member := 'pandurhun';
         _por : member := 'jagerpor';
         _swi : member := 'jagerswi';
         else
         member := '';
      end;
      if (member<>'') then
      begin
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3000, 750, True, 1, 4000, 1100, True, 2, 7000, 1800, True, 1, 12000, 350, True, 1, 32020, 850, True, 2, 45200, 1330, blacksmith, century18); // Pandur_Avstria
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 3000, 750, True, 2, 4000, 1100, True, 2, 7000, 1800, True, 2, 12000, 350, True, 2, 32020, 850, True, 2, 45200, 1330, blacksmith, century18); // Strelec_France
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 4000, 750, True, 2, 3000, 1100, True, 3, 7500, 1700, True, 1, 11000, 400, True, 1, 27020, 1150, True, 1, 40200, 1220, blacksmith, century18); // Strelec_eng
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3000, 750, True, 1, 4000, 1100, True, 1, 7000, 1800, True, 1, 12000, 350, True, 1, 32020, 850, True, 1, 45200, 1330, blacksmith, century18); // Strelec_France
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3000, 750, True, 1, 4000, 1100, True, 2, 7000, 1800, True, 1, 12000, 350, True, 1, 32020, 850, True, 2, 45200, 1330, blacksmith, century18); //
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 3, 3000, 750, True, 2, 4000, 1100, True, 1, 7000, 1800, True, 3, 12000, 350, True, 2, 32020, 850, True, 1, 45200, 1330, blacksmith, century18); //
         end;
         AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, 1, 1, True, ind, linkind);
         if (cid=_eng) then
         begin
            // disabling upgrades past 4th one
            var i, j : Integer;
            for i:=0 to gc_country_maxupgradecount-1 do
            for j:=0 to gc_country_upgradelinks_maxcount-1 do
            begin
               if StrExists(country.upgradelinks[i, 0], 'ba2.highlander.1.3') or StrExists(country.upgradelinks[i, 0], 'ba2.highlander.1.3') then
               country.upgradelinks[i, 1]:='';
            end;
         end;
         case cid of
            _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 2, 12060, 1350, True, 2, 36706, 2250, True, 1, 36706, 3350, True, 2, 37060, 1350, True, 2, 16706, 1350, blacksmith, century18); // Pandur_Avstria
            _fra : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 1, 12060, 1350, True, 1, 36706, 2150, True, 1, 36706, 3350, True, 1, 37060, 1350, True, 1, 16706, 1350, blacksmith, century18); // Strelec_France
            _eng : SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 3006, 400, True, 2, 10020, 1550, True, 2, 35706, 1850, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, century18); // Strelec_eng had 6 grades
            _por : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 1, 12060, 1350, True, 1, 36706, 2250, True, 1, 36706, 3350, True, 1, 37060, 1350, True, 1, 16706, 1350, blacksmith, century18); // Strelec_France
            _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 1, 12060, 1350, True, 2, 36706, 2050, True, 1, 36706, 3350, True, 1, 37060, 1350, True, 2, 16706, 1350, blacksmith, century18); // Pandur_Avstria
            _swi : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 3706, 350, True, 1, 12060, 1350, True, 1, 36706, 2250, True, 1, 36706, 3350, True, 1, 37060, 1350, True, 1, 16706, 1350, blacksmith, century18); //
         end;
         AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 1, 2, True, ind, linkind);
      end;
   end;
   
   // stable unique units
   upgplace := csid+'sta';
   case cid of
      _aus : member := 'croat';
      _ukr : member := 'cossacksich';
      _pol : member := 'wingedhussar';
      _swe : member := 'hackapell';
      _sco : member := 'raidersco';
      _hun : member := 'hussarhun';
      else
      member := '';
   end;
   if (member<>'') then
   begin
      var posx : Integer;
      if (cid=_aus) or (cid=_swe) or (cid=_hun) then
      posx := 1;
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 2, 5000, 800, True, 2, 10000, 1200, True, 1, 20000, 1300, True, 2, 30000, 3000, True, 2, 20000, 5000, blacksmith, ''); // Kavalerist_avstrii
         _ukr : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 1000, 3000, True, 2, 2000, 2000, True, 2, 7100, 8000, True, 1, 2250, 2000, True, 2, 3030, 4000, True, 2, 7000, 18000, blacksmith, ''); // Kozak_loshad
         _pol : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 400, 200, True, 2, 990, 120, True, 2, 2400, 380, True, 2, 4250, 220, True, 2, 7030, 200, True, 1, 3000, 2200, blacksmith, ''); // Poland_pikiner
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 2, 5000, 800, True, 2, 10000, 1200, True, 1, 20000, 1300, True, 2, 30000, 3000, True, 2, 20000, 5000, blacksmith, '');
         _sco : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 2, 5000, 800, True, 2, 10000, 1200, True, 3, 2000, 6000, True, 3, 8100, 1000, True, 1, 20000, 3000, blacksmith, '');
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 500, True, 2, 5000, 800, True, 2, 10000, 1200, True, 3, 20000, 1300, True, 4, 30000, 3000, True, 5, 20000, 5000, blacksmith, ''); // Kavalerist_avstrii
      end;
      //restored upgrades, only wingedhussar and hackapell has pikes
      var cUpgType : Integer = ctypeDamageSword;
      if (cid=_pol) or (cid=_swe) then cUpgType := ctypeDamagePike;
      AddUpgradePack(country, upgstruct, cUpgType, gc_upg_tooltiptype_infdmg, posx, 1, True, ind, linkind);
      case cid of
         _aus : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 1350, True, 1, 1500, 2100, True, 2, 5000, 2300, True, 2, 10500, 3400, True, 3, 12600, 4500, True, 3, 40000, 5000, blacksmith, ''); // Kavalerist_avstrii
         _ukr : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 200, 135, 3000, True, 2, 2000, 100, 5000, True, 2, 44930, 200, 10000, True, 2, 44930, 300, 4000, True, 2, 44930, 350, 20000, True, 2, 44930, 1000, 30000, blacksmith, ''); // Kozak_loshad
         _pol : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 2, 300, 35, 100, True, 2, 500, 200, 600, True, 2, 600, 300, 260, True, 2, 1800, 200, 940, True, 2, 2200, 150, 700, True, 2, 17150, 1200, 4600, blacksmith, ''); // Poland_pikiner
         _swe : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 1350, True, 2, 1500, 2100, True, 2, 5000, 2300, True, 1, 10500, 3400, True, 2, 12600, 4500, True, 2, 40000, 5000, blacksmith, '');
         _sco : SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 500, 50, 0, True, 2, 1500, 150, 0, True, 2, 5625, 560, 0, True, 2, 16200, 1080, 0, True, 2, 16200, 1080, 0, True, 1, 15000, 750, 0, blacksmith, '');
         _hun : SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 2000, 1350, True, 1, 1500, 2100, True, 1, 5000, 2300, True, 2, 10500, 3400, True, 2, 12600, 4500, True, 3, 40000, 5000, blacksmith, ''); // Kavalerist_avstrii
      end;
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, posx, 2, True, ind, linkind);
   end;
   if (cid=_fra) then
   begin
      member := 'kingmusketeer';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 12, 2000, 1350, True, 1, 0, 0, True, 2, 0, 0, True, 2, 0, 0, True, 2, 0, 0, True, 2, 0, 0, blacksmith, ''); // Korolrv_Mus
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 1, 2, True, ind, linkind);
      // removing upgrades past 2-nd, while leaving indices intact
      var i, j : Integer;
      for i:=0 to gc_country_maxupgradecount-1 do
      for j:=0 to gc_country_upgradelinks_maxcount-1 do
      begin
         if (country.upgradelinks[i, 0]='frasta.kingmusketeer.2.1') then
         country.upgradelinks[i, 1] := '';
      end;
   end;
   if (cid=_ukr) then
   begin
      member := 'hetman';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 30, 7000, 18000, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, ''); // Getman
      AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 4, 1, True, ind, linkind);
      SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 10, 44950, 1000, 20000, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, True, 0, 0, 0, 0, blacksmith, ''); // Getman
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 4, 2, True, ind, linkind);
   end;
   {if (cid=_pol) then
   begin
      member := 'dragoonpol';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 700, 250, True, 2, 500, 200, True, 3, 700, 240, True, 1, 1200, 900, True, 1, 1800, 800, True, 3, 850, 650, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, 2, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 3, 6200, 1150, True, 3, 5400, 2150, True, 1, 2000, 1200, True, 1, 3000, 4250, True, 6, 5001, 8101, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 2, 2, True, ind, linkind);
   end;}
   // hardcoded unique upgrades
   if (cid=_fra) then
   begin
      member := 'kingmusketeer';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 20, 7000, 2500, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, True, 0, 0, 0, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageBullet, gc_upg_tooltiptype_shooterdmg, 1, 1, True, ind, linkind);
   end;
   if (cid=_tur) then
   begin
      member := 'tatar';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 700, 250, True, 2, 500, 200, True, 2, 700, 240, True, 3, 1200, 900, True, 3, 1800, 800, True, 3, 850, 650, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageArrow, gc_upg_tooltiptype_shooterdmg, 2, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 1, 6200, 1150, True, 2, 5400, 2150, True, 1, 2000, 1200, True, 1, 3000, 4250, True, 2, 5001, 8101, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 2, 2, True, ind, linkind);
      member :='archertur';
      upgplace := csid+'bar';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 700, 250, True, 2, 500, 200, True, 2, 700, 240, True, 3, 1200, 900, True, 3, 1800, 800, True, 3, 850, 650, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageArrow, gc_upg_tooltiptype_shooterdmg, 3, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 2, 6200, 1150, True, 2, 5400, 2150, True, 1, 2000, 1200, True, 2, 3000, 4250, True, 2, 5001, 8101, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 3, 2, True, ind, linkind);
      //member :='jannisary';
   end;
   if (cid=_alg) then
   begin
      member :='archer';
      upgplace := csid+'bar';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 700, 250, True, 2, 500, 200, True, 2, 700, 240, True, 3, 1200, 900, True, 3, 1800, 800, True, 3, 850, 650, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageArrow, gc_upg_tooltiptype_shooterdmg, 2, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 1, 2200, 550, True, 2, 3400, 850, True, 1, 2000, 400, True, 1, 3000, 850, True, 2, 4000, 1200, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 2, 2, True, ind, linkind);
   end;
   if (cid=_sco) then
   begin
      member :='archersco';
      upgplace := csid+'ba2';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 2, 3000, 360, True, 3, 7500, 700, True, 4, 9750, 1200, True, 2, 18000, 1800, True, 4, 33200, 4320, True, 5, 55000, 7550, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageArrow, gc_upg_tooltiptype_shooterdmg, 2, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 900, 250, True, 2, 2200, 450, True, 3, 5400, 800, True, 3, 12500, 1000, True, 2, 20000, 1200, True, 1, 16500, 1875, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 2, 2, True, ind, linkind);
   end;
   // linked additional upgrades
   upgplace := csid+'bar';
   case cid of
      _rus : member := 'pikemanrus';
      _ukr : member := '';
      _pol : member := 'pikemanpol';
      _tur : member := 'pikemantur';
      _alg : member := 'pikemantur';
      _sco : member := 'pikemansco';
      _por : member := 'pikemanpor';
      _swi : member := 'pikemanswi';
      //_spa : member := 'pikemanspa';
      else
      member := 'pikeman';
   end;
   if (member<>'') then
   begin
      case cid of
         _rus : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 0, 1, ind, 15000, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 0, 2, ind, 11250, 0, 0, 1500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _pol : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 3, False, 500, 0, 1, ind, 22500, 0, 0, 2800, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 0, 2, ind, 15000, 0, 0, 1000, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _tur : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 0, 1, ind, 18750, 0, 0, 2350, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 0, 2, ind, 16875, 0, 0, 2250, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _alg : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 0, 1, ind, 18750, 0, 0, 2350, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 0, 2, ind, 16875, 0, 0, 2250, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _sco : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 3, False, 500, 0, 1, ind, 22500, 0, 0, 2800, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 0, 2, ind, 16875, 0, 0, 2250, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _por : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 3, False, 500, 0, 1, ind, 15000, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 0, 2, ind, 11250, 0, 0, 1500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         _swi : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 1, False, 500, 0, 1, ind, 15000, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 0, 2, ind, 11250, 0, 0, 1500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
         {_spa : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 0, 1, ind, 15000, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 0, 2, ind, 11250, 0, 0, 1500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;}
         else
         begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 0, 1, ind, 15000, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 0, 2, ind, 11250, 0, 0, 1500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
         end;
      end;
   end;
   //swordinfantry
   case cid of
      _aus : member := 'roundshier';
      _tur : member := 'lightinfantry';
      _alg : member := 'lightinfantry';
      else
      member := '';
   end;
   if (member<>'') then
   begin
      var i : Integer;
      case cid of
         _aus : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(4), 5, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 1, False, 500, 1, 1, ind, 7500, 0, 0, 900, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(5), 6, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 1, False, 500, 1, 1, ind, 9000, 0, 0, 1080, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 1, 1, ind, 18750, 0, 0, 2250, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(i), upgplace+'.'+member+'.1.'+IntToStr(i+1), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(4), 5, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 3750, 0, 0, 450, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(5), 6, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 6750, 0, 0, 810, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 1, 2, ind, 9375, 0, 0, 1125, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(i), upgplace+'.'+member+'.2.'+IntToStr(i+1), linkind);
         end;
         _tur : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(4), 5, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 1, False, 500, 1, 1, ind, 3000, 0, 0, 360, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(5), 6, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 1, False, 500, 1, 1, ind, 4500, 0, 0, 540, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 1, 1, ind, 9375, 0, 0, 1125, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(i), upgplace+'.'+member+'.1.'+IntToStr(i+1), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(4), 5, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 3600, 0, 0, 600, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(5), 6, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 5400, 0, 0, 900, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 1, 2, ind, 11250, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(i), upgplace+'.'+member+'.2.'+IntToStr(i+1), linkind);
         end;
         _alg : begin
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(4), 5, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 1, 1, ind, 3000, 0, 0, 360, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(5), 6, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 2, False, 500, 1, 1, ind, 4500, 0, 0, 540, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_infdmg, gc_upg_type_damage, 3, False, 500, 1, 1, ind, 9375, 0, 0, 1125, 0, 0, bAddIfNotExist, 0, gc_obj_weapon_kind_sword, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(i), upgplace+'.'+member+'.1.'+IntToStr(i+1), linkind);
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(4), 5, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 3600, 0, 0, 600, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(5), 6, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 1, False, 500, 1, 2, ind, 5400, 0, 0, 900, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 1, 2, ind, 11250, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
            for i:=3 to 5 do
            _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(i), upgplace+'.'+member+'.2.'+IntToStr(i+1), linkind);
         end;
      end;
   end;
   //unique musketeer upgrades
   if (cid=_tur) then
   begin
      var i : Integer;
      member := 'jannisary';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(4), 5, gc_upg_tooltiptype_shooterdmg, gc_upg_type_damage, 1, False, 500, 2, 1, ind, 5000, 0, 0, 1600, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(5), 6, gc_upg_tooltiptype_shooterdmg, gc_upg_type_damage, 2, False, 500, 2, 1, ind, 7500, 0, 0, 3200, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_shooterdmg, gc_upg_type_damage, 3, False, 500, 2, 1, ind, 10000, 0, 0, 4800, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      for i:=3 to 5 do
      _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(i), upgplace+'.'+member+'.1.'+IntToStr(i+1), linkind);
   end;
   if (cid=_ukr) then
   begin
      member := 'serdiuk';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.'+IntToStr(6), 7, gc_upg_tooltiptype_shooterdmg, gc_upg_type_damage, 3, False, 500, 0, 1, ind, 60000, 0, 0, 8000, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 2, False, 500, 0, 2, ind, 11250, 0, 0, 1125, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeLink(country, upgplace+'.'+member+'.1.'+IntToStr(5), upgplace+'.'+member+'.1.'+IntToStr(6), linkind);
      _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(5), upgplace+'.'+member+'.2.'+IntToStr(6), linkind);
   end;
   if (cid=_tur) then
   begin
      member := 'sipahi';
      upgplace := csid+'sta';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 500, 100, True, 2, 900, 220, True, 1, 4400, 280, True, 1, 2250, 320, True, 1, 3030, 600, True, 1, 7000, 1800, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamageSword, gc_upg_tooltiptype_infdmg, 4, 1, True, ind, linkind);
      SetUpgStructFoodGoldIron(upgstruct, upgplace, member, 1, 200, 135, 300, True, 2, 600, 100, 400, True, 2, 800, 200, 560, True, 2, 1600, 300, 640, True, 2, 3200, 350, 300, True, 3, 16000, 1000, 5000, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_horsedef, 4, 2, True, ind, linkind);
   end;
   if (cid=_spa) then
   begin
      member := 'pikemanspa';
      upgplace := csid+'bar';
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 200, 50, True, 2, 1300, 300, True, 3, 3600, 450, True, 2, 7200, 1850, True, 1, 16030, 2000, True, 1, 15000, 1875, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeDamagePike, gc_upg_tooltiptype_infdmg, 0, 1, True, ind, linkind);
      SetUpgStructFoodGold(upgstruct, upgplace, member, 1, 150, 50, True, 1, 900, 175, True, 2, 4500, 300, True, 1, 9005, 507, True, 1, 18010, 3050, True, 2, 16000, 1000, blacksmith, '');
      AddUpgradePack(country, upgstruct, ctypeProtection, gc_upg_tooltiptype_infdef, 0, 2, True, ind, linkind);
   end;
   if (cid=_eng) then
   begin
      member := 'highlander';
      upgplace := csid+'ba2';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(4), 5, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 1, 2, ind, 3600, 0, 0, 600, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(5), 6, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 1, 2, ind, 5400, 0, 0, 900, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.'+IntToStr(6), 7, gc_upg_tooltiptype_infdef, gc_upg_type_protection, 3, False, 500, 1, 2, ind, 11250, 0, 0, 1875, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, gc_obj_weapon_kind_arrow, member, '', '', '', '', '', '', '', '', '', True, blacksmith, '', '', '', '', '', '', '');
      var i : Integer;
      for i:=3 to 5 do
      _country_AddUpgradeLink(country, upgplace+'.'+member+'.2.'+IntToStr(i), upgplace+'.'+member+'.2.'+IntToStr(i+1), linkind);
   end;
end;

// _country_ClearOfficerFormations
//
procedure _country_ClearOfficerFormations(var country : TCountry);
begin
   var i, j, k : Integer;
   for i:=0 to gc_country_maxofficers-1 do
   begin
      country.officers[i].officersid := '';
      country.officers[i].drummersid := '';
      for j:=0 to gc_country_maxformationcount-1 do
      begin
         country.officers[i].formations[j].stype := '';
         for k:=0 to gc_country_maxofficersformationmask-1 do
         country.officers[i].formations[j].masks[k] := '';
      end;
      for j:=0 to gc_country_maxformationunitcount-1 do
      country.officers[i].units[j] := '';
   end;
end;

// _country_GetOfficersIndexByOfficerSID
//
function _country_GetOfficersIndexByOfficerSID(cid : Integer; var officersid : String) : Integer;
begin
   Result := -1;
   var i : Integer;
   for i:=0 to gc_country_maxofficers-1 do
   begin
      if (gCountry[cid].officers[i].officersid=officersid) then
      begin
         Result := i;
         break;
      end;
   end;
end;

// _country_InitOfficerFormations
//
procedure _country_InitOfficerFormations(var country : TCountry);
begin
   procedure AddFormationArtHowitzer(var country : TCountry; var ind : Integer; const artillerysid : String; const sformationtype, m0, m1, m2, m3, m4, m5, m6, m7, m8 : String);
   begin
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, artillerysid)) then
      begin
         var iformationtype : Integer;
         country.officers[ind].officersid := artillerysid;
         country.officers[ind].drummersid := artillerysid;
         country.officers[ind].units[0] := artillerysid;
         country.officers[ind].formations[iformationtype].stype := sformationtype;
         country.officers[ind].formations[iformationtype].masks[0] := m0;
         country.officers[ind].formations[iformationtype].masks[1] := m1;
         country.officers[ind].formations[iformationtype].masks[2] := m2;
         country.officers[ind].formations[iformationtype].masks[3] := m3;
         country.officers[ind].formations[iformationtype].masks[4] := m4;
         country.officers[ind].formations[iformationtype].masks[5] := m5;
         country.officers[ind].formations[iformationtype].masks[6] := m6;
         country.officers[ind].formations[iformationtype].masks[7] := m7;
         country.officers[ind].formations[iformationtype].masks[8] := m8;
         ind := ind+1;
      end;
   end;
   procedure AddFormationArtMortar(var country : TCountry; var ind : Integer; const artillerysid : String; const sformationtype, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18 : String);
   begin
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, artillerysid)) then
      begin
         var iformationtype : Integer;
         country.officers[ind].officersid := artillerysid;
         country.officers[ind].drummersid := artillerysid;
         country.officers[ind].units[0] := artillerysid;
         country.officers[ind].formations[iformationtype].stype := sformationtype;
         country.officers[ind].formations[iformationtype].masks[0] := m0;
         country.officers[ind].formations[iformationtype].masks[1] := m1;
         country.officers[ind].formations[iformationtype].masks[2] := m2;
         country.officers[ind].formations[iformationtype].masks[3] := m3;
         country.officers[ind].formations[iformationtype].masks[4] := m4;
         country.officers[ind].formations[iformationtype].masks[5] := m5;
         country.officers[ind].formations[iformationtype].masks[6] := m6;
         country.officers[ind].formations[iformationtype].masks[7] := m7;
         country.officers[ind].formations[iformationtype].masks[8] := m8;
         country.officers[ind].formations[iformationtype].masks[9] := m9;
         country.officers[ind].formations[iformationtype].masks[10] := m10;
         country.officers[ind].formations[iformationtype].masks[11] := m11;
         country.officers[ind].formations[iformationtype].masks[12] := m12;
         country.officers[ind].formations[iformationtype].masks[13] := m13;
         country.officers[ind].formations[iformationtype].masks[14] := m14;
         country.officers[ind].formations[iformationtype].masks[15] := m15;
         country.officers[ind].formations[iformationtype].masks[16] := m16;
         country.officers[ind].formations[iformationtype].masks[17] := m17;
         country.officers[ind].formations[iformationtype].masks[18] := m18;
         ind := ind+1;
      end;
   end;
   procedure AddFormationArtCannon(var country : TCountry; var ind : Integer; const artillerysid : String; const sformationtype, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20, m21, m22, m23, m24, m25, m26, m27, m28, m29, m30, m31, m32, m33, m34, m35, m36, m37, m38, m39 : String);
   begin
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, artillerysid)) then
      begin
         var iformationtype : Integer;
         country.officers[ind].officersid := artillerysid;
         country.officers[ind].drummersid := artillerysid;
         country.officers[ind].units[0] := artillerysid;
         country.officers[ind].formations[iformationtype].stype := sformationtype;
         country.officers[ind].formations[iformationtype].masks[0] := m0;
         country.officers[ind].formations[iformationtype].masks[1] := m1;
         country.officers[ind].formations[iformationtype].masks[2] := m2;
         country.officers[ind].formations[iformationtype].masks[3] := m3;
         country.officers[ind].formations[iformationtype].masks[4] := m4;
         country.officers[ind].formations[iformationtype].masks[5] := m5;
         country.officers[ind].formations[iformationtype].masks[6] := m6;
         country.officers[ind].formations[iformationtype].masks[7] := m7;
         country.officers[ind].formations[iformationtype].masks[8] := m8;
         country.officers[ind].formations[iformationtype].masks[9] := m9;
         country.officers[ind].formations[iformationtype].masks[10] := m10;
         country.officers[ind].formations[iformationtype].masks[11] := m11;
         country.officers[ind].formations[iformationtype].masks[12] := m12;
         country.officers[ind].formations[iformationtype].masks[13] := m13;
         country.officers[ind].formations[iformationtype].masks[14] := m14;
         country.officers[ind].formations[iformationtype].masks[15] := m15;
         country.officers[ind].formations[iformationtype].masks[16] := m16;
         country.officers[ind].formations[iformationtype].masks[17] := m17;
         country.officers[ind].formations[iformationtype].masks[18] := m18;
         country.officers[ind].formations[iformationtype].masks[19] := m19;
         country.officers[ind].formations[iformationtype].masks[20] := m20;
         country.officers[ind].formations[iformationtype].masks[21] := m21;
         country.officers[ind].formations[iformationtype].masks[22] := m22;
         country.officers[ind].formations[iformationtype].masks[23] := m23;
         country.officers[ind].formations[iformationtype].masks[24] := m24;
         country.officers[ind].formations[iformationtype].masks[25] := m25;
         country.officers[ind].formations[iformationtype].masks[26] := m26;
         country.officers[ind].formations[iformationtype].masks[27] := m27;
         country.officers[ind].formations[iformationtype].masks[28] := m28;
         country.officers[ind].formations[iformationtype].masks[29] := m29;
         country.officers[ind].formations[iformationtype].masks[30] := m30;
         country.officers[ind].formations[iformationtype].masks[31] := m31;
         country.officers[ind].formations[iformationtype].masks[32] := m32;
         country.officers[ind].formations[iformationtype].masks[33] := m33;
         country.officers[ind].formations[iformationtype].masks[34] := m34;
         country.officers[ind].formations[iformationtype].masks[35] := m35;
         country.officers[ind].formations[iformationtype].masks[36] := m36;
         country.officers[ind].formations[iformationtype].masks[37] := m37;
         country.officers[ind].formations[iformationtype].masks[38] := m38;
         country.officers[ind].formations[iformationtype].masks[39] := m39;
         ind := ind+1;
      end;
   end;
   procedure AddOfficersFormationInfExt(var country : TCountry; var ind : Integer; const officersid, drummersid, u0, u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15, u16, u17, u18 : String);
   begin
      if (ind>=gc_country_maxofficers) then
      begin
         ErrorLog('AddOfficersFormationInfNoOfficersExt : officers[out of bounds]');
         exit;
      end;
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, officersid)) and (_country_IsCountryMember(cid, drummersid)) then
      begin
         procedure AddOfficersFormationInf(var country : TCountry; ind : Integer; var iformationtype : Integer; const sformationtype, m0, m1, m2, m3, m4, m5 : String);
         begin
            country.officers[ind].formations[iformationtype].stype := sformationtype;
            country.officers[ind].formations[iformationtype].masks[0] := m0;
            country.officers[ind].formations[iformationtype].masks[1] := m1;
            country.officers[ind].formations[iformationtype].masks[2] := m2;
            country.officers[ind].formations[iformationtype].masks[3] := m3;
            country.officers[ind].formations[iformationtype].masks[4] := m4;
            country.officers[ind].formations[iformationtype].masks[5] := m5;
            iformationtype := iformationtype+1;
         end;
         var i : Integer;
         country.officers[ind].officersid := officersid;
         country.officers[ind].drummersid := drummersid;
         if (_country_IsCountryMember(cid, u0)) then begin country.officers[ind].units[i] := u0; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u1)) then begin country.officers[ind].units[i] := u1; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u2)) then begin country.officers[ind].units[i] := u2; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u3)) then begin country.officers[ind].units[i] := u3; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u4)) then begin country.officers[ind].units[i] := u4; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u5)) then begin country.officers[ind].units[i] := u5; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u6)) then begin country.officers[ind].units[i] := u6; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u7)) then begin country.officers[ind].units[i] := u7; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u8)) then begin country.officers[ind].units[i] := u8; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u9)) then begin country.officers[ind].units[i] := u9; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u10)) then begin country.officers[ind].units[i] := u10; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u11)) then begin country.officers[ind].units[i] := u11; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u12)) then begin country.officers[ind].units[i] := u12; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u13)) then begin country.officers[ind].units[i] := u13; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u14)) then begin country.officers[ind].units[i] := u14; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u15)) then begin country.officers[ind].units[i] := u15; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u16)) then begin country.officers[ind].units[i] := u16; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u17)) then begin country.officers[ind].units[i] := u17; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         if (_country_IsCountryMember(cid, u18)) then begin country.officers[ind].units[i] := u18; i:=i+1; if i>=gc_country_maxformationunitcount then ErrorLog('country.officers[ind].units[out of bounds]'+' i='+IntToStr(i)+' officersid='+officersid+' cid='+IntToStr(cid)); end;
         var iformationtype : Integer;
         AddOfficersFormationInf(country, ind, iformationtype, 'LINE', 'LINE15', 'LINE36', 'LINE72', 'LINE120', 'LINE196', 'LINE400');
         AddOfficersFormationInf(country, ind, iformationtype, 'SQUARE', 'SQUARE15', 'SQUARE36', 'SQUARE72', 'SQUARE120', 'SQUARE196', 'SQUARE400');
         AddOfficersFormationInf(country, ind, iformationtype, 'KARE', 'KARE15', 'KARE36', 'KARE72', 'KARE120', 'KARE196', 'KARE400');
         ind := ind+1;
      end;
   end;
   procedure AddOfficersFormationInfNoOfficersExt(var country : TCountry; var ind : Integer; const u0 : String);
   begin
      if (ind>=gc_country_maxofficers) then
      begin
         ErrorLog('AddOfficersFormationInfNoOfficersExt : officers[out of bounds]');
         exit;
      end;
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, u0)) then
      begin
         procedure AddOfficersFormationInf(var country : TCountry; ind : Integer; var iformationtype : Integer; const sformationtype, m0, m1, m2, m3, m4, m5 : String);
         begin
            country.officers[ind].formations[iformationtype].stype := sformationtype;
            country.officers[ind].formations[iformationtype].masks[0] := m0;
            country.officers[ind].formations[iformationtype].masks[1] := m1;
            country.officers[ind].formations[iformationtype].masks[2] := m2;
            country.officers[ind].formations[iformationtype].masks[3] := m3;
            country.officers[ind].formations[iformationtype].masks[4] := m4;
            country.officers[ind].formations[iformationtype].masks[5] := m5;
            iformationtype := iformationtype+1;
         end;
         var i : Integer;
         country.officers[ind].officersid := u0;
         country.officers[ind].drummersid := u0;
         if (_country_IsCountryMember(cid, u0)) then begin country.officers[ind].units[i] := u0; i:=i+1; end;
         var iformationtype : Integer;
         AddOfficersFormationInf(country, ind, iformationtype, 'LINE', 'LINE15', 'LINE36', 'LINE72', 'LINE120', 'LINE196', 'LINE400');
         AddOfficersFormationInf(country, ind, iformationtype, 'SQUARE', 'SQUARE15', 'SQUARE36', 'SQUARE72', 'SQUARE120', 'SQUARE196', 'SQUARE400');
         AddOfficersFormationInf(country, ind, iformationtype, 'KARE', 'KARE15', 'KARE36', 'KARE72', 'KARE120', 'KARE196', 'KARE400');
         ind := ind+1;
      end;
   end;
   procedure AddOfficersFormationInfNoOfficersExtDip(var country : TCountry; var ind : Integer; const u0 : String);
   begin
      if (ind>=gc_country_maxofficers) then
      begin
         ErrorLog('AddOfficersFormationInfNoOfficersExt : officers[out of bounds]');
         exit;
      end;
      var cid : Integer = country.id;
      if (_country_IsCountryMember(cid, u0)) then
      begin
         procedure AddOfficersFormationInf(var country : TCountry; ind : Integer; var iformationtype : Integer; const sformationtype, m0, m1, m2, m3, m4, m5 : String);
         begin
            country.officers[ind].formations[iformationtype].stype := sformationtype;
            country.officers[ind].formations[iformationtype].masks[0] := m0;
            country.officers[ind].formations[iformationtype].masks[1] := m1;
            country.officers[ind].formations[iformationtype].masks[2] := m2;
            country.officers[ind].formations[iformationtype].masks[3] := m3;
            country.officers[ind].formations[iformationtype].masks[4] := m4;
            country.officers[ind].formations[iformationtype].masks[5] := m5;
            iformationtype := iformationtype+1;
         end;
         var i : Integer;
         country.officers[ind].officersid := u0;
         country.officers[ind].drummersid := u0;
         if (_country_IsCountryMember(cid, u0)) then begin country.officers[ind].units[i] := u0; i:=i+1; end;
         var iformationtype : Integer;
         AddOfficersFormationInf(country, ind, iformationtype, 'LINE', 'LINE15NB', 'LINE36NB', 'LINE72NB', 'LINE120NB', 'LINE196NB', 'LINE400NB');
         AddOfficersFormationInf(country, ind, iformationtype, 'SQUARE', 'SQUARE15NB', 'SQUARE36NB', 'SQUARE72NB', 'SQUARE120NB', 'SQUARE196NB', 'SQUARE400NB');
         AddOfficersFormationInf(country, ind, iformationtype, 'KARE', 'KARE15NB', 'KARE36NB', 'KARE72NB', 'KARE120NB', 'KARE196NB', 'KARE400NB');
         ind := ind+1;
      end;
   end;
   procedure AddOfficersFormationCavExt(var country : TCountry; var ind : Integer; const officersid : String; itype : Integer);
   begin
      if (ind>=gc_country_maxofficers) then
      begin
         ErrorLog('AddOfficersFormationCavExt : officers[out of bounds]');
         exit;
      end;
      if (_country_IsCountryMember(country.id, officersid)) then
      begin
         procedure AddFormationCav(var country : TCountry; ind : Integer; var iformationtype : Integer; const sformationtype, m0, m1, m2 : String);
         begin
            country.officers[ind].formations[iformationtype].stype := sformationtype;
            country.officers[ind].formations[iformationtype].masks[0] := m0;
            country.officers[ind].formations[iformationtype].masks[1] := m1;
            country.officers[ind].formations[iformationtype].masks[2] := m2;
            iformationtype := iformationtype+1;
         end;
         var iformationtype : Integer;
         country.officers[ind].officersid := officersid;
         country.officers[ind].drummersid := officersid;
         country.officers[ind].units[0] := officersid;
         case itype of
            0 : begin
               AddFormationCav(country, ind, iformationtype, 'PRUS', 'PRUS3', 'PRUS2', 'PRUS');
               AddFormationCav(country, ind, iformationtype, 'TRI', 'TRI3', 'TRI2', 'TRI');
               AddFormationCav(country, ind, iformationtype, 'SHER', 'SHER3', 'SHER2', 'SHER');
            end
            else
            begin
               AddFormationCav(country, ind, iformationtype, 'PRUS', 'PRUS03', 'PRUS02', 'PRUS0');
               AddFormationCav(country, ind, iformationtype, 'TRI', 'TRI03', 'TRI02', 'TRI0');
               AddFormationCav(country, ind, iformationtype, 'SHER', 'SHER03', 'SHER02', 'SHER0');
            end;
         end;
         ind := ind+1;
      end;
   end;
   _country_ClearOfficerFormations(country);
   var ind : Integer;
   if country.sid='ukr' then
   begin
      AddOfficersFormationInfNoOfficersExt(country, ind, 'roundshierdip');
      AddOfficersFormationInfNoOfficersExt(country, ind, 'grenadierdip');
   end;

   var pikeman : String = 'pikeman';
   if country.sid='spa' then
   pikeman := '';

   AddOfficersFormationInfExt(country, ind, 'officer', 'drummer', pikeman, 'pikemanpol', 'roundshier', 'musketeer', 'musketeeraus', 'musketeerpol', 'musketeerspa', 'grenadierdip', 'roundshierdip', 'musketeernet', 'gauduk', 'pikemanpor', 'pikemanspa', 'pikemanswi', '', '', '', '', '');
   AddOfficersFormationInfExt(country, ind, 'officerrus', 'drummerrus', 'pikemanrus', 'strelet', 'grenadierdip', 'roundshierdip', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
   AddOfficersFormationInfExt(country, ind, 'officertur', 'drummertur', 'pikemantur', 'lightinfantry', 'archer', 'archertur', 'jannisary', 'grenadierdip', 'roundshierdip', '', '', '', '', '', '', '', '', '', '', '', '');
   AddOfficersFormationInfExt(country, ind, 'officer18', 'drummer18', 'pikeman18', 'pikeman18swe', 'pandur', 'chasseur', 'highlander', 'musketeer18', 'musketeer18pru', 'grenadier', 'musketeer18den', 'grenadierden', 'grenadierpru', 'musketeer18bav', 'grenadierbav', 'musketeer18sax', 'grenadiersax', 'grenadierhun', 'pandurhun', 'jagerpor', 'jagerswi');
   AddOfficersFormationInfExt(country, ind, 'officer18', 'bagpiper', 'pikeman18', 'pikeman18swe', 'pandur', 'chasseur', 'highlander', 'musketeer18', 'musketeer18pru', 'grenadier', 'musketeer18den', 'grenadierden', 'grenadierpru', 'musketeer18bav', 'grenadierbav', 'musketeer18sax', 'grenadiersax', '', '', '', '');
   AddOfficersFormationInfExt(country, ind, 'officersco', 'bagpiper', 'pikemansco', 'musketeersco', 'grenadierdip', 'roundshierdip', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
   AddOfficersFormationInfNoOfficersExt(country, ind, 'serdiuk');
   AddOfficersFormationInfNoOfficersExtDip(country, ind, 'archerdip');
   AddOfficersFormationInfNoOfficersExtDip(country, ind, 'lightinfantrydip');
   AddOfficersFormationInfNoOfficersExtDip(country, ind, 'archerturdip');
   AddOfficersFormationInfNoOfficersExt(country, ind, 'archersco');
   AddOfficersFormationInfNoOfficersExt(country, ind, 'swordsmansco');
   //AddOfficersFormationInfNoOfficersExt(country, ind, 'roundshierdip');
   AddOfficersFormationCavExt(country, ind, 'reiter', 0);
   AddOfficersFormationCavExt(country, ind, 'reiterswe', 0);
   AddOfficersFormationCavExt(country, ind, 'guardcavalrysax', 0);
   AddOfficersFormationCavExt(country, ind, 'vityaz', 0);
   AddOfficersFormationCavExt(country, ind, 'spakh', 1);
   AddOfficersFormationCavExt(country, ind, 'mameluke', 1);
   AddOfficersFormationCavExt(country, ind, 'reiterpol', 1);
   AddOfficersFormationCavExt(country, ind, 'hetman', 1);
   AddOfficersFormationCavExt(country, ind, 'cossackregister', 1);
   AddOfficersFormationCavExt(country, ind, 'cossackdon', 1);
   AddOfficersFormationCavExt(country, ind, 'cuirassier', 0);
   AddOfficersFormationCavExt(country, ind, 'dragoon', 1);
   AddOfficersFormationCavExt(country, ind, 'dragoon18', 1);
   AddOfficersFormationCavExt(country, ind, 'dragoon18fra', 1);
   AddOfficersFormationCavExt(country, ind, 'kingmusketeer', 1);
   AddOfficersFormationCavExt(country, ind, 'dragoonpol', 1);
   AddOfficersFormationCavExt(country, ind, 'dragoon18net', 1);
   AddOfficersFormationCavExt(country, ind, 'dragoon18pie', 1);
   AddOfficersFormationCavExt(country, ind, 'lancersco', 1);
   AddOfficersFormationCavExt(country, ind, 'sipahi', 0);
   AddOfficersFormationCavExt(country, ind, 'lightcavalry', 1);

   AddOfficersFormationCavExt(country, ind, 'dragoon18dip', 1);
   AddOfficersFormationCavExt(country, ind, 'lightcavalrydip', 1);
   AddOfficersFormationCavExt(country, ind, 'wingedhussar', 1);

   AddFormationArtHowitzer(country, ind, 'howitzer', 'LINE', 'LINE2', 'LINE3', 'LINE4', 'LINE5', 'LINE6', 'LINE7', 'LINE8', 'LINE9', 'LINE10');
   AddFormationArtMortar(country, ind, 'mortar', 'LINE', 'LINEMORB2', 'LINEMORB3', 'LINEMORB4', 'LINEMORB5', 'LINEMORB6', 'LINEMORB7', 'LINEMORB8', 'LINEMORB9', 'LINEMORB10', 'LINEMORB11', 'LINEMORB12', 'LINEMORB13', 'LINEMORB14', 'LINEMORB15', 'LINEMORB16', 'LINEMORB17', 'LINEMORB18', 'LINEMORB19', 'LINEMORB20');
   AddFormationArtCannon(country, ind, 'cannon', 'LINE', 'LINE2PUS', 'LINE3PUS', 'LINE4PUS', 'LINE5PUS', 'LINE6PUS', 'LINE7PUS', 'LINE8PUS', 'LINE9PUS', 'LINE10PUS', 'LINE11PUS', 'LINE12PUS', 'LINE13PUS', 'LINE14PUS', 'LINE15PUS', 'LINE16PUS', 'LINE17PUS', 'LINE18PUS', 'LINE19PUS', 'LINE20PUS', 'LINE21PUS', 'LINE22PUS', 'LINE23PUS', 'LINE24PUS', 'LINE25PUS', 'LINE26PUS', 'LINE27PUS', 'LINE28PUS', 'LINE29PUS', 'LINE30PUS', 'LINE31PUS', 'LINE32PUS', 'LINE33PUS', 'LINE34PUS', 'LINE35PUS', 'LINE36PUS', 'LINE37PUS', 'LINE38PUS', 'LINE39PUS', 'LINE40PUS', 'LINE100PUS');
   AddFormationArtCannon(country, ind, 'framegun', 'LINE', 'LINE2PUS', 'LINE3PUS', 'LINE4PUS', 'LINE5PUS', 'LINE6PUS', 'LINE7PUS', 'LINE8PUS', 'LINE9PUS', 'LINE10PUS', 'LINE11PUS', 'LINE12PUS', 'LINE13PUS', 'LINE14PUS', 'LINE15PUS', 'LINE16PUS', 'LINE17PUS', 'LINE18PUS', 'LINE19PUS', 'LINE20PUS', 'LINE21PUS', 'LINE22PUS', 'LINE23PUS', 'LINE24PUS', 'LINE25PUS', 'LINE26PUS', 'LINE27PUS', 'LINE28PUS', 'LINE29PUS', 'LINE30PUS', 'LINE31PUS', 'LINE32PUS', 'LINE33PUS', 'LINE34PUS', 'LINE35PUS', 'LINE36PUS', 'LINE37PUS', 'LINE38PUS', 'LINE39PUS', 'LINE40PUS', 'LINE100PUS');
   AddFormationArtHowitzer(country, ind, 'multicannon', 'LINE', 'LINE2', 'LINE3', 'LINE4', 'LINE5', 'LINE6', 'LINE7', 'LINE8', 'LINE9', 'LINE10');
end;

// _country_Init
//
procedure _country_Init(var country : TCountry; var csid : String);
begin
   const bAddIfNotExist = True;
   
   var bEarlyBird : Boolean = True;
   
   var cid : Integer = _country_GetIDBySID(csid);
   country.id := cid;
   country.sid := csid;
   
   const _aus = 0;
   const _fra = 1;
   const _eng = 2;
   const _spa = 3;
   const _rus = 4;
   const _ukr = 5;
   const _pol = 6;
   const _swe = 7;
   const _pru = 8;
   const _ven = 9;
   const _tur = 10;
   const _alg = 11;
   const _mis = 12;
   const _net = 13;
   const _den = 14;
   const _por = 15;
   const _pie = 16;
   const _sax = 17;
   const _bav = 18;
   const _hun = 19;
   const _swi = 20;
   const _sco = 21;
   const _tat = 22;
   const _lit = 23;
   var aus, fra, eng, spa, rus, ukr, pol, swe, pru, ven, tur, alg, mis, net, den, por, pie, sax, bav, hun, swi, sco, tat, lit : Boolean;
   _country_IDToBoolean(cid, aus, fra, eng, spa, rus, ukr, pol, swe, pru, ven, tur, alg, mis, net, den, por, pie, sax, bav, hun, swi, sco, tat, lit);
   
   // MEMBERS
   var ind : Integer;
   _country_AddMember(country, 'null', ind, False, gc_country_editorplace_category_none, 0, gc_ai_unit_none); // NULL ID (empty)
   
   if (mis) then // mission specific objects
   begin
      _country_AddMember(country, 'peaaus', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      _country_AddMember(country, 'misdonkey', ind, True, gc_country_editorplace_category_infantry, 0, gc_ai_unit_none);
      _country_AddMember(country, 'misflagman', ind, True, gc_country_editorplace_category_infantry, 0, gc_ai_unit_none);
      _country_AddMember(country, 'misgeneral', ind, True, gc_country_editorplace_category_infantry, 0, gc_ai_unit_none);
      _country_AddMember(country, 'mistrader', ind, True, gc_country_editorplace_category_infantry, 0, gc_ai_unit_none);
      _country_AddMember(country, 'misblg', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'misblg2', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'miscauldron', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'mischest1', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'mischest2', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'miswel1', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'miswel2', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'miswel3', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'misyurt', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'mistent', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      _country_AddMember(country, 'miscommandcenter', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
      
      var member : String = 'peaaus';
      var fixedproduceind : Integer = _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      if (fixedproduceind<>-1) then
      begin
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'misblg', 6, 0, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'misblg2', 7, 0, ind, '', '', '');
      end;
   end
   else
   begin
      var century18 : String = csid+'cen'+'.1'; // name is static, used in apply map settings procedure
      var enablefrigate : String = csid+'aca.6';
      var enablebattleship : String = csid+'aca.29';
      var enablemulticannon : String = csid+'aca.19';
      var commonName : String;
      if (rus) or (ukr) then
      commonName := 'rus'
      else
      if (tur) or (alg) then
      commonName := 'tur'
      else
      commonName := 'eur';
      
      // peasants
      if (aus) or (pru) or (bav) or (sax) or (swi) then _country_AddMember(country, 'peaaus', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (ukr) then _country_AddMember(country, 'peaukr', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (rus) then _country_AddMember(country, 'pearus', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (pol) or (hun) then _country_AddMember(country, 'peapol', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (spa) or (ven) or (por) or (pie) then _country_AddMember(country, 'peaspa', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (tur) or (alg) then _country_AddMember(country, 'peatur', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (fra) or (eng) or (swe) or (den) or (net) then _country_AddMember(country, 'peaeng', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);
      if (sco) then _country_AddMember(country, 'peasco', ind, True, gc_country_editorplace_category_infantry, 32, gc_ai_unit_peasant);

      // infantry
      // melee
      if (pol) then _country_AddMember(country, 'pikemanpol', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (rus) then _country_AddMember(country, 'pikemanrus', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (tur) then
      begin
         _country_AddMember(country, 'pikemantur', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
         _country_AddMember(country, 'lightinfantry', ind, True, gc_country_editorplace_category_infantry, 30, gc_ai_unit_uniq_inf17);
      end;
      if (alg) then // another order gc_ai_unit_infantry17 gc_ai_unit_uniq_inf17. used when starting units picked
      begin
         _country_AddMember(country, 'pikemantur', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_uniq_inf17);
         _country_AddMember(country, 'lightinfantry', ind, True, gc_country_editorplace_category_infantry, 30, gc_ai_unit_infantry17);
      end;
      if (aus) then
      begin
         _country_AddMember(country, 'pikeman', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
         _country_AddMember(country, 'roundshier', ind, True, gc_country_editorplace_category_infantry, 30, gc_ai_unit_uniq_inf17);
      end;
      if (sco) then
      _country_AddMember(country, 'pikemansco', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (fra) or (eng) or (spa) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (hun) or (pie) then _country_AddMember(country, 'pikeman', ind, (not spa), gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (por) then _country_AddMember(country, 'pikemanpor', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (swi) then _country_AddMember(country, 'pikemanswi', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      // 18 century
      if (swe) then _country_AddMember(country, 'pikeman18swe', ind, True, gc_country_editorplace_category_infantry, 24, gc_ai_unit_pikeman18);
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'pikeman18', ind, True, gc_country_editorplace_category_infantry, 24, gc_ai_unit_pikeman18);
      // shooters
      if (pol) then _country_AddMember(country, 'musketeerpol', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (rus) then _country_AddMember(country, 'strelet', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (aus) then _country_AddMember(country, 'musketeeraus', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (spa) then _country_AddMember(country, 'musketeerspa', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (ukr) then _country_AddMember(country, 'serdiuk', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (tur) then _country_AddMember(country, 'jannisary', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (alg) then _country_AddMember(country, 'archer', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_archer);
      if (net) then _country_AddMember(country, 'musketeernet', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (fra) or (eng) or (swe) or (pru) or (ven) or (den) or (bav) or (sax) or (por) or (pie) or (swi) then _country_AddMember(country, 'musketeer', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (sco) then _country_AddMember(country, 'musketeersco', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      if (hun) then _country_AddMember(country, 'gauduk', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk17);
      // scotland castle specials
      if (sco) then _country_AddMember(country, 'archersco', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_musk18);
      if (sco) then _country_AddMember(country, 'swordsmansco', ind, True, gc_country_editorplace_category_infantry, 28, gc_ai_unit_uniq_inf18);
      // 18 century musketeers
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (swe) or (ven) or (net) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'musketeer18', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_musk18);
      if (pru) then _country_AddMember(country, 'musketeer18pru', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_musk18);
      if (den) then _country_AddMember(country, 'musketeer18den', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_musk18);
      if (bav) then _country_AddMember(country, 'musketeer18bav', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_musk18);
      if (sax) then _country_AddMember(country, 'musketeer18sax', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_musk18);
      // 18 century shooters
      if (aus) then _country_AddMember(country, 'pandur', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      if (fra) then _country_AddMember(country, 'chasseur', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      if (eng) then _country_AddMember(country, 'highlander', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      if (por) then _country_AddMember(country, 'jagerpor', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      if (swi) then _country_AddMember(country, 'jagerswi', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      if (hun) then _country_AddMember(country, 'pandurhun', ind, True, gc_country_editorplace_category_infantry, 23, gc_ai_unit_uniq_inf18);
      // 18 century grenadiers
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (swe) or (pru) or (ven) or (net) or (por) or (pie) or (swi) then _country_AddMember(country, 'grenadier', ind, (not pru), gc_country_editorplace_category_infantry, 21, gc_ai_unit_grenadier);
      if (den) then _country_AddMember(country, 'grenadierden', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_grenadier);
      if (bav) then _country_AddMember(country, 'grenadierbav', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_grenadier);
      if (sax) then _country_AddMember(country, 'grenadiersax', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_grenadier);
      if (hun) then _country_AddMember(country, 'grenadierhun', ind, True, gc_country_editorplace_category_infantry, 22, gc_ai_unit_grenadier);
      // support
      if (rus) then _country_AddMember(country, 'officerrus', ind, True, gc_country_editorplace_category_infantry, 26, gc_ai_unit_officer17);
      if (tur) or (alg) then _country_AddMember(country, 'officertur', ind, True, gc_country_editorplace_category_infantry, 26, gc_ai_unit_officer17);
      if (aus) or (fra) or (eng) or (spa) or (pol) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'officer', ind, True, gc_country_editorplace_category_infantry, 26, gc_ai_unit_officer17);
      if (sco) then _country_AddMember(country, 'officersco', ind, True, gc_country_editorplace_category_infantry, 26, gc_ai_unit_officer17);

      if (rus) then _country_AddMember(country, 'drummerrus', ind, True, gc_country_editorplace_category_infantry, 25, gc_ai_unit_drummer17);
      if (tur) or (alg) then _country_AddMember(country, 'drummertur', ind, True, gc_country_editorplace_category_infantry, 25, gc_ai_unit_drummer17);
      if (aus) or (fra) or (eng) or (spa) or (pol) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'drummer', ind, True, gc_country_editorplace_category_infantry, 25, gc_ai_unit_drummer17);
      if (sco) then _country_AddMember(country, 'bagpiper', ind, True, gc_country_editorplace_category_infantry, 25, gc_ai_unit_drummer17);

      if (aus) or (fra) or (eng) or (spa) or (pol) or (swe) or (pru) or (ven) or (rus) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'officer18', ind, True, gc_country_editorplace_category_infantry, 20, gc_ai_unit_officer18);
      
      if (eng) then _country_AddMember(country, 'bagpiper', ind, True, gc_country_editorplace_category_infantry, 19, gc_ai_unit_drummer18);
      if (aus) or (fra) or (spa) or (pol) or (swe) or (pru) or (ven) or (rus) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'drummer18', ind, True, gc_country_editorplace_category_infantry, 19, gc_ai_unit_drummer18);
      
      if (rus) or (ukr) then  _country_AddMember(country, 'pope', ind, True, gc_country_editorplace_category_infantry, 16, gc_ai_unit_priest);
      if (tur) or (alg) then  _country_AddMember(country, 'mullah', ind, True, gc_country_editorplace_category_infantry, 16, gc_ai_unit_priest);
      if (aus) or (fra) or (eng) or (spa) or (pol) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (sco) or (por) or (hun) or (swi) then _country_AddMember(country, 'priest', ind, True, gc_country_editorplace_category_infantry, 16, gc_ai_unit_priest);
      if (pie) then  _country_AddMember(country, 'padre', ind, True, gc_country_editorplace_category_infantry, 16, gc_ai_unit_priest);
      // cavalry
      // light
      if (ukr) then _country_AddMember(country, 'cossacksich', ind, True, gc_country_editorplace_category_cavalry, 30, gc_ai_unit_uniq_cav17);
      if (pol) then _country_AddMember(country, 'wingedhussar', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_reitar);
      if (aus) then _country_AddMember(country, 'croat', ind, True, gc_country_editorplace_category_cavalry, 30, gc_ai_unit_uniq_cav17);
      if (sco) then _country_AddMember(country, 'raidersco', ind, True, gc_country_editorplace_category_cavalry, 30, gc_ai_unit_uniq_cav17);
      if (hun) then _country_AddMember(country, 'hussarhun', ind, True, gc_country_editorplace_category_cavalry, 30, gc_ai_unit_uniq_cav17); // 17 century
      if (pru) then _country_AddMember(country, 'hussarpru', ind, True, gc_country_editorplace_category_cavalry, 19, gc_ai_unit_hussar);
      if (swi) then _country_AddMember(country, 'hussarswi', ind, True, gc_country_editorplace_category_cavalry, 19, gc_ai_unit_hussar);
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (swe) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (pie) then _country_AddMember(country, 'hussar', ind, True, gc_country_editorplace_category_cavalry, 19, gc_ai_unit_hussar);

      // heavy
      if (swe) then _country_AddMember(country, 'reiterswe', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_reitar);
      if (pol) then _country_AddMember(country, 'reiterpol', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_uniq_cav17);
      if (sax) then _country_AddMember(country, 'guardcavalrysax', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_reitar);
      if (ukr) then
      begin
         _country_AddMember(country, 'cossackregister', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_reitar);
         _country_AddMember(country, 'hetman', ind, True, gc_country_editorplace_category_cavalry, 20, gc_ai_unit_none);
      end;
      if (rus) then
      begin
         _country_AddMember(country, 'cossackdon', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_uniq_cav17);
         _country_AddMember(country, 'vityaz', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_reitar);
      end;
      if (tur) then _country_AddMember(country, 'spakh', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_reitar);
      if (alg) then _country_AddMember(country, 'mameluke', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_reitar);
      if (sco) then _country_AddMember(country, 'lancersco', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_reitar);
      if (aus) or (fra) or (eng) or (spa) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'reiter', ind, True, gc_country_editorplace_category_cavalry, 32, gc_ai_unit_reitar);
      
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'cuirassier', ind, (not sax), gc_country_editorplace_category_cavalry, 20, gc_ai_unit_cuirassier);
      // shooters
      if (fra) then _country_AddMember(country, 'kingmusketeer', ind, True, gc_country_editorplace_category_cavalry, 29, gc_ai_unit_uniq_cav17);
      if (aus) or (eng) or (spa) or (pol) or (swe) or (pru) or (ven) or (fra) or (den) or (net) or (bav) or (sax) or (por) or (hun) or (pie) or (swi) then _country_AddMember(country, 'dragoon', ind, (not pol), gc_country_editorplace_category_cavalry, 29, gc_ai_unit_dragoon17);
      if (tur) then _country_AddMember(country, 'tatar', ind, True, gc_country_editorplace_category_cavalry, 29, gc_ai_unit_uniq_cav17);
      
      if (fra) then _country_AddMember(country, 'dragoon18fra', ind, True, gc_country_editorplace_category_cavalry, 18, gc_ai_unit_dragun18);
      if (net) then _country_AddMember(country, 'dragoon18net', ind, True, gc_country_editorplace_category_cavalry, 18, gc_ai_unit_dragun18);
      if (pie) then _country_AddMember(country, 'dragoon18pie', ind, True, gc_country_editorplace_category_cavalry, 18, gc_ai_unit_dragun18);
      if (aus) or (eng) or (spa) or (rus) or (pol) or (swe) or (pru) or (ven) or (den) or (bav) or (sax) or (por) or (swi) then _country_AddMember(country, 'dragoon18', ind, True, gc_country_editorplace_category_cavalry, 18, gc_ai_unit_dragun18);
      // diplomatic
      _country_AddMember(country, 'lightinfantrydip', ind, True, gc_country_editorplace_category_diplomatic, 32, gc_ai_unit_light_dip);
      _country_AddMember(country, 'roundshierdip', ind, True, gc_country_editorplace_category_diplomatic, 31, gc_ai_unit_round_dip);
      _country_AddMember(country, 'grenadierdip', ind, True, gc_country_editorplace_category_diplomatic, 30, gc_ai_unit_grendip);
      var airole : Integer = gc_ai_unit_archer;
      if (alg) then airole := gc_ai_unit_none;
      _country_AddMember(country, 'archerdip', ind, True, gc_country_editorplace_category_diplomatic, 29, airole);
      _country_AddMember(country, 'cossacksichdip', ind, True, gc_country_editorplace_category_diplomatic, 28, gc_ai_unit_cossackdip);
      _country_AddMember(country, 'dragoon18dip', ind, True, gc_country_editorplace_category_diplomatic, 27, gc_ai_unit_dragundip);
      // ships
      _country_AddMember(country, 'fishboat', ind, True, gc_country_editorplace_category_ships, 32, gc_ai_unit_boat);
      _country_AddMember(country, 'ferry', ind, True, gc_country_editorplace_category_ships, 31, gc_ai_unit_ferry);
      if (not sco) then _country_AddMember(country, 'galley', ind, True, gc_country_editorplace_category_ships, 29, gc_ai_unit_galley);
      
      if (aus) or (fra) or (eng) or (spa) or (rus) or (pol) or (swe) or (pru) or (ven) or (den) or (net) or (bav) or (sax) or (sco) or (por) or (hun) or (pie) or (swi) then
      begin
         _country_AddMember(country, 'yacht', ind, True, gc_country_editorplace_category_ships, 30, gc_ai_unit_yacht);
         _country_AddMember(country, 'frigate', ind, True, gc_country_editorplace_category_ships, 28, gc_ai_unit_frigate);
      end;
      if (tur) then
      begin
         _country_AddMember(country, 'yachttur', ind, True, gc_country_editorplace_category_ships, 30, gc_ai_unit_yacht);
         _country_AddMember(country, 'xebec', ind, True, gc_country_editorplace_category_ships, 28, gc_ai_unit_frigate);
      end;
      if (alg) then
      _country_AddMember(country, 'xebec', ind, True, gc_country_editorplace_category_ships, 28, gc_ai_unit_frigate);
      if (not ukr) then
      _country_AddMember(country, 'battleship', ind, True, gc_country_editorplace_category_ships, 27, gc_ai_unit_lineship);
      // artillery
      _country_AddMember(country, 'cannon', ind, True, gc_country_editorplace_category_artillery, 32, gc_ai_unit_cannon);
      _country_AddMember(country, 'howitzer', ind, True, gc_country_editorplace_category_artillery, 31, gc_ai_unit_howitzer);
      _country_AddMember(country, 'mortar', ind, True, gc_country_editorplace_category_artillery, 30, gc_ai_unit_mortar);
      if (not tur) and (not alg) and (not ukr) and (not sco) then
      _country_AddMember(country, 'multicannon', ind, True, gc_country_editorplace_category_artillery, 29, gc_ai_unit_mbarrel);
      if (sco) then
      _country_AddMember(country, 'framegun', ind, True, gc_country_editorplace_category_artillery, 29, gc_ai_unit_mbarrel);

      // buildings
      _country_AddMember(country, csid+'cen', ind, True, gc_country_editorplace_category_buildings, 18, gc_ai_unit_center);
      _country_AddMember(country, csid+'hou', ind, True, gc_country_editorplace_category_buildings, 32, gc_ai_unit_house);
      _country_AddMember(country, csid+'bla', ind, True, gc_country_editorplace_category_buildings, 24, gc_ai_unit_smith);
      _country_AddMember(country, csid+'sta', ind, True, gc_country_editorplace_category_buildings, 23, gc_ai_unit_stable);
      _country_AddMember(country, csid+'tem', ind, True, gc_country_editorplace_category_buildings, 28, gc_ai_unit_temple);
      _country_AddMember(country, csid+'aca', ind, True, gc_country_editorplace_category_buildings, 21, gc_ai_unit_academi);
      _country_AddMember(country, csid+'dip', ind, True, gc_country_editorplace_category_buildings, 20, gc_ai_unit_dipcenter);
      _country_AddMember(country, csid+'bar', ind, True, gc_country_editorplace_category_buildings, 25, gc_ai_unit_ba17);
      _country_AddMember(country, csid+'art', ind, True, gc_country_editorplace_category_buildings, 22, gc_ai_unit_artdepo);
      if (not tur) and (not alg) and (not ukr) then
      _country_AddMember(country, csid+'ba2', ind, True, gc_country_editorplace_category_buildings, 19, gc_ai_unit_ba18);
      
      // common
      var commonNameStorehouse : String;
      var commonNameMarket : String;
      var commonNamePort : String;
      if (pol) then
      commonNameStorehouse := 'russto'
      else
      commonNameStorehouse := commonName+'sto';
      if (spa) or (por) then
      begin
         commonNameMarket := 'spamar';
         commonNameStorehouse := 'spasto';
      end
      else
      begin
         commonNameMarket := commonName+'mar';
         commonNameStorehouse := commonName+'sto';
      end;
      if (por) then
      commonNamePort := 'porpor'
      else
      if (ukr) then
      commonNamePort := 'ukrpor'
      else
      commonNamePort := commonName+'por';
      _country_AddMember(country, commonName+'mil', ind, True, gc_country_editorplace_category_buildings, 31, gc_ai_unit_mill);
      _country_AddMember(country, commonNameStorehouse{+'sto'}, ind, True, gc_country_editorplace_category_buildings, 30, gc_ai_unit_store);
      _country_AddMember(country, commonNameMarket{commonName+'mar'}, ind, True, gc_country_editorplace_category_buildings, 26, gc_ai_unit_market);
      _country_AddMember(country, commonNamePort{commonName+'por'}, ind, True, gc_country_editorplace_category_buildings, 27, gc_ai_unit_port);
      _country_AddMember(country, 'eurgol', ind, True, gc_country_editorplace_category_buildings, 29, gc_ai_unit_minegold);
      _country_AddMember(country, 'euriro', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_mineiron);
      _country_AddMember(country, 'eurcoa', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_minecoal);
      if (not ukr) then
      _country_AddMember(country, commonName+'tow', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_tower);
      
      _country_AddMember(country, 'ukrwwa', ind, True, gc_country_editorplace_category_buildings, 17, gc_ai_unit_none);
      _country_AddMember(country, 'ukrwga', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_none);
      if (not ukr) and (not tur) and (not alg) and (not rus) then
      begin
         _country_AddMember(country, 'eurswa', ind, True, gc_country_editorplace_category_buildings, 16, gc_ai_unit_none);
         _country_AddMember(country, 'eursga', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_none);
      end;
      if (tur) or (alg) then
      begin
         _country_AddMember(country, 'turswa', ind, True, gc_country_editorplace_category_buildings, 16, gc_ai_unit_none);
         _country_AddMember(country, 'tursga', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_none);
      end;
      if (rus) then
      begin
         _country_AddMember(country, 'russwa', ind, True, gc_country_editorplace_category_buildings, 16, gc_ai_unit_none);
         _country_AddMember(country, 'russga', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_none);
      end;
      
      // misc
      _country_AddMember(country, 'field', ind, True, gc_country_editorplace_category_none, 0, gc_ai_unit_none);
      _country_AddMember(country, 'unitbox', ind, False, gc_country_editorplace_category_none, 0, gc_ai_unit_none); // TEST unit, enabled=false
      
      // new units to preserve indexation put here
      if (ukr) then
      _country_AddMember(country, 'chaika', ind, True, gc_country_editorplace_category_ships, 28, gc_ai_unit_frigate);
      
      // early-bird
      if (tur) then
      _country_AddMember(country, 'archertur', ind, True, gc_country_editorplace_category_infantry, 26, gc_ai_unit_archer);
      _country_AddMember(country, 'lightcavalry', ind, (hun), gc_country_editorplace_category_cavalry, 25, gc_ai_unit_uniq_cav17);
      _country_AddMember(country, 'archerturdip', ind, True, gc_country_editorplace_category_diplomatic, 26, gc_ai_unit_none);
      _country_AddMember(country, 'lightcavalrydip', ind, True, gc_country_editorplace_category_diplomatic, 25, gc_ai_unit_none);
      // new units for already released nations goes here, at the end_ of AddMember order
      // dlc1
      if (pol) then _country_AddMember(country, 'dragoonpol', ind, True, gc_country_editorplace_category_cavalry, 29, gc_ai_unit_uniq_cav17);
      // dlc2
      if (swe) then _country_AddMember(country, 'hackapell', ind, True, gc_country_editorplace_category_cavalry, 30, gc_ai_unit_uniq_cav17);
      if (pru) then _country_AddMember(country, 'grenadierpru', ind, True, gc_country_editorplace_category_infantry, 21, gc_ai_unit_grenadier);
      if (spa) then _country_AddMember(country, 'pikemanspa', ind, True, gc_country_editorplace_category_infantry, 31, gc_ai_unit_infantry17);
      if (tur) then _country_AddMember(country, 'sipahi', ind, True, gc_country_editorplace_category_cavalry, 31, gc_ai_unit_uniq_cav17);

      // FIXED PRODUCE
      ind := 0;
      // peasants
      var member : String;
      if (aus) or (pru) or (bav) or (sax) or (swi) then member := 'peaaus';
      if (ukr) then member := 'peaukr';
      if (rus) then member := 'pearus';
      if (pol) or (hun) then member := 'peapol';
      if (spa) or (ven) or (por) or (pie) then member := 'peaspa';
      if (tur) or (alg) then member := 'peatur';
      if (fra) or (eng) or (swe) or (den) or (net) then member := 'peaeng';
      if (sco) then member := 'peasco';
      var fixedproduceind : Integer = _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      if (fixedproduceind<>-1) then
      begin
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'cen', 2, 2, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'hou', 0, 0, ind, csid+'cen', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'bla', 2, 1, ind, csid+'cen', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'sta', 3, 1, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'tem', 4, 0, ind, csid+'cen', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'aca', 5, 1, ind, csid+'bar', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'dip', 0, 2, ind, {csid+'bar', }csid+'aca', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'bar', 1, 1, ind, csid+'bla', '', '');
         if (sco) then
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'ba2', 1, 2, ind, csid+'bla', '', '')
         else
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'ba2', 1, 2, ind, century18, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, csid+'art', 4, 1, ind, csid+'aca'{csid+'bla', }{csid+'sta'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, commonName+'mil', 1, 0, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, commonNameStorehouse{commonName+'sto'}, 2, 0, ind, csid+'cen', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, commonNameMarket{commonName+'mar'}, 0, 1, ind, commonName+'mil', commonNameStorehouse{commonName+'sto'}, '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, commonName+'tow', 5, 2, ind, commonNameStorehouse{commonName+'sto'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, commonNamePort{commonName+'por'}, 5, 0, ind, commonNameMarket{commonName+'mar'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'eurgol', 3, 0, ind, '', '', '');
         //_country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'euriro', 3, 0, ind, '', '', '');
         //_country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'eurcoa', 3, 0, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'ukrwwa', 3, 2, ind, commonNameStorehouse{commonName+'sto'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'eurswa', 4, 2, ind, commonNameStorehouse{commonName+'sto'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'turswa', 4, 2, ind, commonNameStorehouse{commonName+'sto'}, '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'russwa', 4, 2, ind, commonNameStorehouse{commonName+'sto'}, '', '');
      end;
      
      ind := 0;
      member := csid+'cen';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peaaus', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peaeng', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peaspa', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peapol', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pearus', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peaukr', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peatur', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'peasco', 0, 0, ind, '', '', '');

      ind := 0;
      member := csid+'sta';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'reiter', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'reiterswe', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'vityaz', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'wingedhussar', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cossacksich', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'spakh', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'mameluke', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'croat', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'reiterpol', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cossackregister', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'kingmusketeer', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'tatar', 2, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cossackdon', 2, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cuirassier', 3, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hussar', 4, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hussarpru', 4, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hetman', 4, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon18', 5, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon18fra', 5, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoonpol', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon18net', 5, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon18pie', 5, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hackapell', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'guardcavalrysax', 3, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'raidersco', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'lancersco', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hussarhun', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'hussarswi', 4, 0, ind, csid+'bla', century18, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'sipahi', 4, 0, ind, csid+'bla', '', '');
      if (hun) then
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'lightcavalry', 5, 0, ind, csid+'bla', century18, '');

      ind := 0;
      member := csid+'tem';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'priest', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pope', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'mullah', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'padre', 0, 0, ind, '', '', '');

      ind := 0;
      member := csid+'dip';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'roundshierdip', 0, 0, ind, csid+'cen', csid+'aca', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'lightinfantrydip', 1, 0, ind, csid+'cen', csid+'aca', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'archerdip', 2, 0, ind, csid+'cen', csid+'aca', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadierdip', 3, 0, ind, csid+'cen', csid+'aca', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cossacksichdip', 4, 0, ind, csid+'cen', csid+'aca', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'dragoon18dip', 5, 0, ind, csid+'cen', csid+'aca', '');
      if (bEarlyBird) then
      begin
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'lightcavalrydip', 5, 1, ind, csid+'cen', csid+'aca', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'archerturdip', 2, 1, ind, csid+'cen', csid+'aca', '');
      end;
      
      ind := 0;
      member := csid+'bar';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikeman', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemanpol', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemantur', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemanrus', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemansco', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemanspa', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemanpor', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikemanswi', 0, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'roundshier', 1, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'lightinfantry', 1, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeeraus', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeerpol', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeerspa', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeersco', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'strelet', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'serdiuk', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'jannisary', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'gauduk', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'archer', 2, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'drummer', 4, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'drummerrus', 4, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'drummertur', 4, 0, ind, csid+'aca', '', '');
      if (sco) then _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'bagpiper', 4, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officer', 5, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officerrus', 5, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officertur', 5, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officersco', 5, 0, ind, csid+'aca', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeernet', 2, 0, ind, csid+'bla', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'archertur', 3, 0, ind, csid+'bla', '', '');
      
      ind := 0;
      member := csid+'ba2';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      if (fixedproduceind<>-1) then
      begin
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikeman18', 0, 0, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pikeman18swe', 0, 0, ind, '', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pandur', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'chasseur', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'highlander', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'jagerpor', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'jagerswi', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'pandurhun', 1, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer18', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer18pru', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadier', 3, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'drummer18', 4, 0, ind, csid+'aca', '', '');
         if (not sco) then _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'bagpiper', 4, 0, ind, csid+'aca', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officer18', 5, 0, ind, csid+'aca', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer18den', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadierden', 3, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadierpru', 3, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer18bav', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'musketeer18sax', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadierbav', 3, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadiersax', 3, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'grenadierhun', 3, 0, ind, csid+'bla', '', '');

         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'archersco', 2, 0, ind, csid+'bla', '', '');
         _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'swordsmansco', 0, 0, ind, csid+'bla', '', '');
         //_country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'officersco', 5, 0, ind, csid+'aca', '', '');
      end;
      
      ind := 0;
      member := csid+'art';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'cannon', 0, 0, ind, csid+'bla'{, csid+'sta'}, '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'howitzer', 2, 0, ind, csid+'bla'{, csid+'sta'}, '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'mortar', 3, 0, ind, csid+'bla'{, csid+'sta'}, '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'multicannon', 4, 0, ind, csid+'bla'{, csid+'sta'}, enablemulticannon, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'framegun', 4, 0, ind, csid+'bla'{, csid+'sta'}, '', '');

      ind := 0;
      member := commonNamePort{commonName+'por'};
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'fishboat', 0, 0, ind, '', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'yacht', 1, 0, ind, {csid+'bla', }csid+'art', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'yachttur', 1, 0, ind, {csid+'bla', }csid+'art', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'ferry', 2, 0, ind, {csid+'bla', }csid+'art', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'galley', 4, 0, ind, {csid+'bla', }csid+'art', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'frigate', 5, 0, ind, {csid+'bla', }csid+'art', enablefrigate, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'chaika', 5, 0, ind, {csid+'bla', }csid+'art', '', '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'xebec', 5, 0, ind, {csid+'bla', }csid+'art', enablefrigate, '');
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'battleship', 6, 0, ind, {csid+'bla', }csid+'art', enablebattleship, '');
      
      ind := 0;
      member := commonName+'mil';
      fixedproduceind := _country_GetFixedProduceIndexBySID(cid, member, bAddIfNotExist);
      _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'field', 0, 0, ind, '', '', '');
      
      // UNIT LOCK
      ind := 0;
      member := csid+'dip';
      var unitlockind : Integer = _country_GetUnitLockIndexBySID(cid, member, bAddIfNotExist);
      if (unitlockind<>-1) then
      _country_AddUnitLock(country, unitlockind, member, member, 1, ind);
      
      ind := 0;
      member := 'ferry';
      unitlockind := _country_GetUnitLockIndexBySID(cid, member, bAddIfNotExist);
      if (unitlockind<>-1) then
      _country_AddUnitLock(country, unitlockind, member, member, 10, ind);
      
      // UPGRADE + UPGRADEPLACE + UPGRADEENABLE + UPGRADELINKS
      // UPGRADEPLACE - encoded in upgrade name. first part till dot char is obj.sid.
      // UPGRADEENABLE - flag in AddUpgrade function
      // UPGRADELINKS - AddUpgradeLink and AddUpgradeLinkRange functions
      // consts for better reading
      const cTrue = True; // for better formating and reading
      ind := 0;
      var linkind : Integer;
      
      const cMaxUnitsArr = 128;
      var sarrUnitsAll : array [0..cMaxUnitsArr-1] of String;
      var sarrUnitsShooters : array [0..cMaxUnitsArr-1] of String;
      var sarrUnitsCavalry : array [0..cMaxUnitsArr-1] of String;
      var sarrUnitsCavalryMelee : array [0..cMaxUnitsArr-1] of String;
      var sarrUnitsArmored : array [0..cMaxUnitsArr-1] of String;
      var sarrUnitsBayonet : array [0..cMaxUnitsArr-1] of String;
      var sarrShipsCannon : array [0..cMaxUnitsArr-1] of String;
      var sarrBuildingsAll : array [0..cMaxUnitsArr-1] of String;
      var k : Integer;
      for k:=0 to cMaxUnitsArr-1 do
      begin
         sarrUnitsAll[k] := '';
         sarrUnitsArmored[k] := '';
         sarrUnitsShooters[k] := '';
         sarrUnitsCavalry[k] := '';
         sarrUnitsCavalryMelee[k] := '';
         sarrUnitsBayonet[k] := '';
         sarrShipsCannon[k] := '';
         sarrBuildingsAll[k] := '';
      end;
      k := 0;   sarrUnitsAll[k] := 'peaaus';
      k := k+1; sarrUnitsAll[k] := 'peaukr';
      k := k+1; sarrUnitsAll[k] := 'pearus';
      k := k+1; sarrUnitsAll[k] := 'peapol';
      k := k+1; sarrUnitsAll[k] := 'peaspa';
      k := k+1; sarrUnitsAll[k] := 'peatur';
      k := k+1; sarrUnitsAll[k] := 'peaeng';
      k := k+1; sarrUnitsAll[k] := 'peasco';
      k := k+1; sarrUnitsAll[k] := 'priest';
      k := k+1; sarrUnitsAll[k] := 'pope';
      k := k+1; sarrUnitsAll[k] := 'mullah';
      k := k+1; sarrUnitsAll[k] := 'padre';
      k := k+1; sarrUnitsAll[k] := 'pikeman';
      k := k+1; sarrUnitsAll[k] := 'pikemanpol';
      k := k+1; sarrUnitsAll[k] := 'pikemantur';
      k := k+1; sarrUnitsAll[k] := 'pikemanrus';
      k := k+1; sarrUnitsAll[k] := 'pikemansco';
      k := k+1; sarrUnitsAll[k] := 'pikemanspa';
      k := k+1; sarrUnitsAll[k] := 'pikemanpor';
      k := k+1; sarrUnitsAll[k] := 'pikemanswi';
      k := k+1; sarrUnitsAll[k] := 'roundshier';
      k := k+1; sarrUnitsAll[k] := 'lightinfantry';
      k := k+1; sarrUnitsAll[k] := 'swordsmansco';
      k := k+1; sarrUnitsAll[k] := 'musketeer';
      k := k+1; sarrUnitsAll[k] := 'musketeeraus';
      k := k+1; sarrUnitsAll[k] := 'musketeerpol';
      k := k+1; sarrUnitsAll[k] := 'musketeerspa';
      k := k+1; sarrUnitsAll[k] := 'musketeernet';
      k := k+1; sarrUnitsAll[k] := 'musketeersco';
      k := k+1; sarrUnitsAll[k] := 'strelet';
      k := k+1; sarrUnitsAll[k] := 'serdiuk';
      k := k+1; sarrUnitsAll[k] := 'jannisary';
      k := k+1; sarrUnitsAll[k] := 'gauduk';
      k := k+1; sarrUnitsAll[k] := 'archer';
      k := k+1; sarrUnitsAll[k] := 'archersco';
      k := k+1; sarrUnitsAll[k] := 'drummer';
      k := k+1; sarrUnitsAll[k] := 'drummerrus';
      k := k+1; sarrUnitsAll[k] := 'drummertur';
      k := k+1; sarrUnitsAll[k] := 'officer';
      k := k+1; sarrUnitsAll[k] := 'officerrus';
      k := k+1; sarrUnitsAll[k] := 'officertur';
      k := k+1; sarrUnitsAll[k] := 'officersco';
      k := k+1; sarrUnitsAll[k] := 'pikeman18';
      k := k+1; sarrUnitsAll[k] := 'pikeman18swe';
      k := k+1; sarrUnitsAll[k] := 'pandur';
      k := k+1; sarrUnitsAll[k] := 'chasseur';
      k := k+1; sarrUnitsAll[k] := 'highlander';
      k := k+1; sarrUnitsAll[k] := 'pandurhun';
      k := k+1; sarrUnitsAll[k] := 'jagerpor';
      k := k+1; sarrUnitsAll[k] := 'jagerswi';
      k := k+1; sarrUnitsAll[k] := 'musketeer18';
      k := k+1; sarrUnitsAll[k] := 'musketeer18pru';
      k := k+1; sarrUnitsAll[k] := 'musketeer18den';
      k := k+1; sarrUnitsAll[k] := 'musketeer18bav';
      k := k+1; sarrUnitsAll[k] := 'musketeer18sax';
      k := k+1; sarrUnitsAll[k] := 'grenadier';
      k := k+1; sarrUnitsAll[k] := 'grenadierden';
      k := k+1; sarrUnitsAll[k] := 'grenadierpru';
      k := k+1; sarrUnitsAll[k] := 'grenadierbav';
      k := k+1; sarrUnitsAll[k] := 'grenadiersax';
      k := k+1; sarrUnitsAll[k] := 'grenadierhun';
      k := k+1; sarrUnitsAll[k] := 'drummer18';
      k := k+1; sarrUnitsAll[k] := 'bagpiper';
      k := k+1; sarrUnitsAll[k] := 'officer18';
      k := k+1; sarrUnitsAll[k] := 'reiter';
      k := k+1; sarrUnitsAll[k] := 'vityaz';
      k := k+1; sarrUnitsAll[k] := 'wingedhussar';
      k := k+1; sarrUnitsAll[k] := 'cossacksich';
      k := k+1; sarrUnitsAll[k] := 'raidersco';
      k := k+1; sarrUnitsAll[k] := 'spakh';
      k := k+1; sarrUnitsAll[k] := 'mameluke';
      k := k+1; sarrUnitsAll[k] := 'sipahi';
      k := k+1; sarrUnitsAll[k] := 'croat';
      k := k+1; sarrUnitsAll[k] := 'hackapell';
      k := k+1; sarrUnitsAll[k] := 'reiterpol';
      k := k+1; sarrUnitsAll[k] := 'cossackregister';
      k := k+1; sarrUnitsAll[k] := 'lancersco';
      k := k+1; sarrUnitsAll[k] := 'dragoon';
      k := k+1; sarrUnitsAll[k] := 'dragoonpol';
      k := k+1; sarrUnitsAll[k] := 'kingmusketeer';
      k := k+1; sarrUnitsAll[k] := 'tatar';
      k := k+1; sarrUnitsAll[k] := 'cossackdon';
      k := k+1; sarrUnitsAll[k] := 'cuirassier';
      k := k+1; sarrUnitsAll[k] := 'hussar';
      k := k+1; sarrUnitsAll[k] := 'hussarpru';
      k := k+1; sarrUnitsAll[k] := 'hussarhun';
      k := k+1; sarrUnitsAll[k] := 'hussarswi';
      k := k+1; sarrUnitsAll[k] := 'hetman';
      k := k+1; sarrUnitsAll[k] := 'dragoon18';
      k := k+1; sarrUnitsAll[k] := 'dragoon18fra';
      k := k+1; sarrUnitsAll[k] := 'dragoon18net';
      k := k+1; sarrUnitsAll[k] := 'dragoon18pie';
      k := k+1; sarrUnitsAll[k] := 'lightcavalry';

      k := 0;   sarrUnitsArmored[k] := 'pikeman';
      k := k+1; sarrUnitsArmored[k] := 'pikemanrus';
      k := k+1; sarrUnitsArmored[k] := 'pikemanpor';
      k := k+1; sarrUnitsArmored[k] := 'pikemanswi';
      k := k+1; sarrUnitsArmored[k] := 'pikemanspa';
      k := k+1; sarrUnitsArmored[k] := 'roundshier';
      k := k+1; sarrUnitsArmored[k] := 'musketeeraus';
      k := k+1; sarrUnitsArmored[k] := 'musketeerspa';
      k := k+1; sarrUnitsArmored[k] := 'officer';
      k := k+1; sarrUnitsArmored[k] := 'reiter';
      k := k+1; sarrUnitsArmored[k] := 'vityaz';
      k := k+1; sarrUnitsArmored[k] := 'wingedhussar';
      k := k+1; sarrUnitsArmored[k] := 'reiterswe';
      k := k+1; sarrUnitsArmored[k] := 'guardcavalrysax';
      k := k+1; sarrUnitsArmored[k] := 'cuirassier';
      k := k+1; sarrUnitsArmored[k] := 'sipahi';

      k := 0;   sarrUnitsShooters[k] := 'musketeer';
      k := k+1; sarrUnitsShooters[k] := 'musketeeraus';
      k := k+1; sarrUnitsShooters[k] := 'musketeerpol';
      k := k+1; sarrUnitsShooters[k] := 'musketeerspa';
      k := k+1; sarrUnitsShooters[k] := 'musketeernet';
      k := k+1; sarrUnitsShooters[k] := 'musketeersco';
      k := k+1; sarrUnitsShooters[k] := 'strelet';
      k := k+1; sarrUnitsShooters[k] := 'serdiuk';
      k := k+1; sarrUnitsShooters[k] := 'jannisary';
      k := k+1; sarrUnitsShooters[k] := 'gauduk';
      k := k+1; sarrUnitsShooters[k] := 'pandur';
      k := k+1; sarrUnitsShooters[k] := 'chasseur';
      k := k+1; sarrUnitsShooters[k] := 'pandurhun';
      k := k+1; sarrUnitsShooters[k] := 'jagerpor';
      k := k+1; sarrUnitsShooters[k] := 'jagerswi';
      k := k+1; sarrUnitsShooters[k] := 'highlander';
      k := k+1; sarrUnitsShooters[k] := 'musketeer18';
      k := k+1; sarrUnitsShooters[k] := 'musketeer18pru';
      k := k+1; sarrUnitsShooters[k] := 'musketeer18den';
      k := k+1; sarrUnitsShooters[k] := 'musketeer18bav';
      k := k+1; sarrUnitsShooters[k] := 'musketeer18sax';
      k := k+1; sarrUnitsShooters[k] := 'grenadier';
      k := k+1; sarrUnitsShooters[k] := 'grenadierden';
      k := k+1; sarrUnitsShooters[k] := 'grenadierpru';
      k := k+1; sarrUnitsShooters[k] := 'grenadierbav';
      k := k+1; sarrUnitsShooters[k] := 'grenadiersax';
      k := k+1; sarrUnitsShooters[k] := 'grenadierhun';
      k := k+1; sarrUnitsShooters[k] := 'dragoon';
      k := k+1; sarrUnitsShooters[k] := 'dragoonpol';
      k := k+1; sarrUnitsShooters[k] := 'kingmusketeer';
      k := k+1; sarrUnitsShooters[k] := 'dragoon18';
      k := k+1; sarrUnitsShooters[k] := 'dragoon18fra';
      k := k+1; sarrUnitsShooters[k] := 'dragoon18net';
      k := k+1; sarrUnitsShooters[k] := 'dragoon18pie';
      k := k+1; sarrUnitsShooters[k] := 'lightcavalry';
      
      k := 0;   sarrUnitsCavalry[k] := 'reiter';
      k := k+1; sarrUnitsCavalry[k] := 'vityaz';
      k := k+1; sarrUnitsCavalry[k] := 'wingedhussar';
      k := k+1; sarrUnitsCavalry[k] := 'cossacksich';
      k := k+1; sarrUnitsCavalry[k] := 'raidersco';
      k := k+1; sarrUnitsCavalry[k] := 'spakh';
      k := k+1; sarrUnitsCavalry[k] := 'mameluke';
      k := k+1; sarrUnitsCavalry[k] := 'croat';
      k := k+1; sarrUnitsCavalry[k] := 'hackapell';
      k := k+1; sarrUnitsCavalry[k] := 'reiterpol';
      k := k+1; sarrUnitsCavalry[k] := 'cossackregister';
      k := k+1; sarrUnitsCavalry[k] := 'lancersco';
      k := k+1; sarrUnitsCavalry[k] := 'dragoon';
      k := k+1; sarrUnitsCavalry[k] := 'dragoonpol';
      k := k+1; sarrUnitsCavalry[k] := 'kingmusketeer';
      k := k+1; sarrUnitsCavalry[k] := 'tatar';
      k := k+1; sarrUnitsCavalry[k] := 'cossackdon';
      k := k+1; sarrUnitsCavalry[k] := 'cuirassier';
      k := k+1; sarrUnitsCavalry[k] := 'hussar';
      k := k+1; sarrUnitsCavalry[k] := 'hussarpru';
      k := k+1; sarrUnitsCavalry[k] := 'hussarhun';
      k := k+1; sarrUnitsCavalry[k] := 'hussarswi';
      k := k+1; sarrUnitsCavalry[k] := 'hetman';
      k := k+1; sarrUnitsCavalry[k] := 'dragoon18';
      k := k+1; sarrUnitsCavalry[k] := 'dragoon18fra';
      k := k+1; sarrUnitsCavalry[k] := 'dragoon18net';
      k := k+1; sarrUnitsCavalry[k] := 'dragoon18pie';
      k := k+1; sarrUnitsCavalry[k] := 'reiterswe';
      k := k+1; sarrUnitsCavalry[k] := 'guardcavalrysax';
      k := k+1; sarrUnitsCavalry[k] := 'sipahi';
      k := k+1; sarrUnitsCavalry[k] := 'lightcavalry';

      k := 0;   sarrUnitsCavalryMelee[k] := 'reiter';
      k := k+1; sarrUnitsCavalryMelee[k] := 'vityaz';
      k := k+1; sarrUnitsCavalryMelee[k] := 'wingedhussar';
      k := k+1; sarrUnitsCavalryMelee[k] := 'cossacksich';
      k := k+1; sarrUnitsCavalryMelee[k] := 'raidersco';
      k := k+1; sarrUnitsCavalryMelee[k] := 'spakh';
      k := k+1; sarrUnitsCavalryMelee[k] := 'mameluke';
      k := k+1; sarrUnitsCavalryMelee[k] := 'croat';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hackapell';
      k := k+1; sarrUnitsCavalryMelee[k] := 'reiterpol';
      k := k+1; sarrUnitsCavalryMelee[k] := 'cossackregister';
      k := k+1; sarrUnitsCavalryMelee[k] := 'lancersco';
      k := k+1; sarrUnitsCavalryMelee[k] := 'cossackdon';
      k := k+1; sarrUnitsCavalryMelee[k] := 'cuirassier';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hussar';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hussarpru';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hussarhun';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hussarswi';
      k := k+1; sarrUnitsCavalryMelee[k] := 'hetman';
      k := k+1; sarrUnitsCavalryMelee[k] := 'reiterswe';
      k := k+1; sarrUnitsCavalryMelee[k] := 'guardcavalrysax';
      k := k+1; sarrUnitsCavalryMelee[k] := 'sipahi';

      k := 0;   sarrUnitsBayonet[k] := 'musketeer18';
      k := k+1; sarrUnitsBayonet[k] := 'musketeer18pru';
      k := k+1; sarrUnitsBayonet[k] := 'musketeer18den';
      k := k+1; sarrUnitsBayonet[k] := 'musketeer18bav';
      k := k+1; sarrUnitsBayonet[k] := 'musketeer18sax';
      k := k+1; sarrUnitsBayonet[k] := 'grenadier';
      k := k+1; sarrUnitsBayonet[k] := 'grenadierden';
      k := k+1; sarrUnitsBayonet[k] := 'grenadierpru';
      k := k+1; sarrUnitsBayonet[k] := 'grenadierbav';
      k := k+1; sarrUnitsBayonet[k] := 'grenadiersax';
      k := k+1; sarrUnitsBayonet[k] := 'grenadierhun';

      k := 0;   sarrShipsCannon[k] := 'yacht';
      k := k+1; sarrShipsCannon[k] := 'yachttur';
      k := k+1; sarrShipsCannon[k] := 'frigate';
      k := k+1; sarrShipsCannon[k] := 'chaika';
      k := k+1; sarrShipsCannon[k] := 'xebec';
      k := k+1; sarrShipsCannon[k] := 'battleship';
      k := k+1; sarrShipsCannon[k] := 'galley';
      
      k := 0;   sarrBuildingsAll[k] := csid+'cen';
      k := k+1; sarrBuildingsAll[k] := csid+'hou';
      k := k+1; sarrBuildingsAll[k] := csid+'bla';
      k := k+1; sarrBuildingsAll[k] := csid+'sta';
      k := k+1; sarrBuildingsAll[k] := csid+'tem';
      k := k+1; sarrBuildingsAll[k] := csid+'aca';
      k := k+1; sarrBuildingsAll[k] := csid+'dip';
      k := k+1; sarrBuildingsAll[k] := csid+'bar';
      k := k+1; sarrBuildingsAll[k] := csid+'ba2';
      k := k+1; sarrBuildingsAll[k] := csid+'art';
      k := k+1; sarrBuildingsAll[k] := commonName+'mil';
      k := k+1; sarrBuildingsAll[k] := commonNameStorehouse{commonName+'sto'};
      k := k+1; sarrBuildingsAll[k] := 'eurgol';
      k := k+1; sarrBuildingsAll[k] := 'euriro';
      k := k+1; sarrBuildingsAll[k] := 'eurcoa';
      k := k+1; sarrBuildingsAll[k] := commonNameMarket{commonName+'mar'};
      k := k+1; sarrBuildingsAll[k] := commonNamePort{commonName+'por'};
      
      // NULL ID (empty)
      _country_AddUpgrade(country, 'null', 0, gc_upg_tooltiptype_none, gc_upg_type_none, 0, False, 0, 0, 0, ind, 0, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      
      const default = -1;
      // center
      var bhave18century : Boolean = (not ukr) and (not tur) and (not alg) and (not sco);
      if (bhave18century) then
      begin
         _country_AddUpgradeWithAccessControl(country, century18, 1, gc_upg_tooltiptype_none, gc_upg_type_enableunit, 0, cTrue, 300, 2, 2, ind, 30000, 0, 0, 5000, 2000, 2000, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'aca', csid+'tem', csid+'art', '', '', '', '', ''); // no more market, blacksmith, barrack, stable for 18 century upgrade in c3
         case cid of
            _fra : _country_ModifyUpgrade(country, ind-1, default, 40000, default, default, 3500, 4000, 4000);
            _eng : _country_ModifyUpgrade(country, ind-1, default, 25000, default, default, default, 5500, 5500);
            _pol : _country_ModifyUpgrade(country, ind-1, default, 30000, default, default, 4800, 2200, 2200);
            _swe : _country_ModifyUpgrade(country, ind-1, default, 37000, default, default, 5500, 1500, 1500);
            _pru : _country_ModifyUpgrade(country, ind-1, default, 20000, default, default, 6500, 1100, 1100);
            _ven : _country_ModifyUpgrade(country, ind-1, default, 40000, default, default, 3000, 2500, 2500);
            _den : _country_ModifyUpgrade(country, ind-1, default, 20000, default, default, 6500, 1100, 1100);
            _net : _country_ModifyUpgrade(country, ind-1, default, 33000, default, default, 4800, 1800, 1800);
         end;
      end;

      // mill
      var upgplace : String = commonName+'mil';
      _country_AddUpgradeLink(country, upgplace+'.1', upgplace+'.2', linkind);
      _country_AddUpgrade(country, upgplace+'.1', 1, gc_upg_tooltiptype_none, gc_upg_type_effectfood, 140, cTrue, 500, 2, 2, ind, 750, 0, 0, 250, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      case cid of
         _tur : _country_ModifyUpgrade(country, ind-1, default, 600, default, default, default, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, 600, default, default, default, default, default);
      end;
      if (not tur) and (not alg) then
      begin
         var req0 : String;
         if (not ukr) and (not sco) then
         req0 := century18
         else
         req0 := csid+'aca';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.2', 2, gc_upg_tooltiptype_none, gc_upg_type_effectfood, 180{250}, False, 500, 2, 2, ind, 25600, 0, 0, 3350, 2000, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, req0, '', '', '', '', '', '', '');
         if (ukr) or (sco) then
         _country_ModifyUpgrade(country, ind-1, default, 5600, default, default, 1350, 1900, default);
      end;
      // academy
      upgplace := csid+'aca';
      _country_AddUpgradeLink(country, upgplace+'.21', upgplace+'.21', linkind);
      _country_AddUpgradeLink(country, upgplace+'.26', upgplace+'.26', linkind);
      _country_AddUpgrade(country, upgplace+'.1', 1, gc_upg_tooltiptype_none, gc_upg_type_effectfood, 40, cTrue, 500, 0, 0, ind, 0, 200, 0, 325, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      case cid of
         _fra : _country_ModifyUpgrade(country, ind-1, default, default, 190, default, 315, default, default);
      end;
      _country_AddUpgrade(country, upgplace+'.2', 1, gc_upg_tooltiptype_none, gc_upg_type_effectfood, 50, cTrue, 500, 0, 1, ind, 0, 2400, 0, 625, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      case cid of
         //_fra : _country_ModifyUpgrade(country, ind-1, default, default, 2100, default, default, default, default);
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, 400, default, 522, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, 400, default, 522, default, default);
      end;
      _country_AddUpgrade(country, upgplace+'.3', 1, gc_upg_tooltiptype_none, gc_upg_type_effectfood, 50, cTrue, 500, 0, 2, ind, 0, 3600, 0, 850, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      case cid of
         //_fra : _country_ModifyUpgrade(country, ind-1, default, default, 15400, default, 1030, default, default);
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, 2400, default, default, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, 1240, default, default, default, default);
      end;
      _country_AddUpgrade(country, upgplace+'.4', 1, gc_upg_tooltiptype_none, gc_upg_type_fieldlifeperc, 200, cTrue, 500, 1, 0, ind, 0, 1000, 0, 475, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      case cid of
         //_fra : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 822, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, 700, default, default, default, default);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.5', 1, gc_upg_tooltiptype_none, gc_upg_type_fishingperc, 100, cTrue, 500, 1, 1, ind, 0, 12400, 0, 2520, 0, 0, bAddIfNotExist, 0, 0, 0, 'fishboat', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
      case cid of
         _fra : _country_ModifyUpgrade(country, ind-1, default, default, 13900, default, 2420, default, default);
         _eng : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 3520, default, default);
      end;
      if (not ukr) then
      begin
         //enablefrigate := csid+'aca.6';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.6', 1, gc_upg_tooltiptype_none, gc_upg_type_enableunit, 0, cTrue, 500, 1, 2, ind, 0, 12400, 0, 7040, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
         //_country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'frigate');
         //_country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'xebec');
         case cid of
            _fra : _country_ModifyUpgrade(country, ind-1, default, default, 13500, default, 7250, default, default);
            _tur : _country_ModifyUpgrade(country, ind-1, default, default, 9500, default, default, default, default);
            _alg : _country_ModifyUpgrade(country, ind-1, default, default, 9500, default, default, default, default);
         end;
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.7', 1, gc_upg_tooltiptype_none, gc_upg_type_priceperc, 0, cTrue, 500, 2, 0, ind, 0, 7300, 0, 1220, 0, 0, bAddIfNotExist, 0, 0, 0, 'fishboat', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-85';
      case cid of
         _fra : _country_ModifyUpgrade(country, ind-1, default, default, 7800, default, 1110, default, default);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.8', 1, gc_upg_tooltiptype_none, gc_upg_type_effectwoodperc, 100, cTrue, 500, 2, 1, ind, 5500, 0, 0, 550, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      _country_AddUpgrade(country, upgplace+'.9', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 85, cTrue, 500, 2, 2, ind, 0, 9400, 7850, 1150, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrBuildingsAll[k]);
      case cid of
         _ukr : _country_ModifyUpgrade(country, ind-1, default, default, 3200, default, 950, default, default);
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, default, 0, default, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, default, 0, default, default, default);
      end;
      _country_AddUpgrade(country, upgplace+'.10', 1, gc_upg_tooltiptype_none, gc_upg_type_buildtimeperc, -7500000, cTrue, 500, 3, 0, ind, 0, 0, 0, 6950, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrBuildingsAll[k]);
      case cid of
         _ukr : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 1750, default, default);
         _sco : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 2650, default, default);
      end;
      if (not ukr) then
      begin
         _country_AddUpgrade(country, upgplace+'.11', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 80, cTrue, 500, 3, 1, ind, 0, 0, 16200, 1500, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'eurswa');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'eursga');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'russwa');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'russga');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'turswa');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'tursga');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, commonName+'tow');
         case cid of
            _fra : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 500, default, default);
            _swe : _country_ModifyUpgrade(country, ind-1, default, default, 12200, default, 1100, default, default);
            _tur : _country_ModifyUpgrade(country, ind-1, default, default, 16200, 0, default, default, default);
            _alg : _country_ModifyUpgrade(country, ind-1, default, default, 16200, 0, default, default, default);
         end;
      end;
      if (not alg) then
      begin
         _country_AddUpgradeWithAccessControl(country, upgplace+'.12', 1, gc_upg_tooltiptype_none, gc_upg_type_damageperc, 10, cTrue, 500, 3, 2, ind, 0, 0, 0, 0, 5000, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.13', 1, gc_upg_tooltiptype_none, gc_upg_type_damageperc, 10, cTrue, 500, 4, 0, ind, 0, 0, 0, 4000, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.14', 1, gc_upg_tooltiptype_none, gc_upg_type_damageperc, 15, cTrue, 500, 4, 1, ind, 0, 0, 0, 7000, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.15', 1, gc_upg_tooltiptype_none, gc_upg_type_damageperc, 25, cTrue, 500, 4, 2, ind, 0, 0, 0, 0, 0, 11000, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.16', 1, gc_upg_tooltiptype_none, gc_upg_type_attrangeperc, 5, cTrue, 500, 5, 0, ind, 0, 0, 0, 2000, 12150, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, commonName+'tow');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      case cid of
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, default, default, default, 0, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, default, default, default, 0, default);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.17', 1, gc_upg_tooltiptype_none, gc_upg_type_attrangeperc, 10, cTrue, 500, 5, 1, ind, 0, 0, 3000, 4550, 19200, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, commonName+'tow');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      case cid of
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, default, default, default, 0, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, default, default, default, 0, default);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.18', 1, gc_upg_tooltiptype_none, gc_upg_type_lifeperc, 50{c1=150, i change base cannon hp from 25000 to 5000}, cTrue, 500, 5, 2, ind, 0, 0, 0, 500, 3830, 1500, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      if (bhave18century) and (not sco) then
      begin
         //enablemulticannon := csid+'aca.19';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.19', 1, gc_upg_tooltiptype_none, gc_upg_type_enableunit, 0, cTrue, 500, 6, 0, ind, 0, 0, 0, 1500, 0, 2500, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         //_country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'multicannon');
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.20', 1, gc_upg_tooltiptype_none, gc_upg_type_attdispertionperc, -35, cTrue, 500, 6, 1, ind, 0, 3540, 0, 2000, 0, 7250, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      case cid of
         _fra : _country_ModifyUpgrade(country, ind-1, default, default, 13540, default, 1500, default, 5950);
         _pru : _country_ModifyUpgrade(country, ind-1, default, default, 23540, default, 1900, default, 4250);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.21', 1, gc_upg_tooltiptype_none, gc_upg_type_healing, 25, cTrue, 500, 6, 2, ind, 0, 350, 0, 100, 0, 250, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'multicannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      _country_AddUpgrade(country, upgplace+'.22', 1, gc_upg_tooltiptype_none, gc_upg_type_geology, 0, cTrue, 500, 7, 0, ind, 0, 0, 0, 250, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      _country_AddUpgrade(country, upgplace+'.23', 1, gc_upg_tooltiptype_none, gc_upg_type_effectstoneperc, 100, cTrue, 500, 7, 1, ind, 0, 0, 0, 1550, 3000, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      _country_AddUpgrade(country, upgplace+'.24', 1, gc_upg_tooltiptype_none, gc_upg_type_effectstoneperc, 200, cTrue, 500, 7, 2, ind, 4200, 0, 0, 1550, 0, 12520, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      if (not tur) and (not alg) then
      begin
         var req0 : String;
         if (not ukr) and (not sco) then
         req0 := century18;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.25', 1, gc_upg_tooltiptype_none, gc_upg_type_balloon, 0, cTrue, 500, 8, 0, ind, 0, 0, 0, 5750, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, req0, '', '', '', '', '', '', '');
         case cid of
            _ukr : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 12750, default, default);
            _sco : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 12750, default, default);
         end;
      end;
      _country_AddUpgrade(country, upgplace+'.26', 1, gc_upg_tooltiptype_none, gc_upg_type_healing, 50, cTrue, 1000, 8, 1, ind, 0, 0, 0, 200, 0, 200, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsAll[k]);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.27', 1, gc_upg_tooltiptype_none, gc_upg_type_attdispertionperc, -35, cTrue, 500, 8, 2, ind, 0, 9540, 0, 12000, 0, 65200, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'cannon');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'howitzer');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'mortar');
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'framegun');
      case cid of
         _fra : _country_ModifyUpgrade(country, ind-1, default, default, 23580, default, 9800, default, 65400);
         _pru : _country_ModifyUpgrade(country, ind-1, default, default, 12540, default, 8500, default, 57200);
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.28', 1, gc_upg_tooltiptype_none, gc_upg_type_speedperc, 40, cTrue, 500, 9, 0, ind, 0, 65400, 0, 24050, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      case cid of
         _eng : _country_ModifyUpgrade(country, ind-1, default, default, 53400, default, 22050, default, default);
         _ukr : _country_ModifyUpgrade(country, ind-1, default, default, 0, default, 900, default, default);
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, 0, default, 1900, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, 0, default, 1900, default, default);
      end;
      if (not ukr) then
      begin
         //enablebattleship := csid+'aca'+'.29';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.29', 1, gc_upg_tooltiptype_none, gc_upg_type_enableunit, 0, cTrue, 500, 9, 1, ind, 0, 32300, 0, 6800, 9000, 12800, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
         case cid of
            _eng : _country_ModifyUpgrade(country, ind-1, default, default, 22300, default, default, 7500, 13200);
         end;
      end;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.30', 1, gc_upg_tooltiptype_none, gc_upg_type_buildtimeperc, -5000000, cTrue, 500, 9, 2, ind, 0, 2300, 42700, 1150, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, commonNamePort{commonName+'por'}, '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrShipsCannon[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'fishboat');
      case cid of
         _tur : _country_ModifyUpgrade(country, ind-1, default, default, 0, default, 0, default, default);
         _alg : _country_ModifyUpgrade(country, ind-1, default, default, 0, default, 0, default, default);
      end;
      if (not alg) then
      begin
         _country_AddUpgrade(country, upgplace+'.31', 1, gc_upg_tooltiptype_none, gc_upg_type_attpauseperc, -30, cTrue, 500, 10, 0, ind, 0, 0, 6000, 5500, 4200, 0, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
      end;
      if (bhave18century) then
      begin
         _country_AddUpgradeWithAccessControl(country, upgplace+'.32', 1, gc_upg_tooltiptype_none, gc_upg_type_priceperc, 0, cTrue, 500, 10, 1, ind, 0, 0, 0, 6050, 0, 7750, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, century18, '', '', '', '', '', '', '');
         country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-50';
         country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-50';
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'musketeer18');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'musketeer18pru');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'musketeer18den');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'musketeer18bav');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'musketeer18sax');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadier');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadierden');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadierpru');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadierbav');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadiersax');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'grenadierhun');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'pandur');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'chasseur');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'pandurhun');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'jagerpor');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'jagerswi');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'highlander');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'dragoon18');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'dragoon18fra');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'dragoon18net');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'dragoon18pie');
         _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'lightcavalry');
      end;
      if (not alg) then
      begin
         _country_AddUpgrade(country, upgplace+'.33', 1, gc_upg_tooltiptype_none, gc_upg_type_attpauseperc, -30, cTrue, 500, 10, 2, ind, 0, 5000, 0, 5500, 0, 15200, bAddIfNotExist, gc_obj_weapon_kind_bullet, 0, 0, '', '', '', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsShooters[k]);
      end;
      if (bhave18century) then
      begin
         _country_AddUpgradeWithAccessControl(country, upgplace+'.34', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 2, cTrue, 500, 11, 0, ind, 0, 0, 0, 9750, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsArmored[k]);
      end;
      if (bhave18century) then
      begin
         _country_AddUpgradeWithAccessControl(country, upgplace+'.35', 1, gc_upg_tooltiptype_none, gc_upg_type_damage, 5, cTrue, 500, 11, 1, ind, 0, 0, 0, 11500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, '', '', '', '', '', '', '', '', '', '', True, century18, csid+'bla', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsBayonet[k]);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.36', 1, gc_upg_tooltiptype_none, gc_upg_type_damageperc, 25, cTrue, 500, 11, 2, ind, 0, 0, 0, 19500, 0, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, '', '', '', '', '', '', '', '', '', '', True, century18, csid+'bla', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsBayonet[k]);
      end;
      // blacksmith
      upgplace := csid+'bla';
      _country_AddUpgrade(country, upgplace+'.1', 1, gc_upg_tooltiptype_none, gc_upg_type_fieldlifeperc, 100, cTrue, 500, 0, 0, ind, 0, 400, 0, 90, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      _country_AddUpgrade(country, upgplace+'.2', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 50, cTrue, 500, 1, 0, ind, 0, 0, 12320, 350, 900, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrBuildingsAll[k]);
      _country_AddUpgrade(country, upgplace+'.3', 1, gc_upg_tooltiptype_none, gc_upg_type_buildtimeperc, -3333333, cTrue, 500, 2, 0, ind, 0, 0, 0, 3650, 5300, 8200, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsCavalry[k]);
      case cid of
         _eng : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 3550, 4100, 6700);
         _pru : _country_ModifyUpgrade(country, ind-1, default, default, default, default, default, 4300, 5200);
         _ven : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 650, 9800, 530);
      end;
      if (bhave18century) then
      begin
         _country_AddUpgradeWithAccessControl(country, upgplace+'.4', 1, gc_upg_tooltiptype_none, gc_upg_type_damage, 5, cTrue, 500, 3, 0, ind, 0, 1300, 0, 1500, 900, 5000, bAddIfNotExist, gc_obj_weapon_kind_pike, 0, 0, '', '', '', '', '', '', '', '', '', '', True, century18, '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsBayonet[k]);
      end;
      _country_AddUpgrade(country, upgplace+'.5', 1, gc_upg_tooltiptype_none, gc_upg_type_damage, 5, cTrue, 500, 4, 0, ind, 0, 0, 0, 4000, 7900, 0, bAddIfNotExist, gc_obj_weapon_kind_pike, gc_obj_weapon_kind_sword, 0, '', '', '', '', '', '', '', '', '', '');
      for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsCavalryMelee[k]);
      _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, 'swordsmansco');
      case cid of
         _eng : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 6550, default, default);
         _pru : _country_ModifyUpgrade(country, ind-1, default, default, default, default, 9550, default, default);
      end;
      if (bhave18century) then
      begin
         _country_AddUpgrade(country, upgplace+'.6', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 2, cTrue, 500, 5, 0, ind, 0, 0, 0, 4950, 10500, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsArmored[k]);
      end;
      // artillery depot
      upgplace := csid+'art';
      member := 'cannon';
      var x, y : Integer;
      x := 0;
      y := 1;
      _country_AddUpgradeLinkRange(country, upgplace+'.'+member+'.1.', 1, 6, linkind);
      country.upgradelinks[linkind-1][1] := '';
      country.upgradelinks[linkind-2][1] := '';
      country.upgradelinks[linkind-3][1] := '';
      
      _country_AddUpgradeLinkRange(country, upgplace+'.'+member+'.2.', 1, 6, linkind);
      country.upgradelinks[linkind-1][1] := '';
      country.upgradelinks[linkind-2][1] := '';
      country.upgradelinks[linkind-3][1] := '';
      
      const cValueForTooltip = 35;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.1', 2, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, cTrue, 320, x, y, ind, 0, 1000, 500, 300, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.2', 3, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 320, x, y, ind, 0, 3000, 1000, 500, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.3', 4, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 320, x, y, ind, 0, 6000, 2000, 1000, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.4', 5, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.5', 6, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.6', 7, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      y := 2;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.1', 2, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, cTrue, 320, x, y, ind, 0, 0, 0, 500, 1000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 950, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.2', 3, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, False, 320, x, y, ind, 0, 0, 0, 1000, 2000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 150, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.3', 4, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, False, 320, x, y, ind, 0, 0, 0, 2000, 3000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 250, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.4', 5, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 500, x, y, ind, 2560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 1350, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.5', 6, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 500, x, y, ind, 3560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 2500, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.6', 7, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 500, x, y, ind, 5560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 3350, default, 0);

      member := 'howitzer';
      x := 2;
      y := 1;
      _country_AddUpgradeLinkRange(country, upgplace+'.'+member+'.1.', 1, 6, linkind);
      country.upgradelinks[linkind-1][1] := '';
      country.upgradelinks[linkind-2][1] := '';
      country.upgradelinks[linkind-3][1] := '';

      _country_AddUpgradeLinkRange(country, upgplace+'.'+member+'.2.', 1, 6, linkind);
      country.upgradelinks[linkind-1][1] := '';
      country.upgradelinks[linkind-2][1] := '';
      country.upgradelinks[linkind-3][1] := '';

      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.1', 2, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, cTrue, 320, x, y, ind, 0, 1000, 500, 300, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.2', 3, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 320, x, y, ind, 0, 3000, 1000, 500, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.3', 4, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 320, x, y, ind, 0, 6000, 2000, 1000, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.4', 5, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.5', 6, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.1.6', 7, gc_upg_tooltiptype_artillerycost, gc_upg_type_priceperc, cValueForTooltip, False, 500, x, y, ind, 1760, 0, 0, 350, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_wood-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_gold-1] := '-25';
      country.upgrade[ind-1].sarrparam2[gc_upgrade_maxarrparam2count-gc_ResCount+gc_resource_type_iron-1] := '-25';
      y := 2;
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.1', 2, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, cTrue, 320, x, y, ind, 0, 0, 0, 500, 1000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 350, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.2', 3, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, False, 320, x, y, ind, 0, 0, 0, 1000, 2000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 450, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.3', 4, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2500000, False, 320, x, y, ind, 0, 0, 0, 2000, 3000, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 550, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.4', 5, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 1000, x, y, ind, 2560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 1150, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.5', 6, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 1000, x, y, ind, 3560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 3200, default, 0);
      _country_AddUpgradeWithAccessControl(country, upgplace+'.'+member+'.2.6', 7, gc_upg_tooltiptype_artillerybuild, gc_upg_type_buildtimeperc, -2000000, False, 1000, x, y, ind, 5560, 0, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, member, '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
      if (tur) or (alg) then _country_ModifyUpgrade(country, ind-1, default, default, default, default, 4500, default, 0);

      var privateind : Integer;
      // single (unique) upgrades
      var i : Integer;
      for i:=1 to 3 do
      begin
         case i of
            1 : member := 'gol';
            2 : member := 'iro';
            3 : member := 'coa';
         end;
         upgplace := 'eur'+member;
         _country_AddUpgradeLink(country, upgplace+'.1', upgplace+'.2', linkind);
         _country_AddUpgradeLink(country, upgplace+'.2', upgplace+'.3', linkind);
         if (bhave18century) then
         _country_AddUpgradeLink(country, century18, upgplace+'.4', linkind)
         else
         _country_AddUpgradeLink(country, upgplace+'.3', upgplace+'.4', linkind);
         _country_AddUpgradeLink(country, upgplace+'.4', upgplace+'.5', linkind);
         _country_AddUpgradeLink(country, upgplace+'.5', upgplace+'.6', linkind);
         
         var req0 : String;
         if (bhave18century) then
         req0 := century18;
         
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 5, cTrue, 300, 2, 2, ind, 1000, 0, 0, 1250, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.2', 3, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 8, False, 300, 2, 2, ind, 5250, 0, 0, 4950, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.3', 4, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 10, False, 300, 2, 2, ind, 12500, 0, 0, 9250, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.4', 5, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 12, False, 300, 2, 2, ind, 15800, 0, 0, 18500, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, req0, '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.5', 6, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 15, False, 300, 2, 2, ind, 19800, 0, 0, 21050, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, req0, '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.6', 7, gc_upg_tooltiptype_none, gc_upg_type_single_inside_mine, 40, False, 300, 2, 2, ind, 50200, 0, 0, 25950, 0, 0, bAddIfNotExist, 0, 0, 0, 'eur'+member, '', '', '', '', '', '', '', '', '', True, req0, '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         if (not bhave18century) then
         _country_ModifyUpgrade(country, ind-1, default, 7080, default, default, 25410, default, default);
      // add to private list
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.2', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.2', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.3', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.3', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.4', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.4', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.5', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.5', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.6', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.6', privateind);
      end;
      if (not ukr) then
      begin
         upgplace := commonName+'tow';
         _country_AddUpgradeLinkRange(country, upgplace+'.', 1, 6, linkind);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -20, cTrue, 1000, 0, 0, ind, 0, 0, 0, 250, 0, 0, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.2', 3, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -20, False, 1000, 0, 0, ind, 0, 0, 0, 0, 350, 0, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.3', 4, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -10, False, 1000, 0, 0, ind, 0, 0, 0, 0, 0, 400, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.4', 5, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -10, False, 1000, 0, 0, ind, 0, 0, 0, 0, 450, 0, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         _country_AddUpgradeWithAccessControl(country, upgplace+'.5', 6, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -10, False, 1000, 0, 0, ind, 0, 0, 0, 0, 0, 500, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         //_country_AddUpgradeWithAccessControl(country, upgplace+'.6', 7, gc_upg_tooltiptype_none, gc_upg_type_single_attpauseperc, -10, False, 1000, 0, 0, ind, 0, 0, 0, 0, 1000, 0, bAddIfNotExist, 0, 0, 0, commonName+'tow', '', '', '', '', '', '', '', '', '', True, csid+'art', '', '', '', '', '', '', '');
         //country.upgrade[ind-1].bindividual := True;
      // add to private list
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.2', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.2', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.3', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.3', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.4', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.4', privateind);
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.5', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.5', privateind);
         //privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.6', bAddIfNotExist);
         //_country_AddPrivateUpgrade(country, upgplace+'.6', privateind);
      end;
      
      // UNITS
      // single units
      if (bhave18century) then
      begin
         upgplace := 'ferry';
         _country_AddUpgradeLink(country, century18, upgplace+'.1', linkind);
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_inside, 200, False, 500, 2, 1, ind, 1000, 0, 0, 1250, 0, 0, bAddIfNotExist, 0, 0, 0, 'ferry', '', '', '', '', '', '', '', '', '', True, century18, '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
      end;
      
      upgplace := 'ukrwwa';
      _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_buildgate, 5, cTrue, 1, 0, 0, ind, 0, 400, 0, 0, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
      country.upgrade[ind-1].bindividual := True;
      privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
      _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
      
      if (rus) then
      begin
         upgplace := 'russwa';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_buildgate, 5, cTrue, 1, 0, 0, ind, 0, 0, 500, 0, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
      end
      else
      if (tur) or (alg) then
      begin
         upgplace := 'turswa';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_buildgate, 5, cTrue, 1, 0, 0, ind, 0, 0, 500, 0, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
      end
      else
      if (not ukr) then
      begin
         upgplace := 'eurswa';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.1', 2, gc_upg_tooltiptype_none, gc_upg_type_single_buildgate, 5, cTrue, 1, 0, 0, ind, 0, 0, 500, 0, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, '', '', '', '', '', '', '', '');
         country.upgrade[ind-1].bindividual := True;
         privateind := _country_GetPrivateUpgradeIndexBySID(cid, upgplace+'.1', bAddIfNotExist);
         _country_AddPrivateUpgrade(country, upgplace+'.1', privateind);
      end;

      _country_InitUnitsUpgrades(country, ind, linkind);
      _country_InitOfficerFormations(country);

      // Add upgrades
      if (tur) then
      begin
         upgplace := csid+'aca';
         _country_AddUpgradeWithAccessControl(country, upgplace+'.34', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 2, cTrue, 500, 11, 0, ind, 0, 0, 0, 6950, 0, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', True, csid+'bla', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsArmored[k]);

         upgplace := csid+'bla';
         _country_AddUpgrade(country, upgplace+'.6', 1, gc_upg_tooltiptype_none, gc_upg_type_shield, 2, cTrue, 500, 5, 0, ind, 0, 0, 0, 4950, 10200, 0, bAddIfNotExist, 0, 0, 0, '', '', '', '', '', '', '', '', '', '');
         for k:=0 to cMaxUnitsArr-1 do _country_AddUpgradeSArrParam2MemberIfExists(country, ind-1, sarrUnitsArmored[k]);
      end;
   end;
end;

// _country_GetUpgradeNameBySID
//
procedure _country_GetUpgradeNameBySID(cid : Integer; var upgsid : String; var text : String);
begin
   var hintid : String = gc_loc_upgrades+'|'+upgsid;
   var upgind : Integer = _country_GetUpgradeIndexByUpgradeID(cid, upgsid, False);
   if (gCountry[cid].upgrade[upgind].tooltiptype=gc_upg_tooltiptype_none) then
   begin
      if (not _misc_StringToText(hintid, text)) then
      begin
         var tmp : String = SubStr(upgsid, 4, StrLength(upgsid)-3);
         hintid := gc_loc_upgrades+'|'+'%nat%'+tmp;
         if (not _misc_StringToText(hintid, text)) then
         begin
            hintid := gc_loc_upgrades+'|'+'%com%'+tmp;
            if (not _misc_StringToText(hintid, text)) then
            begin
               hintid := 'misc|'+upgsid;
               if (not _misc_StringToText(hintid, text)) then
               begin
                  hintid := 'misc|%nat%'+tmp;
                  if (not _misc_StringToText(hintid, text)) then
                  begin
                     hintid := 'misc|%com%'+tmp;
                     _misc_StringToText(hintid, text);
                  end;
               end;
            end;
         end;
      end;
   end
   else
   begin
      var hintid : String = gc_loc_upgrades+'|'+'tooltiptype.'+IntToStr(gCountry[cid].upgrade[upgind].tooltiptype);
      _misc_StringToText(hintid, text);
   end;
   var value : Float = gCountry[cid].upgrade[upgind].value;
   if (gCountry[cid].upgrade[upgind].itype=gc_upg_type_buildtimeperc) then
   value := value/100000;
   text := StrReplace(text, '%value%', FloatToStr(value));
end;

// _unit_FindMemberNearestCountryID
//
function _unit_FindMemberNearestCountryID(var basename : String) : Integer;
begin
   Result := -1;
   var i, j : Integer;
   for i:=0 to gc_MaxCountryCount-1 do
   begin
      for j:=0 to gc_country_maxmembers-1 do
      begin
         if (gCountry[i].members[j]=basename) then
         begin
            Result := i;
            break;
         end;
      end;
   end;
end;

// _country_InitAll
//
procedure _country_InitAll();
begin
   var sid : String;
   var empty : TCountry;
   var i : Integer;
   for i:=0 to gc_MaxCountryCount-1 do
   begin
      if (gCountry[i].sid<>'') then
      gCountry[i] := empty;
      _country_GetSIDByID(i, sid);
      if (sid<>'') then
      _country_Init(gCountry[i], sid);
   end;
end;

// _country_InitWallCustomPoints
//
procedure _country_InitWallCustomPoints();
begin
   var pParser : Integer = _parser_ParserTemporary(True);
   ParserLoadFromFileByHandle(pParser, gc_filepath_wallcustom);
   var i, j : Integer;
   for i:=0 to ParserGetCountByHandle(pParser)-1 do
   begin
      var pVariation : Integer = ParserSelectByHandleByIndex(pParser, i);
      if (pVariation<>0) then
      begin
         var variation : Integer = ParserGetIntValueByKeyByHandle(pVariation, 'WallVariation');
         var pBuilderPoints : Integer = ParserSelectByHandleByKey(pVariation, 'BuilderPoints');
         if (pBuilderPoints<>0) then
         begin
            var builderCount : Integer = ParserGetCountByHandle(pBuilderPoints);
            gCustomBuildPointsWall[variation].builderCount := builderCount;
            for j:=0 to builderCount-1 do
            begin
               var pBuilderPoint : Integer = ParserSelectByHandleByIndex(pBuilderPoints, j);
               gCustomBuildPointsWall[variation].builderPoints[j].x := ParserGetFloatValueByKeyByHandle(pBuilderPoint, 'x');
               gCustomBuildPointsWall[variation].builderPoints[j].y := ParserGetFloatValueByKeyByHandle(pBuilderPoint, 'y');
            end;
         end;
      end;
   end;
end;

// _country_InitObjCustom
//
procedure _country_InitObjCustom();
begin
   var pParser : Integer = _parser_ParserTemporary(True);
   ParserLoadFromFileByHandle(pParser, gc_filepath_objcustom);
   var i, j : Integer;
   for i:=0 to ParserGetCountByHandle(pParser)-1 do
   begin
      var pBuilding : Integer = ParserSelectByHandleByIndex(pParser, i);
      if (pBuilding<>0) then
      begin
         var sid : String = ParserGetValueByKeyByHandle(pBuilding, 'sid');
         if (sid<>'') then
         begin
            var cid, id : Integer;
            for cid:=0 to gc_MaxCountryCount-1 do
            begin
               for id:=0 to gc_country_maxmembers-1 do
               begin
                  if (gCountry[cid].members[id]=sid) then
                  begin
                     var pBuilderPoints : Integer = ParserSelectByHandleByKey(pBuilding, 'BuilderPoints');
                     if (pBuilderPoints<>0) then
                     begin
                        var builderCount : Integer = ParserGetCountByHandle(pBuilderPoints);
                        gCustomObjPoints[cid][id].builderCount := builderCount;
                        for j:=0 to builderCount-1 do
                        begin
                           var pBuilderPoint : Integer = ParserSelectByHandleByIndex(pBuilderPoints, j);
                           gCustomObjPoints[cid][id].builderPoints[j].x := ParserGetFloatValueByKeyByHandle(pBuilderPoint, 'x');
                           gCustomObjPoints[cid][id].builderPoints[j].y := ParserGetFloatValueByKeyByHandle(pBuilderPoint, 'y');
                        end;
                     end;
                     var pExitPoints : Integer = ParserSelectByHandleByKey(pBuilding, 'ExitPoints');
                     if (pExitPoints<>0) then
                     begin
                        var exitCount : Integer = ParserGetCountByHandle(pExitPoints);
                        gCustomObjPoints[cid][id].exitCount := exitCount;
                        for j:=0 to exitCount-1 do
                        begin
                           var pExitPoint : Integer = ParserSelectByHandleByIndex(pExitPoints, j);
                           gCustomObjPoints[cid][id].exitPoints[j].x := ParserGetFloatValueByKeyByHandle(pExitPoint, 'x');
                           gCustomObjPoints[cid][id].exitPoints[j].y := ParserGetFloatValueByKeyByHandle(pExitPoint, 'y');
                           gCustomObjPoints[cid][id].exitPoints[j].z := ParserGetFloatValueByKeyByHandle(pExitPoint, 'z');
                        end;
                     end;
                     var pDecal : Integer = ParserSelectByHandleByKey(pBuilding, 'Decal');
                     if (pDecal<>0) then
                     begin
                        gCustomObjPoints[cid][id].decal.bexists := True;
                        gCustomObjPoints[cid][id].decal.scale := ParserGetFloatValueByKeyByHandle(pDecal, 'scale');
                        gCustomObjPoints[cid][id].decal.offx := ParserGetFloatValueByKeyByHandle(pDecal, 'offx');
                        gCustomObjPoints[cid][id].decal.offz := ParserGetFloatValueByKeyByHandle(pDecal, 'offy');
                        gCustomObjPoints[cid][id].decal.angle := ParserGetFloatValueByKeyByHandle(pDecal, 'angle');
                     end;
                     var pResourcePoint : Integer = ParserSelectByHandleByKey(pBuilding, 'ResourcePoint');
                     if (pResourcePoint<>0) then
                     begin
                        gCustomObjPoints[cid][id].resourcePoint.x := ParserGetFloatValueByKeyByHandle(pResourcePoint, 'x');
                        gCustomObjPoints[cid][id].resourcePoint.y := 0; //ParserGetFloatValueByKeyByHandle(pResourcePoint, 'y');
                        gCustomObjPoints[cid][id].resourcePoint.z := ParserGetFloatValueByKeyByHandle(pResourcePoint, 'z');
                     end;
                     var pShotPoints : Integer = ParserSelectByHandleByKey(pBuilding, 'ShotPoints');
                     if (pShotPoints<>0) then
                     begin
                        var shotCount : Integer = ParserGetCountByHandle(pShotPoints);
                        gCustomObjPoints[cid][id].shotCount := shotCount;
                        for j:=0 to shotCount-1 do
                        begin
                           var pShotPoint : Integer = ParserSelectByHandleByIndex(pShotPoints, j);
                           gCustomObjPoints[cid][id].shotPoints[j].x := ParserGetFloatValueByKeyByHandle(pShotPoint, 'x');
                           gCustomObjPoints[cid][id].shotPoints[j].y := ParserGetFloatValueByKeyByHandle(pShotPoint, 'y');
                           gCustomObjPoints[cid][id].shotPoints[j].z := ParserGetFloatValueByKeyByHandle(pShotPoint, 'z');
                           gCustomObjPoints[cid][id].shotPoints[j].bcustomdir := ParserGetBoolValueByKeyByHandle(pShotPoint, 'bcustomdir');
                           gCustomObjPoints[cid][id].shotPoints[j].minangle := ParserGetFloatValueByKeyByHandle(pShotPoint, 'minangle');
                           gCustomObjPoints[cid][id].shotPoints[j].maxangle := ParserGetFloatValueByKeyByHandle(pShotPoint, 'maxangle');
                           gCustomObjPoints[cid][id].shotPoints[j].bcustomweaponind := ParserGetBoolValueByKeyByHandle(pShotPoint, 'bcustomweaponind');
                           gCustomObjPoints[cid][id].shotPoints[j].weaponind := ParserGetIntValueByKeyByHandle(pShotPoint, 'weaponind');
                        end;
                     end;
                     var pSmokePoints : Integer = ParserSelectByHandleByKey(pBuilding, 'SmokePoints');
                     if (pSmokePoints<>0) then
                     begin
                        var smokeCount : Integer = Min(gc_MaxSmokePointsCount, ParserGetCountByHandle(pSmokePoints));
                        gCustomObjPoints[cid][id].smokeCount := smokeCount;
                        for j:=0 to smokeCount-1 do
                        begin
                           var pSmokePoint : Integer = ParserSelectByHandleByIndex(pSmokePoints, j);
                           gCustomObjPoints[cid][id].smokePoints[j].x := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'px');
                           gCustomObjPoints[cid][id].smokePoints[j].y := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'py');
                           gCustomObjPoints[cid][id].smokePoints[j].z := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'pz');
                           gCustomObjPoints[cid][id].smokePoints[j].nx := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'nx');
                           gCustomObjPoints[cid][id].smokePoints[j].ny := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'ny');
                           gCustomObjPoints[cid][id].smokePoints[j].nz := ParserGetFloatValueByKeyByHandle(pSmokePoint, 'nz');
                        end;
                     end;
                     var pCustomAABB : Integer = ParserSelectByHandleByKey(pBuilding, 'CustomAABB');
                     if (pCustomAABB<>0) then
                     begin
                        gCustomObjPoints[cid][id].aabb.buse := ParserGetBoolValueByKeyByHandle(pCustomAABB, 'buse');
                        gCustomObjPoints[cid][id].aabb.minx := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'minx');
                        gCustomObjPoints[cid][id].aabb.maxx := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'maxx');
                        gCustomObjPoints[cid][id].aabb.miny := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'miny');
                        gCustomObjPoints[cid][id].aabb.maxy := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'maxy');
                        gCustomObjPoints[cid][id].aabb.minz := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'minz');
                        gCustomObjPoints[cid][id].aabb.maxz := ParserGetFloatValueByKeyByHandle(pCustomAABB, 'maxz');
                     end;
                  end;
               end;
            end;
         end;
      end;
   end;
   ParserFreeByHandle(pParser);
end;

// _country_IsCountryAvailable
//
procedure _country_IsCountryAvailable(plind, cid, dlcs : Integer; var bVisibleInEditor, bVisibleInMP, bPlayable : Boolean);
begin
   bVisibleInEditor := False;
   bVisibleInMP := False;
   bPlayable := False;
   var csid : String;
   if (cid>=0) and (cid<gc_MaxCountryCount) then
   begin
      if (cid=gc_country_ind_mis) then
      bVisibleInEditor := True
      else
      begin
         if (cid<gc_MaxCountryCountRelease) then
         bPlayable := True
         else
         begin
            _country_GetSIDByID(cid, csid);
            case csid of
               'net', 'den' : bPlayable := True;
               'sax', 'bav' : begin
                  if ((dlcs and gc_lastknowndlc_dlc2)<>0) or ((dlcs and gc_lastknowndlc_deluxe)<>0) or (not _net_IsReplay) or (gRecordGeneratorVersion>66) then
                  bPlayable := True
                  else
                  bVisibleInMP := True;
               end;
               'por', 'hun' : begin
                  if ((dlcs and gc_lastknowndlc_dlc3)<>0) or ((dlcs and gc_lastknowndlc_deluxe)<>0) or (not _net_IsReplay) or (gRecordGeneratorVersion>75) then
                  bPlayable := True
                  else
                  bVisibleInMP := True;
               end;
               'pie', 'swi' : begin
                  if ((dlcs and gc_lastknowndlc_dlc4)<>0) or ((dlcs and gc_lastknowndlc_deluxe)<>0) or (not _net_IsReplay) or (gRecordGeneratorVersion>81) then
                  bPlayable := True
                  else
                  bVisibleInMP := True;
               end;
               'sco' : begin
                  if ((dlcs and gc_lastknowndlc_exp1)<>0) and ((not _net_IsReplay) or (gRecordGeneratorVersion>70)) then
                  bPlayable := True
                  else
                  bVisibleInMP := True;
               end;
            end;
         end;
         if (bPlayable) then
         begin
            bVisibleInEditor := True;
            bVisibleInMP := True;
         end;
      end
   end;
end;

_country_InitAll;
_country_InitObjCustom;
_country_InitWallCustomPoints;
