hedgewars/uVisualGearsHandlers.pas
changeset 9720 453a1c29b7e4
parent 9656 18422d205080
child 9761 b497a6c679cb
--- a/hedgewars/uVisualGearsHandlers.pas	Wed Nov 27 19:10:53 2013 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Thu Nov 28 00:41:35 2013 +0400
@@ -71,6 +71,7 @@
 procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword);
 procedure doStepStraightShot(Gear: PVisualGear; Steps: Longword);
 
+function isSorterActive: boolean; inline;
 procedure initModule;
 
 implementation
@@ -481,11 +482,17 @@
             dy, ny, dw: LongInt;
             team: PTeam;
             SortFactor: QWord;
+            hdw: array[0..cMaxHHIndex] of LongInt;
             end;
     currsorter: PVisualGear = nil;
 
+function isSorterActive: boolean; inline;
+begin
+    isSorterActive:= currsorter <> nil
+end;
+
 procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword);
-var i, t: LongInt;
+var i, t, h: LongInt;
 begin
 for t:= 1 to min(Steps, Gear^.Timer) do
     begin
@@ -496,7 +503,13 @@
                 begin
                 {$WARNINGS OFF}
                 team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div cSorterWorkTime;
-                team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime;
+                team^.TeamHealthBarHealth:= team^.TeamHealth + dw * LongInt(Gear^.Timer) div cSorterWorkTime;
+
+                for h:= 0 to cMaxHHIndex do
+                    if (team^.Hedgehogs[h].Gear <> nil) then
+                        team^.Hedgehogs[h].HealthBarHealth:= team^.Hedgehogs[h].Gear^.Health + hdw[h] * LongInt(Gear^.Timer) div cSorterWorkTime
+                    else
+                        team^.Hedgehogs[h].HealthBarHealth:= hdw[h] * LongInt(Gear^.Timer) div cSorterWorkTime;
                 {$WARNINGS ON}
                 end;
     end;
@@ -513,7 +526,7 @@
 procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword);
 var i: Longword;
     b: boolean;
-    t: LongInt;
+    t, h: LongInt;
 begin
 Steps:= Steps; // avoid compiler hint
 
@@ -522,7 +535,7 @@
         begin
         team:= TeamsArray[t];
         dy:= team^.DrawHealthY;
-        dw:= team^.TeamHealthBarWidth - team^.NewTeamHealthBarWidth;
+        dw:= team^.TeamHealthBarHealth - team^.TeamHealth;
         if team^.TeamHealth > 0 then
             begin
             SortFactor:= team^.Clan^.ClanHealth;
@@ -531,6 +544,12 @@
             end
         else
             SortFactor:= 0;
+
+        for h:= 0 to cMaxHHIndex do
+            if (team^.Hedgehogs[h].Gear <> nil) then
+                hdw[h]:= team^.Hedgehogs[h].HealthBarHealth - team^.Hedgehogs[h].Gear^.Health
+            else
+                hdw[h]:= team^.Hedgehogs[h].HealthBarHealth;
         end;
 
 if TeamsCount > 1 then