Fix TotalRounds counting rounds a couple of turns too late
authorWuzzy <Wuzzy2@mail.ru>
Wed, 07 Feb 2018 12:30:11 +0100
changeset 12924 0f02dd1ff4c9
parent 12923 6deb29364723
child 12925 21827fc9ca98
Fix TotalRounds counting rounds a couple of turns too late
ChangeLog.txt
hedgewars/uTeams.pas
--- a/ChangeLog.txt	Wed Feb 07 11:03:14 2018 +0100
+++ b/ChangeLog.txt	Wed Feb 07 12:30:11 2018 +0100
@@ -24,6 +24,7 @@
 Lua API:
  + New call: WriteLnToChat(string): Add a line in the chat
  * Fix call: SetWeapon(amNothing) now unselects weapon
+ * Fix global: TotalRounds was stuck at -1 for several turns
 
 ====================== 0.9.23 ======================
 HIGHLIGHTS:
--- a/hedgewars/uTeams.pas	Wed Feb 07 11:03:14 2018 +0100
+++ b/hedgewars/uTeams.pas	Wed Feb 07 12:30:11 2018 +0100
@@ -191,23 +191,26 @@
 c:= CurrentTeam^.Clan^.ClanIndex;
 repeat
     with ClansArray[c]^ do
-        if (CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0) then
+        if (GameFlags and gfTagTeam) <> 0 then
             begin
-            TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber;
-            CurrTeam:= Pred(CurrTeam) mod TeamsNumber;
-            inc(c);
-            NextClan:= true;
-            end;
+            if (CurrTeam = TagTeamIndex) then
+                begin
+                if (c = 0) and (not PlacingHogs) then
+                    inc(TotalRounds);
+                TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber;
+                CurrTeam:= Pred(CurrTeam) mod TeamsNumber;
+                inc(c);
+                NextClan:= true;
+                end;
+            end
+        else if (c = 0) and (not PlacingHogs) then
+            inc(TotalRounds);
 
     if (GameFlags and gfTagTeam) = 0 then
         inc(c);
 
     if c = ClansCount then
-        begin
-        if not PlacingHogs then
-            inc(TotalRounds);
-        c:= 0
-        end;
+        c:= 0;
 
     with ClansArray[c]^ do
         begin