1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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");
}
}
|