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.

998 lines
40 KiB

  1. //========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef STEAMCLIENTPUBLIC_H
  7. #define STEAMCLIENTPUBLIC_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. //lint -save -e1931 -e1927 -e1924 -e613 -e726
  12. // This header file defines the interface between the calling application and the code that
  13. // knows how to communicate with the connection manager (CM) from the Steam service
  14. // This header file is intended to be portable; ideally this 1 header file plus a lib or dll
  15. // is all you need to integrate the client library into some other tree. So please avoid
  16. // including or requiring other header files if possible. This header should only describe the
  17. // interface layer, no need to include anything about the implementation.
  18. #include "steamtypes.h"
  19. // General result codes
  20. enum EResult
  21. {
  22. k_EResultOK = 1, // success
  23. k_EResultFail = 2, // generic failure
  24. k_EResultNoConnection = 3, // no/failed network connection
  25. // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
  26. k_EResultInvalidPassword = 5, // password/ticket is invalid
  27. k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
  28. k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
  29. k_EResultInvalidParam = 8, // a parameter is incorrect
  30. k_EResultFileNotFound = 9, // file was not found
  31. k_EResultBusy = 10, // called method busy - action not taken
  32. k_EResultInvalidState = 11, // called object was in an invalid state
  33. k_EResultInvalidName = 12, // name is invalid
  34. k_EResultInvalidEmail = 13, // email is invalid
  35. k_EResultDuplicateName = 14, // name is not unique
  36. k_EResultAccessDenied = 15, // access is denied
  37. k_EResultTimeout = 16, // operation timed out
  38. k_EResultBanned = 17, // VAC2 banned
  39. k_EResultAccountNotFound = 18, // account not found
  40. k_EResultInvalidSteamID = 19, // steamID is invalid
  41. k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
  42. k_EResultNotLoggedOn = 21, // The user is not logged on
  43. k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
  44. k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
  45. k_EResultInsufficientPrivilege = 24, // Insufficient privilege
  46. k_EResultLimitExceeded = 25, // Too much of a good thing
  47. k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
  48. k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
  49. k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
  50. k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
  51. k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
  52. k_EResultIPNotFound = 31, // IP address not found
  53. k_EResultPersistFailed = 32, // failed to write change to the data store
  54. k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
  55. k_EResultLogonSessionReplaced = 34,
  56. k_EResultConnectFailed = 35,
  57. k_EResultHandshakeFailed = 36,
  58. k_EResultIOFailure = 37,
  59. k_EResultRemoteDisconnect = 38,
  60. k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
  61. k_EResultBlocked = 40, // a user didn't allow it
  62. k_EResultIgnored = 41, // target is ignoring sender
  63. k_EResultNoMatch = 42, // nothing matching the request found
  64. k_EResultAccountDisabled = 43,
  65. k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
  66. k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
  67. k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
  68. k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
  69. k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
  70. k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
  71. k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
  72. k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
  73. k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
  74. k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
  75. k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
  76. k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
  77. k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
  78. k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
  79. k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
  80. k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
  81. k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
  82. k_EResultIllegalPassword = 61, // The requested new password is not legal
  83. k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
  84. k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
  85. k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
  86. k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
  87. k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
  88. k_EResultHardwareNotCapableOfIPT = 67, //
  89. k_EResultIPTInitError = 68, //
  90. k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
  91. k_EResultFacebookQueryError = 70, // Facebook query returned an error
  92. k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
  93. k_EResultIPLoginRestrictionFailed = 72,
  94. };
  95. // Error codes for use with the voice functions
  96. enum EVoiceResult
  97. {
  98. k_EVoiceResultOK = 0,
  99. k_EVoiceResultNotInitialized = 1,
  100. k_EVoiceResultNotRecording = 2,
  101. k_EVoiceResultNoData = 3,
  102. k_EVoiceResultBufferTooSmall = 4,
  103. k_EVoiceResultDataCorrupted = 5,
  104. k_EVoiceResultRestricted = 6,
  105. k_EVoiceResultUnsupportedCodec = 7,
  106. };
  107. // Result codes to GSHandleClientDeny/Kick
  108. typedef enum
  109. {
  110. k_EDenyInvalid = 0,
  111. k_EDenyInvalidVersion = 1,
  112. k_EDenyGeneric = 2,
  113. k_EDenyNotLoggedOn = 3,
  114. k_EDenyNoLicense = 4,
  115. k_EDenyCheater = 5,
  116. k_EDenyLoggedInElseWhere = 6,
  117. k_EDenyUnknownText = 7,
  118. k_EDenyIncompatibleAnticheat = 8,
  119. k_EDenyMemoryCorruption = 9,
  120. k_EDenyIncompatibleSoftware = 10,
  121. k_EDenySteamConnectionLost = 11,
  122. k_EDenySteamConnectionError = 12,
  123. k_EDenySteamResponseTimedOut = 13,
  124. k_EDenySteamValidationStalled = 14,
  125. k_EDenySteamOwnerLeftGuestUser = 15,
  126. } EDenyReason;
  127. // return type of GetAuthSessionTicket
  128. typedef uint32 HAuthTicket;
  129. const HAuthTicket k_HAuthTicketInvalid = 0;
  130. // results from BeginAuthSession
  131. typedef enum
  132. {
  133. k_EBeginAuthSessionResultOK = 0, // Ticket is valid for this game and this steamID.
  134. k_EBeginAuthSessionResultInvalidTicket = 1, // Ticket is not valid.
  135. k_EBeginAuthSessionResultDuplicateRequest = 2, // A ticket has already been submitted for this steamID
  136. k_EBeginAuthSessionResultInvalidVersion = 3, // Ticket is from an incompatible interface version
  137. k_EBeginAuthSessionResultGameMismatch = 4, // Ticket is not for this game
  138. k_EBeginAuthSessionResultExpiredTicket = 5, // Ticket has expired
  139. } EBeginAuthSessionResult;
  140. // Callback values for callback ValidateAuthTicketResponse_t which is a response to BeginAuthSession
  141. typedef enum
  142. {
  143. k_EAuthSessionResponseOK = 0, // Steam has verified the user is online, the ticket is valid and ticket has not been reused.
  144. k_EAuthSessionResponseUserNotConnectedToSteam = 1, // The user in question is not connected to steam
  145. k_EAuthSessionResponseNoLicenseOrExpired = 2, // The license has expired.
  146. k_EAuthSessionResponseVACBanned = 3, // The user is VAC banned for this game.
  147. k_EAuthSessionResponseLoggedInElseWhere = 4, // The user account has logged in elsewhere and the session containing the game instance has been disconnected.
  148. k_EAuthSessionResponseVACCheckTimedOut = 5, // VAC has been unable to perform anti-cheat checks on this user
  149. k_EAuthSessionResponseAuthTicketCanceled = 6, // The ticket has been canceled by the issuer
  150. k_EAuthSessionResponseAuthTicketInvalidAlreadyUsed = 7, // This ticket has already been used, it is not valid.
  151. k_EAuthSessionResponseAuthTicketInvalid = 8, // This ticket is not from a user instance currently connected to steam.
  152. } EAuthSessionResponse;
  153. // results from UserHasLicenseForApp
  154. typedef enum
  155. {
  156. k_EUserHasLicenseResultHasLicense = 0, // User has a license for specified app
  157. k_EUserHasLicenseResultDoesNotHaveLicense = 1, // User does not have a license for the specified app
  158. k_EUserHasLicenseResultNoAuth = 2, // User has not been authenticated
  159. } EUserHasLicenseForAppResult;
  160. // Steam universes. Each universe is a self-contained Steam instance.
  161. enum EUniverse
  162. {
  163. k_EUniverseInvalid = 0,
  164. k_EUniversePublic = 1,
  165. k_EUniverseBeta = 2,
  166. k_EUniverseInternal = 3,
  167. k_EUniverseDev = 4,
  168. k_EUniverseRC = 5,
  169. k_EUniverseMax
  170. };
  171. // Steam account types
  172. enum EAccountType
  173. {
  174. k_EAccountTypeInvalid = 0,
  175. k_EAccountTypeIndividual = 1, // single user account
  176. k_EAccountTypeMultiseat = 2, // multiseat (e.g. cybercafe) account
  177. k_EAccountTypeGameServer = 3, // game server account
  178. k_EAccountTypeAnonGameServer = 4, // anonymous game server account
  179. k_EAccountTypePending = 5, // pending
  180. k_EAccountTypeContentServer = 6, // content server
  181. k_EAccountTypeClan = 7,
  182. k_EAccountTypeChat = 8,
  183. k_EAccountTypeConsoleUser = 9, // Fake SteamID for local PSN account on PS3 or Live account on 360, etc.
  184. k_EAccountTypeAnonUser = 10,
  185. // Max of 16 items in this field
  186. k_EAccountTypeMax
  187. };
  188. //-----------------------------------------------------------------------------
  189. // types of user game stats fields
  190. // WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN DATABASE
  191. //-----------------------------------------------------------------------------
  192. enum ESteamUserStatType
  193. {
  194. k_ESteamUserStatTypeINVALID = 0,
  195. k_ESteamUserStatTypeINT = 1,
  196. k_ESteamUserStatTypeFLOAT = 2,
  197. // Read as FLOAT, set with count / session length
  198. k_ESteamUserStatTypeAVGRATE = 3,
  199. k_ESteamUserStatTypeACHIEVEMENTS = 4,
  200. k_ESteamUserStatTypeGROUPACHIEVEMENTS = 5,
  201. // max, for sanity checks
  202. k_ESteamUserStatTypeMAX
  203. };
  204. //-----------------------------------------------------------------------------
  205. // Purpose: Chat Entry Types (previously was only friend-to-friend message types)
  206. //-----------------------------------------------------------------------------
  207. enum EChatEntryType
  208. {
  209. k_EChatEntryTypeInvalid = 0,
  210. k_EChatEntryTypeChatMsg = 1, // Normal text message from another user
  211. k_EChatEntryTypeTyping = 2, // Another user is typing (not used in multi-user chat)
  212. k_EChatEntryTypeInviteGame = 3, // Invite from other user into that users current game
  213. k_EChatEntryTypeEmote = 4, // text emote message
  214. //k_EChatEntryTypeLobbyGameStart = 5, // lobby game is starting (dead - listen for LobbyGameCreated_t callback instead)
  215. k_EChatEntryTypeLeftConversation = 6, // user has left the conversation ( closed chat window )
  216. // Above are previous FriendMsgType entries, now merged into more generic chat entry types
  217. };
  218. //-----------------------------------------------------------------------------
  219. // Purpose: Chat Room Enter Responses
  220. //-----------------------------------------------------------------------------
  221. enum EChatRoomEnterResponse
  222. {
  223. k_EChatRoomEnterResponseSuccess = 1, // Success
  224. k_EChatRoomEnterResponseDoesntExist = 2, // Chat doesn't exist (probably closed)
  225. k_EChatRoomEnterResponseNotAllowed = 3, // General Denied - You don't have the permissions needed to join the chat
  226. k_EChatRoomEnterResponseFull = 4, // Chat room has reached its maximum size
  227. k_EChatRoomEnterResponseError = 5, // Unexpected Error
  228. k_EChatRoomEnterResponseBanned = 6, // You are banned from this chat room and may not join
  229. k_EChatRoomEnterResponseLimited = 7, // Joining this chat is not allowed because you are a limited user (no value on account)
  230. k_EChatRoomEnterResponseClanDisabled = 8, // Attempt to join a clan chat when the clan is locked or disabled
  231. k_EChatRoomEnterResponseCommunityBan = 9, // Attempt to join a chat when the user has a community lock on their account
  232. k_EChatRoomEnterResponseMemberBlockedYou = 10, // Join failed - some member in the chat has blocked you from joining
  233. k_EChatRoomEnterResponseYouBlockedMember = 11, // Join failed - you have blocked some member already in the chat
  234. };
  235. //-----------------------------------------------------------------------------
  236. // Purpose: Status of a given depot version, these are stored in the DB, don't renumber
  237. //-----------------------------------------------------------------------------
  238. enum EStatusDepotVersion
  239. {
  240. k_EStatusDepotVersionInvalid = 0,
  241. k_EStatusDepotVersionDisabled = 1, // version was disabled, no manifest & content available
  242. k_EStatusDepotVersionAvailable = 2, // manifest & content is available, but not current
  243. k_EStatusDepotVersionCurrent = 3, // current depot version. The can be multiple, one for public and one for each beta key
  244. };
  245. typedef void (*PFNLegacyKeyRegistration)( const char *pchCDKey, const char *pchInstallPath );
  246. typedef bool (*PFNLegacyKeyInstalled)();
  247. const unsigned int k_unSteamAccountIDMask = 0xFFFFFFFF;
  248. const unsigned int k_unSteamAccountInstanceMask = 0x000FFFFF;
  249. // we allow 2 simultaneous user account instances right now, 1= desktop, 2 = console, 0 = all
  250. const unsigned int k_unSteamUserDesktopInstance = 1;
  251. const unsigned int k_unSteamUserConsoleInstance = 2;
  252. // Special flags for Chat accounts - they go in the top 8 bits
  253. // of the steam ID's "instance", leaving 12 for the actual instances
  254. enum EChatSteamIDInstanceFlags
  255. {
  256. k_EChatAccountInstanceMask = 0x00000FFF, // top 8 bits are flags
  257. k_EChatInstanceFlagClan = ( k_unSteamAccountInstanceMask + 1 ) >> 1, // top bit
  258. k_EChatInstanceFlagLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 2, // next one down, etc
  259. k_EChatInstanceFlagMMSLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 3, // next one down, etc
  260. // Max of 8 flags
  261. };
  262. //-----------------------------------------------------------------------------
  263. // Purpose: Marketing message flags that change how a client should handle them
  264. //-----------------------------------------------------------------------------
  265. enum EMarketingMessageFlags
  266. {
  267. k_EMarketingMessageFlagsNone = 0,
  268. k_EMarketingMessageFlagsHighPriority = 1 << 0,
  269. k_EMarketingMessageFlagsPlatformWindows = 1 << 1,
  270. k_EMarketingMessageFlagsPlatformMac = 1 << 2,
  271. //aggregate flags
  272. k_EMarketingMessageFlagsPlatformRestrictions =
  273. k_EMarketingMessageFlagsPlatformWindows | k_EMarketingMessageFlagsPlatformMac,
  274. };
  275. //-----------------------------------------------------------------------------
  276. // Purpose: Possible positions to tell the overlay to show notifications in
  277. //-----------------------------------------------------------------------------
  278. enum ENotificationPosition
  279. {
  280. k_EPositionTopLeft = 0,
  281. k_EPositionTopRight = 1,
  282. k_EPositionBottomLeft = 2,
  283. k_EPositionBottomRight = 3,
  284. };
  285. #pragma pack( push, 1 )
  286. // Steam ID structure (64 bits total)
  287. class CSteamID
  288. {
  289. public:
  290. //-----------------------------------------------------------------------------
  291. // Purpose: Constructor
  292. //-----------------------------------------------------------------------------
  293. CSteamID()
  294. {
  295. m_steamid.m_comp.m_unAccountID = 0;
  296. m_steamid.m_comp.m_EAccountType = k_EAccountTypeInvalid;
  297. m_steamid.m_comp.m_EUniverse = k_EUniverseInvalid;
  298. m_steamid.m_comp.m_unAccountInstance = 0;
  299. }
  300. //-----------------------------------------------------------------------------
  301. // Purpose: Constructor
  302. // Input : unAccountID - 32-bit account ID
  303. // eUniverse - Universe this account belongs to
  304. // eAccountType - Type of account
  305. //-----------------------------------------------------------------------------
  306. CSteamID( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
  307. {
  308. Set( unAccountID, eUniverse, eAccountType );
  309. }
  310. //-----------------------------------------------------------------------------
  311. // Purpose: Constructor
  312. // Input : unAccountID - 32-bit account ID
  313. // unAccountInstance - instance
  314. // eUniverse - Universe this account belongs to
  315. // eAccountType - Type of account
  316. //-----------------------------------------------------------------------------
  317. CSteamID( uint32 unAccountID, unsigned int unAccountInstance, EUniverse eUniverse, EAccountType eAccountType )
  318. {
  319. #if defined(_SERVER) && defined(Assert)
  320. Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( unAccountInstance > k_unSteamUserConsoleInstance ) ) ); // enforce that for individual accounts, instance is always 1
  321. #endif // _SERVER
  322. InstancedSet( unAccountID, unAccountInstance, eUniverse, eAccountType );
  323. }
  324. //-----------------------------------------------------------------------------
  325. // Purpose: Constructor
  326. // Input : ulSteamID - 64-bit representation of a Steam ID
  327. // Note: Will not accept a uint32 or int32 as input, as that is a probable mistake.
  328. // See the stubbed out overloads in the private: section for more info.
  329. //-----------------------------------------------------------------------------
  330. CSteamID( uint64 ulSteamID )
  331. {
  332. SetFromUint64( ulSteamID );
  333. }
  334. //-----------------------------------------------------------------------------
  335. // Purpose: Sets parameters for steam ID
  336. // Input : unAccountID - 32-bit account ID
  337. // eUniverse - Universe this account belongs to
  338. // eAccountType - Type of account
  339. //-----------------------------------------------------------------------------
  340. void Set( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
  341. {
  342. m_steamid.m_comp.m_unAccountID = unAccountID;
  343. m_steamid.m_comp.m_EUniverse = eUniverse;
  344. m_steamid.m_comp.m_EAccountType = eAccountType;
  345. if ( eAccountType == k_EAccountTypeClan )
  346. {
  347. m_steamid.m_comp.m_unAccountInstance = 0;
  348. }
  349. else
  350. {
  351. // by default we pick the desktop instance
  352. m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance;
  353. }
  354. }
  355. //-----------------------------------------------------------------------------
  356. // Purpose: Sets parameters for steam ID
  357. // Input : unAccountID - 32-bit account ID
  358. // eUniverse - Universe this account belongs to
  359. // eAccountType - Type of account
  360. //-----------------------------------------------------------------------------
  361. void InstancedSet( uint32 unAccountID, uint32 unInstance, EUniverse eUniverse, EAccountType eAccountType )
  362. {
  363. m_steamid.m_comp.m_unAccountID = unAccountID;
  364. m_steamid.m_comp.m_EUniverse = eUniverse;
  365. m_steamid.m_comp.m_EAccountType = eAccountType;
  366. m_steamid.m_comp.m_unAccountInstance = unInstance;
  367. }
  368. //-----------------------------------------------------------------------------
  369. // Purpose: Initializes a steam ID from its 52 bit parts and universe/type
  370. // Input : ulIdentifier - 52 bits of goodness
  371. //-----------------------------------------------------------------------------
  372. void FullSet( uint64 ulIdentifier, EUniverse eUniverse, EAccountType eAccountType )
  373. {
  374. m_steamid.m_comp.m_unAccountID = ( ulIdentifier & k_unSteamAccountIDMask ); // account ID is low 32 bits
  375. m_steamid.m_comp.m_unAccountInstance = ( ( ulIdentifier >> 32 ) & k_unSteamAccountInstanceMask ); // account instance is next 20 bits
  376. m_steamid.m_comp.m_EUniverse = eUniverse;
  377. m_steamid.m_comp.m_EAccountType = eAccountType;
  378. }
  379. //-----------------------------------------------------------------------------
  380. // Purpose: Initializes a steam ID from its 64-bit representation
  381. // Input : ulSteamID - 64-bit representation of a Steam ID
  382. //-----------------------------------------------------------------------------
  383. void SetFromUint64( uint64 ulSteamID )
  384. {
  385. m_steamid.m_unAll64Bits = ulSteamID;
  386. }
  387. #if defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H )
  388. //-----------------------------------------------------------------------------
  389. // Purpose: Initializes a steam ID from a Steam2 ID structure
  390. // Input: pTSteamGlobalUserID - Steam2 ID to convert
  391. // eUniverse - universe this ID belongs to
  392. //-----------------------------------------------------------------------------
  393. void SetFromSteam2( TSteamGlobalUserID *pTSteamGlobalUserID, EUniverse eUniverse )
  394. {
  395. m_steamid.m_comp.m_unAccountID = pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits * 2 +
  396. pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits;
  397. m_steamid.m_comp.m_EUniverse = eUniverse; // set the universe
  398. m_steamid.m_comp.m_EAccountType = k_EAccountTypeIndividual; // Steam 2 accounts always map to account type of individual
  399. m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance; // Steam2 only knew desktop instances
  400. }
  401. //-----------------------------------------------------------------------------
  402. // Purpose: Fills out a Steam2 ID structure
  403. // Input: pTSteamGlobalUserID - Steam2 ID to write to
  404. //-----------------------------------------------------------------------------
  405. void ConvertToSteam2( TSteamGlobalUserID *pTSteamGlobalUserID ) const
  406. {
  407. // only individual accounts have any meaning in Steam 2, only they can be mapped
  408. // Assert( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual );
  409. pTSteamGlobalUserID->m_SteamInstanceID = 0;
  410. pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits = m_steamid.m_comp.m_unAccountID % 2;
  411. pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits = m_steamid.m_comp.m_unAccountID / 2;
  412. }
  413. #endif // defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H )
  414. //-----------------------------------------------------------------------------
  415. // Purpose: Converts steam ID to its 64-bit representation
  416. // Output : 64-bit representation of a Steam ID
  417. //-----------------------------------------------------------------------------
  418. uint64 ConvertToUint64() const
  419. {
  420. return m_steamid.m_unAll64Bits;
  421. }
  422. //-----------------------------------------------------------------------------
  423. // Purpose: Converts the static parts of a steam ID to a 64-bit representation.
  424. // For multiseat accounts, all instances of that account will have the
  425. // same static account key, so they can be grouped together by the static
  426. // account key.
  427. // Output : 64-bit static account key
  428. //-----------------------------------------------------------------------------
  429. uint64 GetStaticAccountKey() const
  430. {
  431. // note we do NOT include the account instance (which is a dynamic property) in the static account key
  432. return (uint64) ( ( ( (uint64) m_steamid.m_comp.m_EUniverse ) << 56 ) + ((uint64) m_steamid.m_comp.m_EAccountType << 52 ) + m_steamid.m_comp.m_unAccountID );
  433. }
  434. //-----------------------------------------------------------------------------
  435. // Purpose: create an anonymous game server login to be filled in by the AM
  436. //-----------------------------------------------------------------------------
  437. void CreateBlankAnonLogon( EUniverse eUniverse )
  438. {
  439. m_steamid.m_comp.m_unAccountID = 0;
  440. m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonGameServer;
  441. m_steamid.m_comp.m_EUniverse = eUniverse;
  442. m_steamid.m_comp.m_unAccountInstance = 0;
  443. }
  444. //-----------------------------------------------------------------------------
  445. // Purpose: create an anonymous game server login to be filled in by the AM
  446. //-----------------------------------------------------------------------------
  447. void CreateBlankAnonUserLogon( EUniverse eUniverse )
  448. {
  449. m_steamid.m_comp.m_unAccountID = 0;
  450. m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonUser;
  451. m_steamid.m_comp.m_EUniverse = eUniverse;
  452. m_steamid.m_comp.m_unAccountInstance = 0;
  453. }
  454. //-----------------------------------------------------------------------------
  455. // Purpose: Is this an anonymous game server login that will be filled in?
  456. //-----------------------------------------------------------------------------
  457. bool BBlankAnonAccount() const
  458. {
  459. return m_steamid.m_comp.m_unAccountID == 0 && BAnonAccount() && m_steamid.m_comp.m_unAccountInstance == 0;
  460. }
  461. //-----------------------------------------------------------------------------
  462. // Purpose: Is this a game server account id? (Either persistent or anonymous)
  463. //-----------------------------------------------------------------------------
  464. bool BGameServerAccount() const
  465. {
  466. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  467. }
  468. //-----------------------------------------------------------------------------
  469. // Purpose: Is this a persistent (not anonymous) game server account id?
  470. //-----------------------------------------------------------------------------
  471. bool BPersistentGameServerAccount() const
  472. {
  473. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer;
  474. }
  475. //-----------------------------------------------------------------------------
  476. // Purpose: Is this an anonymous game server account id?
  477. //-----------------------------------------------------------------------------
  478. bool BAnonGameServerAccount() const
  479. {
  480. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  481. }
  482. //-----------------------------------------------------------------------------
  483. // Purpose: Is this a content server account id?
  484. //-----------------------------------------------------------------------------
  485. bool BContentServerAccount() const
  486. {
  487. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeContentServer;
  488. }
  489. //-----------------------------------------------------------------------------
  490. // Purpose: Is this a clan account id?
  491. //-----------------------------------------------------------------------------
  492. bool BClanAccount() const
  493. {
  494. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan;
  495. }
  496. //-----------------------------------------------------------------------------
  497. // Purpose: Is this a chat account id?
  498. //-----------------------------------------------------------------------------
  499. bool BChatAccount() const
  500. {
  501. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat;
  502. }
  503. //-----------------------------------------------------------------------------
  504. // Purpose: Is this a chat account id?
  505. //-----------------------------------------------------------------------------
  506. bool IsLobby() const
  507. {
  508. return ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat )
  509. && ( m_steamid.m_comp.m_unAccountInstance & k_EChatInstanceFlagLobby );
  510. }
  511. //-----------------------------------------------------------------------------
  512. // Purpose: Is this an individual user account id?
  513. //-----------------------------------------------------------------------------
  514. bool BIndividualAccount() const
  515. {
  516. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual || m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
  517. }
  518. //-----------------------------------------------------------------------------
  519. // Purpose: Is this an anonymous account?
  520. //-----------------------------------------------------------------------------
  521. bool BAnonAccount() const
  522. {
  523. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  524. }
  525. //-----------------------------------------------------------------------------
  526. // Purpose: Is this an anonymous user account? ( used to create an account or reset a password )
  527. //-----------------------------------------------------------------------------
  528. bool BAnonUserAccount() const
  529. {
  530. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser;
  531. }
  532. //-----------------------------------------------------------------------------
  533. // Purpose: Is this a faked up Steam ID for a PSN friend account?
  534. //-----------------------------------------------------------------------------
  535. bool BConsoleUserAccount() const
  536. {
  537. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
  538. }
  539. // simple accessors
  540. void SetAccountID( uint32 unAccountID ) { m_steamid.m_comp.m_unAccountID = unAccountID; }
  541. void SetAccountInstance( uint32 unInstance ){ m_steamid.m_comp.m_unAccountInstance = unInstance; }
  542. void ClearIndividualInstance() { if ( BIndividualAccount() ) m_steamid.m_comp.m_unAccountInstance = 0; }
  543. bool HasNoIndividualInstance() const { return BIndividualAccount() && (m_steamid.m_comp.m_unAccountInstance==0); }
  544. AccountID_t GetAccountID() const { return m_steamid.m_comp.m_unAccountID; }
  545. uint32 GetUnAccountInstance() const { return m_steamid.m_comp.m_unAccountInstance; }
  546. EAccountType GetEAccountType() const { return ( EAccountType ) m_steamid.m_comp.m_EAccountType; }
  547. EUniverse GetEUniverse() const { return m_steamid.m_comp.m_EUniverse; }
  548. void SetEUniverse( EUniverse eUniverse ) { m_steamid.m_comp.m_EUniverse = eUniverse; }
  549. bool IsValid() const;
  550. // this set of functions is hidden, will be moved out of class
  551. explicit CSteamID( const char *pchSteamID, EUniverse eDefaultUniverse = k_EUniverseInvalid );
  552. const char * Render() const; // renders this steam ID to string
  553. static const char * Render( uint64 ulSteamID ); // static method to render a uint64 representation of a steam ID to a string
  554. void SetFromString( const char *pchSteamID, EUniverse eDefaultUniverse );
  555. bool SetFromSteam2String( const char *pchSteam2ID, EUniverse eUniverse );
  556. inline bool operator==( const CSteamID &val ) const { return m_steamid.m_unAll64Bits == val.m_steamid.m_unAll64Bits; }
  557. inline bool operator!=( const CSteamID &val ) const { return !operator==( val ); }
  558. inline bool operator<( const CSteamID &val ) const { return m_steamid.m_unAll64Bits < val.m_steamid.m_unAll64Bits; }
  559. inline bool operator>( const CSteamID &val ) const { return m_steamid.m_unAll64Bits > val.m_steamid.m_unAll64Bits; }
  560. // DEBUG function
  561. bool BValidExternalSteamID() const;
  562. private:
  563. // These are defined here to prevent accidental implicit conversion of a u32AccountID to a CSteamID.
  564. // If you get a compiler error about an ambiguous constructor/function then it may be because you're
  565. // passing a 32-bit int to a function that takes a CSteamID. You should explicitly create the SteamID
  566. // using the correct Universe and account Type/Instance values.
  567. CSteamID( uint32 );
  568. CSteamID( int32 );
  569. // 64 bits total
  570. union SteamID_t
  571. {
  572. struct SteamIDComponent_t
  573. {
  574. #ifdef VALVE_BIG_ENDIAN
  575. EUniverse m_EUniverse : 8; // universe this account belongs to
  576. unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
  577. unsigned int m_unAccountInstance : 20; // dynamic instance ID
  578. uint32 m_unAccountID : 32; // unique account identifier
  579. #else
  580. uint32 m_unAccountID : 32; // unique account identifier
  581. unsigned int m_unAccountInstance : 20; // dynamic instance ID
  582. unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
  583. EUniverse m_EUniverse : 8; // universe this account belongs to
  584. #endif
  585. } m_comp;
  586. uint64 m_unAll64Bits;
  587. } m_steamid;
  588. };
  589. inline bool CSteamID::IsValid() const
  590. {
  591. if ( m_steamid.m_comp.m_EAccountType <= k_EAccountTypeInvalid || m_steamid.m_comp.m_EAccountType >= k_EAccountTypeMax )
  592. return false;
  593. if ( m_steamid.m_comp.m_EUniverse <= k_EUniverseInvalid || m_steamid.m_comp.m_EUniverse >= k_EUniverseMax )
  594. return false;
  595. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual )
  596. {
  597. if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance > k_unSteamUserConsoleInstance )
  598. return false;
  599. }
  600. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan )
  601. {
  602. if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance != 0 )
  603. return false;
  604. }
  605. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer )
  606. {
  607. if ( m_steamid.m_comp.m_unAccountID == 0 )
  608. return false;
  609. // Any limit on instances? We use them for local users and bots
  610. }
  611. return true;
  612. }
  613. // generic invalid CSteamID
  614. #define k_steamIDNil CSteamID()
  615. // This steamID comes from a user game connection to an out of date GS that hasnt implemented the protocol
  616. // to provide its steamID
  617. #define k_steamIDOutofDateGS CSteamID( 0, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  618. // This steamID comes from a user game connection to an sv_lan GS
  619. #define k_steamIDLanModeGS CSteamID( 0, 0, k_EUniversePublic, k_EAccountTypeInvalid )
  620. // This steamID can come from a user game connection to a GS that has just booted but hasnt yet even initialized
  621. // its steam3 component and started logging on.
  622. #define k_steamIDNotInitYetGS CSteamID( 1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  623. // This steamID can come from a user game connection to a GS that isn't using the steam authentication system but still
  624. // wants to support the "Join Game" option in the friends list
  625. #define k_steamIDNonSteamGS CSteamID( 2, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  626. #ifdef STEAM
  627. // Returns the matching chat steamID, with the default instance of 0
  628. // If the steamID passed in is already of type k_EAccountTypeChat it will be returned with the same instance
  629. CSteamID ChatIDFromSteamID( const CSteamID &steamID );
  630. // Returns the matching clan steamID, with the default instance of 0
  631. // If the steamID passed in is already of type k_EAccountTypeClan it will be returned with the same instance
  632. CSteamID ClanIDFromSteamID( const CSteamID &steamID );
  633. // Asserts steamID type before conversion
  634. CSteamID ChatIDFromClanID( const CSteamID &steamIDClan );
  635. // Asserts steamID type before conversion
  636. CSteamID ClanIDFromChatID( const CSteamID &steamIDChat );
  637. #endif // _STEAM
  638. //-----------------------------------------------------------------------------
  639. // Purpose: encapsulates an appID/modID pair
  640. //-----------------------------------------------------------------------------
  641. class CGameID
  642. {
  643. public:
  644. CGameID()
  645. {
  646. m_gameID.m_nType = k_EGameIDTypeApp;
  647. m_gameID.m_nAppID = k_uAppIdInvalid;
  648. m_gameID.m_nModID = 0;
  649. }
  650. explicit CGameID( uint64 ulGameID )
  651. {
  652. m_ulGameID = ulGameID;
  653. }
  654. explicit CGameID( int32 nAppID )
  655. {
  656. m_ulGameID = 0;
  657. m_gameID.m_nAppID = nAppID;
  658. }
  659. explicit CGameID( uint32 nAppID )
  660. {
  661. m_ulGameID = 0;
  662. m_gameID.m_nAppID = nAppID;
  663. }
  664. CGameID( uint32 nAppID, uint32 nModID )
  665. {
  666. m_ulGameID = 0;
  667. m_gameID.m_nAppID = nAppID;
  668. m_gameID.m_nModID = nModID;
  669. m_gameID.m_nType = k_EGameIDTypeGameMod;
  670. }
  671. // Hidden functions used only by Steam
  672. explicit CGameID( const char *pchGameID );
  673. const char *Render() const; // render this Game ID to string
  674. static const char *Render( uint64 ulGameID ); // static method to render a uint64 representation of a Game ID to a string
  675. // must include checksum_crc.h first to get this functionality
  676. #if defined( CHECKSUM_CRC_H )
  677. CGameID( uint32 nAppID, const char *pchModPath )
  678. {
  679. m_ulGameID = 0;
  680. m_gameID.m_nAppID = nAppID;
  681. m_gameID.m_nType = k_EGameIDTypeGameMod;
  682. char rgchModDir[MAX_PATH];
  683. Q_FileBase( pchModPath, rgchModDir, sizeof( rgchModDir ) );
  684. CRC32_t crc32;
  685. CRC32_Init( &crc32 );
  686. CRC32_ProcessBuffer( &crc32, rgchModDir, Q_strlen( rgchModDir ) );
  687. CRC32_Final( &crc32 );
  688. // set the high-bit on the mod-id
  689. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  690. // replacement for appID's
  691. m_gameID.m_nModID = crc32 | (0x80000000);
  692. }
  693. CGameID( const char *pchExePath, const char *pchAppName )
  694. {
  695. m_ulGameID = 0;
  696. m_gameID.m_nAppID = k_uAppIdInvalid;
  697. m_gameID.m_nType = k_EGameIDTypeShortcut;
  698. CRC32_t crc32;
  699. CRC32_Init( &crc32 );
  700. CRC32_ProcessBuffer( &crc32, pchExePath, Q_strlen( pchExePath ) );
  701. CRC32_ProcessBuffer( &crc32, pchAppName, Q_strlen( pchAppName ) );
  702. CRC32_Final( &crc32 );
  703. // set the high-bit on the mod-id
  704. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  705. // replacement for appID's
  706. m_gameID.m_nModID = crc32 | (0x80000000);
  707. }
  708. #if defined( VSTFILEID_H )
  709. CGameID( VstFileID vstFileID )
  710. {
  711. m_ulGameID = 0;
  712. m_gameID.m_nAppID = k_uAppIdInvalid;
  713. m_gameID.m_nType = k_EGameIDTypeP2P;
  714. CRC32_t crc32;
  715. CRC32_Init( &crc32 );
  716. const char *pchFileId = vstFileID.Render();
  717. CRC32_ProcessBuffer( &crc32, pchFileId, Q_strlen( pchFileId ) );
  718. CRC32_Final( &crc32 );
  719. // set the high-bit on the mod-id
  720. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  721. // replacement for appID's
  722. m_gameID.m_nModID = crc32 | (0x80000000);
  723. }
  724. #endif /* VSTFILEID_H */
  725. #endif /* CHECKSUM_CRC_H */
  726. uint64 ToUint64() const
  727. {
  728. return m_ulGameID;
  729. }
  730. uint64 *GetUint64Ptr()
  731. {
  732. return &m_ulGameID;
  733. }
  734. void Set( uint64 ulGameID )
  735. {
  736. m_ulGameID = ulGameID;
  737. }
  738. bool IsMod() const
  739. {
  740. return ( m_gameID.m_nType == k_EGameIDTypeGameMod );
  741. }
  742. bool IsShortcut() const
  743. {
  744. return ( m_gameID.m_nType == k_EGameIDTypeShortcut );
  745. }
  746. bool IsP2PFile() const
  747. {
  748. return ( m_gameID.m_nType == k_EGameIDTypeP2P );
  749. }
  750. bool IsSteamApp() const
  751. {
  752. return ( m_gameID.m_nType == k_EGameIDTypeApp );
  753. }
  754. uint32 ModID() const
  755. {
  756. return m_gameID.m_nModID;
  757. }
  758. uint32 AppID() const
  759. {
  760. return m_gameID.m_nAppID;
  761. }
  762. bool operator == ( const CGameID &rhs ) const
  763. {
  764. return m_ulGameID == rhs.m_ulGameID;
  765. }
  766. bool operator != ( const CGameID &rhs ) const
  767. {
  768. return !(*this == rhs);
  769. }
  770. bool operator < ( const CGameID &rhs ) const
  771. {
  772. return ( m_ulGameID < rhs.m_ulGameID );
  773. }
  774. bool IsValid() const
  775. {
  776. // each type has it's own invalid fixed point:
  777. switch( m_gameID.m_nType )
  778. {
  779. case k_EGameIDTypeApp:
  780. return m_gameID.m_nAppID != k_uAppIdInvalid;
  781. case k_EGameIDTypeGameMod:
  782. return m_gameID.m_nAppID != k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000;
  783. case k_EGameIDTypeShortcut:
  784. return (m_gameID.m_nModID & 0x80000000) != 0;
  785. case k_EGameIDTypeP2P:
  786. return m_gameID.m_nAppID == k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000;
  787. default:
  788. #if defined(Assert)
  789. Assert(false);
  790. #endif
  791. return false;
  792. }
  793. }
  794. void Reset()
  795. {
  796. m_ulGameID = 0;
  797. }
  798. private:
  799. enum EGameIDType
  800. {
  801. k_EGameIDTypeApp = 0,
  802. k_EGameIDTypeGameMod = 1,
  803. k_EGameIDTypeShortcut = 2,
  804. k_EGameIDTypeP2P = 3,
  805. };
  806. struct GameID_t
  807. {
  808. #ifdef VALVE_BIG_ENDIAN
  809. unsigned int m_nModID : 32;
  810. unsigned int m_nType : 8;
  811. unsigned int m_nAppID : 24;
  812. #else
  813. unsigned int m_nAppID : 24;
  814. unsigned int m_nType : 8;
  815. unsigned int m_nModID : 32;
  816. #endif
  817. };
  818. union
  819. {
  820. uint64 m_ulGameID;
  821. GameID_t m_gameID;
  822. };
  823. };
  824. #pragma pack( pop )
  825. const int k_cchGameExtraInfoMax = 64;
  826. //-----------------------------------------------------------------------------
  827. // Constants used for query ports.
  828. //-----------------------------------------------------------------------------
  829. #define QUERY_PORT_NOT_INITIALIZED 0xFFFF // We haven't asked the GS for this query port's actual value yet.
  830. #define QUERY_PORT_ERROR 0xFFFE // We were unable to get the query port for this server.
  831. //-----------------------------------------------------------------------------
  832. // Purpose: Passed as argument to SteamAPI_UseBreakpadCrashHandler to enable optional callback
  833. // just before minidump file is captured after a crash has occurred. (Allows app to append additional comment data to the dump, etc.)
  834. //-----------------------------------------------------------------------------
  835. typedef void (*PFNPreMinidumpCallback)(void *context);
  836. //-----------------------------------------------------------------------------
  837. // Purpose: Used by ICrashHandler interfaces to reference particular installed crash handlers
  838. //-----------------------------------------------------------------------------
  839. typedef void *BREAKPAD_HANDLE;
  840. #define BREAKPAD_INVALID_HANDLE (BREAKPAD_HANDLE)0
  841. #endif // STEAMCLIENTPUBLIC_H