diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/tfstats/scoreboard.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/tfstats/scoreboard.cpp')
| -rw-r--r-- | utils/tfstats/scoreboard.cpp | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/utils/tfstats/scoreboard.cpp b/utils/tfstats/scoreboard.cpp new file mode 100644 index 0000000..1085b9f --- /dev/null +++ b/utils/tfstats/scoreboard.cpp @@ -0,0 +1,126 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Implementation of CScoreboard +// +// $Workfile: $ +// $Date: $ +// +//------------------------------------------------------------------------------------------------------ +// $Log: $ +// +// $NoKeywords: $ +//=============================================================================// +#include "Scoreboard.h" + + +//------------------------------------------------------------------------------------------------------ +// Function: CScoreboard::init +// Purpose: initializes the object +//------------------------------------------------------------------------------------------------------ +void CScoreboard::init() +{ +} + +//------------------------------------------------------------------------------------------------------ +// Function: CScoreboard::generate +// Purpose: generates intermediate data based on match info +//------------------------------------------------------------------------------------------------------ +void CScoreboard::generate() +{ +} + +//------------------------------------------------------------------------------------------------------ +// Function: CScoreboard::writeHTML +// Purpose: generates html from the intermediate data generated by generate() +// Input: html - the html file to write the html code into +//------------------------------------------------------------------------------------------------------ +void CScoreboard::writeHTML(CHTMLFile& html) +{ + CPlayerListIterator i; + int t; + + bool teamFound=false; + + for (t=0;t<MAX_TEAMS;t++) + { + if (!g_pMatchInfo->teamExists(t)) + continue; + + if (!teamFound) + { + html.write("<p>"); + html.write("<img src=\"%s/scores.gif\">",g_pApp->supportHTTPPath.c_str()); + teamFound=true; + } + + int totalkills=0; + int totaldeaths=0; + double teamrank=0; + int numplrs=0; + + html.write("<table cellpadding=3 cellspacing=0 border=0 class=scores>"); + html.write("<tr class=header>"); + html.write("<td ><font class=boardtext>%s</font></td>",g_pMatchInfo->teamName(t).c_str()); + html.write("<td><font class=boardtext>Kills</font></td>"); + html.write("<td><font class=boardtext>Deaths</font></td>"); + html.write("<td><font class=boardtext>Rank</font></td>"); + html.write("</tr>"); + + multimap<double,CPlayer> ranksort; + for (i=g_pMatchInfo->playerBegin();i!=g_pMatchInfo->playerEnd();++i) + { + pair<PID,CPlayer> plr=(*i); + PID pid=plr.first; + CPlayer& p=plr.second; + + if (p.teams.contains(t)) + { + double rank=p.perteam[t].rank(); + pair<double,CPlayer> insertme(rank,p); + ranksort.insert(insertme); + //ranksort[rank]=p; + } + } + + multimap<double,CPlayer>::reverse_iterator i2; + for (i2=ranksort.rbegin();i2!=ranksort.rend();++i2) + { + double rank=(*i2).first; + CPlayer p=(*i2).second; + + if (!p.teams.contains(t)) + { + continue; + } + + html.write("<tr>\n"); + html.write("\n"); + html.write("<td width=140><font class=player%s>%s</font></td>\n",Util::teamcolormap[t],p.name.c_str()); + html.write("<td width=100><font class=boardtext>%li</font></td>\n",p.perteam[t].kills); + html.write("<td width=100><font class=boardtext>%li</font></td>\n",p.perteam[t].deaths); + html.write("<td width=100><font class=boardtext>%.2lf</font></td>\n",rank); + + html.write("</tr>\n"); + totalkills+=p.perteam[t].kills; + totaldeaths+=p.perteam[t].deaths; + teamrank+=rank; + numplrs++; + } + + html.write("<tr>"); + html.write("<td colspan=4><hr></td>"); + html.write("</tr>"); + html.write("<tr>"); + html.write("<td><font class=boardtext>totals</font></td>"); + html.write("<td><font class=boardtext>%li</font></td>",totalkills); + html.write("<td><font class=boardtext>%li</font></td>",totaldeaths); + html.write("<td><font class=boardtext>%.2lf (avg)</font></td>",teamrank/numplrs); + html.write("</tr>"); + html.write("</table>\n<p>\n"); + + + } + +} + + |