forked from SwagSoftware/Kisak-Strike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayermanager.h
141 lines (110 loc) · 3.28 KB
/
playermanager.h
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
//========= Copyright © 1996-2009, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=====================================================================================//
#ifndef _PLAYERMANAGER_H_
#define _PLAYERMANAGER_H_
class PlayerManager;
#include <list>
#include "utlvector.h"
#include "utlmap.h"
#ifndef SWDS
#include "player.h"
class PlayerManager: public IPlayerManager, public IMatchEventsSink
{
public :
PlayerManager();
virtual ~PlayerManager();
//IPlayerManager
public:
//
// EnableServersUpdate
// controls whether friends data is being updated in the background
//
virtual void EnableFriendsUpdate( bool bEnable );
//
// GetLocalPlayer
// returns a local player interface for a given controller index
//
virtual IPlayerLocal * GetLocalPlayer( int iController );
//
// GetNumFriends
// returns number of friends discovered and for which data is available
//
virtual int GetNumFriends();
//
// GetFriend
// returns player interface to the given friend or NULL if friend not found or not available
//
virtual IPlayerFriend * GetFriendByIndex( int index );
virtual IPlayerFriend * GetFriendByXUID( XUID xuid );
//
// FindPlayer
// returns player interface by player's XUID or NULL if friend not found or not available
//
virtual IPlayer * FindPlayer( XUID xuid );
// IMatchEventsSink
public:
virtual void OnEvent( KeyValues *pEvent );
public:
void OnGameUsersChanged();
void Update();
void OnLocalPlayerDisconnectedFromLive( int iCtrlr );
void RecomputePlayerXUIDs( char const *szNetwork );
PlayerFriend *FindPlayerFriend( XUID xuid );
PlayerLocal *FindPlayerLocal( XUID xuid );
void RequestStoreStats();
protected:
void MarkOldFriends();
void RemoveOldFriends();
void OnSigninChange( KeyValues *pEvent );
void OnLostConnectionToConsoleNetwork();
#if defined( _PS3 ) && !defined( NO_STEAM )
STEAM_CALLBACK( PlayerManager, Steam_OnPS3PSNStatusChange, PS3PSNStatusChange_t, m_CallbackOnPS3PSNStatusChange );
#endif
private:
void CreateFriendEnumeration( int iCtrlr );
void CreateLanSearch();
void UpdateLanSearch();
void ExecuteStoreStatsRequest();
// Players instances
PlayerLocal * mLocalPlayer[ XUSER_MAX_COUNT ]; // local Players are cached off here for convienience.
CUtlVector< PlayerFriend * > mFriendsList;
bool m_bUpdateEnabled; // whether data should be auto-updated
float m_flNextUpdateTime; // when next update cycle should occur
struct SFriendSearchData
{
SFriendSearchData() { memset( this, 0, sizeof( *this ) ); }
bool mSearchInProgress;
void * mFriendBuffer;
int mFriendBufferSize;
int mFriendsStartIndex;
#ifdef _X360
HANDLE mFriendEnumHandle;
XOVERLAPPED mFriendsOverlapped;
#endif
XUID mXuid;
};
SFriendSearchData m_searchData[ XUSER_MAX_COUNT ];
struct SLanSearchData_t
{
SLanSearchData_t() { memset( this, 0, sizeof( *this ) ); }
bool m_bSearchInProgress;
float m_flStartTime;
float m_flLastBroadcastTime;
};
SLanSearchData_t m_lanSearchData;
int m_searchesPending; // Number of searches in progress
bool m_bRequestStoreStats;
};
#else // SWDS
class PlayerManager: public IPlayerManager, public IMatchEventsSink
{
public:
// SWDS declaration is intentionally left stripped
virtual void Update() = 0;
};
#endif
extern class PlayerManager *g_pPlayerManager;
#endif // _PLAYERMANAGER_H_