hedgewars/uTeams.pas
branchwebgl
changeset 9160 fc46e75f6b72
parent 9127 e350500c4edb
parent 9157 2f8b60b89121
child 9236 ddd675825672
--- a/hedgewars/uTeams.pas	Tue Jun 04 23:56:17 2013 +0200
+++ b/hedgewars/uTeams.pas	Sun Jun 09 12:22:53 2013 +0200
@@ -110,7 +110,7 @@
 end;
 
 procedure SwitchHedgehog;
-var c, i, t, j: LongWord;
+var c, i, t: LongWord;
     PrevHH, PrevTeam : LongWord;
 begin
 TargetPoint.X:= NoPointX;
@@ -190,18 +190,22 @@
                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
                 until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] < 256)) or (CurrHedgehog = PrevHH)
                 end
-        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))
+        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)
+                                begin
+                                if Effects[heFrozen] > 255 then Effects[heFrozen]:= max(255,Effects[heFrozen]-50000);
+                                if (Gear <> nil) and (Effects[heFrozen] < 256) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then
+                                    CurrHedgehog:= i
+                                end;
+            if (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then
+                inc(CurrentTeam^.Clan^.TurnNumber);
             end
 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256);