Team Fortress 2 Source Code as on 22/4/2020
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.

192 lines
7.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Dota specific GC based party
  4. //
  5. //=============================================================================
  6. #ifndef DOTA_PARTY_H
  7. #define DOTA_PARTY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "gcsdk/protobufsharedobject.h"
  12. #include "tf_gcmessages.h"
  13. #include "party.h"
  14. #include "tf_matchmaking_shared.h"
  15. #ifdef GC
  16. namespace GCSDK
  17. {
  18. CWebAPIValues;
  19. }
  20. #endif
  21. const int k_nTFPartyMaxSize = 6;
  22. class CTFParty : public GCSDK::CProtoBufSharedObject<CSOTFParty, k_EProtoObjectTFParty>, public GCSDK::IParty
  23. {
  24. #ifdef GC
  25. DECLARE_CLASS_MEMPOOL( CTFParty );
  26. #endif
  27. typedef GCSDK::CProtoBufSharedObject<CSOTFParty, k_EProtoObjectTFParty> BaseClass;
  28. public:
  29. CTFParty();
  30. virtual ~CTFParty();
  31. const static int k_nTypeID = k_EProtoObjectTFParty;
  32. virtual bool BShouldDeleteByCache() const { return false; }
  33. virtual GCSDK::PlayerGroupID_t GetGroupID() const { return Obj().party_id(); }
  34. // Parties are their own SharedObject for all involved
  35. virtual CSharedObject* GetSharedObjectForMember( const CSteamID &steamID ) OVERRIDE { return this; }
  36. // Ambiguous between ISharedObject and IPlayerGroup.
  37. virtual void Dump() const OVERRIDE { return BaseClass::Dump(); }
  38. virtual const CSteamID GetLeader() const;
  39. virtual int GetNumMembers() const { return Obj().member_ids_size(); }
  40. virtual const CSteamID GetMember( int i ) const;
  41. virtual int GetMemberIndexBySteamID( const CSteamID &steamID ) const;
  42. virtual int GetNumPendingInvites() const { return Obj().pending_invites_size(); }
  43. virtual const CSteamID GetPendingInvite( int i ) const;
  44. virtual int GetPendingInviteIndexBySteamID( const CSteamID &steamID ) const;
  45. RTime32 GetStartedMatchmakingTime() const;
  46. CSOTFParty_State GetState() const
  47. {
  48. CSOTFParty_State result = Obj().state();
  49. #ifndef GC
  50. // The client really never needs to see this state. Let's
  51. // treat it as equivalent to the finding match state
  52. if ( result == CSOTFParty_State_AWAITING_RESERVATION_CONFIRMATION )
  53. {
  54. result = CSOTFParty_State_FINDING_MATCH;
  55. }
  56. #endif
  57. return result;
  58. }
  59. CSteamID GetSteamLobbyID() const { return CSteamID( Obj().steam_lobby_id() ); }
  60. int GetNumSearchingPlayers( int group );
  61. int GetMaxNumSearchingPlayers(); // Returns the group with the largest number of players searching
  62. virtual bool AllowInvites() const { return false; } // we are using Steam invites
  63. void SpewDebug();
  64. bool BAnyMemberWithoutTicket() const;
  65. bool BAnyMemberWithoutCompetitiveAccess() const;
  66. bool BAnyMemberWithLowPriority() const;
  67. inline bool GetSearchLateJoinOK() const { return Obj().search_late_join_ok(); }
  68. inline bool GetSearchPlayForBraggingRights() const { return Obj().search_play_for_bragging_rights(); }
  69. TF_MatchmakingMode GetMatchmakingMode() const { return Obj().matchmaking_mode(); }
  70. uint32 GetSearchQuickplayGameType() const { return Obj().search_quickplay_game_type(); }
  71. EMatchGroup GetMatchGroup() const;
  72. void GetSearchChallenges( CMvMMissionSet &challenges ) const;
  73. uint32 GetSearchLadderGameType() const { return Obj().search_ladder_game_type(); }
  74. #ifdef USE_MVM_TOUR
  75. /// Return name of tour we are searching for. Returns NULL if we are not manned up
  76. const char *GetSearchMannUpTourName() const;
  77. /// Return index of tour we are searching for. Might return one of the k_iMvmTourIndex_xxx values
  78. int GetSearchMannUpTourIndex() const;
  79. #endif // USE_MVM_TOUR
  80. #ifdef GC
  81. virtual void SetGroupID( GCSDK::PlayerGroupID_t nGroupID );
  82. virtual void SetLeader( const CSteamID &steamID );
  83. virtual void AddMember( const CSteamID &steamID );
  84. virtual void RemoveMember( const CSteamID &steamID );
  85. //virtual void SetSearchKey( const char *key );
  86. void SetMatchmakingMode( TF_MatchmakingMode mode );
  87. void SetSearchChallenges( const ::google::protobuf::RepeatedPtrField< ::std::string> &challenges );
  88. #ifdef USE_MVM_TOUR
  89. void SetSearchMannUpTourName( const char *pszTourName );
  90. #endif // USE_MVM_TOUR
  91. void CheckRemoveInvalidSearchChallenges();
  92. void SetSearchQuickplayGameType( uint32 nType );
  93. void SetSearchPlayForBraggingRights( bool bPlayForBraggingRights );
  94. void SetSearchLadderGameType( uint32 nType );
  95. void SetCasualSearchCriteria( const CMsgCasualMatchmakingSearchCriteria& msg );
  96. void SetCustomPingTolerance( uint32 nPingTolerance );
  97. uint32 GetCustomPingTolerance() const { return Obj().custom_ping_tolerance(); }
  98. void SetState( CSOTFParty_State newState );
  99. //virtual void SetMatchingPlayers( uint32 unMatchingPlayers );
  100. //virtual void SetSearchFraction( float flFraction );
  101. virtual void SetLateJoinOK( bool bLateJoinOK );
  102. virtual void SetMemberUseSquadSurplus( int nMemberIndex, bool bUseVoucher );
  103. virtual void AddPendingInvite( const CSteamID &steamID );
  104. virtual void RemovePendingInvite( const CSteamID &steamID );
  105. void SetStartedMatchmakingTime( RTime32 time );
  106. void AssociatePartyWithLobby( CTFLobby* pLobby );
  107. void DissociatePartyFromLobby( CTFLobby* pLobby );
  108. CTFLobby* GetAssociatedLobby() const;
  109. void SetUIStateAndWizardStep( TF_Matchmaking_WizardStep eWizardStep );
  110. void SetNumSearchingPlayers( int group, uint32 nPlayers );
  111. void SetSteamLobbyID( const CSteamID &steamIDLobby );
  112. bool IsIntroModeEligible();
  113. bool IsProModeEligible();
  114. void UpdatePreventMatchmakingDate(); // sets prevent_match variables to match the party member blocked from matchmaking the longest
  115. void YldUpdateMemberData( int nMemberIndex );
  116. void SetWebAPIDebugValues( GCSDK::CWebAPIValues *pPartyObject );
  117. protected:
  118. void SetStateInternal( CSOTFParty_State newState );
  119. void DirtyParty();
  120. #endif
  121. #ifdef CLIENT_DLL
  122. // We mark a party as offline when we dont get any response from the GC regarding
  123. // changes to the party while messing with the MM UI. If we get an update for an
  124. // offline party and we no longer want to be in MM, then we leave matchmaking to
  125. // match the user's intent. If it comes back and we're still in the MM UI, it'll
  126. // just update like normal.
  127. void SetOffline( bool bOffLine ) { m_bOffLine = bOffLine; }
  128. bool BOffline() const { return m_bOffLine; }
  129. private:
  130. bool m_bOffLine;
  131. #endif
  132. };
  133. class CTFPartyInvite : public GCSDK::CProtoBufSharedObject<CSOTFPartyInvite, k_EProtoObjectTFPartyInvite>, public GCSDK::IPlayerGroupInvite
  134. {
  135. #ifdef GC
  136. DECLARE_CLASS_MEMPOOL( CTFPartyInvite );
  137. #endif
  138. typedef GCSDK::CProtoBufSharedObject<CSOTFPartyInvite, k_EProtoObjectTFPartyInvite> BaseClass;
  139. public:
  140. const static int k_nTypeID = k_EProtoObjectTFPartyInvite;
  141. virtual const CSteamID GetSenderID() const { return Obj().sender_id(); }
  142. virtual GCSDK::PlayerGroupID_t GetGroupID() const { return Obj().group_id(); }
  143. virtual const char* GetSenderName() const { return Obj().sender_name().c_str(); }
  144. virtual int GetNumMembers() const { return Obj().members_size(); }
  145. virtual const CSteamID GetMember( int i ) const;
  146. virtual const char* GetMemberName( int i ) const;
  147. virtual uint16 GetMemberAvatar( int i ) const;
  148. virtual GCSDK::CSharedObject* GetSharedObject() { return this; }
  149. #ifdef GC
  150. virtual void YldInitFromPlayerGroup( GCSDK::IPlayerGroup *pPlayerGroup );
  151. // NOTE: These do not dirty fields
  152. virtual void SetSenderID( const CSteamID &steamID ) { Obj().set_sender_id( steamID.ConvertToUint64() ); }
  153. virtual void SetGroupID( GCSDK::PlayerGroupID_t nGroupID ) { Obj().set_group_id( nGroupID ); }
  154. virtual void SetSenderName( const char *szName ) { Obj().set_sender_name( szName ); }
  155. virtual void AddMember( const CSteamID &steamID, const char *szPersonaName, uint16 unAvatar );
  156. #endif
  157. };
  158. #endif