hedgewars/uWorld.pas
changeset 13179 061d55939e47
parent 13161 26f0c3669b4e
child 13375 e202d58236b1
child 13784 c384117f90eb
--- a/hedgewars/uWorld.pas	Mon Mar 12 19:39:00 2018 +0100
+++ b/hedgewars/uWorld.pas	Mon Mar 12 22:53:28 2018 +0100
@@ -1027,20 +1027,21 @@
 
 
 procedure RenderTeamsHealth;
-var t, i,  h, smallScreenOffset, TeamHealthBarWidth : LongInt;
+var t, i, h, v, smallScreenOffset, TeamHealthBarWidth : LongInt;
     r: TSDL_Rect;
     highlight: boolean;
     hasVisibleHog: boolean;
     htex: PTexture;
 begin
-if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
+if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
     begin
     SetScale(1.5);
     smallScreenOffset:= cScreenHeight div 6;
-    if TeamsCount * 100 > Longword(cScreenHeight) then
+    if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
         Tint($FF,$FF,$FF,$80);
     end
 else smallScreenOffset:= 0;
+v:= 0; // for updating VisibleTeamsCount
 for t:= 0 to Pred(TeamsCount) do
     with TeamsArray[t]^ do
       begin
@@ -1050,6 +1051,8 @@
               hasVisibleHog:= true;
       if (TeamHealth > 0) and hasVisibleHog then
         begin
+        // count visible teams
+        inc(v);
         highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
 
         if highlight then
@@ -1104,7 +1107,7 @@
         // this approach should be faster than drawing all borders one by one tinted or not
         if highlight then
             begin
-            if TeamsCount * 100 > Longword(cScreenHeight) then
+            if VisibleTeamsCount * 100 > Longword(cScreenHeight) then
                 Tint($FF,$FF,$FF,$80)
             else untint;
 
@@ -1153,9 +1156,10 @@
 if smallScreenOffset <> 0 then
     begin
     SetScale(cDefaultZoomLevel);
-    if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
+    if VisibleTeamsCount * 20 > Longword(cScreenHeight) div 5 then
         untint;
     end;
+VisibleTeamsCount:= v;
 end;