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.

181 lines
4.4 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef MM_SESSION_ONLINE_TEAM_SEARCH_H
  7. #define MM_SESSION_ONLINE_TEAM_SEARCH_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CMatchSessionOnlineTeamSearch;
  12. class CMatchSessionOnlineTeamSearchLinkHost;
  13. class CMatchSessionOnlineTeamSearchLinkClient;
  14. //
  15. // CMatchSessionOnlineTeamSearch
  16. //
  17. // Implementation of an online team session search (aka team-on-team matchmaking)
  18. //
  19. class CMatchSessionOnlineTeamSearch : public CMatchSessionOnlineSearch
  20. {
  21. public:
  22. explicit CMatchSessionOnlineTeamSearch( KeyValues *pSettings, CMatchSessionOnlineHost *pHost );
  23. virtual ~CMatchSessionOnlineTeamSearch();
  24. //
  25. // Overrides when search is used as a nested object
  26. //
  27. protected:
  28. virtual CMatchSearcher * OnStartSearching();
  29. virtual void OnSearchCompletedSuccess( CSysSessionClient *pSysSession, KeyValues *pSettings );
  30. virtual void OnSearchCompletedEmpty( KeyValues *pSettings );
  31. virtual void OnSearchEvent( KeyValues *pNotify );
  32. virtual CSysSessionClient * OnBeginJoiningSearchResult();
  33. // Hooks for the nested sys sessions
  34. public:
  35. virtual void OnSessionEvent( KeyValues *pNotify );
  36. CSysSessionBase * LinkSysSession();
  37. //
  38. // Match session overrides
  39. //
  40. public:
  41. // Run a frame update
  42. virtual void Update();
  43. // Destroy the session object
  44. virtual void Destroy();
  45. // Debug print a session object
  46. virtual void DebugPrint();
  47. // Process event
  48. virtual void OnEvent( KeyValues *pEvent );
  49. protected:
  50. void OnRunSessionCommand( KeyValues *pCommand );
  51. CMatchSessionOnlineTeamSearchLinkHost & LinkHost();
  52. CMatchSessionOnlineTeamSearchLinkClient & LinkClient();
  53. void ResetAndRestartTeamSearch();
  54. void RememberHostSessionUpdatePacket( KeyValues *pPacket );
  55. void ApplyHostSessionUpdatePacket();
  56. protected:
  57. enum State_t
  58. {
  59. STATE_SEARCHING,
  60. STATE_CREATING,
  61. STATE_AWAITING_PEER,
  62. STATE_LINK_HOST,
  63. STATE_LINK_CLIENT,
  64. STATE_ERROR,
  65. };
  66. State_t m_eState;
  67. int m_iLinkState;
  68. XUID m_xuidLinkPeer;
  69. CMatchSessionOnlineHost *m_pHostSession; // parent object that contains our TeamSearch
  70. CSysSessionHost *m_pSysSessionHost; // nested SysSessionHost object when we are hosting
  71. CSysSessionClient *m_pSysSessionClient; // nested SysSessionClient object when we are peer
  72. CDsSearcher *m_pDsSearcher; // for searching dedicated servers
  73. float m_flActionTime; // time to perform action of the current state
  74. KeyValues *m_pUpdateHostSessionPacket; // packet that should be applied to host session before the game commences
  75. // this packet is the case of team sessions being reconciled and unknown settings resolved
  76. KeyValues::AutoDelete m_autodelete_pUpdateHostSessionPacket;
  77. // LINK HOST STATE
  78. float m_flCreationTime;
  79. #ifdef _X360
  80. CXlspConnection *m_pXlspConnection;
  81. CXlspConnectionCmdBatch *m_pXlspCommandBatch;
  82. #endif
  83. };
  84. class CMatchSessionOnlineTeamSearchLinkBase : public CMatchSessionOnlineTeamSearch
  85. {
  86. private:
  87. CMatchSessionOnlineTeamSearchLinkBase();
  88. public:
  89. enum State_t
  90. {
  91. STATE_HOSTING_LISTEN_SERVER,
  92. STATE_WAITING_FOR_PEER_SERVER,
  93. STATE_SEARCHING_DEDICATED,
  94. STATE_LINK_FINISHED,
  95. STATE_LINK_BASE_LAST
  96. };
  97. protected:
  98. void StartHostingListenServer();
  99. void StartDedicatedServerSearch();
  100. void StartWaitingForPeerServer();
  101. void OnDedicatedSearchFinished();
  102. public:
  103. void LinkCommand( KeyValues *pCommand );
  104. void LinkUpdate();
  105. };
  106. class CMatchSessionOnlineTeamSearchLinkHost : public CMatchSessionOnlineTeamSearchLinkBase
  107. {
  108. private:
  109. CMatchSessionOnlineTeamSearchLinkHost();
  110. public:
  111. enum State_t
  112. {
  113. STATE_LINK_INITIAL = STATE_LINK_BASE_LAST,
  114. STATE_SUBMIT_STATS,
  115. STATE_REPORTING_STATS,
  116. STATE_CONFIRM_JOIN,
  117. STATE_CONFIRM_JOIN_WAIT,
  118. };
  119. public:
  120. void LinkInit();
  121. void LinkCommand( KeyValues *pCommand );
  122. void LinkUpdate();
  123. };
  124. class CMatchSessionOnlineTeamSearchLinkClient : public CMatchSessionOnlineTeamSearchLinkBase
  125. {
  126. private:
  127. CMatchSessionOnlineTeamSearchLinkClient();
  128. public:
  129. enum State_t
  130. {
  131. STATE_LINK_INITIAL = STATE_LINK_BASE_LAST,
  132. STATE_WAITING_FOR_HOST_READY,
  133. STATE_CONFIRM_JOIN,
  134. };
  135. public:
  136. void LinkInit();
  137. void LinkCommand( KeyValues *pCommand );
  138. void LinkUpdate();
  139. };
  140. class CMatchSearcher_OnlineTeamSearch : public CMatchSearcher_OnlineSearch
  141. {
  142. public:
  143. CMatchSearcher_OnlineTeamSearch( CMatchSessionOnlineTeamSearch *pSession, KeyValues *pSettings );
  144. protected:
  145. virtual void StartSearchPass( KeyValues *pSearchPass );
  146. };
  147. #endif