# HG changeset patch # User Wuzzy # Date 1520595816 -3600 # Node ID e330feceb6624d600c0e3d6bf7c2517788964362 # Parent 674b76f2d64a9c0f69af0bb6e8ce5872e5a740ad Hide team bar if all hedgehogs in it are hidden or dead This fixes some minor spoilers in the campaigns, especially A Classic Fairytale. This only affects hogs hidden with HideHog. Invisible hogs (gstInvisible) don't affect the team bars. diff -r 674b76f2d64a -r e330feceb662 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Fri Mar 09 11:32:36 2018 +0100 +++ b/hedgewars/uGearsHandlersMess.pas Fri Mar 09 12:43:36 2018 +0100 @@ -257,7 +257,8 @@ Message := Message and (not gmAttack); end; HH^.GearHidden:= HH^.Gear; - HH^.Gear:= nil + HH^.Gear:= nil; + AddVisualGear(0, 0, vgtTeamHealthSorter); end; diff -r 674b76f2d64a -r e330feceb662 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Fri Mar 09 11:32:36 2018 +0100 +++ b/hedgewars/uTeams.pas Fri Mar 09 12:43:36 2018 +0100 @@ -539,7 +539,8 @@ HH^.Gear^.State:= (HH^.Gear^.State and (not (gstHHDriven or gstInvisible or gstAttacking))) or gstAttacked; AddCI(HH^.Gear); HH^.Gear^.Active:= true; - ScriptCall('onHogRestore', HH^.Gear^.Uid) + ScriptCall('onHogRestore', HH^.Gear^.Uid); + AddVisualGear(0, 0, vgtTeamHealthSorter); end; procedure RestoreTeamsFromSave; diff -r 674b76f2d64a -r e330feceb662 hedgewars/uVisualGearsHandlers.pas --- a/hedgewars/uVisualGearsHandlers.pas Fri Mar 09 11:32:36 2018 +0100 +++ b/hedgewars/uVisualGearsHandlers.pas Fri Mar 09 12:43:36 2018 +0100 @@ -561,7 +561,7 @@ procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); var i: Longword; - b: boolean; + b, noHogs: boolean; t, h: LongInt; begin {$IFNDEF PAS2C} @@ -606,12 +606,20 @@ t:= - 4; for i:= 0 to Pred(TeamsCount) do with thexchar[i] do - if team^.TeamHealth > 0 then + begin + noHogs:= true; + for h:= 0 to cMaxHHIndex do + // Check if all hogs are hidden + if team^.Hedgehogs[h].Gear <> nil then + noHogs:= false; + // Skip team bar if all hogs are dead or hidden + if (team^.TeamHealth > 0) and (noHogs = false) then begin dec(t, team^.Clan^.HealthTex^.h + 2); ny:= t; dy:= dy - ny end; + end; Gear^.Timer:= cSorterWorkTime; Gear^.doStep:= @doStepTeamHealthSorterWork; diff -r 674b76f2d64a -r e330feceb662 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Fri Mar 09 11:32:36 2018 +0100 +++ b/hedgewars/uWorld.pas Fri Mar 09 12:43:36 2018 +0100 @@ -1030,6 +1030,7 @@ var t, i, h, 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 @@ -1042,7 +1043,12 @@ else smallScreenOffset:= 0; for t:= 0 to Pred(TeamsCount) do with TeamsArray[t]^ do - if TeamHealth > 0 then + begin + hasVisibleHog:= false; + for i:= 0 to cMaxHHIndex do + if (Hedgehogs[i].Gear <> nil) then + hasVisibleHog:= true; + if (TeamHealth > 0) and hasVisibleHog then begin highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); @@ -1143,6 +1149,7 @@ DrawSpriteRotatedF(sprFinger, h, cScreenHeight + DrawHealthY + smallScreenOffset + 2 + SpritesData[sprFinger].Width div 4, 0, 1, -90); end; end; + end; if smallScreenOffset <> 0 then begin SetScale(cDefaultZoomLevel);