From d6aca6fcc07fcff3c98e62fb0ac550c7c23aa2cc Mon Sep 17 00:00:00 2001 From: Ronald Reagan Date: Thu, 10 Jan 2013 09:10:41 +0000 Subject: [PATCH] FFA winner message git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7050 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- changelog.txt | 3 ++- source/src/scoreboard.cpp | 45 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 56a241d3..79a85733 100644 --- a/changelog.txt +++ b/changelog.txt @@ -84,7 +84,8 @@ Rendering / HUD / ... [*] screenshotscale - in-engine scaling of screenshots. [*] showtargetname - turns on/off showing the player name on the HUD when in your crosshair. [*] Scoreboard doesn't show ping/score/pj in singleplayer -[*] Customizable scoreboard, ability to display ratio +[*] Customizable scoreboard, ability to display ratio +[*] Scoreboard shows the winner of each game. [*] showspeed - turns speed indicator on/off [*] Improved tab completion. diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 1bd9dbe5..28fbdf7f 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -306,6 +306,39 @@ int getwinningteam() { } +playerent *getWinningPlayer() { + playerent *winner; + int winningscore = 0; + bool istie = true; //If no players, then it is a tie. + + int curscore; + + loopv(players) { + if (!players[i]) continue; + curscore = m_flags ? players[i]->flagscore : players[i]->frags; + if (winningscore < curscore) { + winningscore = curscore; + winner = players[i]; + istie = false; + } + else if (winningscore == curscore) { + istie = true; + } + } + + //Lets look at player1 + curscore = m_flags ? player1->flagscore : player1->frags; + if (winningscore < curscore) { + winningscore = curscore; + winner = player1; + istie = false; + } + else if (winningscore == curscore) { + istie = true; + } + return (istie ? NULL : winner); +} + void renderscores(void *menu, bool init) { if(needscoresreorder) reorderscorecolumns(); @@ -351,8 +384,18 @@ void renderscores(void *menu, bool init) concatstring(modeline, ", \f3CLA wins!"); } } + else { //FFA modes + playerent *winner = getWinningPlayer(); + if (winner == NULL) { + concatstring(modeline, ", \f2it's a tie!"); + } + else { + defformatstring(winnerstr)(", \f1%s wins!", winner->name); + concatstring(modeline, winnerstr); + } + } } - else + else { defformatstring(timestr)(", %d %s remaining", minutesremaining, minutesremaining==1 ? "minute" : "minutes"); concatstring(modeline, timestr);