Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.3 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #ifndef _PLAYERMANAGER_H_
  7. #define _PLAYERMANAGER_H_
  8. class PlayerManager;
  9. #include <list>
  10. #include "utlvector.h"
  11. #include "utlmap.h"
  12. #ifndef SWDS
  13. #include "player.h"
  14. class PlayerManager: public IPlayerManager, public IMatchEventsSink
  15. {
  16. public :
  17. PlayerManager();
  18. virtual ~PlayerManager();
  19. //IPlayerManager
  20. public:
  21. //
  22. // EnableServersUpdate
  23. // controls whether friends data is being updated in the background
  24. //
  25. virtual void EnableFriendsUpdate( bool bEnable );
  26. //
  27. // GetLocalPlayer
  28. // returns a local player interface for a given controller index
  29. //
  30. virtual IPlayerLocal * GetLocalPlayer( int iController );
  31. //
  32. // GetNumFriends
  33. // returns number of friends discovered and for which data is available
  34. //
  35. virtual int GetNumFriends();
  36. //
  37. // GetFriend
  38. // returns player interface to the given friend or NULL if friend not found or not available
  39. //
  40. virtual IPlayerFriend * GetFriendByIndex( int index );
  41. virtual IPlayerFriend * GetFriendByXUID( XUID xuid );
  42. //
  43. // FindPlayer
  44. // returns player interface by player's XUID or NULL if friend not found or not available
  45. //
  46. virtual IPlayer * FindPlayer( XUID xuid );
  47. // IMatchEventsSink
  48. public:
  49. virtual void OnEvent( KeyValues *pEvent );
  50. public:
  51. void OnGameUsersChanged();
  52. void Update();
  53. void OnLocalPlayerDisconnectedFromLive( int iCtrlr );
  54. void RecomputePlayerXUIDs( char const *szNetwork );
  55. PlayerFriend *FindPlayerFriend( XUID xuid );
  56. PlayerLocal *FindPlayerLocal( XUID xuid );
  57. void RequestStoreStats();
  58. protected:
  59. void MarkOldFriends();
  60. void RemoveOldFriends();
  61. void OnSigninChange( KeyValues *pEvent );
  62. void OnLostConnectionToConsoleNetwork();
  63. #if defined( _PS3 ) && !defined( NO_STEAM )
  64. STEAM_CALLBACK( PlayerManager, Steam_OnPS3PSNStatusChange, PS3PSNStatusChange_t, m_CallbackOnPS3PSNStatusChange );
  65. #endif
  66. private:
  67. void CreateFriendEnumeration( int iCtrlr );
  68. void CreateLanSearch();
  69. void UpdateLanSearch();
  70. void ExecuteStoreStatsRequest();
  71. // Players instances
  72. PlayerLocal * mLocalPlayer[ XUSER_MAX_COUNT ]; // local Players are cached off here for convienience.
  73. CUtlVector< PlayerFriend * > mFriendsList;
  74. bool m_bUpdateEnabled; // whether data should be auto-updated
  75. float m_flNextUpdateTime; // when next update cycle should occur
  76. struct SFriendSearchData
  77. {
  78. SFriendSearchData() { memset( this, 0, sizeof( *this ) ); }
  79. bool mSearchInProgress;
  80. void * mFriendBuffer;
  81. int mFriendBufferSize;
  82. int mFriendsStartIndex;
  83. #ifdef _X360
  84. HANDLE mFriendEnumHandle;
  85. XOVERLAPPED mFriendsOverlapped;
  86. #endif
  87. XUID mXuid;
  88. };
  89. SFriendSearchData m_searchData[ XUSER_MAX_COUNT ];
  90. struct SLanSearchData_t
  91. {
  92. SLanSearchData_t() { memset( this, 0, sizeof( *this ) ); }
  93. bool m_bSearchInProgress;
  94. float m_flStartTime;
  95. float m_flLastBroadcastTime;
  96. };
  97. SLanSearchData_t m_lanSearchData;
  98. int m_searchesPending; // Number of searches in progress
  99. bool m_bRequestStoreStats;
  100. };
  101. #else // SWDS
  102. class PlayerManager: public IPlayerManager, public IMatchEventsSink
  103. {
  104. public:
  105. // SWDS declaration is intentionally left stripped
  106. virtual void Update() = 0;
  107. };
  108. #endif
  109. extern class PlayerManager *g_pPlayerManager;
  110. #endif // _PLAYERMANAGER_H_