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.

136 lines
3.9 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #include "tier0/dbg.h"
  7. #include "tier0/icommandline.h"
  8. #include "tier1/strtools.h"
  9. #include "tier1/checksum_crc.h"
  10. #include "tier1/keyvalues.h"
  11. #include "tier1/utlbuffer.h"
  12. #include "tier2/tier2.h"
  13. #include "mathlib/mathlib.h"
  14. #include "const.h"
  15. #include "inetmsghandler.h"
  16. #include "appframework/iappsystemgroup.h"
  17. #include "matchmaking/imatchframework.h"
  18. #include <memdbgon.h>
  19. #ifdef _GAMECONSOLE
  20. class CMoviePlayer_IMatchEventsSubscription : public IMatchEventsSubscription
  21. {
  22. virtual void Subscribe( IMatchEventsSink *pSink ) {}
  23. virtual void Unsubscribe( IMatchEventsSink *pSink ) {}
  24. virtual void BroadcastEvent( KeyValues *pEvent ) { pEvent->deleteThis(); }
  25. virtual void RegisterEventData( KeyValues *pEventData ) {}
  26. virtual KeyValues * GetEventData( char const *szEventDataKey ) { return NULL; }
  27. }
  28. g_CMoviePlayer_IMatchEventsSubscription;
  29. class CMoviePlayer_MatchFramework : public CTier2AppSystem< IMatchFramework >
  30. {
  31. public:
  32. // Run frame of the matchmaking framework
  33. virtual void RunFrame() {}
  34. // Get matchmaking extensions
  35. virtual IMatchExtensions * GetMatchExtensions() { return NULL; }
  36. // Get events container
  37. virtual IMatchEventsSubscription * GetEventsSubscription() { return &g_CMoviePlayer_IMatchEventsSubscription; }
  38. // Get the matchmaking title interface
  39. virtual IMatchTitle * GetMatchTitle() { return NULL; }
  40. // Get the match session interface of the current match framework type
  41. virtual IMatchSession * GetMatchSession() { return NULL; }
  42. // Get the network msg encode/decode factory
  43. virtual IMatchNetworkMsgController * GetMatchNetworkMsgController() { return NULL; }
  44. // Get the match system
  45. virtual IMatchSystem * GetMatchSystem() { return NULL; }
  46. // Send the key values back to the server
  47. virtual void ApplySettings( KeyValues *keyValues) {}
  48. // Entry point to create session
  49. virtual void CreateSession( KeyValues *pSettings ) {}
  50. // Entry point to match into a session
  51. virtual void MatchSession( KeyValues *pSettings ) {}
  52. // Accept invite
  53. virtual void AcceptInvite( int iController );
  54. // Close the session
  55. virtual void CloseSession() {}
  56. virtual bool IsOnlineGame( void ) { return false; }
  57. // Called by the client to notify matchmaking that it should update matchmaking properties based
  58. // on player distribution among the teams.
  59. virtual void UpdateTeamProperties( KeyValues *pTeamProperties ) {}
  60. // IAppSystem
  61. public:
  62. // Here's where the app systems get to learn about each other
  63. virtual bool Connect( CreateInterfaceFn factory ) { return true; }
  64. virtual void Disconnect() {}
  65. // Here's where systems can access other interfaces implemented by this object
  66. // Returns NULL if it doesn't implement the requested interface
  67. virtual void *QueryInterface( const char *pInterfaceName ) { return NULL; }
  68. // Init, shutdown
  69. virtual InitReturnVal_t Init() { return INIT_OK; }
  70. virtual void Shutdown() {}
  71. }
  72. g_CMoviePlayer_MatchFramework;
  73. IMatchFramework *g_pMoviePlayer_MatchFramework = &g_CMoviePlayer_MatchFramework;
  74. void CMoviePlayer_MatchFramework::AcceptInvite( int iController )
  75. {
  76. #ifdef _X360
  77. // Collect our session data
  78. XINVITE_INFO inviteInfo = {0};
  79. DWORD dwError = XInviteGetAcceptedInfo( iController, &inviteInfo );
  80. if ( dwError != ERROR_SUCCESS )
  81. {
  82. return;
  83. }
  84. DWORD dwTitleIDrequired = 0;
  85. dwTitleIDrequired = 0x45410912; // PORTAL2 RETAIL ID
  86. if ( !dwTitleIDrequired )
  87. Error( "TitleID is not defined for game invite during movie!\n" );
  88. if ( dwTitleIDrequired && inviteInfo.dwTitleID != dwTitleIDrequired )
  89. return;
  90. // Store off the session ID and mark the invite as accepted internally
  91. XBX_SetInvitedUserId( iController );
  92. XBX_SetInvitedUserXuid( inviteInfo.xuidInvitee );
  93. XBX_SetInviteSessionId( inviteInfo.hostInfo.sessionID );
  94. #endif
  95. }
  96. #endif