Make team disappear after 3 turns in 'gone' state
authorunc0rr
Mon, 30 Jun 2014 00:07:03 +0400
changeset 10345 2b264d67fac3
parent 10344 cceabf9628bb
child 10346 dd22bcf08e4f
Make team disappear after 3 turns in 'gone' state
hedgewars/uTeams.pas
hedgewars/uTypes.pas
--- a/hedgewars/uTeams.pas	Sun Jun 29 22:50:21 2014 +0400
+++ b/hedgewars/uTeams.pas	Mon Jun 30 00:07:03 2014 +0400
@@ -516,20 +516,26 @@
 procedure TeamGoneEffect(var Team: TTeam);
 var i: LongInt;
 begin
-with Team do
-    for i:= 0 to cMaxHHIndex do
-        with Hedgehogs[i] do
+    with Team do
+        if skippedTurns < 3 then
             begin
-            if Hedgehogs[i].GearHidden <> nil then
-                RestoreHog(@Hedgehogs[i]);
+                inc(skippedTurns);
+                ParseCommand('/skip', true);
+            end
+        else
+            for i:= 0 to cMaxHHIndex do
+                with Hedgehogs[i] do
+                    begin
+                    if Hedgehogs[i].GearHidden <> nil then
+                        RestoreHog(@Hedgehogs[i]);
 
-            if Gear <> nil then
-                begin
-                Gear^.Hedgehog^.Effects[heInvulnerable]:= 0;
-                Gear^.Damage:= Gear^.Health;
-                Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven)
-                end
-            end
+                    if Gear <> nil then
+                        begin
+                        Gear^.Hedgehog^.Effects[heInvulnerable]:= 0;
+                        Gear^.Damage:= Gear^.Health;
+                        Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven)
+                        end
+                    end
 end;
 
 procedure chAddHH(var id: shortstring);
@@ -654,6 +660,7 @@
                 AddChatString('** '+ TeamName + ' is gone'); // TODO: localize
                 if not CurrentTeam^.ExtDriven then SendIPC(_S'f' + s);
                 hasGone:= true;
+                skippedTurns:= 0;
                 isGoneFlagPengingToBeSet:= false;
                 RecountTeamHealth(TeamsArray[i])
                 end;
--- a/hedgewars/uTypes.pas	Sun Jun 29 22:50:21 2014 +0400
+++ b/hedgewars/uTypes.pas	Mon Jun 30 00:07:03 2014 +0400
@@ -403,6 +403,7 @@
             PlayerHash: shortstring;   // md5 hash of player name. For temporary enabling of hats as thank you. Hashed for privacy of players
             stats: TTeamStats;
             hasGone: boolean;
+            skippedTurns: Longword;
             isGoneFlagPengingToBeSet, isGoneFlagPengingToBeUnset: boolean;
             end;