summaryrefslogtreecommitdiff
path: root/utils/tfstats/allplayersstats.cpp
blob: c4b05cccb584c67823ed9549af48f0b86ceb5354 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Implementation of CAllPlayersStats
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "AllPlayersStats.h"
#include "PlayerReport.h"
#include "TextFile.h"

//------------------------------------------------------------------------------------------------------
// Function:	CAllPlayersStats::init
// Purpose:	 intializes the object
//------------------------------------------------------------------------------------------------------
void CAllPlayersStats::init()
{
}

//------------------------------------------------------------------------------------------------------
// Function:	CAllPlayersStats::generate
// Purpose:	generates intermediate data from match info
//------------------------------------------------------------------------------------------------------
void CAllPlayersStats::generate()
{
}

//------------------------------------------------------------------------------------------------------
// Function:	CAllPlayersStats::writeHTML
// Purpose:	writes out html based on the intermediate data generated by generate()
// Input:	html - the html file to output to
//------------------------------------------------------------------------------------------------------
void CAllPlayersStats::writeHTML(CHTMLFile& html)
{
	string filename;
	bool result=g_pApp->os->findfirstfile("*.tfs",filename);

	if (!result)
		return;
	
	multimap<double,CPlrPersist,greater<double> > ranksort;

	html.write("<table cols=1 cellspacing=0 border=0 cellpadding=10 bordercolor=black>\n");
	while(1)
	{
		CTextFile f(filename);
		pair<double,CPlrPersist> insertme;
		insertme.second.read(f);
		insertme.first=insertme.second.rank();
		
		ranksort.insert(insertme);

		if (!g_pApp->os->findnextfile(filename))
			break;
		

	}
	
	g_pApp->os->findfileclose();
	
	multimap<double,CPlrPersist,greater<double> >::iterator rankit=ranksort.begin();
	
	for (rankit;rankit!=ranksort.end();++rankit)
	{
		bool rowstarted=false;
		//double rank=rankit->first;
		CPlrPersist* pcpp=&(rankit->second);

		time_t cutoff=g_pMatchInfo->logOpenTime() - g_pApp->getCutoffSeconds();
		
		if (pcpp->lastplayed >= cutoff || !g_pApp->eliminateOldPlayers)
		{
			if (!rowstarted)
			{
				rowstarted=true;
				html.write("<tr>\n");
			}

			html.write("<td width=300 valign=top>");	
			CPlayerReport pr(pcpp);
			pr.writeHTML(html);
			html.write("</td>\n");
		}
		if (++rankit==ranksort.end())
		{
			if (rowstarted)
				html.write("</tr>\n");
			break;
		}


		//double rank=rankit->first;
		CPlrPersist* pcpp2=&(rankit->second);
		if (pcpp->lastplayed >= cutoff ||  !g_pApp->eliminateOldPlayers)
		{
			if (!rowstarted)
			{
				rowstarted=true;
				html.write("<tr>\n");
			}

			html.write("<td width=300 valign=top>");	
			CPlayerReport pr2(pcpp2);
			pr2.writeHTML(html);
			html.write("</td>\n");
		}
		if (rowstarted)
			html.write("</tr>\n");
	}

	html.write("</table>");

}