hedgewars/uTeams.pas
changeset 8934 a4ec39eac0be
parent 8681 d0fc1dca739c
child 8935 701e3267edce
--- a/hedgewars/uTeams.pas	Sun Apr 21 01:38:52 2013 +0200
+++ b/hedgewars/uTeams.pas	Sun Apr 21 16:39:36 2013 -0400
@@ -110,7 +110,7 @@
 end;
 
 procedure SwitchHedgehog;
-var c, i, j: LongWord;
+var c, i, t, j: LongWord;
     PrevHH, PrevTeam : LongWord;
 begin
 TargetPoint.X:= NoPointX;
@@ -173,15 +173,7 @@
     if c = ClansCount then
         begin
         if not PlacingHogs then
-            begin
             inc(TotalRounds);
-            for i:= 0 to Pred(TeamsCount) do
-                with TeamsArray[i]^ do
-                    for j:= 0 to Pred(HedgehogsNumber) do
-                        with Hedgehogs[j] do
-                            if Effects[heFrozen] > 255 then
-                                Effects[heFrozen]:= max(255,Effects[heFrozen]-50000)
-            end;
         c:= 0
         end;
 
@@ -198,9 +190,20 @@
                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
                 until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] = 0)) or (CurrHedgehog = PrevHH)
                 end
-        until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0));
-        end
-until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] = 0);
+        until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256)) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0))
+        end;
+        if (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then
+            begin
+            inc(CurrentTeam^.Clan^.TurnNumber);
+            with CurrentTeam^.Clan^ do
+                for t:= 0 to Pred(TeamsNumber) do
+                    with Teams[t]^ do
+                        for i:= 0 to Pred(HedgehogsNumber) do
+                            with Hedgehogs[i] do
+                                if Effects[heFrozen] > 255 then
+                                    Effects[heFrozen]:= max(255,Effects[heFrozen]-50000);
+            end;
+until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256);
 
 SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]));
 {$IFDEF USE_TOUCH_INTERFACE}