section.begin
   Name = DoProgress
   UsedFileName = 
   Code : struct.begin
      [*] = ;procedure ExecuteStateByFlag(var flag : Boolean; state : String; bSwitchFlag : Boolean);
      [*] = ;begin
      [*] = ;   if (flag) then
      [*] = ;   begin
      [*] = ;      if (bSwitchFlag) then
      [*] = ;      flag := not flag;
      [*] = ;      ExecuteState(state);
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;//_misc_ProfilerBegin('gui:doprogress');
      [*] = ;var myPlHnd : Integer = GetPlayerHandleInterfaceIO;
      [*] = ;var myPlInd : Integer = GetPlayerIndexByHandle(myPlHnd);
      [*] = ;if (gbool_gui_mapgenerationfinished) and (myPlHnd<>0) then
      [*] = ;begin
      [*] = ;   gbool_gui_mapgenerationfinished := False;
      [*] = ;   _control_MoveCameraToPosition(gMap.players[myPlInd].startx, gMap.players[myPlInd].starty, 0, True);
      [*] = ;   //GUIMiniMapUpdate;
      [*] = ;   _misc_UpdateMiniMapPrimitives(False);
      [*] = ;end;
      [*] = ;
      [*] = ;gbool_lan_isonlinecached := _net_IsOnline;
      [*] = ;
      [*] = ;// uncomment for primitives alert
      [*] = ;//gPrimitives.Clear;
      [*] = ;if (gPrimitives.GetCount>0) then
      [*] = ;begin
      [*] = ;   var i : Integer;
      [*] = ;   for i:=gPrimitives.GetCount-1 downto 0 do
      [*] = ;   begin
      [*] = ;      var prim : Integer = gPrimitives.Get(i);
      [*] = ;      if (prim>-1) then
      [*] = ;      begin
      [*] = ;         const cVisibleTime = 10;
      [*] = ;         var tag : Integer = GetGUIMiniMapPrimitiveTag(prim);
      [*] = ;         if (tag>0) and ((GetGUIMiniMapPrimitiveTag(prim)+cVisibleTime)<GetCurrentTime) then // new game start
      [*] = ;         begin
      [*] = ;            SetGUIMiniMapPrimitiveTag(prim, 1);
      [*] = ;            SetGUIMiniMapPrimitiveVisible(prim, False);
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if ((GetCurrentTime-gfloat_gui_musiclastbattletimeend)>(gc_gui_battlemusicinterval div 2)) then
      [*] = ;_sound_MusicSwitchToNational;
      [*] = ;
      [*] = ;if (gbool_gui_doalarm) then
      [*] = ;begin
      [*] = ;   _misc_ShowAlarm(gfloat_gui_alarmx, gfloat_gui_alarmz);
      [*] = ;
      [*] = ;   var s1, s2 : String;
      [*] = ;   var logmessageid : Integer;
      [*] = ;   case gint_gui_alarmevent of
      [*] = ;      gc_gui_alarmevent_attack : logmessageid := gc_logmessagesid_alarmattack;
      [*] = ;      gc_gui_alarmevent_attacked : logmessageid := gc_logmessagesid_alarmattacked;
      [*] = ;      gc_gui_alarmevent_capture : logmessageid := gc_logmessagesid_alarmcapture;
      [*] = ;      gc_gui_alarmevent_captured : logmessageid := gc_logmessagesid_alarmcaptured;
      [*] = ;   end;
      [*] = ;   if (logmessageid<>0) then
      [*] = ;   _misc_ShowLogMessage(logmessageid, s1, s2, False);
      [*] = ;   _sound_PlaySound(gc_sndlib_ind_interface, gc_snd_ind_alarm);
      [*] = ;
      [*] = ;   if ((GetCurrentTime-gfloat_gui_musiclastnationaltimestart)>gc_gui_battlemusicinterval) or (gfloat_gui_musiclastnationaltimestart=0) then
      [*] = ;   _sound_MusicSwitchToBattle;
      [*] = ;
      [*] = ;   gbool_gui_doalarm := False;
      [*] = ;   //gfloat_gui_alarmx := 0;
      [*] = ;   //gfloat_gui_alarmz := 0;
      [*] = ;end;
      [*] = ;
      [*] = ;// double soundtrack fixer
      [*] = ;var musthread : Integer = GetSndAmbientThreadHandleByName('music');
      [*] = ;var batthread : Integer = GetSndAmbientThreadHandleByName('battle');
      [*] = ;if (musthread<>0) and (GetSndAmbientThreadSetPlaying(musthread)) and (batthread<>0) and (GetSndAmbientThreadSetPlaying(batthread)) then
      [*] = ;begin
      [*] = ;   if ((GetCurrentTime-gfloat_gui_lasttimemusiccrossfade)>5) then
      [*] = ;   begin
      [*] = ;      Log('double soundtrack fixer');
      [*] = ;      SetSndAmbientThreadSetPlayingFade(batthread, False, 3);
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;//if (gbool_gui_update_editorinfo) then
      [*] = ;//begin
      [*] = ;   gbool_gui_update_editorinfo := False;
      [*] = ;//end;
      [*] = ;
      [*] = ;if (gbool_gui_update_unitcontrol) then
      [*] = ;begin
      [*] = ;   ExecuteState('ShowUnitControl');
      [*] = ;   gbool_gui_updateprogress_unitcontrol := True;
      [*] = ;   gbool_gui_update_unitcontrol := False;
      [*] = ;end;
      [*] = ;
      [*] = ;ExecuteStateByFlag(gbool_gui_debug, 'ShowEditorInfo', False);
      [*] = ;ExecuteStateByFlag(gbool_gui_updateprogress_unitcontrol, 'ShowUnitControl', False);
      [*] = ;ExecuteStateByFlag(gbool_gui_update_rallypoints, 'ShowRallyPoints', True);
      [*] = ;if (gbool_gui_updateadviser) then
      [*] = ;begin
      [*] = ;   if (not gPlayer[myplind].playeradviser.adviser.bavailable) then
      [*] = ;   begin
      [*] = ;      const elmname = 'AIAssistant';
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent(elmname, _gui_GetTop);
      [*] = ;      if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;      SetGUIElementVisible(elm, False);
      [*] = ;   end
      [*] = ;   else
      [*] = ;   ExecuteState('ShowAIAssistant');
      [*] = ;
      [*] = ;   if (not gPlayer[myplind].playeradviser.adviser.bavailable) {or (gPlayer[myplind].playeradviser.adviser.settings=0)} then
      [*] = ;   begin
      [*] = ;      const elmname = 'AIAssistantSettings';
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent(elmname, _gui_GetTop);
      [*] = ;      if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;      SetGUIElementVisible(elm, False);
      [*] = ;   end
      [*] = ;   else
      [*] = ;   ExecuteState('ShowAIAssistantSettings');
      [*] = ;
      [*] = ;   if (not gPlayer[myplind].playeradviser.adviser.bavailable) or (gPlayer[myplind].playeradviser.adviser.settings<>2) then
      [*] = ;   begin
      [*] = ;      const elmname = 'AIAssistantSettingsAdvanced';
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent(elmname, _gui_GetTop);
      [*] = ;      if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;      SetGUIElementVisible(elm, False);
      [*] = ;   end
      [*] = ;   else
      [*] = ;   ExecuteState('ShowAIAssistantSettingsAdvanced');
      [*] = ;
      [*] = ;   gbool_gui_updateadviser := False;
      [*] = ;end;
      [*] = ;if (_net_IsClient and ((gbool_gui_updateadviseradvice) or (_player_CheckProgressLastTimeAndIncrease(gPlayer[myplind].lastprogressaitime, 2, gc_global_TimeProgressAI)))) and (not gPlayer[myplInd].bai) then
      [*] = ;if (gPlayer[myplind].bexists) and (gPlayer[myplind].playeradviser.adviser.bavailable) and (gPlayer[myplind].playeradviser.adviser.benable) then
      [*] = ;PlayerExecuteStateByHandle(myPlHnd, 'ProgressEconomicAI');
      [*] = ;
      [*] = ;if (gbool_gui_updateadviseradvice) then
      [*] = ;begin
      [*] = ;   if (not gPlayer[myplind].playeradviser.adviser.bavailable) or (not gPlayer[myplind].playeradviser.adviser.benable) then
      [*] = ;   begin
      [*] = ;      const elmname = 'AIAssistantAdvices';
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent(elmname, _gui_GetTop);
      [*] = ;      if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;      SetGUIElementVisible(elm, False);
      [*] = ;   end
      [*] = ;   else
      [*] = ;   ExecuteState('ShowAIAssistantAdvices');
      [*] = ;   gbool_gui_updateadviseradvice := False;
      [*] = ;end
      [*] = ;else
      [*] = ;if (gPlayer[myplind].playeradviser.adviser.bavailable) then
      [*] = ;ExecuteState('ShowAIAssistantAdvices');
      [*] = ;
      [*] = ;//ExecuteStateByFlag(gbool_gui_update_cursor, 'DoUpdateCursor', True);
      [*] = ;if (gbool_gui_update_cursor) then
      [*] = ;begin
      [*] = ;   gbool_gui_update_cursor := False;
      [*] = ;   GUIInvokeMouseMove;
      [*] = ;end;
      [*] = ;ExecuteState('DoUpdateCursor');
      [*] = ;
      [*] = ;ExecuteState('ShowResourcePanel');
      [*] = ;if ((not _net_IsReplay) and (gProfile.bCheatPlaceUnits)) or (gInterface.gamemode=gc_gamemode_editor) then
      [*] = ;ExecuteStateByFlag(gbool_editor_placeunits, 'ShowEditorControl', True);
      [*] = ;
      [*] = ;gbool_gui_requestsoundonunitcontrol := False;
      [*] = ;
      [*] = ;if (random>0.9) and (myPlInd>=0) and (myPlInd<gc_MaxPlayerCount-1) then
      [*] = ;begin
      [*] = ;   var i : Integer;
      [*] = ;   for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;   if (gPlayer[i].lastattacktime<>0) and ((gPlayer[i].lastattacktime<GetCurrentTime) or (GetCurrentTime-gPlayer[i].lastattacktime)>(gc_gui_battlemusicinterval-gc_gui_underattackalarminterval)) then
      [*] = ;   gPlayer[i].lastattacktime := 0;
      [*] = ;   // Show log if player InterfaceIO
      [*] = ;   if (gPlayer[myPlInd].res[gc_resource_type_gold]<=0) and (_player_GoldIncomeLessThanConsume(myPlInd)) then
      [*] = ;   begin
      [*] = ;      var s1, s2 : String;
      [*] = ;      _misc_ShowLogMessage(gc_logmessagesid_nogold, s1, s2, False);
      [*] = ;   end;
      [*] = ;   if (gPlayer[myPlInd].res[gc_resource_type_food]<500) and (gPlayer[myPlInd].res[gc_resource_type_food]>0) then
      [*] = ;   begin
      [*] = ;      var s1, s2 : String;
      [*] = ;      _misc_ShowLogMessage(gc_logmessagesid_lowfood, s1, s2, False);
      [*] = ;   end;
      [*] = ;   if (gPlayer[myPlInd].res[gc_resource_type_gold]<500) and (gPlayer[myPlInd].res[gc_resource_type_gold]>0) and (_player_GoldIncomeLessThanConsume(myPlInd)) then
      [*] = ;   begin
      [*] = ;      var s1, s2 : String;
      [*] = ;      _misc_ShowLogMessage(gc_logmessagesid_lowgold, s1, s2, False);
      [*] = ;   end;
      [*] = ;   if gProfile.bFamine and (gPlayer[myPlInd].counter.resconsume[gc_resource_type_food]>0) and (gPlayer[myPlInd].res[gc_resource_type_food]<=0) then
      [*] = ;   begin
      [*] = ;      if (gInterface.gamemode=gc_gamemode_game) or (gInterface.gamemode=gc_gamemode_spectator) then
      [*] = ;      begin
      [*] = ;         var s1, s2 : String;
      [*] = ;         _misc_ShowLogMessage(gc_logmessagesid_famine, s1, s2, False);
      [*] = ;      end
      [*] = ;      else
      [*] = ;      begin
      [*] = ;         // Show log if player InterfaceIO
      [*] = ;         var s1 : String = 'Famine, but in editor mode your units wont die';
      [*] = ;         var s2 : String;
      [*] = ;         _misc_ShowLogMessage(gc_logmessagesid_custom, s1, s2, False);
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;_misc_GUIProgressPickedBldUID;
      [*] = ;_misc_GUIVisualizeLogMessages;
      [*] = ;_misc_GUIVisualizeChatMessages;
      [*] = ;
      [*] = ;// Clear hint from deleted element
      [*] = ;if (not GameManagerIsSelectionMode) and (not IsGUIShortcutPressed('MButton')) then
      [*] = ;begin
      [*] = ;   var elmHnd : Integer = GetGUIElementUnderMouse;
      [*] = ;   if (elmHnd<>gint_gui_prevelementundermouse) then
      [*] = ;   begin
      [*] = ;      SetIntValueByName('ElementHandle', elmHnd);
      [*] = ;      ExecuteState('OnMouseLeave');
      [*] = ;      if (elmHnd<>0) then
      [*] = ;      begin
      [*] = ;         //log('DoProgress : OnMouseEnter');
      [*] = ;         SetIntValueByName('ElementHandle', elmHnd);
      [*] = ;         ExecuteState('OnMouseEnter');
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gProfile.bDevMode) then
      [*] = ;ExecuteState('DoProgressDebug');
      [*] = ;
      [*] = ;const cHighlightSelected = 'selection.friend';
      [*] = ;const cHighlightSelectedBuilding = 'selection.building';
      [*] = ;const cHighlightSelectedShip = 'selection.ship';
      [*] = ;const cHighlightFriend = 'highlight.friend';
      [*] = ;const cHighlightAlly = 'highlight.ally';
      [*] = ;const cHighlightEnemy = 'highlight.enemy';
      [*] = ;
      [*] = ;if (myPlHnd<>0) then
      [*] = ;begin
      [*] = ;   var count : Integer = gGuiUpdateHighlights.GetCount;
      [*] = ;   if (count>0) then
      [*] = ;   begin
      [*] = ;      var i : Integer;
      [*] = ;      for i:=count-1 downto 0 do
      [*] = ;      begin
      [*] = ;         var goHnd : Integer = gGuiUpdateHighlights.Get(i);
      [*] = ;         case _misc_GetBaseObjID(goHnd) of
      [*] = ;            gc_baseid_obj : begin
      [*] = ;               var pobj : Pointer = _unit_GetTObj(goHnd);
      [*] = ;               if (pobj<>nil) and (not TObj(pobj).bdead) then
      [*] = ;               begin
      [*] = ;                  var bPicked, visible : Boolean;
      [*] = ;                  var plHnd : Integer = GetGameObjectPlayerHandleByHandle(goHnd);
      [*] = ;                  if (myPlHnd=plHnd) and GetGameObjectPickedByHandle(goHnd) then
      [*] = ;                  bPicked := True;
      [*] = ;                  if (_unit_GetTagStateByType(goHnd, gc_statetag_essential)<>gc_statetag_essential_birth) then
      [*] = ;                  visible := True;
      [*] = ;
      [*] = ;                  var mat : String = cHighlightFriend;
      [*] = ;                  if (bPicked) then
      [*] = ;                  begin
      [*] = ;                     if (gObjProp[TObj(pObj).cid][TObj(pObj).id].bbuilding) and not (gObjProp[TObj(pobj).cid][TObj(pobj).id].bwall) then
      [*] = ;                     begin
      [*] = ;                        visible := True;
      [*] = ;                        var w : Integer = GetGameObjectCollisionMaskWidthByHandle(goHnd);
      [*] = ;                        var h : Integer = GetGameObjectCollisionMaskHeightByHandle(goHnd);
      [*] = ;                        var cmaxh, cmaxw : Integer;
      [*] = ;                        var cminh, cminw : Integer = gc_MaxInt;
      [*] = ;                        var x, y : Integer;
      [*] = ;                        for x := 0 to h-1 do
      [*] = ;                        for y := 0 to w-1 do
      [*] = ;                        if GetGameObjectCollisionMaskValueByHandle(goHnd, x, y) then
      [*] = ;                        begin
      [*] = ;                           cminw := Min(cminw, x);
      [*] = ;                           cminh := Min(cminh, y);
      [*] = ;                           cmaxw := Max(cmaxw, x);
      [*] = ;                           cmaxh := Max(cmaxh, y);
      [*] = ;                        end;
      [*] = ;                        var cw : Integer = cmaxw-cminw+1;
      [*] = ;                        var ch : Integer = cmaxh-cminh+1;
      [*] = ;                        var mid : Integer = ((cw+ch) div 2);
      [*] = ;                        var size : Integer;
      [*] = ;                        if (mid>2) then
      [*] = ;                        begin
      [*] = ;                           if (mid<5) then
      [*] = ;                           size := 0
      [*] = ;                           else
      [*] = ;                           if (mid<8) then
      [*] = ;                           size := 1
      [*] = ;                           else
      [*] = ;                           if (mid<12) then
      [*] = ;                           size := 2
      [*] = ;                           else
      [*] = ;                           size := 3;
      [*] = ;                           mat := cHighlightSelectedBuilding+'.'+IntToStr(size);
      [*] = ;                        end
      [*] = ;                        else
      [*] = ;                        visible := False;
      [*] = ;                     end
      [*] = ;                     else
      [*] = ;                     {if (gObjProp[TObj(pObj).cid][TObj(pObj).id].media=gc_obj_media_water) then
      [*] = ;                     begin
      [*] = ;                        var size : Integer = 0;
      [*] = ;                        mat := cHighlightSelectedShip+'.'+IntToStr(size);
      [*] = ;                     end
      [*] = ;                     else}
      [*] = ;                     mat := cHighlightSelected
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  if (TObj(pObj).cid=gc_country_ind_mis) then
      [*] = ;                  visible := False
      [*] = ;                  else
      [*] = ;                  if (myPlHnd=plHnd) then
      [*] = ;                  mat := cHighlightFriend
      [*] = ;                  else
      [*] = ;                  begin
      [*] = ;                     if ((gPlayer[TObj(pobj).pl].myplmask and gPlayer[myPlInd].enemyplmask)<>0) then
      [*] = ;                     mat := cHighlightEnemy
      [*] = ;                     else
      [*] = ;                     mat := cHighlightAlly;
      [*] = ;                  end;
      [*] = ;                  if (gProfile.bDbgNoBrushes) then
      [*] = ;                  visible := False;
      [*] = ;                  //if (not bPicked) and (gObjProp[TObj(pobj).cid][TObj(pobj).id].bbuilding) then //bwall
      [*] = ;                  if (gObjProp[TObj(pobj).cid][TObj(pobj).id].bwall) then //bwall
      [*] = ;                  visible := False;
      [*] = ;                  EffectHighlightGetOrCreate(goHnd, 'h', visible, mat);
      [*] = ;
      [*] = ;                  _misc_UnitUpdateMiniMapPrimitive(goHnd, bPicked);
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;            gc_baseid_res : begin
      [*] = ;               if (not gbool_gui_screenshotcamera) then
      [*] = ;               begin
      [*] = ;                  var bGeology : Boolean = (gPlayer[myPlInd].bgeology);
      [*] = ;                  var bNotInFOW : Boolean = (not GetFOWEnable) or (GetFOWLOSData(GetGameObjectPositionXByHandle(goHnd), GetGameObjectPositionZByHandle(goHnd))>0);
      [*] = ;                  var bVisible : Boolean = bGeology or (bNotInFOW);
      [*] = ;                  var top : Integer = _gui_GetTop;
      [*] = ;                  var hudCollection : Integer = GetGUIElementIndexByNameParent('envhud', top);
      [*] = ;                  if (hudCollection<>0) then
      [*] = ;                  begin
      [*] = ;                     var hudHnd, elmHnd : Integer;
      [*] = ;                     var userBlend, newUserBlend : Float;
      [*] = ;                     var bElmIsVisible : Boolean;
      [*] = ;                     if (bVisible) and (not bNotInFOW) then
      [*] = ;                     newUserBlend := 0.5
      [*] = ;                     else
      [*] = ;                     newUserBlend := 1;
      [*] = ;                     hudHnd := GetGUIGroupHUDCollectionItemByGameObject(hudCollection, goHnd);
      [*] = ;                     if (hudHnd<>0) then
      [*] = ;                     elmHnd := GetGUIElementIndexByNameParent('hud_img', hudHnd);
      [*] = ;                     if (elmHnd<>0) then
      [*] = ;                     begin
      [*] = ;                        bElmIsVisible := GetGUIElementVisible(elmHnd);
      [*] = ;                        userBlend := GetGUIElementUserBlend(elmHnd);
      [*] = ;                     end;
      [*] = ;                     if (bVisible) then
      [*] = ;                     begin
      [*] = ;                        if (elmHnd=0) then
      [*] = ;                        begin
      [*] = ;                           IntRegister0 := goHnd;
      [*] = ;                           ExecuteState('ShowHUD');
      [*] = ;                           hudHnd := GetGUIGroupHUDCollectionItemByGameObject(hudCollection, goHnd);
      [*] = ;                           elmHnd := GetGUIElementIndexByNameParent('hud_img', hudHnd);
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;
      [*] = ;                     if (hudHnd<>0) then
      [*] = ;                     begin
      [*] = ;                        var elmHnd : Integer = GetGUIElementIndexByNameParent('hud_img', hudHnd);
      [*] = ;                        if (elmHnd<>0) then
      [*] = ;                        begin
      [*] = ;                           if (bVisible) and (userBlend<>newUserBlend) then
      [*] = ;                           SetGUIElementUserBlend(elmHnd, newUserBlend);
      [*] = ;                           if (bVisible) and (not bElmIsVisible) and (not GetGUIElementFadeStarted(elmHnd)) or (not GetGUIElementVisible(elmHnd)) then
      [*] = ;                           begin
      [*] = ;                              SetGUIElementVisible(elmHnd, bVisible);
      [*] = ;                              _gui_FadeElement(elmHnd, 0.75, True)
      [*] = ;                           end
      [*] = ;                           else
      [*] = ;                           if (not bVisible) and (bElmIsVisible) and (not GetGUIElementFadeStarted(elmHnd)) then
      [*] = ;                           _gui_FadeElement(elmHnd, 0.5, False);
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;
      [*] = ;         if (GameManagerIsBrushMode) and (GetStretchBrushUseGrid) then
      [*] = ;         for i := gPlayer[myPlInd].squads.GetCount-1 downto 0 do
      [*] = ;         begin
      [*] = ;            var pSquad : Pointer = gPlayer[myPlInd].squads.Get(i);
      [*] = ;            if (pSquad<>nil) then
      [*] = ;            begin
      [*] = ;               var grHnd : Integer = GetPlayerGrHandleByHandle(myPlHnd, TSquad(pSquad).fGroupName);
      [*] = ;
      [*] = ;               if TSquad(pSquad).fSelected and (grHnd <> 0) then
      [*] = ;               begin
      [*] = ;                  var goGrid : array [0..gc_formation_maskmaxheight] of array [0..gc_formation_maskmaxwidth] of Integer;
      [*] = ;                  var i, j : Integer;
      [*] = ;                  for i := 0 to gc_formation_maskmaxheight-1 do
      [*] = ;                  for j := 0 to gc_formation_maskmaxwidth-1 do
      [*] = ;                  goGrid[i, j] := TSquad(pSquad).arGrid[i, j];
      [*] = ;
      [*] = ;                  var x : Float = GetPlayerStretchBrushGroupTargetPositionX(grHnd);
      [*] = ;                  var y : Float = GetPlayerStretchBrushGroupTargetPositionY(grHnd);
      [*] = ;                  var angle : Float = GetPlayerStretchBrushGroupTargetAngle(grHnd);
      [*] = ;                  var dirX : Float;
      [*] = ;                  var dirY : Float;
      [*] = ;                  var dirZ : Float = -1;
      [*] = ;                  VectorRotateY(dirX, dirY, dirZ, angle);
      [*] = ;
      [*] = ;                  _squad_RebuildGrid(pSquad, x, y, dirX, dirZ);
      [*] = ;                  _group_Initialize(grHnd, pSquad);
      [*] = ;
      [*] = ;                  for i := 0 to gc_formation_maskmaxheight-1 do
      [*] = ;                  for j := 0 to gc_formation_maskmaxwidth-1 do
      [*] = ;                  TSquad(pSquad).arGrid[i, j] := goGrid[i, j];
      [*] = ;               end;
      [*] = ;            end
      [*] = ;            else
      [*] = ;            ErrorLog('GUI : DoProgress : pSquad=nil')
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;      gGuiUpdateHighlights.Clear;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if ((gint_gui_progresstick mod 2)=0) then
      [*] = ;begin
      [*] = ;   //_misc_ProfilerBegin('gui:idlepeasants');
      [*] = ;   gPlayer[myPlInd].counter.idlepeasants := 0;
      [*] = ;   gPlayer[myPlInd].counter.idlemines := 0;
      [*] = ;   var idlepeasants, idlemines : Integer;
      [*] = ;   var i : Integer;
      [*] = ;   for i:=0 to gc_ResCount-1 do
      [*] = ;   gPlayer[myPlInd].counter.workersonres[i] := 0;
      [*] = ;   var psind : Integer = GetPlayerProgressSectionIndexByInterval(myPlHnd, gc_statemachine_interval_peasants);
      [*] = ;   if (psind>=0) then
      [*] = ;   begin
      [*] = ;      var porder, pobj : Pointer;
      [*] = ;      var statetag, goHnd : Integer;
      [*] = ;      for i:=GetPlayerProgressSectionCountGOByIndex(myPlHnd, psind)-1 downto 0 do
      [*] = ;      begin
      [*] = ;         var goHnd : Integer = GetPlayerProgressSectionGOHandleByIndex(myPlHnd, psind, i);
      [*] = ;         if (goHnd<>0) then
      [*] = ;         begin
      [*] = ;            var pobj : Pointer = _unit_GetTObjFast(goHnd);
      [*] = ;            if (pobj<>nil) then
      [*] = ;            begin
      [*] = ;               if (GetGameObjectPlayableObjectByHandle(goHnd)) then
      [*] = ;               begin
      [*] = ;                  porder := TObj(pobj).orders[0];
      [*] = ;                  if (_net_IsClient) or (_net_IsReplay) then
      [*] = ;                  begin
      [*] = ;                     if (TOrder(porder).itype=gc_obj_order_type_gainres) then
      [*] = ;                     gPlayer[myPlInd].counter.workersonres[TObj(pobj).orders[0].info.restype] := gPlayer[myPlInd].counter.workersonres[TObj(pobj).orders[0].info.restype]+1
      [*] = ;                     else
      [*] = ;                     begin
      [*] = ;                        var bIdle : Boolean = (GetGameObjectTrackPointMovementModeIntByHandle(goHnd)=0);
      [*] = ;                        if (bIdle) then
      [*] = ;                        begin
      [*] = ;                           var statetag : Integer = GetGameObjectStatesTagByHandle(goHnd);
      [*] = ;                           if ((statetag and gc_statetag_action_none)<>0) and ((statetag and gc_statetag_move_idle)<>0) and ((statetag and gc_statetag_visual_none)<>0) then
      [*] = ;                           idlepeasants := idlepeasants+1;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  begin
      [*] = ;                     if (TOrder(porder).itype=gc_obj_order_type_none) then
      [*] = ;                     begin
      [*] = ;                        var statetag : Integer = GetGameObjectStatesTagByHandle(goHnd);
      [*] = ;                        if ((statetag and gc_statetag_action_none)<>0) and ((statetag and gc_statetag_move_idle)<>0) and ((statetag and gc_statetag_visual_none)<>0) then
      [*] = ;                        idlepeasants := idlepeasants+1;
      [*] = ;                     end
      [*] = ;                     else
      [*] = ;                     if (TOrder(porder).itype=gc_obj_order_type_gainres) then
      [*] = ;                     gPlayer[myPlInd].counter.workersonres[TObj(pobj).orders[0].info.restype] := gPlayer[myPlInd].counter.workersonres[TObj(pobj).orders[0].info.restype]+1;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;   gPlayer[myPlInd].counter.idlepeasants := idlepeasants;
      [*] = ;   //_misc_ProfilerEnd('gui:idlepeasants');
      [*] = ;
      [*] = ;   //_misc_ProfilerBegin('gui:idlemines');
      [*] = ;   psind := GetPlayerProgressSectionIndexByInterval(myPlHnd, gc_statemachine_interval_mines);
      [*] = ;   if (psind>=0) then
      [*] = ;   begin
      [*] = ;      var i : Integer;
      [*] = ;      for i:=GetPlayerProgressSectionCountGOByIndex(myPlHnd, psind)-1 downto 0 do
      [*] = ;      begin
      [*] = ;         var goHnd : Integer = GetPlayerProgressSectionGOHandleByIndex(myPlHnd, psind, i);
      [*] = ;         if (goHnd<>0) then
      [*] = ;         begin
      [*] = ;            var pobj : Pointer = _unit_GetTObj(goHnd);
      [*] = ;            if (pobj<>nil) then
      [*] = ;            begin
      [*] = ;               var pobjprop : Pointer = gObjProp[TObj(pobj).cid][TObj(pobj).id];
      [*] = ;               if (TObj(pobj).bbuilt) and (TObjProp(pobjprop).peasantabsorber>0) then
      [*] = ;               begin
      [*] = ;                  var pobjinside : Pointer = _misc_GetObjectArgData(goHnd, gc_argunit_inside);
      [*] = ;                  if (pobjinside<>nil) then
      [*] = ;                  begin
      [*] = ;                     if (GetGameObjectPlayableObjectByHandle(goHnd)) then
      [*] = ;                     begin
      [*] = ;                        var insidecount : Integer = TIntegerList(pobjinside).GetCount;
      [*] = ;                        if ((TObjProp(pobjprop).peasantabsorber+TObj(pobj).individual.addpeasantabsorber)>insidecount+TObj(pobj).insidereserved) then
      [*] = ;                        idlemines := idlemines+1;
      [*] = ;                        if (insidecount>0) then
      [*] = ;                        begin
      [*] = ;                           var j : Integer;
      [*] = ;                           for j:=0 to gc_ResCount-1 do
      [*] = ;                           begin
      [*] = ;                              if (gObjProp[TObj(pobj).cid][TObj(pobj).id].produce[j]>0) then
      [*] = ;                              gPlayer[myPlInd].counter.workersonres[j] := gPlayer[myPlInd].counter.workersonres[j]+insidecount;
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;   gPlayer[myPlInd].counter.idlemines := idlemines;
      [*] = ;   //_misc_ProfilerEnd('gui:idlemines');
      [*] = ;end;
      [*] = ;
      [*] = ;if ((gint_gui_progresstick mod 3)=0) then
      [*] = ;begin
      [*] = ;   //_misc_ProfilerBegin('gui:showhud');
      [*] = ;   var n : Integer;
      [*] = ;   for n:=0 to 1 do
      [*] = ;   begin
      [*] = ;      var interval : Integer;
      [*] = ;      case n of
      [*] = ;         0 : interval := gc_statemachine_interval_buildings;
      [*] = ;         1 : interval := gc_statemachine_interval_mines;
      [*] = ;         else
      [*] = ;         break;
      [*] = ;      end;
      [*] = ;      _control_PrepareUnitUnderCursorList(gUnderCursorList);
      [*] = ;      var bShowOnlyDamaged : Boolean = True;
      [*] = ;      var pl : Integer;
      [*] = ;      for pl:=0 to gc_MaxPlayerCount-1 do
      [*] = ;      begin
      [*] = ;         var plHnd : Integer = GetPlayerHandleByIndex(pl);
      [*] = ;         var psind : Integer = GetPlayerProgressSectionIndexByInterval(plHnd, interval);
      [*] = ;         if (psind>=0) then
      [*] = ;         begin
      [*] = ;            var i : Integer;
      [*] = ;            for i:=GetPlayerProgressSectionCountGOByIndex(plHnd, psind)-1 downto 0 do
      [*] = ;            begin
      [*] = ;               var goHnd : Integer = GetPlayerProgressSectionGOHandleByIndex(plHnd, psind, i);
      [*] = ;               if (goHnd<>0) then
      [*] = ;               begin
      [*] = ;                  var pobj : Pointer = _unit_GetTObj(goHnd);
      [*] = ;                  if (pobj<>nil) then
      [*] = ;                  begin
      [*] = ;                     var pobjprop : Pointer = gObjProp[TObj(pobj).cid][TObj(pobj).id];
      [*] = ;                     if (TObjProp(pobjprop).bbuilding) and (GetGameObjectIsVolumeClippedByHandle(goHnd)) then
      [*] = ;                     begin
      [*] = ;                        //if (n=1) or (((not bShowOnlyDamaged) or ((TObj(pobj).bbuilt) and (TObj(pobj).hp<>gPlayer[TObj(pobj).pl].objbase[TObj(pobj).cid][TObj(pobj).id].maxHP)))) then
      [*] = ;                        begin
      [*] = ;                           var bVisible : Boolean = (not GetFOWEnable) or (GetFOWLOSData(GetGameObjectPositionXByHandle(goHnd), GetGameObjectPositionZByHandle(goHnd))>0);
      [*] = ;                           var top : Integer = _gui_GetTop;
      [*] = ;                           var hudCollection : Integer = GetGUIElementIndexByNameParent('hud', top);
      [*] = ;                           if (hudCollection<>0) then
      [*] = ;                           begin
      [*] = ;                              var hudHnd, elmHnd : Integer;
      [*] = ;                              var bElmIsVisible : Boolean;
      [*] = ;                              hudHnd := GetGUIGroupHUDCollectionItemByGameObject(hudCollection, goHnd);
      [*] = ;                              if (hudHnd<>0) then
      [*] = ;                              elmHnd := GetGUIElementIndexByNameParent('hud_frm', hudHnd);
      [*] = ;                              if (elmHnd<>0) then
      [*] = ;                              bElmIsVisible := GetGUIElementVisible(elmHnd);
      [*] = ;                              if (bVisible) {and (GetGameObjectIsVolumeClippedByHandle(goHnd))} then
      [*] = ;                              begin
      [*] = ;                                 IntRegister0 := goHnd;
      [*] = ;                                 ExecuteState('ShowHUD');
      [*] = ;                                 //hudHnd := GetGUIGroupHUDCollectionItemByGameObject(hudCollection, goHnd);
      [*] = ;                                 //elmHnd := GetGUIElementIndexByNameParent('hud_img', hudHnd);
      [*] = ;                              end;
      [*] = ;                              {else
      [*] = ;                              if (hudHnd<>0) then
      [*] = ;                              begin
      [*] = ;                                 var elmHnd : Integer = GetGUIElementIndexByNameParent('hud_frm', hudHnd);
      [*] = ;                                 if (elmHnd<>0) then
      [*] = ;                                 begin
      [*] = ;                                    if (bVisible) and (not bElmIsVisible) and (not GetGUIElementFadeStarted(elmHnd)) then
      [*] = ;                                    _gui_FadeElement(elmHnd, 0.75, True)
      [*] = ;                                    else
      [*] = ;                                    if (not bVisible) and (bElmIsVisible) and (not GetGUIElementFadeStarted(elmHnd)) then
      [*] = ;                                    _gui_FadeElement(elmHnd, 0.5, False);
      [*] = ;                                 end;
      [*] = ;                              end;}
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;   //_misc_ProfilerEnd('gui:showhud');
      [*] = ;end;
      [*] = ;
      [*] = ;// debug animation window for natalie
      [*] = ;var elmParent : Integer = GetGUIElementIndexByNameParent('debuganimations', _gui_GetTop);
      [*] = ;if (elmParent<>0) and (GetGUIElementVisible(elmParent)) then
      [*] = ;ExecuteState('ShowDebugAnimations');
      [*] = ;
      [*] = ;if (gScenario.bexists) then
      [*] = ;ExecuteState('DoProgressScenarioEditor')
      [*] = ;else
      [*] = ;if (gScenario.ui.bshowui) then
      [*] = ;begin
      [*] = ;   elmParent := GetGUIElementIndexByNameParent('progressscenario', _gui_GetTop);
      [*] = ;   if ((elmParent=0) or (not GetGUIElementVisible(elmParent))) then
      [*] = ;   ExecuteState('DoProgressScenarioEditor');
      [*] = ;end;
      [*] = ;
      [*] = ;if (IsGUIShortcutPressed('LButton')) then
      [*] = ;begin
      [*] = ;   var goHnd : Integer = _control_GetUnitUnderCursor(False);
      [*] = ;   if (goHnd<>0) and (GetGameObjectPlayerHandleByHandle(goHnd)<>GetPlayerHandleInterfaceIO) and (_misc_GetBaseObjID(goHnd)=gc_baseid_obj) then
      [*] = ;   begin
      [*] = ;      var pobj : Pointer = _unit_GetTObj(goHnd);
      [*] = ;      if (pobj<>nil) then
      [*] = ;      begin
      [*] = ;         var cid : Integer = TObj(pobj).cid;
      [*] = ;         var id : Integer = TObj(pobj).id;
      [*] = ;         var maxhp : Integer = gPlayer[TObj(pobj).pl].objbase[TObj(pobj).cid][TObj(pobj).id].maxhp;
      [*] = ;         if (maxhp>0) then
      [*] = ;         begin
      [*] = ;            var csid : String;
      [*] = ;            _country_GetSIDByID(cid, csid);
      [*] = ;            var sid : String;
      [*] = ;            if (gObjProp[cid][id].bWall) then
      [*] = ;            _unit_ConvertObjIDToSID(cid, id, sid)
      [*] = ;            else
      [*] = ;            sid := GetGameObjectBaseNameByHandle(goHnd);
      [*] = ;            var textCountry : String = gc_loc_units+'|'+csid;
      [*] = ;            _misc_StringToText(textCountry, textCountry);
      [*] = ;            var unitName : String;
      [*] = ;            if (_misc_GetUnitNameBySID(sid, unitName)) then
      [*] = ;            begin
      [*] = ;               var nul : String;
      [*] = ;
      [*] = ;               var count : Integer = gLogMessages.count;
      [*] = ;               if count<1 then
      [*] = ;               count := 1;
      [*] = ;               var s2 : String = gLogMessages.msg[count-1].s2;
      [*] = ;               var shnd : String = IntToStr(goHnd);
      [*] = ;               var text : String = unitName+' ('+textCountry+') ('+IntToStr(TObj(pobj).hp)+'/'+IntToStr(maxhp)+')';
      [*] = ;               var ballowdublicates : Boolean = {(s2<>shnd) or} not ((gLogMessages.msg[count-1].s1=text) and (gLogMessages.msg[count-1].s2=shnd));
      [*] = ;               _misc_ShowLogMessage(gc_logmessagesid_unitinfo, text, shnd, False);
      [*] = ;               if ballowdublicates then
      [*] = ;               _misc_ShowLogMessage(gc_logmessagesid_unitinfo, text, shnd, False);
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gInterface.gamemode=gc_gamemode_game) and (gMap.gamestage=gc_map_gamestage_started) and (gProfile.bautosave) and (not _net_IsReplay) and ((GetGameTime>10) and (floor(GetGameTime) mod 450)=0) and (not GetUseZLib) and (GetTimeSpeedFactor<100) and (not GetProgressingPauseMode) then
      [*] = ;begin
      [*] = ;   if (GetGUIDelayExecuteState='') then
      [*] = ;   begin
      [*] = ;      if (_net_IsOffline) then
      [*] = ;      begin
      [*] = ;         gbool_gui_quicksave := False;
      [*] = ;         GUIDelayExecuteState('DoAutoSave', 3);
      [*] = ;      end;
      [*] = ;      //else
      [*] = ;      //if (_net_IsOnline) and (_net_IsServer) then
      [*] = ;      //Log('Here was autosave in Lan Game');
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gInterface.gamemode=gc_gamemode_game) and (gMap.gamestage>gc_map_gamestage_waitingloading) then
      [*] = ;begin
      [*] = ;   var plInd : Integer;
      [*] = ;   if (not gScenario.bactive) or (gMap.bbattle) then
      [*] = ;   plInd := myplind
      [*] = ;   else
      [*] = ;   plInd := 0;
      [*] = ;   if (gPlayer[plInd].victorystate<>gc_player_victorystate_none) then
      [*] = ;   begin
      [*] = ;      if (gMap.bbattle) then
      [*] = ;      gInterface.gamemode := gc_gamemode_spectator;
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent('EndGame', _gui_GetTop);
      [*] = ;      if (elm=0) or (not GetGUIElementVisible(elm)) then
      [*] = ;      begin
      [*] = ;         if (gint_gui_achwinlose=0) then
      [*] = ;         gint_gui_achwinlose := 1;
      [*] = ;         if (_net_IsOffline) then
      [*] = ;         SetProgressingPauseMode(True)
      [*] = ;         else
      [*] = ;         begin
      [*] = ;            var leaverind : Integer = _misc_GetFirstLeaver;
      [*] = ;            if (LanPublicServerProfCountry<>'') and (leaverind>=0) and (leaverind<>myplind) then
      [*] = ;            begin
      [*] = ;               var country : String = LanPublicServerProfCountry;
      [*] = ;               if (StrExists(country, '|f=')) then
      [*] = ;               begin
      [*] = ;                  var pos : Integer = StrPos('|f=', country);
      [*] = ;                  var lm : String = SubStr(country, pos+3, 1);
      [*] = ;                  country := StrReplace(country, '|f='+lm, '');
      [*] = ;                  LanSetMyCountry(country);
      [*] = ;                  LanPublicServerRegister;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;         _player_UpdateFOW(plInd);
      [*] = ;         ExecuteState('ShowEndGame');
      [*] = ;      end;
      [*] = ;   end
      [*] = ;   else
      [*] = ;   begin
      [*] = ;      var elm : Integer = GetGUIElementIndexByNameParent('EndGame', _gui_GetTop);
      [*] = ;      if (elm<>0) and (GetGUIElementVisible(elm)) then
      [*] = ;      begin
      [*] = ;         if (_net_IsOffline) then
      [*] = ;         SetProgressingPauseMode(True);
      [*] = ;         ExecuteState('ShowEndGame')
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gint_gui_revertresolutiontimer<>0) and ((GetCurrentTime-gint_gui_revertresolutiontimer)>10) then
      [*] = ;begin
      [*] = ;   const cTagResolutionRevert = 402;
      [*] = ;   _gui_SendTagToStateExt('EventModalMessage', cTagResolutionRevert, 'c', '', '', 0);
      [*] = ;end;
      [*] = ;
      [*] = ;function _misc_ProcessAchs() : Boolean;
      [*] = ;begin
      [*] = ;   //_misc_ProfilerBegin('_misc_ProcessAchs');
      [*] = ;   if (gProfile.bNoAchs) then
      [*] = ;   exit;
      [*] = ;   if (gInterface.gamemode=gc_gamemode_game) or (gint_gui_achwinlose=1) then
      [*] = ;   begin
      [*] = ;      var plhnd : Integer = GetPlayerHandleInterfaceIO;
      [*] = ;      var plind : Integer = GetPlayerIndexByHandle(plhnd);
      [*] = ;      var bSaveProfile : Boolean;
      [*] = ;      function GetLevelFromNameByUpgradeIndex(cid, upgind : Integer) : Integer;
      [*] = ;      begin
      [*] = ;         Result := 0;
      [*] = ;         if (gPlayer[plind].upgstate[cid][upgind].done) then
      [*] = ;         begin
      [*] = ;            var dotcount : Integer;
      [*] = ;            var levelsid : String;
      [*] = ;            var levelfromid : Integer;
      [*] = ;            var upgid : String = gCountry[cid].upgrade[upgind].id;
      [*] = ;            if IsDelimiterCharExists(upgid, gc_gui_dotchar) then
      [*] = ;            begin
      [*] = ;               dotcount := GetDelimiterStringCount(upgid, gc_gui_dotchar, gc_gui_quotechar);
      [*] = ;               if (dotcount>=4) then // <4 is not barrack upgrades, but blacksmith or academy
      [*] = ;               begin
      [*] = ;                  levelsid := GetDelimiterStringByIndex(upgid, gc_gui_dotchar, gc_gui_quotechar, dotcount-1);
      [*] = ;                  if (levelsid<>'') then
      [*] = ;                  Result := StrToInt(levelsid);
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;      procedure GetSubNameFromUpgradeIndex(cid, upgind : Integer; var sub : String);
      [*] = ;      begin
      [*] = ;         var upgid : String = gCountry[cid].upgrade[upgind].id;
      [*] = ;         sub := SubStr(upgid, 4, StrLength(upgid)-3);
      [*] = ;      end;
      [*] = ;
      [*] = ;      //const cProgressPerTick = 10;
      [*] = ;      var plcid : Integer = gPlayer[plind].cid;
      [*] = ;      var cid, id, upgind : Integer;
      [*] = ;      var csid : String;
      [*] = ;      var i, j, k : Integer;
      [*] = ;      //for i:=0 to cProgressPerTick-1 do
      [*] = ;      begin
      [*] = ;         //var ind : Integer = (gint_gui_lastprogressach+i) mod gc_ach_existscount;
      [*] = ;         var bcheckupg : Boolean = gbool_gui_achupdated;
      [*] = ;         // check
      [*] = ;         if (gAchLastUpgrades.GetCount>0) then
      [*] = ;         begin
      [*] = ;            for j:=0 to gAchLastUpgrades.GetCount-1 do
      [*] = ;            begin
      [*] = ;               var packedupg : Integer = gAchLastUpgrades.Get(j);
      [*] = ;               cid := packedupg div gc_country_maxupgradecount;
      [*] = ;               upgind := packedupg mod gc_country_maxupgradecount;
      [*] = ;               var upgid : String = gCountry[cid].upgrade[upgind].id;
      [*] = ;               var subupgid : String;
      [*] = ;               GetSubNameFromUpgradeIndex(cid, upgind, subupgid);
      [*] = ;               var upgtype : Integer = gCountry[cid].upgrade[upgind].itype;
      [*] = ;               var unitsid : String = gCountry[cid].upgrade[upgind].sarrparam2[0];
      [*] = ;               var level : Integer = GetLevelFromNameByUpgradeIndex(cid, upgind);
      [*] = ;
      [*] = ;               // almost consts
      [*] = ;               _country_GetSIDByID(cid, csid);
      [*] = ;               var century18 : String = csid+'cen'+'.1'; // name is static, used in apply map settings procedure
      [*] = ;               if (not gScenario.bexists) then
      [*] = ;               begin
      [*] = ;                  case upgid of
      [*] = ;                     century18 : begin
      [*] = ;                        if (gMap.settings.gen.resourcestart<3) then
      [*] = ;                        begin
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_upgrade_18century].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_18century].cur+1;
      [*] = ;                           if (GetGameTime<(20*60)) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_upgrade_18century_20min].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_18century_20min].cur+1;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;                  case upgtype of
      [*] = ;                     gc_upg_type_balloon : gProfileUserStruct.achs.ach[gc_ach_upgrade_balloon].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_balloon].cur+1;
      [*] = ;                     gc_upg_type_single_attpauseperc : begin
      [*] = ;                        if (level=5) then
      [*] = ;                        gProfileUserStruct.achs.ach[gc_ach_upgrade_towerattspeed].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_towerattspeed].cur+1;
      [*] = ;                     end;
      [*] = ;                     gc_upg_type_single_inside_mine : begin
      [*] = ;                        if (level=6) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                        gProfileUserStruct.achs.ach[gc_ach_upgrade_mine95].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_mine95].cur+1;
      [*] = ;                     end;
      [*] = ;                     gc_upg_type_damage : begin
      [*] = ;                        case unitsid of
      [*] = ;                           'serdiuk' : begin
      [*] = ;                              if (level=5) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_serdiuk_att].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_serdiuk_att].cur+1;
      [*] = ;                           end;
      [*] = ;                           'wingedhussar' : begin
      [*] = ;                              if (level=6) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_protection) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=6) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_wingedhussar_6att6def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_wingedhussar_6att6def].cur+1;
      [*] = ;                           end;
      [*] = ;                           'roundshier' : begin
      [*] = ;                              if (level=3) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_protection) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=3) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_roundshier_5att5def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_roundshier_5att5def].cur+1;
      [*] = ;                           end;
      [*] = ;                           'pikeman', 'pikemanpol', 'pikemantur', 'pikemanrus' : begin
      [*] = ;                              if (level=3) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_protection) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=3) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_pikeman_3att3def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_pikeman_3att3def].cur+1;
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                     gc_upg_type_protection : begin
      [*] = ;                        case unitsid of
      [*] = ;                           'wingedhussar' : begin
      [*] = ;                              if (level=6) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_damage) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=6) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_wingedhussar_6att6def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_wingedhussar_6att6def].cur+1;
      [*] = ;                           end;
      [*] = ;                           'roundshier' : begin
      [*] = ;                              if (level=3) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_damage) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=3) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_roundshier_5att5def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_roundshier_5att5def].cur+1;
      [*] = ;                           end;
      [*] = ;                           'pikeman', 'pikemanpol', 'pikemantur', 'pikemanrus' : begin
      [*] = ;                              if (level=3) then
      [*] = ;                              for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;                              if (gCountry[cid].upgrade[k].itype=gc_upg_type_damage) and (gCountry[cid].upgrade[k].sarrparam2[0]=unitsid) and (GetLevelFromNameByUpgradeIndex(cid, k)>=3) then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_upgrade_pikeman_3att3def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_pikeman_3att3def].cur+1;
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                     gc_upg_type_effectfood : begin
      [*] = ;                        if (subupgid='mil.1') then
      [*] = ;                        gProfileUserStruct.achs.ach[gc_ach_upgrade_mill1].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_mill1].cur+1;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;               var num, all_acablamil, acashotdamage, cavbuildattack, building_def, acawoodstoneeff : Integer;
      [*] = ;               var place, snum : String;
      [*] = ;               if (not gScenario.bexists) then
      [*] = ;               for k:=0 to gc_country_maxupgradecount-1 do
      [*] = ;               begin
      [*] = ;                  if (gPlayer[plind].upgstate[cid][k].done) then
      [*] = ;                  begin
      [*] = ;                     GetSubNameFromUpgradeIndex(cid, k, subupgid);
      [*] = ;                     place := SubStr(subupgid, 1, 3);
      [*] = ;                     snum := SubStr(subupgid, 5, StrLength(subupgid)-4);
      [*] = ;                     num := StrToInt(snum);
      [*] = ;                     case place of
      [*] = ;                        'aca' : begin
      [*] = ;                           case num of
      [*] = ;                              1,2,3,4,5,6,7,10,16,17,18,19,20,22,25,27,28,29,30,31,32,33,34,35,36 : all_acablamil := all_acablamil+1;
      [*] = ;                              8 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acawoodstoneeff := acawoodstoneeff+1;
      [*] = ;                              end;
      [*] = ;                              9 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 building_def := building_def+1;
      [*] = ;                              end;
      [*] = ;                              11 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 building_def := building_def+1;
      [*] = ;                              end;
      [*] = ;                              12 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acashotdamage := acashotdamage+1;
      [*] = ;                              end;
      [*] = ;                              13 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acashotdamage := acashotdamage+1;
      [*] = ;                              end;
      [*] = ;                              14 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acashotdamage := acashotdamage+1;
      [*] = ;                              end;
      [*] = ;                              15 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acashotdamage := acashotdamage+1;
      [*] = ;                              end;
      [*] = ;                              23 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acawoodstoneeff := acawoodstoneeff+1;
      [*] = ;                              end;
      [*] = ;                              24 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 acawoodstoneeff := acawoodstoneeff+1;
      [*] = ;                              end;
      [*] = ;                              //21 : all_acablamil := all_acablamil+1; // repair
      [*] = ;                              //26 : all_acablamil := all_acablamil+1; // heal
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                        'bla' : begin
      [*] = ;                           case num of
      [*] = ;                              1,4,6 : all_acablamil := all_acablamil+1;
      [*] = ;                              2 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 building_def := building_def+1;
      [*] = ;                              end;
      [*] = ;                              3 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 cavbuildattack := cavbuildattack+1;
      [*] = ;                              end;
      [*] = ;                              5 : begin
      [*] = ;                                 all_acablamil := all_acablamil+1;
      [*] = ;                                 cavbuildattack := cavbuildattack+1;
      [*] = ;                              end;
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;               if (not gScenario.bexists) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;               begin
      [*] = ;                  if (all_acablamil>=40) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_upgrade_all_acablamil].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_all_acablamil].cur+1;
      [*] = ;                  if (acashotdamage>=4) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_upgrade_acashotdamage].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_acashotdamage].cur+1;
      [*] = ;                  if (cavbuildattack>=2) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_upgrade_cavbuildattack].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_cavbuildattack].cur+1;
      [*] = ;                  if (building_def>=3) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_upgrade_building_def].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_building_def].cur+1;
      [*] = ;                  if (acawoodstoneeff>=3) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_upgrade_acawoodstoneeff].cur := gProfileUserStruct.achs.ach[gc_ach_upgrade_acawoodstoneeff].cur+1;
      [*] = ;               end;
      [*] = ;               //case ind of
      [*] = ;                  //gc_ach_upgrade_18century : ;
      [*] = ;                  //gc_ach_upgrade_18century_20min : ;
      [*] = ;                  //gc_ach_upgrade_all_acablamil : ;
      [*] = ;                  //gc_ach_upgrade_mine95 : ;
      [*] = ;                  //gc_ach_upgrade_pikeman_3att3def : ;
      [*] = ;                  //gc_ach_upgrade_serdiuk_att : ;
      [*] = ;                  //gc_ach_upgrade_acashotdamage : ;
      [*] = ;                  //gc_ach_upgrade_cavbuildattack : ;
      [*] = ;                  //gc_ach_upgrade_mill1 : ;
      [*] = ;                  //gc_ach_upgrade_building_def : ;
      [*] = ;                  //gc_ach_upgrade_balloon : ;
      [*] = ;                  //gc_ach_upgrade_wingedhussar_6att6def : ;
      [*] = ;                  //gc_ach_upgrade_acawoodstoneeff : ;
      [*] = ;                  //gc_ach_upgrade_towerattspeed : ;
      [*] = ;                  //gc_ach_upgrade_roundshier_5att5def : ;
      [*] = ;               //end;
      [*] = ;            end;
      [*] = ;            gAchLastUpgrades.Clear;
      [*] = ;         end;
      [*] = ;
      [*] = ;         // on showendgame start
      [*] = ;         if (not gScenario.bexists) and (gint_gui_achwinlose=1) then
      [*] = ;         begin
      [*] = ;            gint_gui_achwinlose := 2;
      [*] = ;            var arraicountimpossible : array [0..3] of Integer;
      [*] = ;            var humancount, humanteamcount, aicount, aicountimpossible : Integer;
      [*] = ;            var benemyexists : Boolean;
      [*] = ;            for j:=0 to gc_MaxPlayerCount-1 do
      [*] = ;            if (gMap.players[j].bexists) then
      [*] = ;            begin
      [*] = ;               if (gMap.players[j].lanid>0) then
      [*] = ;               humancount := humancount+1
      [*] = ;               else
      [*] = ;               if (gMap.players[j].bai) then
      [*] = ;               begin
      [*] = ;                  aicount := aicount+1;
      [*] = ;                  if (gPlayer[plind].team=gPlayer[j].team) then
      [*] = ;                  humanteamcount := humanteamcount+1
      [*] = ;                  else
      [*] = ;                  benemyexists := True;
      [*] = ;                  if ((gPlayer[j].difficulty+1)=gc_player_difficulty_impossible) and (gPlayer[plind].team<>gPlayer[j].team) and (gPlayer[j].team>=0) and(gPlayer[j].team<=3) then
      [*] = ;                  arraicountimpossible[gPlayer[j].team] := arraicountimpossible[gPlayer[j].team]+1;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;            if (humancount=0) then
      [*] = ;            humancount := 1;
      [*] = ;            for j:=0 to 3 do
      [*] = ;            aicountimpossible := Max(aicountimpossible, arraicountimpossible[j]);
      [*] = ;
      [*] = ;            if (benemyexists) then
      [*] = ;            begin
      [*] = ;               if (gPlayer[plind].victorystate=gc_player_victorystate_win) then
      [*] = ;               begin
      [*] = ;                  if (humancount>1) then
      [*] = ;                  begin
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_multiplayer_win1].cur := gProfileUserStruct.achs.ach[gc_ach_multiplayer_win1].cur+1;
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_multiplayer_win10].cur := gProfileUserStruct.achs.ach[gc_ach_multiplayer_win10].cur+1;
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_multiplayer_win100].cur := gProfileUserStruct.achs.ach[gc_ach_multiplayer_win100].cur+1;
      [*] = ;                  end;
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_skirmish_win1].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1].cur+1;
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_skirmish_win10].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win10].cur+1;
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_skirmish_win100].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win100].cur+1;
      [*] = ;                  if (GetGameTime>60*60) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_skirmish_win1hour].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1hour].cur+1;
      [*] = ;
      [*] = ;                  if (humancount=1) and (humanteamcount=0) then
      [*] = ;                  begin
      [*] = ;                     if (aicountimpossible>=2) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs2_impossible].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs2_impossible].cur+1;
      [*] = ;                     if (aicountimpossible>=4) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs4_impossible].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs4_impossible].cur+1;
      [*] = ;                     if (aicountimpossible>=6) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs6_impossible].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_1vs6_impossible].cur+1;
      [*] = ;                  end;
      [*] = ;                  if (humancount=1) and (humanteamcount>0) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_randommap_teamai].cur := gProfileUserStruct.achs.ach[gc_ach_randommap_teamai].cur+1;
      [*] = ;                  if (_misc_IsWaterMap) then
      [*] = ;                  begin
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_islands].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win1_islands].cur+1;
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win10_islands].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win10_islands].cur+1;
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_skirmish_win100_islands].cur := gProfileUserStruct.achs.ach[gc_ach_skirmish_win100_islands].cur+1;
      [*] = ;                  end;
      [*] = ;               end
      [*] = ;               else
      [*] = ;               if (gPlayer[plind].victorystate=gc_player_victorystate_lose) then
      [*] = ;               begin
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_multiplayer_lose10].cur := gProfileUserStruct.achs.ach[gc_ach_multiplayer_lose10].cur+1;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;         // on showendgame finish
      [*] = ;         if (not gScenario.bexists) then
      [*] = ;         begin
      [*] = ;            if (gProfileUserStruct.achs.ach[gc_ach_economy_population2000].cur=0) and (gPlayer[plind].counter.farmused>=2000) then
      [*] = ;            gProfileUserStruct.achs.ach[gc_ach_economy_population2000].cur := gProfileUserStruct.achs.ach[gc_ach_economy_population2000].cur+1;
      [*] = ;            if (gProfileUserStruct.achs.ach[gc_ach_economy_population4000].cur=0) and (gPlayer[plind].counter.farmused>=4000) then
      [*] = ;            gProfileUserStruct.achs.ach[gc_ach_economy_population4000].cur := gProfileUserStruct.achs.ach[gc_ach_economy_population4000].cur+1;
      [*] = ;
      [*] = ;            // based on statistics
      [*] = ;            if (gProfileUserStruct.achs.ach[gc_ach_economy_millionres_20min].cur=0) and (GetGameTime<(20*60)) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;            begin
      [*] = ;               var restotal : Integer;
      [*] = ;               for j:=0 to gc_ResCount-1 do
      [*] = ;               restotal := restotal+gPlayer[plind].stat.restotal[j];
      [*] = ;               if (restotal>=1000000) then
      [*] = ;               gProfileUserStruct.achs.ach[gc_ach_economy_millionres_20min].cur := gProfileUserStruct.achs.ach[gc_ach_economy_millionres_20min].cur+1;
      [*] = ;            end;
      [*] = ;            if (gProfileUserStruct.achs.ach[gc_ach_economy_millionres_sell].cur=0) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;            begin
      [*] = ;               var ressell : Integer;
      [*] = ;               for j:=0 to gc_ResCount-1 do
      [*] = ;               ressell := ressell+gPlayer[plind].stat.ressell[j];
      [*] = ;               if (ressell>=1000000) then
      [*] = ;               gProfileUserStruct.achs.ach[gc_ach_economy_millionres_sell].cur := gProfileUserStruct.achs.ach[gc_ach_economy_millionres_sell].cur+1;
      [*] = ;            end;
      [*] = ;            if (gProfileUserStruct.achs.ach[gc_ach_randommap_buildcen_capturednation].cur=0) then
      [*] = ;            begin
      [*] = ;               var bldcencid : Integer = -1;
      [*] = ;               for j:=0 to gPlayer[plind].lists.storehouses.GetCount-1 do
      [*] = ;               begin
      [*] = ;                  var hnd : Integer = gPlayer[plind].lists.storehouses.Get(j);
      [*] = ;                  var pobj : Pointer = _unit_GetTObj(hnd);
      [*] = ;                  if (pobj<>nil) and (gObjProp[TObj(pobj).cid][TObj(pobj).id].usage=gc_obj_usage_center) then
      [*] = ;                  begin
      [*] = ;                     if (bldcencid=-1) then
      [*] = ;                     bldcencid := TObj(pobj).cid
      [*] = ;                     else
      [*] = ;                     if (bldcencid<>TObj(pobj).cid) then
      [*] = ;                     begin
      [*] = ;                        gProfileUserStruct.achs.ach[gc_ach_randommap_buildcen_capturednation].cur := gProfileUserStruct.achs.ach[gc_ach_randommap_buildcen_capturednation].cur+1;
      [*] = ;                        break;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;            var produced : Integer;
      [*] = ;            for j:=0 to gc_country_maxmembers-1 do
      [*] = ;            begin
      [*] = ;               produced := gPlayer[plind].stat.produced[plcid][j];
      [*] = ;               if (produced>0) then
      [*] = ;               begin
      [*] = ;                  var pobjprop : Pointer = gObjProp[plcid][j];
      [*] = ;                  var usage : Integer = TObjProp(pobjprop).usage;
      [*] = ;                  if (TObjProp(pobjprop).bartillery) then
      [*] = ;                  begin
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_cannons20].cur=0) and (produced>=20) and (usage=gc_obj_usage_cannon) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_cannons20].cur := gProfileUserStruct.achs.ach[gc_ach_units_cannons20].cur+1
      [*] = ;                     else
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_mortar50].cur=0) and (produced>=50) and (usage=gc_obj_usage_supermortar) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_mortar50].cur := gProfileUserStruct.achs.ach[gc_ach_units_mortar50].cur+1;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  if (TObjProp(pobjprop).bpriest) then
      [*] = ;                  begin
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_priest50].cur=0) and (produced>=50) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_priest50].cur := gProfileUserStruct.achs.ach[gc_ach_units_priest50].cur+1;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  if (TObjProp(pobjprop).media=gc_obj_media_water) then
      [*] = ;                  begin
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_fishboat100].cur=0) and (usage=gc_obj_usage_fisher) and (produced>=100) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_fishboat100].cur := gProfileUserStruct.achs.ach[gc_ach_units_fishboat100].cur+1
      [*] = ;                     else
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_battleship].cur=0) and (usage=gc_obj_usage_battleship) and (produced>=1) then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_battleship].cur := gProfileUserStruct.achs.ach[gc_ach_units_battleship].cur+1;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  if (gProfileUserStruct.achs.ach[gc_ach_units_wall50].cur=0) and (TObjProp(pobjprop).bwall) and (usage=gc_obj_usage_hardwall) and (produced>=50) then
      [*] = ;                  gProfileUserStruct.achs.ach[gc_ach_units_wall50].cur := gProfileUserStruct.achs.ach[gc_ach_units_wall50].cur+1
      [*] = ;                  else
      [*] = ;                  if (TObjProp(pobjprop).bmercenary) then
      [*] = ;                  begin
      [*] = ;                     var sid : String = TObjProp(pobjprop).sid;
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_archerdip500].cur=0) and (produced>=500) and (sid='archerdip') then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_archerdip500].cur := gProfileUserStruct.achs.ach[gc_ach_units_archerdip500].cur+1
      [*] = ;                     else
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_lightinfantrydip500].cur=0) and (produced>=500) and (sid='lightinfantrydip') then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_lightinfantrydip500].cur := gProfileUserStruct.achs.ach[gc_ach_units_lightinfantrydip500].cur+1
      [*] = ;                     else
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_cossacksichdip50].cur=0) and (produced>=50) and (sid='cossacksichdip') then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_cossacksichdip50].cur := gProfileUserStruct.achs.ach[gc_ach_units_cossacksichdip50].cur+1
      [*] = ;                     else
      [*] = ;                     if (gProfileUserStruct.achs.ach[gc_ach_units_dragoon18dip_100].cur=0) and (produced>=100) and (sid='dragoon18dip') then
      [*] = ;                     gProfileUserStruct.achs.ach[gc_ach_units_dragoon18dip_100].cur := gProfileUserStruct.achs.ach[gc_ach_units_dragoon18dip_100].cur+1;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  begin
      [*] = ;                     case usage of
      [*] = ;                        gc_obj_usage_tower : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_tower10].cur=0) and (produced>=10) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_tower10].cur := gProfileUserStruct.achs.ach[gc_ach_units_tower10].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_farm : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_bldhou100].cur=0) and (produced>=100) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_bldhou100].cur := gProfileUserStruct.achs.ach[gc_ach_units_bldhou100].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_center : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_bldcen5].cur=0) and (produced>=5) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_bldcen5].cur := gProfileUserStruct.achs.ach[gc_ach_units_bldcen5].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_port : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_bldpor10].cur=0) and (produced>=10) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_bldpor10].cur := gProfileUserStruct.achs.ach[gc_ach_units_bldpor10].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_shooter : begin
      [*] = ;                           var sid : String = TObjProp(pobjprop).sid;
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_musketeerpru200].cur=0) and (produced>=200) and (sid='musketeer18pru') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_musketeerpru200].cur := gProfileUserStruct.achs.ach[gc_ach_units_musketeerpru200].cur+1
      [*] = ;                           else
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_janissary200].cur=0) and (produced>=200) and (sid='jannisary') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_janissary200].cur := gProfileUserStruct.achs.ach[gc_ach_units_janissary200].cur+1
      [*] = ;                           else
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_highlander200].cur=0) and (produced>=200) and (sid='highlander') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_highlander200].cur := gProfileUserStruct.achs.ach[gc_ach_units_highlander200].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_horseshooter : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_kingmusketeer100].cur=0) and (produced>=100) and (TObjProp(pobjprop).sid='kingmusketeer') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_kingmusketeer100].cur := gProfileUserStruct.achs.ach[gc_ach_units_kingmusketeer100].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_hardhorse : begin
      [*] = ;                           var sid : String = TObjProp(pobjprop).sid;
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_reiterswe200].cur=0) and (produced>=200) and (sid='reiterswe') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_reiterswe200].cur := gProfileUserStruct.achs.ach[gc_ach_units_reiterswe200].cur+1
      [*] = ;                           else
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_vityaz200].cur=0) and (produced>=200) and (sid='vityaz') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_vityaz200].cur := gProfileUserStruct.achs.ach[gc_ach_units_vityaz200].cur+1
      [*] = ;                           else
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_hetman3].cur=0) and (produced>=3) and (sid='hetman') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_hetman3].cur := gProfileUserStruct.achs.ach[gc_ach_units_hetman3].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_fasthorse : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_croat200].cur=0) and (produced>=200) and (TObjProp(pobjprop).sid='croat') then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_croat200].cur := gProfileUserStruct.achs.ach[gc_ach_units_croat200].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_archer : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_archer1000].cur=0) and (produced>=1000) then
      [*] = ;                           gProfileUserStruct.achs.ach[gc_ach_units_archer1000].cur := gProfileUserStruct.achs.ach[gc_ach_units_archer1000].cur+1;
      [*] = ;                        end;
      [*] = ;                        gc_obj_usage_none : begin
      [*] = ;                           if (gProfileUserStruct.achs.ach[gc_ach_units_bldba2_5].cur=0) and (produced>=5) and (produced<10) and (gMap.settings.gen.resourcestart<3) then
      [*] = ;                           begin
      [*] = ;                              var tmp : String = TObjProp(pobjprop).sid;
      [*] = ;                              tmp := SubStr(tmp, 4, StrLength(tmp)-3);
      [*] = ;                              if (tmp='ba2') then
      [*] = ;                              gProfileUserStruct.achs.ach[gc_ach_units_bldba2_5].cur := gProfileUserStruct.achs.ach[gc_ach_units_bldba2_5].cur+1;
      [*] = ;                           end;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;         // based on statistics
      [*] = ;         {
      [*] = ;         gc_ach_camp_secretplace10 : ;
      [*] = ;         gc_ach_camp_good5 : ;
      [*] = ;         gc_ach_camp_evil5 : ;
      [*] = ;         gc_ach_camp_findchest : ;
      [*] = ;         gc_ach_camp_hirerobbers : ;
      [*] = ;         gc_ach_camp_engmis1_alltowns : ;
      [*] = ;         gc_ach_camp_engmis2_peasantdialogwell : ;
      [*] = ;         gc_ach_camp_ausmis1_capturepackhorses : ;
      [*] = ;         gc_ach_camp_ausmis2_killallunitsblack : ;
      [*] = ;         gc_ach_camp_ausmis3_mantuyunorebels : ;
      [*] = ;         gc_ach_camp_framis1_trophyshipsuccess : ;
      [*] = ;         gc_ach_camp_framis2_donotharmlocals : ;
      [*] = ;         gc_ach_camp_framis2_freeslaves : ;
      [*] = ;         gc_ach_camp_framis3_palermokillgarrison : ;
      [*] = ;         gc_ach_camp_ukrmis1_free100slaves : ;
      [*] = ;         gc_ach_camp_ukrmis1_destroy2turkforts : ;
      [*] = ;         gc_ach_camp_ukrmis2_destroywhitestonebld : ;
      [*] = ;         gc_ach_camp_ukrmis3_destroykafabld : ;
      [*] = ;         gc_ach_camp_ukrmis4_killrusflankstealth : ;
      [*] = ;         gc_ach_camp_ukrmis5_allkingguardssurvived : ;
      [*] = ;         gc_ach_camp_rusmis1_saveorel : ;
      [*] = ;         gc_ach_camp_rusmis2_caravanwontpass : ;
      [*] = ;         gc_ach_camp_rusmis3_blitzkrieg : ;
      [*] = ;         gc_ach_camp_rusmis4_beatallboforeswewar : ;
      [*] = ;         gc_ach_camp_tutmis1_executeofficer : ;
      [*] = ;         gc_ach_camp_tutmis1_mercyofficer : ;}
      [*] = ;
      [*] = ;         {gc_ach_skirmish_ferryunload : ;
      [*] = ;         gc_ach_learn_createsquad : ;
      [*] = ;         gc_ach_learn_fillsquadhalfdead10 : ;
      [*] = ;         gc_ach_capture_cannons20 : ;
      [*] = ;         gc_ach_destroy_buildings10 : ;
      [*] = ;         gc_ach_destroy_buildings100 : ;
      [*] = ;         }
      [*] = ;         // finish
      [*] = ;         var ind : Integer;
      [*] = ;         for ind:=0 to gc_ach_existscount-1 do
      [*] = ;         begin
      [*] = ;            if (gProfileUserStruct.achs.ach[ind].status=gc_ach_status_none) and (gProfileUserStruct.achs.ach[ind].cur>0) then
      [*] = ;            begin
      [*] = ;               var cur : Integer = gProfileUserStruct.achs.ach[ind].cur;
      [*] = ;               if (gProfileUserStruct.achs.ach[ind].bbitcoded) then
      [*] = ;               begin
      [*] = ;                  var bits : Integer;
      [*] = ;                  for j:=0 to 31 do
      [*] = ;                  begin
      [*] = ;                     if ((cur and (1 shl j))<>0) then
      [*] = ;                     bits := bits+1;
      [*] = ;                  end;
      [*] = ;                  if (bits>=gProfileUserStruct.achs.ach[ind].goal) then
      [*] = ;                  begin
      [*] = ;                     bSaveProfile := True;
      [*] = ;                     gProfileUserStruct.achs.ach[ind].status := gc_ach_status_set;
      [*] = ;                     Log('Achivement '+IntToStr(ind)+' set True');
      [*] = ;                  end;
      [*] = ;               end
      [*] = ;               else
      [*] = ;               if (gProfileUserStruct.achs.ach[ind].cur>=gProfileUserStruct.achs.ach[ind].goal) then
      [*] = ;               begin
      [*] = ;                  bSaveProfile := True;
      [*] = ;                  gProfileUserStruct.achs.ach[ind].status := gc_ach_status_set;
      [*] = ;                  Log('Achivement '+IntToStr(ind)+' set True');
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;            if (gProfileUserStruct.achs.ach[ind].status=gc_ach_status_set) then
      [*] = ;            begin
      [*] = ;               bSaveProfile := True;
      [*] = ;               _steam_SetAchievement('ach'+IntToStr(ind));
      [*] = ;               gProfileUserStruct.achs.ach[ind].status := gc_ach_status_onsteam;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;      //gint_gui_lastprogressach := (gint_gui_lastprogressach+cProgressPerTick) mod gc_ach_existscount;
      [*] = ;
      [*] = ;      if (bSaveProfile) then
      [*] = ;      _profile_SaveStructToUserProfileParser('gProfileUserStruct');
      [*] = ;   end;
      [*] = ;   //_misc_ProfilerEnd('_misc_ProcessAchs');
      [*] = ;end;
      [*] = ;_misc_ProcessAchs;
      [*] = ;
      [*] = ;if (gbool_gui_sendadviserchangeparser) then
      [*] = ;begin
      [*] = ;   gbool_gui_sendadviserchangeparser := False;
      [*] = ;   if (_net_IsClient) and (LanGetClientsCount>1) then
      [*] = ;   begin
      [*] = ;      // commented fields that is not needed to be synced with server to work properly.
      [*] = ;
      [*] = ;      var pLan : Integer = _parser_ParserTemporary(True);
      [*] = ;      ParserSetIntValueByKeyByHandle(pLan, 'pl', myPlInd);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'v', gPlayer[myPlInd].playeradviser.adviser.bvisible);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'ea', gPlayer[myPlInd].playeradviser.adviser.benable);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'a', gPlayer[myPlInd].playeradviser.adviser.bavailable);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'c', gPlayer[myPlInd].playeradviser.adviser.bconstruct);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'ec', gPlayer[myPlInd].playeradviser.adviser.beconomy);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'cp', gPlayer[myPlInd].playeradviser.adviser.bcontrolpeasants);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'pp', gPlayer[myPlInd].playeradviser.adviser.bproducepeasants);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'rb', gPlayer[myPlInd].playeradviser.adviser.brepairbuildings);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'fm', gPlayer[myPlInd].playeradviser.adviser.bfillmines);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'ma', gPlayer[myPlInd].playeradviser.adviser.bmarketadvises);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'mr', gPlayer[myPlInd].playeradviser.adviser.bmanualresource);
      [*] = ;      //ParserSetFloatValueByKeyByHandle(pLan, 'rf', gPlayer[myPlInd].playeradviser.adviser.resonfood);
      [*] = ;      //ParserSetFloatValueByKeyByHandle(pLan, 'rw', gPlayer[myPlInd].playeradviser.adviser.resonwood);
      [*] = ;      //ParserSetFloatValueByKeyByHandle(pLan, 'rs', gPlayer[myPlInd].playeradviser.adviser.resonstone);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'u', gPlayer[myPlInd].playeradviser.adviser.bupgrades);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'uu', gPlayer[myPlInd].playeradviser.adviser.bupgradesunavailable);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'q', gPlayer[myPlInd].playeradviser.adviser.bquartermaster);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'sg', gPlayer[myPlInd].playeradviser.adviser.bsetupguards);
      [*] = ;      ParserSetBoolValueByKeyByHandle(pLan, 'po', gPlayer[myPlInd].playeradviser.adviser.bproduceofficers);
      [*] = ;      //ParserSetBoolValueByKeyByHandle(pLan, 'ss', gPlayer[myPlInd].playeradviser.adviser.bshowsquads);
      [*] = ;
      [*] = ;      LanSendParser(gc_LAN_ADVISER_CLIENT_DATACHANGE, pLan);
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gInternetShell.bauth) and (gInterface.gamemode=gc_gamemode_mainmenu) then
      [*] = ;begin
      [*] = ;   if (IsLanPublicServerMode) then
      [*] = ;   begin
      [*] = ;      if (gbool_modsyncparserwait) and ((_misc_GetRealTime-gfloat_modsyncparserwaittime)>5) then
      [*] = ;      begin
      [*] = ;         log('LanTerminateByTimeOut');
      [*] = ;         LanTerminateGame;
      [*] = ;         gstring_roomchecksum := '';
      [*] = ;         gbool_modsyncparserwait := False;
      [*] = ;         gfloat_modsyncparserwaittime := 0;
      [*] = ;      end;
      [*] = ;
      [*] = ;      if (gint_gui_updatesessionlist<>0) then
      [*] = ;      begin
      [*] = ;         var bUpdate : Boolean = ((gint_gui_updatesessionlist and (1 shl 0))<>0);
      [*] = ;         var bGUIUpdate : Boolean = ((gint_gui_updatesessionlist and (1 shl 1))<>0);
      [*] = ;         var bIfRoom : Boolean = ((gint_gui_updatesessionlist and (1 shl 2))<>0);
      [*] = ;         var bIfShell : Boolean = ((gint_gui_updatesessionlist and (1 shl 3))<>0);
      [*] = ;         gint_gui_updatesessionlist := 0;
      [*] = ;         _misc_UpdateSessionList(bUpdate, bGUIUpdate, bIfRoom, bIfShell);
      [*] = ;      end;
      [*] = ;      if (gint_gui_updateclientlist<>0) then
      [*] = ;      begin
      [*] = ;         var bUpdate : Boolean = ((gint_gui_updateclientlist and (1 shl 0))<>0);
      [*] = ;         var bGUIUpdate : Boolean = ((gint_gui_updateclientlist and (1 shl 1))<>0);
      [*] = ;         var bIfRoom : Boolean = ((gint_gui_updateclientlist and (1 shl 2))<>0);
      [*] = ;         var bIfShell : Boolean = ((gint_gui_updateclientlist and (1 shl 3))<>0);
      [*] = ;         gint_gui_updateclientlist := 0;
      [*] = ;         _misc_UpdateClientList(bUpdate, bGUIUpdate, bIfRoom, bIfShell);
      [*] = ;      end;
      [*] = ;      if (gbool_lan_isonlinecached) then
      [*] = ;      begin
      [*] = ;         var bdatachanged : Boolean;
      [*] = ;         if (gbool_gui_updatecurrentsessionname) then
      [*] = ;         begin
      [*] = ;            gbool_gui_updatecurrentsessionname := False;
      [*] = ;            if _net_IsServer then
      [*] = ;            bdatachanged := _misc_InternetShellUpdateCurrentSessionName(gInternetShell, False);
      [*] = ;         end;
      [*] = ;         if (gbool_gui_refreshcurrentsession) then
      [*] = ;         begin
      [*] = ;            gbool_gui_refreshcurrentsession := False;
      [*] = ;            _misc_InternetShellRefreshCurrentSession(gInternetShell, True);
      [*] = ;         end;
      [*] = ;         if (gbool_gui_senddatasyncparser) then
      [*] = ;         begin
      [*] = ;            gbool_gui_senddatasyncparser := False;
      [*] = ;            if (not gInternetShell.bautosearch) and (bdatachanged) and (LanGetClientsCount>1) then
      [*] = ;            begin
      [*] = ;               var pLan : Integer = _parser_ParserTemporary(True);
      [*] = ;               //log('3 : roomdata = '+gInternetShell.roomdata);
      [*] = ;               ParserSetValueByKeyByHandle(pLan, 's', gInternetShell.roomdata);
      [*] = ;               LanPublicServerSendSessionParser(0, gc_LAN_ROOM_SERVER_DATASYNC, pLan);
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;      if (gbool_gui_showcustomgame) then
      [*] = ;      begin
      [*] = ;         gbool_gui_showcustomgame := False;
      [*] = ;         ExecuteState('ShowCustomGame');
      [*] = ;      end;
      [*] = ;      if (gbool_gui_showhistoricalbattle) then
      [*] = ;      begin
      [*] = ;         gbool_gui_showhistoricalbattle := False;
      [*] = ;         ExecuteState('ShowHistoricalBattle');
      [*] = ;      end;
      [*] = ;      if (gbool_gui_showinternetshell) then
      [*] = ;      begin
      [*] = ;         gbool_gui_showinternetshell := False;
      [*] = ;         ExecuteState('ShowInternetShell');
      [*] = ;      end;
      [*] = ;      if (gbool_gui_setshellchatinputfocused) then
      [*] = ;      begin
      [*] = ;         gbool_gui_setshellchatinputfocused := False;
      [*] = ;         _gui_SetShellChatInputBoxFocused;
      [*] = ;      end;
      [*] = ;   end
      [*] = ;   else
      [*] = ;   begin
      [*] = ;      gInternetShell.bauth := False;
      [*] = ;      //_misc_ReconnectManagerStartSession;
      [*] = ;      //_misc_ReconnectManagerStartReconnectProcess;
      [*] = ;      {ErrorLog('IsLanPublicServerMode<>gInternetShell.bauth');
      [*] = ;      gInternetShell.bauth := False;
      [*] = ;      const cTagMultiplayer = 103;
      [*] = ;      _gui_SendTagToState('EventMainMenu', cTagMultiplayer);}
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;if (gbool_lan_isonlinecached) and (gint_gui_progresstick>30) then
      [*] = ;begin
      [*] = ;   if (IsLanReady) and (gInterface.gamemode<>gc_gamemode_mainmenu) then
      [*] = ;   begin
      [*] = ;      gLanRecreate.createdtime := 0;
      [*] = ;
      [*] = ;      var brecreate : Boolean = gLanRecreate.brecreate;
      [*] = ;      if (brecreate) then
      [*] = ;      begin
      [*] = ;         gfloat_gui_onlinedoprogressstart := 0;
      [*] = ;         gLanRecreate.brecreate := False;
      [*] = ;         gLanRecreate.hostid := 0;
      [*] = ;      end;
      [*] = ;
      [*] = ;      if (gLanRecreate.brecreatestarted) then
      [*] = ;      begin
      [*] = ;         Log('DoProgress : gLanRecreate.brecreatestarted : unpause');
      [*] = ;         gLanRecreate.brecreatestarted := False;
      [*] = ;         gLanRecreate.brecreatefinished := True;
      [*] = ;         gConnectTimer := 0;
      [*] = ;
      [*] = ;         var i : Integer;
      [*] = ;         for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;         begin
      [*] = ;            if (gMap.players[i].lanid>0) and (gMap.players[i].lanid<>LanMyInfoID) then
      [*] = ;            begin
      [*] = ;               if (LanGetClientIndexByID(gMap.players[i].lanid)<0) then
      [*] = ;               begin
      [*] = ;                  Log('player '+gMap.players[i].name+' is not here anymore, send his surrender');
      [*] = ;                  var pParser : Integer = _parser_ParserTemporary(True);
      [*] = ;                  var indFrom : Integer = _misc_GetMapPlayerIndexByLanID(gMap.players[i].lanid);
      [*] = ;                  if (indFrom>=0) then
      [*] = ;                  begin
      [*] = ;                     gMap.players[indFrom].bleave := True;
      [*] = ;                     gPlayer[indFrom].victorystate := gc_player_victorystate_lose;
      [*] = ;                     if (gPlayer[indFrom].victorystategametime=0) then
      [*] = ;                     gPlayer[indFrom].victorystategametime := GetGameTime;
      [*] = ;
      [*] = ;                     _misc_LanServerSendResults;
      [*] = ;                     var s1, s2 : String;
      [*] = ;                     _misc_GetNewTextLocale('player.leave', s1);
      [*] = ;                     s1 := StrReplace(s1, '%name%', gMap.players[indFrom].name);
      [*] = ;                     _misc_ShowLogMessage(gc_logmessagesid_custom, s1, s2, False);
      [*] = ;                  end;
      [*] = ;                  ParserSetIntValueByKeyByHandle(pParser, 'id', gMap.players[i].lanid);
      [*] = ;                  ParserSetIntValueByKeyByHandle(pParser, 'ind', indFrom);
      [*] = ;                  LanSendParser(gc_LAN_GAME_SURRENDER_CONFIRM, pParser);
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end;
      [*] = ;      if (gMap.gamestage=gc_map_gamestage_waitingloading) then
      [*] = ;      begin
      [*] = ;         gConnectTimer := 0;
      [*] = ;         gMap.gamestage := gc_map_gamestage_started;
      [*] = ;         if (gMap.bbattle) and (gMap.battlemap<>'') then
      [*] = ;         begin
      [*] = ;            //gScenario.bactive := True; // done on scenario start
      [*] = ;            gbool_editor_peacemode := False;
      [*] = ;         end;
      [*] = ;         gfloat_gui_lanlastgametimesyncreceived := 0;
      [*] = ;         var i : Integer;
      [*] = ;         for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;         gfloat_gui_lanlastaliveeventreceived[i] := 0;
      [*] = ;
      [*] = ;         if (_net_IsServer) then
      [*] = ;         _control_SetGameSpeedByMode(gMap.settings.additional.gamespeed, True);
      [*] = ;         SetProgressingPauseMode(False);
      [*] = ;         ExecuteState('ShowPause');
      [*] = ;
      [*] = ;         if (gbool_gui_bspectator) then
      [*] = ;         gInterface.gamemode := gc_gamemode_spectator;
      [*] = ;      end
      [*] = ;      else
      [*] = ;      if (_net_IsServer) then
      [*] = ;      begin
      [*] = ;         if (LanGetClientsCount>1) then
      [*] = ;         begin
      [*] = ;            //var deltatimeallevents : Float = _misc_GetRealTime-gfloat_gui_lanlasteventreceived;
      [*] = ;
      [*] = ;            if ((gfloat_gui_lanlastgametimesync=0) or ((_misc_GetRealTime-gfloat_gui_lanlastgametimesync)>5)) then
      [*] = ;            begin
      [*] = ;               var pLan : Integer = _parser_ParserTemporary(True);
      [*] = ;               ParserSetFloatValueByKeyByHandle(pLan, 't', GetGameTime);
      [*] = ;               ParserSetFloatValueByKeyByHandle(pLan, 's', GetTimeSpeedFactor);
      [*] = ;               LanSendParser(gc_LAN_GAME_SYNC_GAMETIME, pLan);
      [*] = ;               gfloat_gui_lanlastgametimesync := _misc_GetRealTime;
      [*] = ;
      [*] = ;               {if (deltatimeallevents>115) then
      [*] = ;               begin
      [*] = ;                  ErrorLog('I am server and last event receaved > 115sec = '+FloatToStr(deltatimeallevents)+' : shutdown');
      [*] = ;                  LanShutdown;
      [*] = ;               end;}
      [*] = ;            end;
      [*] = ;            {var i : Integer;
      [*] = ;            for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;            begin
      [*] = ;               if (gMap.players[i].lanid>0) and (gMap.players[i].lanid<>LanMyInfoID) then
      [*] = ;               begin
      [*] = ;                  if ((LanGetClientIndexByID(gMap.players[i].lanid)>=0) and (gfloat_gui_lanlastaliveeventreceived[i]>0) and ((_misc_GetRealTime-gfloat_gui_lanlastaliveeventreceived[i])>110)) then
      [*] = ;                  begin
      [*] = ;                     if (deltatimeallevents<120) then
      [*] = ;                     begin
      [*] = ;                        Log('I am server and client ['+IntToStr(i)+'] didn''t sent alive event>'+FloatToStr(_misc_GetRealTime-gfloat_gui_lanlastaliveeventreceived[i])+'sec');
      [*] = ;                        
      [*] = ;                        // lead to mass kill clients
      [*] = ;                        var pParser : Integer = _parser_ParserTemporary(True);
      [*] = ;                        var indFrom : Integer = _misc_GetMapPlayerIndexByLanID(gMap.players[i].lanid);
      [*] = ;                        if (indFrom>=0) then
      [*] = ;                        begin
      [*] = ;                           gMap.players[indFrom].bleave := True;
      [*] = ;                           gPlayer[indFrom].victorystate := gc_player_victorystate_lose;
      [*] = ;                           if (gPlayer[indFrom].victorystategametime=0) then
      [*] = ;                           gPlayer[indFrom].victorystategametime := GetGameTime;
      [*] = ;                           _misc_LanServerSendResults;
      [*] = ;                           var s1, s2 : String;
      [*] = ;                           _misc_GetNewTextLocale('player.leave', s1);
      [*] = ;                           s1 := StrReplace(s1, '%name%', gMap.players[indFrom].name);
      [*] = ;                           _misc_ShowLogMessage(gc_logmessagesid_custom, s1, s2, False);
      [*] = ;                        end;
      [*] = ;                        gfloat_gui_lanlastaliveeventreceived[i] := 0; // so this code will be executed once and i can detect leave time.
      [*] = ;                        ParserSetIntValueByKeyByHandle(pParser, 'id', gMap.players[i].lanid);
      [*] = ;                        ParserSetIntValueByKeyByHandle(pParser, 'ind', indFrom);
      [*] = ;                        LanSendParser(gc_LAN_GAME_SURRENDER_CONFIRM, pParser);
      [*] = ;
      [*] = ;                        LanKillClient(gMap.players[i].lanid);
      [*] = ;                     end
      [*] = ;                     else
      [*] = ;                     begin
      [*] = ;                        //ErrorLog('I am server and last event receaved > '+FloatToStr(_misc_GetRealTime-gfloat_gui_lanlastaliveeventreceived[i])+'sec. shutdown');
      [*] = ;                        //LanShutdown;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;            }
      [*] = ;         end;
      [*] = ;      end
      [*] = ;      else
      [*] = ;      if (_net_IsClient) and (gfloat_gui_lanlastgametimesyncreceived>0) then
      [*] = ;      begin
      [*] = ;         {if (LanGetClientsCount>1) and ((gfloat_gui_lanlastaliveevent=0) or ((_misc_GetRealTime-gfloat_gui_lanlastaliveevent)>5)) then
      [*] = ;         begin
      [*] = ;            var pLan : Integer = _parser_ParserTemporary(True);
      [*] = ;            ParserSetIntValueByKeyByHandle(pLan, 'a', LanMyInfoID);
      [*] = ;            LanSendParser(gc_LAN_GAME_SYNC_ALIVE, pLan);
      [*] = ;            gfloat_gui_lanlastaliveevent := _misc_GetRealTime;
      [*] = ;         end;}
      [*] = ;
      [*] = ;         var deltatime : Float = _misc_GetRealTime-gfloat_gui_lanlastgametimesyncreceived;
      [*] = ;         // if server stop telling client its time and speed, stop time syncing with inc/dec game speed and set previous server game speed.
      [*] = ;         if (deltatime>6) and (gfloat_gui_lanlastgamespeedsyncreceived>0) then
      [*] = ;         SetTimeSpeedFactor(gfloat_gui_lanlastgamespeedsyncreceived);
      [*] = ;         {if (deltatime>125) then
      [*] = ;         begin
      [*] = ;            var deltatimeallevents : Float = _misc_GetRealTime-gfloat_gui_lanlasteventreceived;
      [*] = ;            if (deltatimeallevents>115) then
      [*] = ;            begin
      [*] = ;               ErrorLog('I am client and last event receaved > 115sec : shutdown');
      [*] = ;               LanShutdown;
      [*] = ;            end
      [*] = ;            else
      [*] = ;            begin
      [*] = ;               //if (gbool_lan_debug) then
      [*] = ;               Log('Server is silent for = '+FloatToStr(deltatime)+' sec and game may be closed. shutdown');
      [*] = ;               if (LanPublicServerProfCountry<>'') {and (_misc_GetFirstLeaver>=0)}{ then
      [*] = ;               begin
      [*] = ;                  var country : String = LanPublicServerProfCountry;
      [*] = ;                  if (StrExists(country, '|f=')) then
      [*] = ;                  begin
      [*] = ;                     var pos : Integer = StrPos('|f=', country);
      [*] = ;                     var lm : String = SubStr(country, pos+3, 1);
      [*] = ;                     country := StrReplace(country, '|f='+lm, '');
      [*] = ;                     LanSetMyCountry(country);
      [*] = ;                     LanPublicServerRegister;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;               //LanTerminateGame;
      [*] = ;               LanShutdown;
      [*] = ;            end;
      [*] = ;         end;}
      [*] = ;      end;
      [*] = ;   end
      [*] = ;   else
      [*] = ;   if (IsLanPublicServerMode) then
      [*] = ;   begin
      [*] = ;      if (_net_IsServer) then
      [*] = ;      begin
      [*] = ;         if (gConnectTimer>0) then
      [*] = ;         begin
      [*] = ;            if ((not gLanRecreate.brecreatestarted) and ((_misc_GetRealTime-gConnectTimer)>4.5*60))
      [*] = ;            or ((gLanRecreate.brecreatestarted) and ((_misc_GetRealTime-gConnectTimer)>20)) then
      [*] = ;            begin
      [*] = ;               LanDoReadyDone;
      [*] = ;               gConnectTimer := 0;
      [*] = ;            end;
      [*] = ;         end
      [*] = ;         else
      [*] = ;         begin
      [*] = ;            if (gLanRecreate.brecreatestarted) and (LanGetClientsCount>1) then
      [*] = ;            begin
      [*] = ;               //var deltatimeallevents : Float = _misc_GetRealTime-gfloat_gui_lanlasteventreceived;
      [*] = ;
      [*] = ;               var i : Integer;
      [*] = ;               {for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;               begin
      [*] = ;                  if (gMap.players[i].lanid>0) and (gMap.players[i].lanid<>LanMyInfoID) then
      [*] = ;                  begin
      [*] = ;                     if ((LanGetClientIndexByID(gMap.players[i].lanid)>=0) and (gfloat_gui_lanlastaliveeventreceived[i]>0) and ((_misc_GetRealTime-gfloat_gui_lanlastaliveeventreceived[i])>100)) then
      [*] = ;                     begin
      [*] = ;                        if (deltatimeallevents<90) then
      [*] = ;                        begin
      [*] = ;                           Log('I am server and client ['+IntToStr(i)+'] didn''t sent alive event>100sec : kick');
      [*] = ;
      [*] = ;                           var pParser : Integer = _parser_ParserTemporary(True);
      [*] = ;                           var indFrom : Integer = _misc_GetMapPlayerIndexByLanID(gMap.players[i].lanid);
      [*] = ;                           if (indFrom>=0) then
      [*] = ;                           begin
      [*] = ;                              gMap.players[indFrom].bleave := True;
      [*] = ;                              gPlayer[indFrom].victorystate := gc_player_victorystate_lose;
      [*] = ;                              if (gPlayer[indFrom].victorystategametime=0) then
      [*] = ;                              gPlayer[indFrom].victorystategametime := GetGameTime;
      [*] = ;                              _misc_LanServerSendResults;
      [*] = ;                              var s1, s2 : String;
      [*] = ;                              _misc_GetNewTextLocale('player.leave', s1);
      [*] = ;                              s1 := StrReplace(s1, '%name%', gMap.players[indFrom].name);
      [*] = ;                              _misc_ShowLogMessage(gc_logmessagesid_custom, s1, s2, False);
      [*] = ;                           end;
      [*] = ;                           ParserSetIntValueByKeyByHandle(pParser, 'id', gMap.players[i].lanid);
      [*] = ;                           ParserSetIntValueByKeyByHandle(pParser, 'ind', indFrom);
      [*] = ;                           LanSendParser(gc_LAN_GAME_SURRENDER_CONFIRM, pParser);
      [*] = ;
      [*] = ;                           LanKillClient(gMap.players[i].lanid);
      [*] = ;                        end
      [*] = ;                        else
      [*] = ;                        begin
      [*] = ;                           ErrorLog('I am server and last event receaved > 90sec : shutdown');
      [*] = ;                           LanShutdown;
      [*] = ;                        end;
      [*] = ;                     end;
      [*] = ;                  end;
      [*] = ;               end;}
      [*] = ;
      [*] = ;               if ((_misc_GetRealTime-gfloat_gui_lanlastgametimesync)>5) then
      [*] = ;               begin
      [*] = ;                  {if (deltatimeallevents>90) then
      [*] = ;                  begin
      [*] = ;                     ErrorLog('I am server and last event receaved > 90sec. shutdown');
      [*] = ;                     LanShutdown;
      [*] = ;                  end
      [*] = ;                  else
      [*] = ;                  begin}
      [*] = ;                     if (gLanRecreate.createdtime>0) then
      [*] = ;                     begin
      [*] = ;                        if ((_misc_GetRealTime-gLanRecreate.createdtime)>40) then
      [*] = ;                        begin
      [*] = ;                           LanLockServer;
      [*] = ;                           LanDoStart;
      [*] = ;                        end;
      [*] = ;                        if ((_misc_GetRealTime-gLanRecreate.createdtime)>50) then
      [*] = ;                        LanDoReadyDone;
      [*] = ;                     end;
      [*] = ;
      [*] = ;                     var pLan : Integer = _parser_ParserTemporary(True);
      [*] = ;                     ParserSetFloatValueByKeyByHandle(pLan, 't', GetGameTime);
      [*] = ;                     ParserSetFloatValueByKeyByHandle(pLan, 's', GetTimeSpeedFactor);
      [*] = ;                     LanSendParser(gc_LAN_GAME_SYNC_GAMETIME, pLan);
      [*] = ;                     gfloat_gui_lanlastgametimesync := _misc_GetRealTime;
      [*] = ;                  {end;}
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;
      [*] = ;      end
      [*] = ;      else
      [*] = ;      if (_net_IsClient) and (gfloat_gui_lanlastgametimesyncreceived>0) then
      [*] = ;      begin
      [*] = ;         {var deltatime : Float = _misc_GetRealTime-gfloat_gui_lanlastgametimesyncreceived;
      [*] = ;         if (deltatime>120) then
      [*] = ;         begin
      [*] = ;            var deltatimeallevents : Float = _misc_GetRealTime-gfloat_gui_lanlasteventreceived;
      [*] = ;            if (deltatimeallevents>110) then
      [*] = ;            begin
      [*] = ;               ErrorLog('I am client and last event receaved > '+FloatToStr(deltatimeallevents)+'sec : do shutdown');
      [*] = ;               LanShutdown;
      [*] = ;            end
      [*] = ;            else
      [*] = ;            begin
      [*] = ;               ErrorLog('I am client and last time sync > '+FloatToStr(deltatime)+' and last event receaved < 110sec');
      [*] = ;               if (LanPublicServerProfCountry<>'') then
      [*] = ;               begin
      [*] = ;                  var country : String = LanPublicServerProfCountry;
      [*] = ;                  if (StrExists(country, '|f=')) then
      [*] = ;                  begin
      [*] = ;                     var pos : Integer = StrPos('|f=', country);
      [*] = ;                     var lm : String = SubStr(country, pos+3, 1);
      [*] = ;                     country := StrReplace(country, '|f='+lm, '');
      [*] = ;                     LanSetMyCountry(country);
      [*] = ;                     LanPublicServerRegister;
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;               ////LanTerminateGame;
      [*] = ;               if (deltatime>130) then
      [*] = ;               begin
      [*] = ;                  Log('I am client and server doesnt respond over 130 sec. so i ll shutdown');
      [*] = ;                  LanShutdown;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end;}
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;
      [*] = ;   if gfloat_gui_onlinedoprogressstart=0 then
      [*] = ;   begin
      [*] = ;      gfloat_gui_lanlastgametimesyncreceived := 0;
      [*] = ;      var i : Integer;
      [*] = ;      for i:=0 to gc_MaxPlayerCount-1 do
      [*] = ;      gfloat_gui_lanlastaliveeventreceived[i] := 0;
      [*] = ;      gfloat_gui_onlinedoprogressstart := _misc_GetRealTime
      [*] = ;   end
      [*] = ;   else
      [*] = ;   begin
      [*] = ;      if (gMap.gamestage=gc_map_gamestage_waitingloading) and (gInterface.gamemode=gc_gamemode_game) and ((not _net_IsOnline) or (_misc_GetRealTime>(gfloat_gui_onlinedoprogressstart+3))) then
      [*] = ;      begin
      [*] = ;         //log('gfloat_gui_onlinedoprogressstart='+FloatToStr(gfloat_gui_onlinedoprogressstart));
      [*] = ;         var pl : Integer = GetPlayerIndexByHandle(GetPlayerHandleInterfaceIO);
      [*] = ;         if (pl>=0) and (pl<gc_MaxPlayerCount) then
      [*] = ;         gMap.players[pl].bloaded := True
      [*] = ;         else
      [*] = ;         ErrorLog('DoCreate invalid pl');
      [*] = ;
      [*] = ;         if (_net_IsOnline) then
      [*] = ;         begin
      [*] = ;            SetGUIEventStateOnLanChange('OnLanEventSession');
      [*] = ;            if (not IsLanReady) and (not gLanRecreate.brecreatestarted) then
      [*] = ;            begin
      [*] = ;               if (LanGetClientsCount<=1) then
      [*] = ;               begin
      [*] = ;                  LanDoReady;
      [*] = ;                  gMap.gamestage := gc_map_gamestage_started;
      [*] = ;               end
      [*] = ;               else
      [*] = ;               begin
      [*] = ;                  if not gbool_gui_onlinedoreadysent then
      [*] = ;                  begin
      [*] = ;                     log('DoProgress:LanDoReady');
      [*] = ;                     LanDoReady;
      [*] = ;                     gbool_gui_onlinedoreadysent := True;
      [*] = ;                     LanSendParser(gc_LAN_GAME_READY, _parser_ParserEmpty);
      [*] = ;                     SetProgressingPauseMode(True);
      [*] = ;                     ExecuteState('ShowPause');
      [*] = ;                  end;
      [*] = ;               end;
      [*] = ;            end;
      [*] = ;         end
      [*] = ;         else
      [*] = ;         gMap.gamestage := gc_map_gamestage_started;
      [*] = ;      end;
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;//ExecuteState('ShowAIDebug');
      [*] = ;
      [*] = ;if (GameManagerIsSelectionMode) or (IsKeyDownByName('LButton')) then
      [*] = ;begin
      [*] = ;   GUIUpdateKeys;
      [*] = ;   //GUIProgressShortcuts;
      [*] = ;   var bLeft : Boolean = IsKeyDownByName('Left');
      [*] = ;   var bRight : Boolean = IsKeyDownByName('Right');
      [*] = ;   var bUp : Boolean = IsKeyDownByName('Up');
      [*] = ;   var bDown : Boolean = IsKeyDownByName('Down');
      [*] = ;   if bLeft or bRight or bUp or bDown then
      [*] = ;   ExecuteState('OnCamera');
      [*] = ;end;
      [*] = ;
      [*] = ;ExecuteState('DoProgressQuickPlay2x2');
      [*] = ;
      [*] = ;if (gint_gui_newsshowvisible=0) then
      [*] = ;begin
      [*] = ;   var prevparent : Integer = GetGUIElementIndexByNameParent('news', _gui_GetTop);
      [*] = ;   var elmScrollLayer : Integer = GetGUIElementIndexByNameParent('newspn.news.news._scrolllayer', prevparent);
      [*] = ;   var lastScrollPos : Float;
      [*] = ;   if (elmScrollLayer<>0) then
      [*] = ;   begin
      [*] = ;      var elmVScroll : Integer = GetGUIElementVScroll(elmScrollLayer);
      [*] = ;      if (elmVScroll<>0) then
      [*] = ;      lastScrollPos := GetGUIScrollBarPosition(elmVScroll);
      [*] = ;   end;
      [*] = ;   if(lastScrollPos<>gfloat_gui_newslastscrollposition) then
      [*] = ;   begin
      [*] = ;      gfloat_news_lasttime := gfloat_news_lasttime + 5;
      [*] = ;      gfloat_gui_newslastscrollposition := lastScrollPos;
      [*] = ;   end;
      [*] = ;   var currenttime : Float = GetCurrentTime;
      [*] = ;   var delta : Float;
      [*] = ;   if (gint_news_manual=0) then
      [*] = ;   delta := currenttime-gfloat_news_lasttime
      [*] = ;   else
      [*] = ;   begin
      [*] = ;      delta := currenttime-gfloat_news_delaypoint;
      [*] = ;      if (delta>30) then
      [*] = ;      gint_news_manual := 0;
      [*] = ;      gfloat_news_lasttime := currenttime-1;
      [*] = ;   end;
      [*] = ;
      [*] = ;   // load bar progressing
      [*] = ;   const maxwidth = 400;
      [*] = ;   const cchangetime = 120;
      [*] = ;   const cupdatetime = 30;
      [*] = ;   {var widthpos : Integer = ClampInt(gfloat_news_loadbarpos, 2, maxwidth);
      [*] = ;   var newsloadbar : Integer = GetGUIElementIndexByNameParent('news.newspn.news.newsimage.back2._meter', _gui_GetTop);
      [*] = ;   if (newsloadbar<>0) then
      [*] = ;   SetGUIElementWidth(newsloadbar, gfloat_news_loadbarpos);
      [*] = ;   if (gfloat_news_loadbarpos<maxwidth) then
      [*] = ;   begin
      [*] = ;      var currentforloadbar : Float = currenttime-gfloat_news_lasttimeloadbar;
      [*] = ;      if (currentforloadbar>cupdatetime) then
      [*] = ;      begin
      [*] = ;         gfloat_news_loadbarpos := gfloat_news_loadbarpos+floor(cupdatetime*maxwidth/cchangetime);
      [*] = ;         gfloat_news_lasttimeloadbar := GetCurrentTime;
      [*] = ;      end;
      [*] = ;   end;}
      [*] = ;
      [*] = ;   if ((delta>cchangetime+1) and (gint_news_manual=0) and (not gbool_gui_newspanelscroll)) then
      [*] = ;   begin
      [*] = ;      var tempposvar : Integer;
      [*] = ;      if (gInterface.newspage=gint_news_limiter) then
      [*] = ;      gint_news_reverse := 1;
      [*] = ;      if (gInterface.newspage=1) then
      [*] = ;      gint_news_reverse := 0;
      [*] = ;      if (gint_news_reverse=0) then
      [*] = ;      begin
      [*] = ;         gInterface.newspage := gInterface.newspage+1;
      [*] = ;         tempposvar := gInterface.newspage;
      [*] = ;         gint_gui_newsnextpage := StrToInt(SubStr(gstring_validpagestoshow, tempposvar, 1));
      [*] = ;      end;
      [*] = ;      if (gint_news_reverse=1) then
      [*] = ;      begin
      [*] = ;         gInterface.newspage := gInterface.newspage-1;
      [*] = ;         tempposvar := gInterface.newspage;
      [*] = ;         gint_gui_newsnextpage := StrToInt(SubStr(gstring_validpagestoshow, tempposvar, 1));
      [*] = ;      end;
      [*] = ;      gfloat_news_lasttime := GetCurrentTime;
      [*] = ;      gfloat_news_loadbarpos := 0;
      [*] = ;      gbool_gui_newspanelscroll := False;
      [*] = ;      ExecuteState('ShowNews');
      [*] = ;   end;
      [*] = ;end;
      [*] = ;
      [*] = ;//if (gReconnectManager.btryreconnect) then
      [*] = ;//_misc_ReconnectManagerProgress;
      [*] = ;
      [*] = ;gint_gui_progresstick := gint_gui_progresstick+1;
      [*] = ;
      [*] = ;gbool_gui_gatefinished := False;
      [*] = ;
      [*] = ;_gui_DoProgressSound;
   struct.end
section.end

