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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef CS_STEAMSTATS_H
#define CS_STEAMSTATS_H
#ifdef _WIN32
#pragma once
#endif
#include "steam/steam_api.h"
#include "GameEventListener.h"
#include "../game/shared/cstrike/cs_gamestats_shared.h"
struct SRoundData : public BaseStatData
{
SRoundData( const StatsCollection_t *pRoundData )
{
nRoundTime = (*pRoundData)[CSSTAT_PLAYTIME];
nWasKilled = (*pRoundData)[CSSTAT_DEATHS];
nIsMVP = (*pRoundData)[CSSTAT_MVPS];
nMoneySpent = (*pRoundData)[CSSTAT_MONEY_SPENT];
nStartingMoney = -1;// We'll get this data separately
nRoundEndReason = Invalid_Round_End_Reason;// We'll get this data separately
nRevenges = (*pRoundData)[CSSTAT_REVENGES];
nDamageDealt = (*pRoundData)[CSSTAT_DAMAGE];
if ( (*pRoundData)[CSSTAT_T_ROUNDS_WON] )
{
nWinningTeamID = TEAM_TERRORIST;
if ( (*pRoundData)[CSSTAT_ROUNDS_WON] )
{
nTeamID = TEAM_TERRORIST;
}
else
{
nTeamID = TEAM_CT;
}
}
else
{
nWinningTeamID = TEAM_CT;
if ( (*pRoundData)[CSSTAT_ROUNDS_WON] )
{
nTeamID = TEAM_CT;
}
else
{
nTeamID = TEAM_TERRORIST;
}
}
}
uint32 nRoundTime;
int nTeamID;
int nWinningTeamID;
int nWasKilled;
int nIsMVP;
int nDamageDealt;
int nMoneySpent;
int nStartingMoney;
int nRevenges;
int nRoundEndReason;
BEGIN_STAT_TABLE( "CSSRoundData" )
REGISTER_STAT_NAMED( nRoundTime, "RoundTime" )
REGISTER_STAT_NAMED( nTeamID, "TeamID" )
REGISTER_STAT_NAMED( nWinningTeamID, "WinningTeamID" )
REGISTER_STAT_NAMED( nWasKilled, "WasKilled" )
REGISTER_STAT_NAMED( nIsMVP, "IsMvp" )
REGISTER_STAT_NAMED( nDamageDealt, "DamageDealt" )
REGISTER_STAT_NAMED( nMoneySpent, "MoneySpent" )
REGISTER_STAT_NAMED( nStartingMoney, "StartingMoney" )
REGISTER_STAT_NAMED( nRevenges, "Revenges" )
REGISTER_STAT_NAMED( nRoundEndReason, "RoundEndReason" )
END_STAT_TABLE()
};
typedef CUtlVector< SRoundData* > VectorRoundData;
struct PlayerStatData_t
{
wchar_t* pStatDisplayName; // Localized display name of the stat
int iStatId; // CSStatType_t enum value of stat
int32 iStatValue; // Value of the stat
};
class CCSClientGameStats : public CAutoGameSystem, public CGameEventListener, public IGameStatTracker
{
public:
CCSClientGameStats();
virtual void PostInit();
virtual void LevelShutdownPreEntity();
virtual void Shutdown();
virtual void LevelShutdownPreClearSteamAPIContext();
int GetStatCount();
PlayerStatData_t GetStatByIndex(int index);
PlayerStatData_t GetStatById(int id);
void ResetAllStats( void );
void ResetMatchStats();
void UploadRoundData( void );
const StatsCollection_t& GetLifetimeStats() { return m_lifetimeStats; }
const StatsCollection_t& GetMatchStats() { return m_matchStats; }
RoundStatsDirectAverage_t* GetDirectCTStatsAverages() { return &m_directCTStatAverages; }
RoundStatsDirectAverage_t* GetDirectTStatsAverages() { return &m_directTStatAverages; }
RoundStatsDirectAverage_t* GetDirectPlayerStatsAverages() { return &m_directPlayerStatAverages; }
void MsgFunc_MatchStatsUpdate( bf_read &msg );
void MsgFunc_PlayerStatsUpdate( bf_read &msg );
// Steamworks Gamestats
virtual void SubmitGameStats( KeyValues *pKV )
{
int listCount = s_StatLists->Count();
for( int i=0; i < listCount; ++i )
{
// Create a master key value that has stats everybody should share (map name, session ID, etc)
(*s_StatLists)[i]->SendData(pKV);
(*s_StatLists)[i]->Clear();
}
}
virtual StatContainerList_t* GetStatContainerList( void )
{
return s_StatLists;
}
protected:
void FireGameEvent( IGameEvent *event );
void UpdateSteamStats();
void RetrieveSteamStats();
void UpdateStats( const StatsCollection_t &stats );
void CalculateMatchFavoriteWeapons();
void UpdateLastMatchStats();
private:
StatsCollection_t m_lifetimeStats;
StatsCollection_t m_matchStats;
StatsCollection_t m_roundStats;
RoundStatsDirectAverage_t m_directCTStatAverages;
RoundStatsDirectAverage_t m_directTStatAverages;
RoundStatsDirectAverage_t m_directPlayerStatAverages;
int m_matchMaxPlayerCount;
bool m_bSteamStatsDownload;
VectorRoundData m_RoundStatData;
int m_RoundEndReason;
// A static list of all the stat containers, one for each data structure being tracked
static StatContainerList_t * s_StatLists;
};
extern CCSClientGameStats g_CSClientGameStats;
#endif //CS_STEAMSTATS_H
|