Update clan passive status when team died / got resurrected
authorWuzzy <Wuzzy2@mail.ru>
Wed, 16 Jan 2019 22:39:27 +0100
changeset 14616 4638aa2ea8f2
parent 14615 c3c0f94a5333
child 14617 244699a97734
Update clan passive status when team died / got resurrected
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/hedgewars/uGearsHandlersMess.pas	Wed Jan 16 21:32:25 2019 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Wed Jan 16 22:39:27 2019 +0100
@@ -5994,6 +5994,8 @@
                     resgear^.Hedgehog^.Team^.hasKing:= true;
                 { Reviving a hog implies its clan is now alive, too. }
                 resgear^.Hedgehog^.Team^.Clan^.DeathLogged:= false;
+                if (not resgear^.Hedgehog^.Team^.Passive) then
+                    resgear^.Hedgehog^.Team^.Clan^.Passive:= false;
                 s:= ansistring(resgear^.Hedgehog^.Name);
                 AddCaption(FormatA(GetEventString(eidResurrected), s), capcolDefault, capgrpMessage);
                 // only make hat-less hedgehogs look like zombies, preserve existing hats
--- a/hedgewars/uGearsList.pas	Wed Jan 16 21:32:25 2019 +0100
+++ b/hedgewars/uGearsList.pas	Wed Jan 16 22:39:27 2019 +0100
@@ -866,6 +866,25 @@
                             Hedgehogs[t].GearHidden^.Health:= 0  // hog is still hidden. if tardis should return though, lua, eh...
             end;
 
+        // Update passive status of clan
+        if (not Gear^.Hedgehog^.Team^.Clan^.Passive) then
+            begin
+            Gear^.Hedgehog^.Team^.Clan^.Passive:= true;
+            for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
+                begin
+                with team^.Clan^.Teams[i]^ do
+                    if (not Passive) then
+                        for t:= 0 to cMaxHHIndex do
+                            if (Hedgehogs[t].Gear <> nil) or (Hedgehogs[t].GearHidden <> nil) then
+                                begin
+                                Gear^.Hedgehog^.Team^.Clan^.Passive:= false;
+                                break;
+                                end;
+                if (not Gear^.Hedgehog^.Team^.Clan^.Passive) then
+                    break;
+                end;
+            end;
+
         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
         // same stand for CheckHHDamage
         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then