hedgewars/uTeams.pas
branchwebgl
changeset 9127 e350500c4edb
parent 8833 c13ebed437cb
parent 9080 9b42757d7e71
child 9160 fc46e75f6b72
--- a/hedgewars/uTeams.pas	Thu Apr 04 14:37:19 2013 +0200
+++ b/hedgewars/uTeams.pas	Tue Jun 04 22:28:12 2013 +0200
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -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;
 
@@ -196,11 +188,22 @@
                 PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn)
                 repeat
                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
-                until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] = 0)) or (CurrHedgehog = PrevHH)
+                until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] < 256)) 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] < 50256)) 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}
@@ -247,6 +250,13 @@
     end;
 
 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);
 
 CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
 if CurWeapon^.Count = 0 then