hedgewars/uTeams.pas
changeset 13656 56a925256039
parent 13655 34aeaa627400
child 13657 de2b7bc00d40
--- a/hedgewars/uTeams.pas	Sat Aug 11 18:36:22 2018 +0200
+++ b/hedgewars/uTeams.pas	Sat Aug 11 21:43:55 2018 +0200
@@ -51,7 +51,7 @@
 
 var TeamsGameOver: boolean;
     NextClan: boolean;
-    SwapClan: LongInt;
+    SwapClanPre, SwapClanReal: LongInt;
 
 function CheckForWin: boolean;
 var AliveClan: PClan;
@@ -204,15 +204,18 @@
                 inc(c);
                 if c = ClansCount then
                     c:= 0;
+                if c = SwapClanReal then
+                    inc(TotalRoundsReal);
                 NextClan:= true;
                 end;
             end;
 
         with ClansArray[c]^ do
             begin
-            if (c = SwapClan) and (not PlacingHogs) and ((Succ(CurrTeam) mod TeamsNumber) = TagTeamIndex) then
+            if (not PlacingHogs) and ((Succ(CurrTeam) mod TeamsNumber) = TagTeamIndex) then
                 begin
-                inc(TotalRounds);
+                if c = SwapClanPre then
+                    inc(TotalRoundsPre);
                 end;
             end;
         end
@@ -221,9 +224,12 @@
         inc(c);
         if c = ClansCount then
             c:= 0;
-        if (c = SwapClan) and (not PlacingHogs) then
+        if (not PlacingHogs) then
             begin
-            inc(TotalRounds);
+            if c = SwapClanPre then
+                inc(TotalRoundsPre);
+            if c = SwapClanReal then
+                inc(TotalRoundsReal);
             end;
         end;
 
@@ -305,13 +311,22 @@
 
     end;
 
-// Determine clan ID to check to determine whether to increase TotalRounds
-if (SwapClan = -1) and (not PlacingHogs) then
+if not PlacingHogs then
+    if (TotalRoundsReal = -1) then
+        TotalRoundsReal:= 0;
+
+// Determine clan ID to check to determine whether to increase TotalRoundsPre/TotalRoundsReal
+if (not PlacingHogs) then
     begin
-    if (GameFlags and gfRandomOrder) <> 0 then
-        SwapClan:= 0
-    else
-        SwapClan:= ClansCount - 1;
+    if SwapClanPre = -1 then
+        begin
+        if (GameFlags and gfRandomOrder) <> 0 then
+            SwapClanPre:= 0
+        else
+            SwapClanPre:= ClansCount - 1;
+        end;
+    if SwapClanReal = -1 then
+        SwapClanReal:= CurrentTeam^.Clan^.ClanIndex;
     end;
 
 inc(CurrentTeam^.Clan^.TurnNumber);
@@ -900,7 +915,8 @@
 LocalAmmo:= -1;
 TeamsGameOver:= false;
 NextClan:= true;
-SwapClan:= -1;
+SwapClanPre:= -1;
+SwapClanReal:= -1;
 MaxTeamHealth:= 0;
 end;
 
@@ -946,7 +962,8 @@
     end;
 TeamsCount:= 0;
 ClansCount:= 0;
-SwapClan:= -1;
+SwapClanPre:= -1;
+SwapClanReal:= -1;
 end;
 
 end.