Fix player rankings getting confused if a clan was revived
authorWuzzy <Wuzzy2@mail.ru>
Tue, 04 Sep 2018 16:12:53 +0200
changeset 13760 b1177e9c9ee9
parent 13759 f0cb47f0bfaf
child 13761 bef952489e0e
Fix player rankings getting confused if a clan was revived
hedgewars/uGearsHandlersMess.pas
hedgewars/uStats.pas
hedgewars/uTeams.pas
hedgewars/uTypes.pas
--- a/hedgewars/uGearsHandlersMess.pas	Tue Sep 04 15:03:35 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Sep 04 16:12:53 2018 +0200
@@ -5908,6 +5908,8 @@
                 RenderHealth(resgear^.Hedgehog^);
                 RecountTeamHealth(resgear^.Hedgehog^.Team);
                 resgear^.Hedgehog^.Effects[heResurrected]:= 1;
+                { Reviving a hog implies its clan is now alive, too. }
+                resgear^.Hedgehog^.Team^.Clan^.DeathLogged:= false;
                 s:= ansistring(resgear^.Hedgehog^.Name);
                 AddCaption(FormatA(GetEventString(eidResurrected), s), capcolDefault, capgrpMessage);
                 // only make hat-less hedgehogs look like zombies, preserve existing hats
--- a/hedgewars/uStats.pas	Tue Sep 04 15:03:35 2018 +0200
+++ b/hedgewars/uStats.pas	Tue Sep 04 16:12:53 2018 +0200
@@ -164,15 +164,15 @@
                 StepDied:= false;
                 end;
 
-// Remember which clans died in this turn
+// Write into the death log which clans died in this turn,
+// important for final rankings.
 c:= 0;
 newEntry:= nil;
 for t:= 0 to Pred(ClansCount) do
     with ClansArray[t]^ do
         begin
-        if (ClanHealth = 0) and (ClansArray[t]^.DiedThisTurn = false) then
+        if (ClanHealth = 0) and (ClansArray[t]^.DeathLogged = false) then
             begin
-            ClansArray[t]^.DiedThisTurn:= true;
             if c = 0 then
                 begin
                 new(newEntry);
@@ -183,6 +183,7 @@
             newEntry^.KilledClans[c]:= ClansArray[t];
             inc(c);
             newEntry^.KilledClansCount := c;
+            ClansArray[t]^.DeathLogged:= true;
             end;
 
         if SendHealthStatsOn then
@@ -386,7 +387,12 @@
     The losing clans are ranked in the reverse order they died.
     The clan that died last is ranked 2nd,
     the clan that died second to last is ranked 3rd,
-    and so on. }
+    and so on.
+    Clans that died in the same turn share their rank.
+    If a clan died multiple times in the match
+    (e.g. due to resurrection), only the *latest* death of
+    that clan counts (handled in gtResurrector).
+    }
     deathEntry := ClanDeathLog;
     i:= 0;
     if SendRankingStatsOn then
--- a/hedgewars/uTeams.pas	Tue Sep 04 15:03:35 2018 +0200
+++ b/hedgewars/uTeams.pas	Tue Sep 04 16:12:53 2018 +0200
@@ -310,7 +310,6 @@
             if ClansArray[i] <> nil then
                 begin
                 ClansArray[i]^.TurnNumber:= 0;
-                ClansArray[i]^.DiedThisTurn:= false;
                 end;
         ResetWeapons
         end;
@@ -475,7 +474,7 @@
         Color:= TeamColor;
         TagTeamIndex:= 0;
         Flawless:= true;
-        DiedThisTurn:= false;
+        DeathLogged:= false;
         StatsHandled:= false;
         end
     end
--- a/hedgewars/uTypes.pas	Tue Sep 04 15:03:35 2018 +0200
+++ b/hedgewars/uTypes.pas	Tue Sep 04 16:12:53 2018 +0200
@@ -453,8 +453,8 @@
             ClanHealth: LongInt;
             ClanIndex: LongInt;
             TurnNumber: LongWord;
-            DiedThisTurn: boolean; // true if clan died in current turn
-            StatsHandled : boolean; // true if clan has been handled for stats screen
+            DeathLogged: boolean; // true if clan is dead and its latest death has been logged in the clan death log
+            StatsHandled : boolean; // true if clan's rank has been handled for stats screen
             Flawless: boolean;
             end;