Fix hedgehogs switching
authorunc0rr
Tue, 03 Jul 2007 20:11:48 +0000
changeset 552 2167020d3bc0
parent 551 86bc0430ba17
child 553 5478386d935f
Fix hedgehogs switching
hedgewars/uTeams.pas
--- a/hedgewars/uTeams.pas	Tue Jul 03 17:06:18 2007 +0000
+++ b/hedgewars/uTeams.pas	Tue Jul 03 20:11:48 2007 +0000
@@ -135,6 +135,7 @@
 var c: LongWord;
     t: LongWord;
     g: PGear;
+    PrevHH, PrevTeam: LongWord;
 begin
 FreeActionsList;
 TargetPoint.X:= NoPointX;
@@ -155,13 +156,17 @@
   c:= Succ(c) mod ClansCount;
   with ClansArray[c]^ do
     repeat
+    PrevTeam:= CurrTeam;
     CurrTeam:= Succ(CurrTeam) mod TeamsNumber;
     CurrentTeam:= Teams[CurrTeam];
     with CurrentTeam^ do
+      begin
+      PrevHH:= CurrHedgehog;
       repeat
-      CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
-      until Hedgehogs[CurrHedgehog].Gear <> nil;
-    until CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil;
+        CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
+      until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
+      end
+    until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam);
 until CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil;
 
 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do