Fix stats screen caption showing only one winner if multiple teams have won
authorWuzzy <almikes@aol.com>
Thu, 28 Sep 2017 21:32:42 +0200
changeset 12579 0411e04cf12a
parent 12578 5b23c42ef150
child 12580 ef71e032254f
Fix stats screen caption showing only one winner if multiple teams have won
ChangeLog.txt
hedgewars/uTeams.pas
--- a/ChangeLog.txt	Thu Sep 28 19:26:22 2017 +0200
+++ b/ChangeLog.txt	Thu Sep 28 21:32:42 2017 +0200
@@ -251,6 +251,7 @@
  + Hedgewars creates 4 teams instead of 1 on its first launch
  + Allow to randomize hog names, hats, team name, flag, grave, voice and fort separately
  + “Random team” button is now able to randomly select from all available hats
+ * Fix flag being selectable for computer players although it had no effect
  * Campaign screen does no longer show AI-controlled teams
  * Campaign names and campaign mission names can now be translated
  * Creating randomized teams now randomizes (almost) every aspect
@@ -258,8 +259,8 @@
  * Clicking on "New" in weapon scheme editor now creates empty weapon scheme instead of default
  * Fix language names in language list being always in English
  * Prevent starting game with >48 hogs (because engine doesn't support it yet)
- * Team editor Fix flag being selectable for computer players although it had no effect
  * Fix the key for toggling team bars being incorrectly described
+ * Fix caption of stats screen showing only one winner if multiple teams have won
 
 Content Creation:
  + Theme objects can now have more than 1 in-land rect specified. You can specify the amount in theme.cfg by adding another number (and ,) before the first rect
--- a/hedgewars/uTeams.pas	Thu Sep 28 19:26:22 2017 +0200
+++ b/hedgewars/uTeams.pas	Thu Sep 28 21:32:42 2017 +0200
@@ -87,6 +87,7 @@
         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000);
         end
     else // win
+        begin
         with AliveClan^ do
             begin
             ts:= ansistring(Teams[0]^.TeamName);
@@ -94,12 +95,28 @@
                 begin
                 s:= FormatA(trmsg[sidWinner], ts);
                 cap:= FormatA(GetEventString(eidRoundWin), ts);
+                AddCaption(cap, cWhiteColor, capgrpGameState);
                 end
             else // clan wins
-                // FIXME: Clan needs a different message
                 begin
-                s:= FormatA(trmsg[sidWinner], ts);
-                cap:= FormatA(GetEventString(eidRoundWin), ts);
+                s:= '';
+                for j:= 0 to Pred(TeamsNumber) do
+                    begin
+                    (*
+                    Currently, the game result string is just the victory
+                    string concatenated multiple times. This assumes that
+                    sidWinner is a complete sentence.
+                    This might not work well for some languages.
+
+                    FIXME/TODO: Add event strings for 2, 3, 4 and >4 teams winning.
+                                 This requires FormatA to work with multiple parameters. *)
+                    ts:= Teams[j]^.TeamName;
+                    s:= s + ' ' + FormatA(trmsg[sidWinner], ts);
+
+                    // FIXME: Show victory captions one-by-one, not all at once
+                    cap:= FormatA(GetEventString(eidRoundWin), ts);
+                    AddCaption(cap, cWhiteColor, capgrpGameState);
+                    end;
                 end;
 
             for j:= 0 to Pred(TeamsNumber) do
@@ -112,12 +129,12 @@
                 AddVoice(sndFlawless, Teams[0]^.voicepack)
             else
                 AddVoice(sndVictory, Teams[0]^.voicepack);
+            end;
 
-            AddCaption(cap, cWhiteColor, capgrpGameState);
-            if SendGameResultOn then
-                SendStat(siGameResult, shortstring(s));
-            AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
-            end;
+        if SendGameResultOn then
+            SendStat(siGameResult, shortstring(s));
+        AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
+        end;
     SendStats;
     end;
 TeamsGameOver:= true;