# HG changeset patch
# User unc0rr
# Date 1426709932 -10800
# Node ID 4575977d3ce0087f2b6963fe47c337c31b7dbd27
# Parent  d84c725fe332b98b64c7bb95eda9a8adb68f1794
Don't spawn team widget sorter on each frame when in lag. Issue 'spectate 0' instead, and only on first lag occasion.

diff -r d84c725fe332 -r 4575977d3ce0 hedgewars/uCommandHandlers.pas
--- a/hedgewars/uCommandHandlers.pas	Wed Mar 18 23:13:37 2015 +0300
+++ b/hedgewars/uCommandHandlers.pas	Wed Mar 18 23:18:52 2015 +0300
@@ -27,6 +27,7 @@
 
 implementation
 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
+    , uVisualGearsList
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
 
 var prevGState: TGameState = gsConfirm;
@@ -776,7 +777,14 @@
 
 procedure chFastUntilLag(var s: shortstring);
 begin
-fastUntilLag:= StrToInt(s) <> 0
+    fastUntilLag:= StrToInt(s) <> 0;
+
+    if not fastUntilLag then
+    begin
+        // update health bars and the wind indicator
+        AddVisualGear(0, 0, vgtTeamHealthSorter);
+        AddVisualGear(0, 0, vgtSmoothWindBar)
+    end
 end;
 
 procedure chCampVar(var s:shortstring);
diff -r d84c725fe332 -r 4575977d3ce0 hedgewars/uIO.pas
--- a/hedgewars/uIO.pas	Wed Mar 18 23:13:37 2015 +0300
+++ b/hedgewars/uIO.pas	Wed Mar 18 23:18:52 2015 +0300
@@ -435,7 +435,11 @@
 
 isInLag:= (headcmd = nil) and tmpflag and (not CurrentTeam^.hasGone);
 
-if isInLag then fastUntilLag:= false
+if isInLag and fastUntilLag then 
+begin
+    ParseCommand('spectate 0', true);
+    fastUntilLag:= false
+end;
 end;
 
 procedure chFatalError(var s: shortstring);