Fix engine freeze when one of the teams is killed before its first turn, number of hedgehogs in that team < 8, and game still goes on
authorunc0rr
Fri, 16 Jan 2009 23:27:25 +0000
changeset 1687 a73c8cda1ed1
parent 1686 f42dbc52225c
child 1688 d94ac781a8e3
Fix engine freeze when one of the teams is killed before its first turn, number of hedgehogs in that team < 8, and game still goes on
hedgewars/uTeams.pas
--- a/hedgewars/uTeams.pas	Fri Jan 16 18:40:52 2009 +0000
+++ b/hedgewars/uTeams.pas	Fri Jan 16 23:27:25 2009 +0000
@@ -185,7 +185,7 @@
 			CurrentTeam:= Teams[CurrTeam];
 			with CurrentTeam^ do
 				begin
-				PrevHH:= CurrHedgehog;
+				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) or (CurrHedgehog = PrevHH)