hide health bars of dead teams
authorunc0rr
Sat, 01 Sep 2012 21:36:57 +0200
changeset 7644 ed7fecd0f5fd
parent 7643 97b98bcfd056
child 7645 0e3c2dd9fee6
hide health bars of dead teams
hedgewars/VGSHandlers.inc
hedgewars/uWorld.pas
--- a/hedgewars/VGSHandlers.inc	Sat Sep 01 12:09:59 2012 -0400
+++ b/hedgewars/VGSHandlers.inc	Sat Sep 01 21:36:57 2012 +0200
@@ -434,7 +434,7 @@
 procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword);
 var i, t: LongInt;
 begin
-for t:= 1 to Steps do
+for t:= 1 to min(Steps, Gear^.Timer) do
     begin
     dec(Gear^.Timer);
     if (Gear^.Timer and 15) = 0 then
@@ -442,18 +442,18 @@
             with thexchar[i] do
                 begin
                 {$WARNINGS OFF}
-                team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640;
+                team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div cSorterWorkTime;
                 team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime;
                 {$WARNINGS ON}
                 end;
+    end;
 
-    if (Gear^.Timer = 0) or (currsorter <> Gear) then
-        begin
-        if currsorter = Gear then
-            currsorter:= nil;
-        DeleteVisualGear(Gear);
-        exit
-        end
+if (Gear^.Timer = 0) or (currsorter <> Gear) then
+    begin
+    if currsorter = Gear then
+        currsorter:= nil;
+    DeleteVisualGear(Gear);
+    exit
     end
 end;
 
@@ -463,15 +463,21 @@
     t: LongInt;
 begin
 Steps:= Steps; // avoid compiler hint
+
 for t:= 0 to Pred(TeamsCount) do
     with thexchar[t] do
         begin
-        dy:= TeamsArray[t]^.DrawHealthY;
-        dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth;
         team:= TeamsArray[t];
-        SortFactor:= TeamsArray[t]^.Clan^.ClanHealth;
-        SortFactor:= (SortFactor shl  3) + TeamsArray[t]^.Clan^.ClanIndex;
-        SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth;
+        dy:= team^.DrawHealthY;
+        dw:= team^.TeamHealthBarWidth - team^.NewTeamHealthBarWidth;
+        if team^.TeamHealth > 0 then
+            begin
+            SortFactor:= team^.Clan^.ClanHealth;
+            SortFactor:= (SortFactor shl  3) + team^.Clan^.ClanIndex;
+            SortFactor:= (SortFactor shl 30) + team^.TeamHealth;
+            end
+        else
+            SortFactor:= 0;
         end;
 
 if TeamsCount > 1 then
@@ -489,12 +495,13 @@
 
 t:= - 4;
 for i:= 0 to Pred(TeamsCount) do
-    with thexchar[i] do
-        begin
-        dec(t, team^.HealthTex^.h + 2);
-        ny:= t;
-        dy:= dy - ny
-        end;
+        with thexchar[i] do
+          if team^.TeamHealth > 0 then
+            begin
+            dec(t, team^.HealthTex^.h + 2);
+            ny:= t;
+            dy:= dy - ny
+            end;
 
 Gear^.Timer:= cSorterWorkTime;
 Gear^.doStep:= @doStepTeamHealthSorterWork;
--- a/hedgewars/uWorld.pas	Sat Sep 01 12:09:59 2012 -0400
+++ b/hedgewars/uWorld.pas	Sat Sep 01 21:36:57 2012 +0200
@@ -1307,6 +1307,7 @@
 else smallScreenOffset:= 0;
 for t:= 0 to Pred(TeamsCount) do
     with TeamsArray[t]^ do
+      if TeamHealth > 0 then
         begin
         h:= 0;
         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);