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.

150 lines
4.1 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef X360_LOBBYAPI_H
  7. #define X360_LOBBYAPI_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef _X360
  12. class CX360LobbyObject;
  13. class CX360LobbyObject
  14. {
  15. public:
  16. CX360LobbyObject() { memset( this, 0, sizeof( *this ) ); }
  17. public:
  18. uint64 GetSessionId() const { return ( uint64 const & ) m_xiInfo.sessionID; }
  19. public:
  20. HANDLE m_hHandle;
  21. uint64 m_uiNonce;
  22. XSESSION_INFO m_xiInfo;
  23. IN_ADDR m_inaSecure;
  24. XSESSION_INFO m_xiExternalPeer;
  25. bool m_bXSessionStarted;
  26. };
  27. abstract_class IDormantOperation
  28. {
  29. public:
  30. // Runs a dormant operation frame loop
  31. // Returns true to keep running
  32. // Return false when the operation should be
  33. // deleted from the dormant update list
  34. virtual bool UpdateDormantOperation() = 0;
  35. };
  36. abstract_class IX360LobbyAsyncOperation : public IMatchAsyncOperation
  37. {
  38. public:
  39. virtual CX360LobbyObject const & GetLobby() = 0;
  40. virtual void Update() = 0;
  41. };
  42. struct CX360LobbyFlags_t
  43. {
  44. DWORD m_dwFlags;
  45. DWORD m_dwGameType;
  46. int m_numPublicSlots;
  47. int m_numPrivateSlots;
  48. bool m_bCanLockJoins;
  49. };
  50. struct CX360LobbyMigrateOperation_t
  51. {
  52. CX360LobbyObject *m_pLobby;
  53. DWORD m_ret;
  54. bool m_bFinished;
  55. };
  56. typedef void* CX360LobbyMigrateHandle_t;
  57. abstract_class IX360LeaderboardBatchWriter
  58. {
  59. public:
  60. virtual void AddProperty( int dwViewId, XUSER_PROPERTY const &xp ) = 0;
  61. virtual void WriteBatchAndDestroy() = 0;
  62. };
  63. CX360LobbyFlags_t MMX360_DescribeLobbyFlags( KeyValues *pSettings, bool bHost, bool bWantLocked = false );
  64. #define XSESSION_INFO_STRING_LENGTH ( 2 * sizeof( XSESSION_INFO ) + 1 )
  65. void MMX360_SessionInfoToString( XSESSION_INFO const &xsi, char *pchBuffer );
  66. void MMX360_SessionInfoFromString( XSESSION_INFO &xsi, char const *pchBuffer );
  67. #define XNADDR_STRING_LENGTH ( 2 * sizeof( XNADDR ) + 1 )
  68. void MMX360_XnaddrToString( XNADDR const &xsi, char *pchBuffer );
  69. void MMX360_XnaddrFromString( XNADDR &xsi, char const *pchBuffer );
  70. void MMX360_LobbyDelete( CX360LobbyObject &lobby, IX360LobbyAsyncOperation **ppOperation );
  71. void MMX360_LobbyCreate( KeyValues *pSettings, IX360LobbyAsyncOperation **ppOperation );
  72. void MMX360_LobbyConnect( KeyValues *pSettings, IX360LobbyAsyncOperation **ppOperation );
  73. CX360LobbyMigrateHandle_t MMX360_LobbyMigrateHost( CX360LobbyObject &lobby, CX360LobbyMigrateOperation_t *pOperation );
  74. CX360LobbyMigrateHandle_t MMX360_LobbyMigrateClient( CX360LobbyObject &lobby, XSESSION_INFO const &xsiNewHost, CX360LobbyMigrateOperation_t *pOperation );
  75. CX360LobbyMigrateOperation_t * MMX360_LobbyMigrateSetListener( CX360LobbyMigrateHandle_t hMigrateCall, CX360LobbyMigrateOperation_t *pOperation );
  76. void MMX360_LobbyJoinMembers( KeyValues *pSettings, CX360LobbyObject &lobby, int idxMachineStart = 0, int idxMachineEnd = -1 );
  77. void MMX360_LobbyLeaveMembers( KeyValues *pSettings, CX360LobbyObject &lobby, int idxMachineStart = 0, int idxMachineEnd = -1 );
  78. bool MMX360_LobbySetActiveGameplayState( CX360LobbyObject &lobby, bool bActive, char const *szSecureServerAddress );
  79. int MMX360_GetUserCtrlrIndex( XUID xuid );
  80. XOVERLAPPED * MMX360_NewOverlappedDormant( void (*pfnCompletion)( XOVERLAPPED *, void * ) = NULL, void *pvParam = NULL );
  81. void MMX360_RegisterDormant( IDormantOperation *pDormant );
  82. void MMX360_UpdateDormantOperations();
  83. IX360LeaderboardBatchWriter * MMX360_CreateLeaderboardBatchWriter( XUID xuidGamer );
  84. void MMX360_CancelOverlapped( XOVERLAPPED *pxOverlapped );
  85. //
  86. // Helpful functions to be used when overlapped operation completes
  87. //
  88. template < typename T >
  89. void OnCompleted_DeleteData( XOVERLAPPED *, void *pvData )
  90. {
  91. delete reinterpret_cast< T * >( pvData );
  92. }
  93. template < typename T >
  94. void OnCompleted_DeleteDataArray( XOVERLAPPED *, void *pvData )
  95. {
  96. delete [] reinterpret_cast< T * >( pvData );
  97. }
  98. #else
  99. class CSteamLobbyObject
  100. {
  101. public:
  102. CSteamLobbyObject() { memset( this, 0, sizeof( *this ) ); }
  103. public:
  104. uint64 GetSessionId() const { return m_uiLobbyID; }
  105. public:
  106. uint64 m_uiLobbyID;
  107. enum LobbyState_t {
  108. STATE_DEFAULT = 0,
  109. STATE_ACTIVE_GAME,
  110. STATE_DISCONNECTED_FROM_STEAM,
  111. };
  112. LobbyState_t m_eLobbyState;
  113. };
  114. #endif
  115. #endif