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.

259 lines
7.0 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef IMATCHEVENTS_H
  7. #define IMATCHEVENTS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. abstract_class IMatchEventsSink
  12. {
  13. public:
  14. virtual void OnEvent( KeyValues *pEvent ) {}
  15. //
  16. // List of events
  17. //
  18. /*
  19. "OnSysStorageDevicesChanged"
  20. Signalled when system storage device change is detected.
  21. params:
  22. void
  23. "OnSysSigninChange"
  24. Signalled when one or more users sign out.
  25. params:
  26. string "action" - signin change event: "signin", "signout"
  27. int "numUsers" - how many users signed in/out (defines valid user0 - userN-1 fields)
  28. int "mask" - bitmask of controllers affected
  29. int "user%d" - controller index affected
  30. "OnSysXUIEvent"
  31. Signalled when an XUI event occurs.
  32. params:
  33. string "action" - XUI action type: "opening", "closed"
  34. "OnSysMuteListChanged"
  35. Signalled when system mute list change occurs.
  36. params:
  37. void
  38. "OnSysInputDevicesChanged"
  39. Signalled when input device disconnection is detected.
  40. params:
  41. int "mask" - bitmask of which slot's controller was disconnected [0-1]
  42. "OnEngineLevelLoadingStarted"
  43. Signalled when a level starts loading.
  44. params:
  45. string "name" - level name
  46. "OnEngineListenServerStarted"
  47. Signalled when a listen server level loads enough to accept client connections.
  48. params:
  49. void
  50. "OnEngineLevelLoadingTick"
  51. Signalled periodically while a level is loading,
  52. after loading started and before loading finished.
  53. params:
  54. void
  55. "OnEngineLevelLoadingFinished"
  56. Signalled when a level is finished loading.
  57. params:
  58. int "error" - whether an extended error occurred
  59. string "reason" - reason description
  60. "OnEngineClientSignonStateChange"
  61. Signalled when client's signon state is changing.
  62. params:
  63. int "slot" - client ss slot
  64. int "old" - old state
  65. int "new" - new state
  66. int "count" - count
  67. "OnEngineDisconnectReason"
  68. Signalled before a disconnect is going to occur and a reason
  69. for disconnect is available.
  70. params:
  71. string "reason" - reason description
  72. "OnEngineEndGame"
  73. Signalled before a disconnect is going to occur and notifies the members
  74. of the game that the game has reached a conclusion or a vote to end the
  75. game has passed and the game should terminate and return to lobby if possible.
  76. params:
  77. string "reason" - reason description
  78. "OnMatchPlayerMgrUpdate"
  79. Signalled when a player manager update occurs.
  80. params:
  81. string "update" = - update type
  82. "searchstarted" - search started
  83. "searchfinished" - search finished
  84. "friend" - friend details updated
  85. uint64 "xuid" - xuid of a player if applicable
  86. "OnMatchPlayerMgrReset"
  87. Signalled when the game needs to go into attract mode.
  88. params:
  89. string "reason" - one of the following reasons:
  90. "GuestSignedIn" - guest user signed in
  91. "GameUserSignedOut" - user involved in game has signed out
  92. "OnMatchServerMgrUpdate"
  93. Signalled when a server manager update occurs.
  94. params:
  95. string "update" = - update type
  96. "searchstarted" - search started
  97. "searchfinished" - search finished
  98. "server" - server details updated
  99. uint64 "xuid" - xuid of a server if applicable
  100. "OnMatchSessionUpdate"
  101. Signalled when a session changes.
  102. params:
  103. strings "state" = - new state of the session
  104. "ready" - session is completely initialized and ready
  105. "updated" - session settings have been updated
  106. "OnNetLanConnectionlessPacket"
  107. Signalled when a lan network packet is received.
  108. params:
  109. string "from" - netadr of sender as recorded by network layer
  110. subkey - packet message
  111. "OnProfilesChanged"
  112. Signalled when new number of game users are set for the game.
  113. params:
  114. int "numProfiles" - number of game users set for the game
  115. "OnProfileDataLoaded"
  116. Signalled when a user profile title data is loaded.
  117. params:
  118. int "iController" - index of controller whose title data is now loaded
  119. "OnProfileStorageAvailable"
  120. Signalled when a user profile storage device is selected.
  121. params:
  122. int "iController" - index of controller whose storage device is now selected
  123. "OnProfileUnavailable"
  124. Signalled when a user profile is detected as unavailable.
  125. params:
  126. int "iController" - index of controller whose profile was detected as unavailable
  127. "OnPlayerUpdated"
  128. Signalled when information about a player changes.
  129. params:
  130. uint64 "xuid" - XUID of the player updated
  131. "OnPlayerRemoved"
  132. Signalled when a player is removed from the game.
  133. params:
  134. uint64 "xuid" - XUID of the player removed
  135. "OnPlayerMachinesConnected"
  136. Signalled when new machines become part of the session, they will be last
  137. in the list of connected machines.
  138. params:
  139. int "numMachines" - number of new machines connected
  140. "OnPlayerActivity"
  141. Signalled when a player activity is detected.
  142. params:
  143. uint64 "xuid" - XUID of the player
  144. string "act" - type of activity:
  145. "voice" - player is voice chatting
  146. "OnMuteChanged"
  147. Signalled when a mute list is updated.
  148. params:
  149. void
  150. "OnInvite"
  151. Signalled when game invite event occurs.
  152. params:
  153. int "user" - controller index accepting the invite or causing invite error
  154. string "sessioninfo" - session info of the invite host
  155. string "action" = - invite action
  156. "accepted" - when an invite is accepted by user
  157. "storage" - when a storage device needs to be validated
  158. "error" - when an error occurs that prevents invite from being accepted
  159. "join" - when destructive actions or storage devices are confirmed by user
  160. "deny" - when invite is rejected by user
  161. string "error" - error description: "NotOnline", "NoMultiplayer", etc.
  162. ptr int "confirmed" - handler should set pointed int to 0 if confirmation is pending
  163. and send a "join" action OnInvite event after destructive
  164. actions are confirmed by user, storage devices are mounted, etc.
  165. */
  166. };
  167. abstract_class IMatchEventsSubscription
  168. {
  169. public:
  170. virtual void Subscribe( IMatchEventsSink *pSink ) = 0;
  171. virtual void Unsubscribe( IMatchEventsSink *pSink ) = 0;
  172. virtual void BroadcastEvent( KeyValues *pEvent ) = 0;
  173. virtual void RegisterEventData( KeyValues *pEventData ) = 0;
  174. virtual KeyValues * GetEventData( char const *szEventDataKey ) = 0;
  175. };
  176. //
  177. // Renamer for the match events event-handler function
  178. // Usage:
  179. // class MyClass : public CMatchEventsSinkFn< MyClass >
  180. // {
  181. // public:
  182. // MyClass() : MatchEventsSinkFnClass( &MyClass::HandleMatchSinkEvent ) {}
  183. // void HandleMatchSinkEvent( KeyValues *pEvent );
  184. // };
  185. //
  186. template < typename TDerived >
  187. class CMatchEventsSinkFn : public IMatchEventsSink
  188. {
  189. protected:
  190. typedef TDerived DerivedClass;
  191. typedef void ( TDerived::*PFnDerivedHandler_t )( KeyValues *pEvent );
  192. typedef CMatchEventsSinkFn< TDerived > MatchEventsSinkFnClass;
  193. protected:
  194. explicit CMatchEventsSinkFn( PFnDerivedHandler_t pfn ) : m_pfnDerived( pfn ) {}
  195. public:
  196. virtual void OnEvent( KeyValues *pEvent )
  197. {
  198. ( static_cast< TDerived * >( this )->*m_pfnDerived )( pEvent );
  199. }
  200. private:
  201. PFnDerivedHandler_t m_pfnDerived;
  202. };
  203. #endif // IMATCHEVENTS_H