Fix TotalRounds increasing incorrectly if gfRandomOrder is off
authorWuzzy <Wuzzy2@mail.ru>
Thu, 09 Aug 2018 19:14:58 +0200
changeset 13649 d5fe7db1baa9
parent 13648 f606ca8b80fd
child 13650 34aeaa627400
Fix TotalRounds increasing incorrectly if gfRandomOrder is off
hedgewars/uTeams.pas
--- a/hedgewars/uTeams.pas	Thu Aug 09 17:49:17 2018 +0200
+++ b/hedgewars/uTeams.pas	Thu Aug 09 19:14:58 2018 +0200
@@ -51,6 +51,7 @@
 
 var TeamsGameOver: boolean;
     NextClan: boolean;
+    SwapClan: LongInt;
 
 function CheckForWin: boolean;
 var AliveClan: PClan;
@@ -204,12 +205,10 @@
     if (GameFlags and gfTagTeam) = 0 then
         inc(c);
 
+    if (c = SwapClan) and (not PlacingHogs) then
+        inc(TotalRounds);
     if c = ClansCount then
-        begin
-        if not PlacingHogs then
-            inc(TotalRounds);
-        c:= 0
-        end;
+        c:= 0;
 
     with ClansArray[c]^ do
         begin
@@ -285,9 +284,17 @@
             if ClansArray[i] <> nil then
                 ClansArray[i]^.TurnNumber:= 0;
         ResetWeapons
-        end
+        end;
+
     end;
 
+// Clan ID (+1) to check to determine whether to increase TotalRounds
+if (SwapClan = -1) and (not PlacingHogs) then
+    if (GameFlags and gfRandomOrder) <> 0 then
+        SwapClan:= ClansCount
+    else
+        SwapClan:= 1;
+
 inc(CurrentTeam^.Clan^.TurnNumber);
 with CurrentTeam^.Clan^ do
     for t:= 0 to Pred(TeamsNumber) do
@@ -874,6 +881,7 @@
 LocalAmmo:= -1;
 TeamsGameOver:= false;
 NextClan:= true;
+SwapClan:= -1;
 MaxTeamHealth:= 0;
 end;
 
@@ -919,6 +927,7 @@
     end;
 TeamsCount:= 0;
 ClansCount:= 0;
+SwapClan:= -1;
 end;
 
 end.