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.

165 lines
5.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Holds the CAccountDetails class.
  4. //
  5. //=============================================================================
  6. #ifndef ACCOUNTDETAILS_H
  7. #define ACCOUNTDETAILS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/thash.h"
  12. #include "tier1/utlhashmaplarge.h"
  13. namespace GCSDK
  14. {
  15. class CAccountDetails
  16. {
  17. public:
  18. CAccountDetails();
  19. void Init( CGCSystemMsg_GetAccountDetails_Response &msgResponse );
  20. void Reset();
  21. bool BIsExpired() const;
  22. bool BIsValid() const { return m_bValid; }
  23. const char *GetAccountName() const { return m_sAccountName.Get(); }
  24. bool BHasPublicProfile() const { return m_bPublicProfile; }
  25. bool BHasPublicInventory() const { return m_bPublicInventory; }
  26. bool BIsVacBanned() const { return m_bVacBanned; }
  27. bool BIsCyberCafe() const { return m_bCyberCafe; }
  28. bool BIsSchoolAccount() const { return m_bSchoolAccount; }
  29. bool BIsFreeTrialAccount() const { return m_bFreeTrialAccount; }
  30. bool BIsFreeTrialAccountOrDemo() const { return m_bFreeTrialAccount || m_unPackage == 0; }
  31. bool BIsSubscribed() const { return m_bSubscribed; }
  32. bool BIsLowViolence() const { return m_bLowViolence; }
  33. bool BIsLimitedAccount() const { return m_bLimited; }
  34. bool BIsAccountLocked() const { return m_bAccountLocked; }
  35. bool BIsCommunityBanned() const { return m_bCommunityBanned; }
  36. bool BIsTradeBanned() const { return m_bTradeBanned; }
  37. bool BIsSteamGuardEnabled() const { return m_bIsSteamGuardEnabled; }
  38. bool BIsPhoneVerified() const { return m_bIsPhoneVerified; }
  39. bool BIsTwoFactorAuthEnabled() const { return m_bIsTwoFactorAuthEnabled; }
  40. bool BIsPhoneIdentifying() const { return m_bIsPhoneIdentifying; }
  41. uint32 GetPackage() const { return m_unPackage; }
  42. RTime32 GetTimeVACBanEnd() const { return m_rtimeVACBanEnd; }
  43. uint32 GetSteamLevel() const { return m_unSteamLevel; }
  44. uint32 GetFriendCount() const { return m_unFriendCount; }
  45. RTime32 GetTimeAccountCreated() const { return m_rtimeAccountCreated; }
  46. RTime32 GetTimeTwoFactorEnabled() const { return m_rtimeTwoFactorEnabled; }
  47. RTime32 GetTimePhoneVerified() const { return m_rtimePhoneVerified; }
  48. uint64 GetPhoneID() const { return m_unPhoneID; }
  49. #ifdef DBGFLAG_VALIDATE
  50. void Validate( CValidator &validator, const char *pchName );
  51. #endif
  52. private:
  53. CUtlConstString m_sAccountName;
  54. CUtlConstString m_sCurrency;
  55. RTime32 m_rtimeCached;
  56. uint32 m_unPackage;
  57. RTime32 m_rtimeVACBanEnd;
  58. uint32 m_unSteamLevel;
  59. uint32 m_unFriendCount;
  60. RTime32 m_rtimeAccountCreated;
  61. RTime32 m_rtimeTwoFactorEnabled;
  62. RTime32 m_rtimePhoneVerified;
  63. uint64 m_unPhoneID;
  64. bool
  65. m_bValid:1,
  66. m_bPublicProfile:1,
  67. m_bPublicInventory:1,
  68. m_bVacBanned:1,
  69. m_bCyberCafe:1,
  70. m_bSchoolAccount:1,
  71. m_bFreeTrialAccount:1,
  72. m_bSubscribed:1,
  73. m_bLowViolence:1,
  74. m_bLimited:1,
  75. m_bAccountLocked:1,
  76. m_bCommunityBanned:1,
  77. m_bTradeBanned:1,
  78. m_bIsSteamGuardEnabled:1,
  79. m_bIsPhoneVerified:1,
  80. m_bIsTwoFactorAuthEnabled:1,
  81. m_bIsPhoneIdentifying:1;
  82. };
  83. class CCachedPersonaName
  84. {
  85. public:
  86. CCachedPersonaName();
  87. ~CCachedPersonaName();
  88. void Init( const char *pchPersonaName );
  89. void Reset();
  90. bool BIsExpired() const;
  91. bool BIsValid() const;
  92. bool BIsLoading() const;
  93. void SetPreloading();
  94. void AddLoadingRef();
  95. void ReleaseLoadingRef();
  96. const char *GetPersonaName() const;
  97. #ifdef DBGFLAG_VALIDATE
  98. void Validate( CValidator &validator, const char *pchName );
  99. #endif
  100. private:
  101. CUtlConstString m_sPersonaName;
  102. RTime32 m_rtimeCached;
  103. int32 m_nLoading;
  104. bool m_bPreloading;
  105. };
  106. //-----------------------------------------------------------------------------
  107. // Purpose: Manages requests for CAccountDetails objects
  108. //-----------------------------------------------------------------------------
  109. class CAccountDetailsManager
  110. {
  111. public:
  112. CAccountDetailsManager();
  113. CAccountDetails *YieldingGetAccountDetails( const CSteamID &steamID, bool bForceReload = false );
  114. void PreloadPersonaName( const CSteamID &steamID );
  115. const char *YieldingGetPersonaName( const CSteamID &steamID );
  116. void ClearCachedPersonaName( const CSteamID &steamID );
  117. void MarkFrame();
  118. bool BExpireRecords( CLimitTimer &limitTimer );
  119. void Dump() const;
  120. private:
  121. friend class CGCJobSendGetAccountDetailsRequest;
  122. bool BFindAccountDetailsInLocalCache( const CSteamID &steamID, CAccountDetails **ppAccount );
  123. void WakeWaitingAccountDetailsJobs( const CSteamID &steamID );
  124. CTHash<CAccountDetails, uint32> m_hashAccountDetailsCache;
  125. CUtlHashMapLarge<CSteamID, CCopyableUtlVector<JobID_t> > m_mapQueuedAccountDetailsRequests;
  126. friend class CGCJobSendGetPersonaNamesRequest;
  127. void SendBatchedPersonaNamesRequest();
  128. CCachedPersonaName *FindOrCreateCachedPersonaName( const CSteamID &steamID );
  129. void CachePersonaName( const CSteamID &steamID, const char *pchPersonaName );
  130. void CachePersonaNameFailure( const CSteamID &steamID );
  131. void WakeWaitingPersonaNameJobs( const CSteamID &steamID );
  132. CUtlVector<CSteamID> m_vecPendingPersonaNameLookups;
  133. CTHash<CCachedPersonaName, uint32> m_hashPersonaNameCache;
  134. CUtlHashMapLarge<CSteamID, CCopyableUtlVector<JobID_t> > m_mapQueuedPersonaNameRequests;
  135. };
  136. } // namespace GCSDK
  137. #endif // ACCOUNTDETAILS_H