blob: 8b950a454c1521001884026db3ddfa33698aa17d (
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
120
121
122
123
124
125
126
127
128
129
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#pragma warning (disable:4786)
#include <string>
#include "Player.h"
#include "MatchInfo.h"
using namespace std;
CPlayer::CPlayer()
:teams()
{
WONID=pid=svrPID=-1;
logontime=logofftime=reconnects=0;
name="uninitted";
}
void CPlayer::nameFound(time_t t, string alias)
{
if (aliases.atTime(t)!=alias)
{
aliases.add(t,alias);
}
name=aliases.favourite();
}
time_t CPlayer::plr_per_team_data::timeOn()
{
/*if (logofftime==0)
{
logofftime=g_pMatchInfo->logCloseTime();
}
return logofftime-logontime;
*/
return timeon;
}
time_t CPlayer::totalTimeOn()
{
if (logofftime==0)
{
logofftime=g_pMatchInfo->logCloseTime();
}
return logofftime-logontime;
}
double CPlayer::plr_per_team_data::rank()
{
double d = (kills-deaths);
double time=((double)timeOn())/1000.0;
if (time < .000001)
return d;
return d/time;
}
string CPlayer::plr_per_team_data::faveWeapon()
{
if (faveweapon=="" && weaponKills.begin()!=weaponKills.end())
{
faveweapkills=0;
//noKills=false;
map<string,int>::iterator weapIt=weaponKills.begin();
string& fave=(string&) (*weapIt).first;
int faveKills=(*weapIt).second;
for (weapIt;weapIt!=weaponKills.end();++weapIt)
{
const string& weapName=(*weapIt).first;
int kills=(*weapIt).second;
if (kills < faveKills)
continue;
fave=weapName;
faveKills=kills;
}
faveweapkills=faveKills;
faveweapon=fave;
}
return faveweapon;
}
int CPlayer::plr_per_team_data::faveWeapKills()
{
if (faveweapkills==0)
{
//calculate favourite weapon stats
faveWeapon();
}
return faveweapkills;
}
void CPlayer::merge()
{
perteam[ALL_TEAMS].kills=perteam[0].kills+perteam[1].kills+perteam[2].kills+perteam[3].kills;
perteam[ALL_TEAMS].deaths=perteam[0].deaths+perteam[1].deaths+perteam[2].deaths+perteam[3].deaths;
perteam[ALL_TEAMS].suicides=perteam[0].suicides+perteam[1].suicides+perteam[2].suicides+perteam[3].suicides;
perteam[ALL_TEAMS].teamkills=perteam[0].teamkills+perteam[1].teamkills+perteam[2].teamkills+perteam[3].teamkills;
perteam[ALL_TEAMS].teamkilled=perteam[0].teamkilled+perteam[1].teamkilled+perteam[2].teamkilled+perteam[3].teamkilled;
perteam[ALL_TEAMS].timeon=perteam[0].timeon+perteam[1].timeon+perteam[2].timeon+perteam[3].timeon;
for (int i=0;i<MAX_TEAMS;i++)
{
map<std::string,int>::iterator it;
for (it=perteam[i].weaponKills.begin();it!=perteam[i].weaponKills.end();++it)
{
string weapname=(*it).first;
int kills=(*it).second;
perteam[ALL_TEAMS].weaponKills[weapname]+=kills;
}
}
//this is probably only a shallow copy, but that's ok
perteam[ALL_TEAMS].classesplayed=allclassesplayed;
}
|