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.

1229 lines
53 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. #include "steamuniverse.h"
  20. // General result codes
  21. enum EResult
  22. {
  23. k_EResultOK = 1, // success
  24. k_EResultFail = 2, // generic failure
  25. k_EResultNoConnection = 3, // no/failed network connection
  26. // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
  27. k_EResultInvalidPassword = 5, // password/ticket is invalid
  28. k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
  29. k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
  30. k_EResultInvalidParam = 8, // a parameter is incorrect
  31. k_EResultFileNotFound = 9, // file was not found
  32. k_EResultBusy = 10, // called method busy - action not taken
  33. k_EResultInvalidState = 11, // called object was in an invalid state
  34. k_EResultInvalidName = 12, // name is invalid
  35. k_EResultInvalidEmail = 13, // email is invalid
  36. k_EResultDuplicateName = 14, // name is not unique
  37. k_EResultAccessDenied = 15, // access is denied
  38. k_EResultTimeout = 16, // operation timed out
  39. k_EResultBanned = 17, // VAC2 banned
  40. k_EResultAccountNotFound = 18, // account not found
  41. k_EResultInvalidSteamID = 19, // steamID is invalid
  42. k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
  43. k_EResultNotLoggedOn = 21, // The user is not logged on
  44. k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
  45. k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
  46. k_EResultInsufficientPrivilege = 24, // Insufficient privilege
  47. k_EResultLimitExceeded = 25, // Too much of a good thing
  48. k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
  49. k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
  50. k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
  51. k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
  52. k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
  53. k_EResultIPNotFound = 31, // IP address not found
  54. k_EResultPersistFailed = 32, // failed to write change to the data store
  55. k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
  56. k_EResultLogonSessionReplaced = 34,
  57. k_EResultConnectFailed = 35,
  58. k_EResultHandshakeFailed = 36,
  59. k_EResultIOFailure = 37,
  60. k_EResultRemoteDisconnect = 38,
  61. k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
  62. k_EResultBlocked = 40, // a user didn't allow it
  63. k_EResultIgnored = 41, // target is ignoring sender
  64. k_EResultNoMatch = 42, // nothing matching the request found
  65. k_EResultAccountDisabled = 43,
  66. k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
  67. k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
  68. k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
  69. k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
  70. k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
  71. k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
  72. k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
  73. k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
  74. k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
  75. k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
  76. k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
  77. k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
  78. k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
  79. k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
  80. k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
  81. k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
  82. k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
  83. k_EResultIllegalPassword = 61, // The requested new password is not legal
  84. k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
  85. k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
  86. k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
  87. k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
  88. k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
  89. k_EResultHardwareNotCapableOfIPT = 67, //
  90. k_EResultIPTInitError = 68, //
  91. k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
  92. k_EResultFacebookQueryError = 70, // Facebook query returned an error
  93. k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
  94. k_EResultIPLoginRestrictionFailed = 72,
  95. k_EResultAccountLockedDown = 73,
  96. k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
  97. k_EResultNoMatchingURL = 75,
  98. k_EResultBadResponse = 76, // parse failure, missing field, etc.
  99. k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password
  100. k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range
  101. k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen
  102. k_EResultDisabled = 80, // The requested service has been configured to be unavailable
  103. k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
  104. k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
  105. k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
  106. k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
  107. k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login
  108. k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted
  109. k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker
  110. k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
  111. k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match
  112. k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners
  113. k_EResultNotModified = 91, // data not modified
  114. k_EResultNoMobileDevice = 92, // the account does not have a mobile device associated with it
  115. k_EResultTimeNotSynced = 93, // the time presented is out of range or tolerance
  116. k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending, etc.)
  117. k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource
  118. k_EResultAccountActivityLimitExceeded = 96, // Too many changes to this account
  119. k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone
  120. k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use wallet
  121. k_EResultEmailSendFailure = 99, // Cannot send an email
  122. k_EResultNotSettled = 100, // Can't perform operation till payment has settled
  123. k_EResultNeedCaptcha = 101, // Needs to provide a valid captcha
  124. k_EResultGSLTDenied = 102, // a game server login token owned by this token's owner has been banned
  125. k_EResultGSOwnerDenied = 103, // game server owner is denied for other reason (account lock, community ban, vac ban, missing phone)
  126. k_EResultInvalidItemType = 104, // the type of thing we were requested to act on is invalid
  127. k_EResultIPBanned = 105, // the ip address has been banned from taking this action
  128. k_EResultGSLTExpired = 106, // this token has expired from disuse; can be reset for use
  129. };
  130. // Error codes for use with the voice functions
  131. enum EVoiceResult
  132. {
  133. k_EVoiceResultOK = 0,
  134. k_EVoiceResultNotInitialized = 1,
  135. k_EVoiceResultNotRecording = 2,
  136. k_EVoiceResultNoData = 3,
  137. k_EVoiceResultBufferTooSmall = 4,
  138. k_EVoiceResultDataCorrupted = 5,
  139. k_EVoiceResultRestricted = 6,
  140. k_EVoiceResultUnsupportedCodec = 7,
  141. k_EVoiceResultReceiverOutOfDate = 8,
  142. k_EVoiceResultReceiverDidNotAnswer = 9,
  143. };
  144. // Result codes to GSHandleClientDeny/Kick
  145. enum EDenyReason
  146. {
  147. k_EDenyInvalid = 0,
  148. k_EDenyInvalidVersion = 1,
  149. k_EDenyGeneric = 2,
  150. k_EDenyNotLoggedOn = 3,
  151. k_EDenyNoLicense = 4,
  152. k_EDenyCheater = 5,
  153. k_EDenyLoggedInElseWhere = 6,
  154. k_EDenyUnknownText = 7,
  155. k_EDenyIncompatibleAnticheat = 8,
  156. k_EDenyMemoryCorruption = 9,
  157. k_EDenyIncompatibleSoftware = 10,
  158. k_EDenySteamConnectionLost = 11,
  159. k_EDenySteamConnectionError = 12,
  160. k_EDenySteamResponseTimedOut = 13,
  161. k_EDenySteamValidationStalled = 14,
  162. k_EDenySteamOwnerLeftGuestUser = 15,
  163. };
  164. // return type of GetAuthSessionTicket
  165. typedef uint32 HAuthTicket;
  166. const HAuthTicket k_HAuthTicketInvalid = 0;
  167. // results from BeginAuthSession
  168. enum EBeginAuthSessionResult
  169. {
  170. k_EBeginAuthSessionResultOK = 0, // Ticket is valid for this game and this steamID.
  171. k_EBeginAuthSessionResultInvalidTicket = 1, // Ticket is not valid.
  172. k_EBeginAuthSessionResultDuplicateRequest = 2, // A ticket has already been submitted for this steamID
  173. k_EBeginAuthSessionResultInvalidVersion = 3, // Ticket is from an incompatible interface version
  174. k_EBeginAuthSessionResultGameMismatch = 4, // Ticket is not for this game
  175. k_EBeginAuthSessionResultExpiredTicket = 5, // Ticket has expired
  176. };
  177. // Callback values for callback ValidateAuthTicketResponse_t which is a response to BeginAuthSession
  178. enum EAuthSessionResponse
  179. {
  180. k_EAuthSessionResponseOK = 0, // Steam has verified the user is online, the ticket is valid and ticket has not been reused.
  181. k_EAuthSessionResponseUserNotConnectedToSteam = 1, // The user in question is not connected to steam
  182. k_EAuthSessionResponseNoLicenseOrExpired = 2, // The license has expired.
  183. k_EAuthSessionResponseVACBanned = 3, // The user is VAC banned for this game.
  184. k_EAuthSessionResponseLoggedInElseWhere = 4, // The user account has logged in elsewhere and the session containing the game instance has been disconnected.
  185. k_EAuthSessionResponseVACCheckTimedOut = 5, // VAC has been unable to perform anti-cheat checks on this user
  186. k_EAuthSessionResponseAuthTicketCanceled = 6, // The ticket has been canceled by the issuer
  187. k_EAuthSessionResponseAuthTicketInvalidAlreadyUsed = 7, // This ticket has already been used, it is not valid.
  188. k_EAuthSessionResponseAuthTicketInvalid = 8, // This ticket is not from a user instance currently connected to steam.
  189. k_EAuthSessionResponsePublisherIssuedBan = 9, // The user is banned for this game. The ban came via the web api and not VAC
  190. };
  191. // results from UserHasLicenseForApp
  192. enum EUserHasLicenseForAppResult
  193. {
  194. k_EUserHasLicenseResultHasLicense = 0, // User has a license for specified app
  195. k_EUserHasLicenseResultDoesNotHaveLicense = 1, // User does not have a license for the specified app
  196. k_EUserHasLicenseResultNoAuth = 2, // User has not been authenticated
  197. };
  198. // Steam account types
  199. enum EAccountType
  200. {
  201. k_EAccountTypeInvalid = 0,
  202. k_EAccountTypeIndividual = 1, // single user account
  203. k_EAccountTypeMultiseat = 2, // multiseat (e.g. cybercafe) account
  204. k_EAccountTypeGameServer = 3, // game server account
  205. k_EAccountTypeAnonGameServer = 4, // anonymous game server account
  206. k_EAccountTypePending = 5, // pending
  207. k_EAccountTypeContentServer = 6, // content server
  208. k_EAccountTypeClan = 7,
  209. k_EAccountTypeChat = 8,
  210. k_EAccountTypeConsoleUser = 9, // Fake SteamID for local PSN account on PS3 or Live account on 360, etc.
  211. k_EAccountTypeAnonUser = 10,
  212. // Max of 16 items in this field
  213. k_EAccountTypeMax
  214. };
  215. //-----------------------------------------------------------------------------
  216. // Purpose:
  217. //-----------------------------------------------------------------------------
  218. enum EAppReleaseState
  219. {
  220. k_EAppReleaseState_Unknown = 0, // unknown, required appinfo or license info is missing
  221. k_EAppReleaseState_Unavailable = 1, // even if user 'just' owns it, can see game at all
  222. k_EAppReleaseState_Prerelease = 2, // can be purchased and is visible in games list, nothing else. Common appInfo section released
  223. k_EAppReleaseState_PreloadOnly = 3, // owners can preload app, not play it. AppInfo fully released.
  224. k_EAppReleaseState_Released = 4, // owners can download and play app.
  225. };
  226. //-----------------------------------------------------------------------------
  227. // Purpose:
  228. //-----------------------------------------------------------------------------
  229. enum EAppOwnershipFlags
  230. {
  231. k_EAppOwnershipFlags_None = 0x0000, // unknown
  232. k_EAppOwnershipFlags_OwnsLicense = 0x0001, // owns license for this game
  233. k_EAppOwnershipFlags_FreeLicense = 0x0002, // not paid for game
  234. k_EAppOwnershipFlags_RegionRestricted = 0x0004, // owns app, but not allowed to play in current region
  235. k_EAppOwnershipFlags_LowViolence = 0x0008, // only low violence version
  236. k_EAppOwnershipFlags_InvalidPlatform = 0x0010, // app not supported on current platform
  237. k_EAppOwnershipFlags_SharedLicense = 0x0020, // license was granted by authorized local device
  238. k_EAppOwnershipFlags_FreeWeekend = 0x0040, // owned by a free weekend licenses
  239. k_EAppOwnershipFlags_RetailLicense = 0x0080, // has a retail license for game, (CD-Key etc)
  240. k_EAppOwnershipFlags_LicenseLocked = 0x0100, // shared license is locked (in use) by other user
  241. k_EAppOwnershipFlags_LicensePending = 0x0200, // owns app, but transaction is still pending. Can't install or play
  242. k_EAppOwnershipFlags_LicenseExpired = 0x0400, // doesn't own app anymore since license expired
  243. k_EAppOwnershipFlags_LicensePermanent = 0x0800, // permanent license, not borrowed, or guest or freeweekend etc
  244. k_EAppOwnershipFlags_LicenseRecurring = 0x1000, // Recurring license, user is charged periodically
  245. k_EAppOwnershipFlags_LicenseCanceled = 0x2000, // Mark as canceled, but might be still active if recurring
  246. k_EAppOwnershipFlags_AutoGrant = 0x4000, // Ownership is based on any kind of autogrant license
  247. k_EAppOwnershipFlags_PendingGift = 0x8000, // user has pending gift to redeem
  248. k_EAppOwnershipFlags_RentalNotActivated = 0x10000, // Rental hasn't been activated yet
  249. k_EAppOwnershipFlags_Rental = 0x20000, // Is a rental
  250. };
  251. //-----------------------------------------------------------------------------
  252. // Purpose: designed as flags to allow filters masks
  253. //-----------------------------------------------------------------------------
  254. enum EAppType
  255. {
  256. k_EAppType_Invalid = 0x000, // unknown / invalid
  257. k_EAppType_Game = 0x001, // playable game, default type
  258. k_EAppType_Application = 0x002, // software application
  259. k_EAppType_Tool = 0x004, // SDKs, editors & dedicated servers
  260. k_EAppType_Demo = 0x008, // game demo
  261. k_EAppType_Media_DEPRECATED = 0x010, // legacy - was used for game trailers, which are now just videos on the web
  262. k_EAppType_DLC = 0x020, // down loadable content
  263. k_EAppType_Guide = 0x040, // game guide, PDF etc
  264. k_EAppType_Driver = 0x080, // hardware driver updater (ATI, Razor etc)
  265. k_EAppType_Config = 0x100, // hidden app used to config Steam features (backpack, sales, etc)
  266. k_EAppType_Hardware = 0x200, // a hardware device (Steam Machine, Steam Controller, Steam Link, etc.)
  267. // 0x400 is up for grabs here
  268. k_EAppType_Video = 0x800, // A video component of either a Film or TVSeries (may be the feature, an episode, preview, making-of, etc)
  269. k_EAppType_Plugin = 0x1000, // Plug-in types for other Apps
  270. k_EAppType_Music = 0x2000, // Music files
  271. k_EAppType_Shortcut = 0x40000000, // just a shortcut, client side only
  272. k_EAppType_DepotOnly = 0x80000000, // placeholder since depots and apps share the same namespace
  273. };
  274. //-----------------------------------------------------------------------------
  275. // types of user game stats fields
  276. // WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN DATABASE
  277. //-----------------------------------------------------------------------------
  278. enum ESteamUserStatType
  279. {
  280. k_ESteamUserStatTypeINVALID = 0,
  281. k_ESteamUserStatTypeINT = 1,
  282. k_ESteamUserStatTypeFLOAT = 2,
  283. // Read as FLOAT, set with count / session length
  284. k_ESteamUserStatTypeAVGRATE = 3,
  285. k_ESteamUserStatTypeACHIEVEMENTS = 4,
  286. k_ESteamUserStatTypeGROUPACHIEVEMENTS = 5,
  287. // max, for sanity checks
  288. k_ESteamUserStatTypeMAX
  289. };
  290. //-----------------------------------------------------------------------------
  291. // Purpose: Chat Entry Types (previously was only friend-to-friend message types)
  292. //-----------------------------------------------------------------------------
  293. enum EChatEntryType
  294. {
  295. k_EChatEntryTypeInvalid = 0,
  296. k_EChatEntryTypeChatMsg = 1, // Normal text message from another user
  297. k_EChatEntryTypeTyping = 2, // Another user is typing (not used in multi-user chat)
  298. k_EChatEntryTypeInviteGame = 3, // Invite from other user into that users current game
  299. k_EChatEntryTypeEmote = 4, // text emote message (deprecated, should be treated as ChatMsg)
  300. //k_EChatEntryTypeLobbyGameStart = 5, // lobby game is starting (dead - listen for LobbyGameCreated_t callback instead)
  301. k_EChatEntryTypeLeftConversation = 6, // user has left the conversation ( closed chat window )
  302. // Above are previous FriendMsgType entries, now merged into more generic chat entry types
  303. k_EChatEntryTypeEntered = 7, // user has entered the conversation (used in multi-user chat and group chat)
  304. k_EChatEntryTypeWasKicked = 8, // user was kicked (data: 64-bit steamid of actor performing the kick)
  305. k_EChatEntryTypeWasBanned = 9, // user was banned (data: 64-bit steamid of actor performing the ban)
  306. k_EChatEntryTypeDisconnected = 10, // user disconnected
  307. k_EChatEntryTypeHistoricalChat = 11, // a chat message from user's chat history or offilne message
  308. //k_EChatEntryTypeReserved1 = 12, // No longer used
  309. //k_EChatEntryTypeReserved2 = 13, // No longer used
  310. k_EChatEntryTypeLinkBlocked = 14, // a link was removed by the chat filter.
  311. };
  312. //-----------------------------------------------------------------------------
  313. // Purpose: Chat Room Enter Responses
  314. //-----------------------------------------------------------------------------
  315. enum EChatRoomEnterResponse
  316. {
  317. k_EChatRoomEnterResponseSuccess = 1, // Success
  318. k_EChatRoomEnterResponseDoesntExist = 2, // Chat doesn't exist (probably closed)
  319. k_EChatRoomEnterResponseNotAllowed = 3, // General Denied - You don't have the permissions needed to join the chat
  320. k_EChatRoomEnterResponseFull = 4, // Chat room has reached its maximum size
  321. k_EChatRoomEnterResponseError = 5, // Unexpected Error
  322. k_EChatRoomEnterResponseBanned = 6, // You are banned from this chat room and may not join
  323. k_EChatRoomEnterResponseLimited = 7, // Joining this chat is not allowed because you are a limited user (no value on account)
  324. k_EChatRoomEnterResponseClanDisabled = 8, // Attempt to join a clan chat when the clan is locked or disabled
  325. k_EChatRoomEnterResponseCommunityBan = 9, // Attempt to join a chat when the user has a community lock on their account
  326. k_EChatRoomEnterResponseMemberBlockedYou = 10, // Join failed - some member in the chat has blocked you from joining
  327. k_EChatRoomEnterResponseYouBlockedMember = 11, // Join failed - you have blocked some member already in the chat
  328. // k_EChatRoomEnterResponseNoRankingDataLobby = 12, // No longer used
  329. // k_EChatRoomEnterResponseNoRankingDataUser = 13, // No longer used
  330. // k_EChatRoomEnterResponseRankOutOfRange = 14, // No longer used
  331. k_EChatRoomEnterResponseRatelimitExceeded = 15, // Join failed - to many join attempts in a very short period of time
  332. };
  333. typedef void (*PFNLegacyKeyRegistration)( const char *pchCDKey, const char *pchInstallPath );
  334. typedef bool (*PFNLegacyKeyInstalled)();
  335. const unsigned int k_unSteamAccountIDMask = 0xFFFFFFFF;
  336. const unsigned int k_unSteamAccountInstanceMask = 0x000FFFFF;
  337. // we allow 3 simultaneous user account instances right now, 1= desktop, 2 = console, 4 = web, 0 = all
  338. const unsigned int k_unSteamUserDesktopInstance = 1;
  339. const unsigned int k_unSteamUserConsoleInstance = 2;
  340. const unsigned int k_unSteamUserWebInstance = 4;
  341. // Special flags for Chat accounts - they go in the top 8 bits
  342. // of the steam ID's "instance", leaving 12 for the actual instances
  343. enum EChatSteamIDInstanceFlags
  344. {
  345. k_EChatAccountInstanceMask = 0x00000FFF, // top 8 bits are flags
  346. k_EChatInstanceFlagClan = ( k_unSteamAccountInstanceMask + 1 ) >> 1, // top bit
  347. k_EChatInstanceFlagLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 2, // next one down, etc
  348. k_EChatInstanceFlagMMSLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 3, // next one down, etc
  349. // Max of 8 flags
  350. };
  351. //-----------------------------------------------------------------------------
  352. // Purpose: Marketing message flags that change how a client should handle them
  353. //-----------------------------------------------------------------------------
  354. enum EMarketingMessageFlags
  355. {
  356. k_EMarketingMessageFlagsNone = 0,
  357. k_EMarketingMessageFlagsHighPriority = 1 << 0,
  358. k_EMarketingMessageFlagsPlatformWindows = 1 << 1,
  359. k_EMarketingMessageFlagsPlatformMac = 1 << 2,
  360. k_EMarketingMessageFlagsPlatformLinux = 1 << 3,
  361. //aggregate flags
  362. k_EMarketingMessageFlagsPlatformRestrictions =
  363. k_EMarketingMessageFlagsPlatformWindows |
  364. k_EMarketingMessageFlagsPlatformMac |
  365. k_EMarketingMessageFlagsPlatformLinux,
  366. };
  367. //-----------------------------------------------------------------------------
  368. // Purpose: Possible positions to tell the overlay to show notifications in
  369. //-----------------------------------------------------------------------------
  370. enum ENotificationPosition
  371. {
  372. k_EPositionTopLeft = 0,
  373. k_EPositionTopRight = 1,
  374. k_EPositionBottomLeft = 2,
  375. k_EPositionBottomRight = 3,
  376. };
  377. //-----------------------------------------------------------------------------
  378. // Purpose: Broadcast upload result details
  379. //-----------------------------------------------------------------------------
  380. enum EBroadcastUploadResult
  381. {
  382. k_EBroadcastUploadResultNone = 0, // broadcast state unknown
  383. k_EBroadcastUploadResultOK = 1, // broadcast was good, no problems
  384. k_EBroadcastUploadResultInitFailed = 2, // broadcast init failed
  385. k_EBroadcastUploadResultFrameFailed = 3, // broadcast frame upload failed
  386. k_EBroadcastUploadResultTimeout = 4, // broadcast upload timed out
  387. k_EBroadcastUploadResultBandwidthExceeded = 5, // broadcast send too much data
  388. k_EBroadcastUploadResultLowFPS = 6, // broadcast FPS too low
  389. k_EBroadcastUploadResultMissingKeyFrames = 7, // broadcast sending not enough key frames
  390. k_EBroadcastUploadResultNoConnection = 8, // broadcast client failed to connect to relay
  391. k_EBroadcastUploadResultRelayFailed = 9, // relay dropped the upload
  392. k_EBroadcastUploadResultSettingsChanged = 10, // the client changed broadcast settings
  393. k_EBroadcastUploadResultMissingAudio = 11, // client failed to send audio data
  394. k_EBroadcastUploadResultTooFarBehind = 12, // clients was too slow uploading
  395. k_EBroadcastUploadResultTranscodeBehind = 13, // server failed to keep up with transcode
  396. };
  397. //-----------------------------------------------------------------------------
  398. // Purpose: codes for well defined launch options
  399. //-----------------------------------------------------------------------------
  400. enum ELaunchOptionType
  401. {
  402. k_ELaunchOptionType_None = 0, // unknown what launch option does
  403. k_ELaunchOptionType_Default = 1, // runs the game, app, whatever in default mode
  404. k_ELaunchOptionType_SafeMode = 2, // runs the game in safe mode
  405. k_ELaunchOptionType_Multiplayer = 3, // runs the game in multiplayer mode
  406. k_ELaunchOptionType_Config = 4, // runs config tool for this game
  407. k_ELaunchOptionType_OpenVR = 5, // runs game in VR mode using OpenVR
  408. k_ELaunchOptionType_Server = 6, // runs dedicated server for this game
  409. k_ELaunchOptionType_Editor = 7, // runs game editor
  410. k_ELaunchOptionType_Manual = 8, // shows game manual
  411. k_ELaunchOptionType_Benchmark = 9, // runs game benchmark
  412. k_ELaunchOptionType_Option1 = 10, // generic run option, uses description field for game name
  413. k_ELaunchOptionType_Option2 = 11, // generic run option, uses description field for game name
  414. k_ELaunchOptionType_Option3 = 12, // generic run option, uses description field for game name
  415. k_ELaunchOptionType_OtherVR = 13, // runs game in VR mode using the Oculus SDK or other vendor-specific VR SDK
  416. k_ELaunchOptionType_OpenVROverlay = 14, // runs an OpenVR dashboard overlay
  417. k_ELaunchOptionType_Dialog = 1000, // show launch options dialog
  418. };
  419. //-----------------------------------------------------------------------------
  420. // Purpose: true if this launch option is any of the vr launching types
  421. //-----------------------------------------------------------------------------
  422. static inline bool BIsVRLaunchOptionType( const ELaunchOptionType eType )
  423. {
  424. return eType == k_ELaunchOptionType_OpenVR || eType == k_ELaunchOptionType_OpenVROverlay || eType == k_ELaunchOptionType_OtherVR;
  425. }
  426. //-----------------------------------------------------------------------------
  427. // Purpose: code points for VR HMD vendors and models
  428. // WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN A DATABASE
  429. //-----------------------------------------------------------------------------
  430. enum EVRHMDType
  431. {
  432. k_eEVRHMDType_Unknown = 0, // unknown vendor and model
  433. k_eEVRHMDType_HTC_Dev = 1, // original HTC dev kits
  434. k_eEVRHMDType_HTC_VivePre = 2, // htc vive pre
  435. k_eEVRHMDType_HTC_Vive = 3, // htc vive consumer release
  436. k_eEVRHMDType_HTC_Unknown = 20, // unknown htc hmd
  437. k_eEVRHMDType_Oculus_DK1 = 21, // occulus DK1
  438. k_eEVRHMDType_Oculus_DK2 = 22, // occulus DK2
  439. k_eEVRHMDType_Oculus_Rift = 23, // occulus rift
  440. k_eEVRHMDType_Oculus_Unknown = 40, // // occulus unknown HMD
  441. };
  442. //-----------------------------------------------------------------------------
  443. // Purpose: true if this is from an Oculus HMD
  444. //-----------------------------------------------------------------------------
  445. static inline bool BIsOcculusHMD( EVRHMDType eType )
  446. {
  447. return eType == k_eEVRHMDType_Oculus_DK1 || eType == k_eEVRHMDType_Oculus_DK2 || eType == k_eEVRHMDType_Oculus_Rift || eType == k_eEVRHMDType_Oculus_Unknown;
  448. }
  449. //-----------------------------------------------------------------------------
  450. // Purpose: true if this is from an Vive HMD
  451. //-----------------------------------------------------------------------------
  452. static inline bool BIsViveHMD( EVRHMDType eType )
  453. {
  454. return eType == k_eEVRHMDType_HTC_Dev || eType == k_eEVRHMDType_HTC_VivePre || eType == k_eEVRHMDType_HTC_Vive || eType == k_eEVRHMDType_HTC_Unknown;
  455. }
  456. #pragma pack( push, 1 )
  457. #define CSTEAMID_DEFINED
  458. // Steam ID structure (64 bits total)
  459. class CSteamID
  460. {
  461. public:
  462. //-----------------------------------------------------------------------------
  463. // Purpose: Constructor
  464. //-----------------------------------------------------------------------------
  465. CSteamID()
  466. {
  467. m_steamid.m_comp.m_unAccountID = 0;
  468. m_steamid.m_comp.m_EAccountType = k_EAccountTypeInvalid;
  469. m_steamid.m_comp.m_EUniverse = k_EUniverseInvalid;
  470. m_steamid.m_comp.m_unAccountInstance = 0;
  471. }
  472. //-----------------------------------------------------------------------------
  473. // Purpose: Constructor
  474. // Input : unAccountID - 32-bit account ID
  475. // eUniverse - Universe this account belongs to
  476. // eAccountType - Type of account
  477. //-----------------------------------------------------------------------------
  478. CSteamID( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
  479. {
  480. Set( unAccountID, eUniverse, eAccountType );
  481. }
  482. //-----------------------------------------------------------------------------
  483. // Purpose: Constructor
  484. // Input : unAccountID - 32-bit account ID
  485. // unAccountInstance - instance
  486. // eUniverse - Universe this account belongs to
  487. // eAccountType - Type of account
  488. //-----------------------------------------------------------------------------
  489. CSteamID( uint32 unAccountID, unsigned int unAccountInstance, EUniverse eUniverse, EAccountType eAccountType )
  490. {
  491. #if defined(_SERVER) && defined(Assert)
  492. Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( unAccountInstance > k_unSteamUserWebInstance ) ) ); // enforce that for individual accounts, instance is always 1
  493. #endif // _SERVER
  494. InstancedSet( unAccountID, unAccountInstance, eUniverse, eAccountType );
  495. }
  496. //-----------------------------------------------------------------------------
  497. // Purpose: Constructor
  498. // Input : ulSteamID - 64-bit representation of a Steam ID
  499. // Note: Will not accept a uint32 or int32 as input, as that is a probable mistake.
  500. // See the stubbed out overloads in the private: section for more info.
  501. //-----------------------------------------------------------------------------
  502. CSteamID( uint64 ulSteamID )
  503. {
  504. SetFromUint64( ulSteamID );
  505. }
  506. #ifdef INT64_DIFFERENT_FROM_INT64_T
  507. CSteamID( uint64_t ulSteamID )
  508. {
  509. SetFromUint64( (uint64)ulSteamID );
  510. }
  511. #endif
  512. //-----------------------------------------------------------------------------
  513. // Purpose: Sets parameters for steam ID
  514. // Input : unAccountID - 32-bit account ID
  515. // eUniverse - Universe this account belongs to
  516. // eAccountType - Type of account
  517. //-----------------------------------------------------------------------------
  518. void Set( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
  519. {
  520. m_steamid.m_comp.m_unAccountID = unAccountID;
  521. m_steamid.m_comp.m_EUniverse = eUniverse;
  522. m_steamid.m_comp.m_EAccountType = eAccountType;
  523. if ( eAccountType == k_EAccountTypeClan || eAccountType == k_EAccountTypeGameServer )
  524. {
  525. m_steamid.m_comp.m_unAccountInstance = 0;
  526. }
  527. else
  528. {
  529. // by default we pick the desktop instance
  530. m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance;
  531. }
  532. }
  533. //-----------------------------------------------------------------------------
  534. // Purpose: Sets parameters for steam ID
  535. // Input : unAccountID - 32-bit account ID
  536. // eUniverse - Universe this account belongs to
  537. // eAccountType - Type of account
  538. //-----------------------------------------------------------------------------
  539. void InstancedSet( uint32 unAccountID, uint32 unInstance, EUniverse eUniverse, EAccountType eAccountType )
  540. {
  541. m_steamid.m_comp.m_unAccountID = unAccountID;
  542. m_steamid.m_comp.m_EUniverse = eUniverse;
  543. m_steamid.m_comp.m_EAccountType = eAccountType;
  544. m_steamid.m_comp.m_unAccountInstance = unInstance;
  545. }
  546. //-----------------------------------------------------------------------------
  547. // Purpose: Initializes a steam ID from its 52 bit parts and universe/type
  548. // Input : ulIdentifier - 52 bits of goodness
  549. //-----------------------------------------------------------------------------
  550. void FullSet( uint64 ulIdentifier, EUniverse eUniverse, EAccountType eAccountType )
  551. {
  552. m_steamid.m_comp.m_unAccountID = ( ulIdentifier & k_unSteamAccountIDMask ); // account ID is low 32 bits
  553. m_steamid.m_comp.m_unAccountInstance = ( ( ulIdentifier >> 32 ) & k_unSteamAccountInstanceMask ); // account instance is next 20 bits
  554. m_steamid.m_comp.m_EUniverse = eUniverse;
  555. m_steamid.m_comp.m_EAccountType = eAccountType;
  556. }
  557. //-----------------------------------------------------------------------------
  558. // Purpose: Initializes a steam ID from its 64-bit representation
  559. // Input : ulSteamID - 64-bit representation of a Steam ID
  560. //-----------------------------------------------------------------------------
  561. void SetFromUint64( uint64 ulSteamID )
  562. {
  563. m_steamid.m_unAll64Bits = ulSteamID;
  564. }
  565. //-----------------------------------------------------------------------------
  566. // Purpose: Clear all fields, leaving an invalid ID.
  567. //-----------------------------------------------------------------------------
  568. void Clear()
  569. {
  570. m_steamid.m_comp.m_unAccountID = 0;
  571. m_steamid.m_comp.m_EAccountType = k_EAccountTypeInvalid;
  572. m_steamid.m_comp.m_EUniverse = k_EUniverseInvalid;
  573. m_steamid.m_comp.m_unAccountInstance = 0;
  574. }
  575. #if defined( INCLUDED_STEAM2_USERID_STRUCTS )
  576. //-----------------------------------------------------------------------------
  577. // Purpose: Initializes a steam ID from a Steam2 ID structure
  578. // Input: pTSteamGlobalUserID - Steam2 ID to convert
  579. // eUniverse - universe this ID belongs to
  580. //-----------------------------------------------------------------------------
  581. void SetFromSteam2( TSteamGlobalUserID *pTSteamGlobalUserID, EUniverse eUniverse )
  582. {
  583. m_steamid.m_comp.m_unAccountID = pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits * 2 +
  584. pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits;
  585. m_steamid.m_comp.m_EUniverse = eUniverse; // set the universe
  586. m_steamid.m_comp.m_EAccountType = k_EAccountTypeIndividual; // Steam 2 accounts always map to account type of individual
  587. m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance; // Steam2 only knew desktop instances
  588. }
  589. //-----------------------------------------------------------------------------
  590. // Purpose: Fills out a Steam2 ID structure
  591. // Input: pTSteamGlobalUserID - Steam2 ID to write to
  592. //-----------------------------------------------------------------------------
  593. void ConvertToSteam2( TSteamGlobalUserID *pTSteamGlobalUserID ) const
  594. {
  595. // only individual accounts have any meaning in Steam 2, only they can be mapped
  596. // Assert( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual );
  597. pTSteamGlobalUserID->m_SteamInstanceID = 0;
  598. pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits = m_steamid.m_comp.m_unAccountID % 2;
  599. pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits = m_steamid.m_comp.m_unAccountID / 2;
  600. }
  601. #endif // defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H )
  602. //-----------------------------------------------------------------------------
  603. // Purpose: Converts steam ID to its 64-bit representation
  604. // Output : 64-bit representation of a Steam ID
  605. //-----------------------------------------------------------------------------
  606. uint64 ConvertToUint64() const
  607. {
  608. return m_steamid.m_unAll64Bits;
  609. }
  610. //-----------------------------------------------------------------------------
  611. // Purpose: Converts the static parts of a steam ID to a 64-bit representation.
  612. // For multiseat accounts, all instances of that account will have the
  613. // same static account key, so they can be grouped together by the static
  614. // account key.
  615. // Output : 64-bit static account key
  616. //-----------------------------------------------------------------------------
  617. uint64 GetStaticAccountKey() const
  618. {
  619. // note we do NOT include the account instance (which is a dynamic property) in the static account key
  620. return (uint64) ( ( ( (uint64) m_steamid.m_comp.m_EUniverse ) << 56 ) + ((uint64) m_steamid.m_comp.m_EAccountType << 52 ) + m_steamid.m_comp.m_unAccountID );
  621. }
  622. //-----------------------------------------------------------------------------
  623. // Purpose: create an anonymous game server login to be filled in by the AM
  624. //-----------------------------------------------------------------------------
  625. void CreateBlankAnonLogon( EUniverse eUniverse )
  626. {
  627. m_steamid.m_comp.m_unAccountID = 0;
  628. m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonGameServer;
  629. m_steamid.m_comp.m_EUniverse = eUniverse;
  630. m_steamid.m_comp.m_unAccountInstance = 0;
  631. }
  632. //-----------------------------------------------------------------------------
  633. // Purpose: create an anonymous game server login to be filled in by the AM
  634. //-----------------------------------------------------------------------------
  635. void CreateBlankAnonUserLogon( EUniverse eUniverse )
  636. {
  637. m_steamid.m_comp.m_unAccountID = 0;
  638. m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonUser;
  639. m_steamid.m_comp.m_EUniverse = eUniverse;
  640. m_steamid.m_comp.m_unAccountInstance = 0;
  641. }
  642. //-----------------------------------------------------------------------------
  643. // Purpose: Is this an anonymous game server login that will be filled in?
  644. //-----------------------------------------------------------------------------
  645. bool BBlankAnonAccount() const
  646. {
  647. return m_steamid.m_comp.m_unAccountID == 0 && BAnonAccount() && m_steamid.m_comp.m_unAccountInstance == 0;
  648. }
  649. //-----------------------------------------------------------------------------
  650. // Purpose: Is this a game server account id? (Either persistent or anonymous)
  651. //-----------------------------------------------------------------------------
  652. bool BGameServerAccount() const
  653. {
  654. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  655. }
  656. //-----------------------------------------------------------------------------
  657. // Purpose: Is this a persistent (not anonymous) game server account id?
  658. //-----------------------------------------------------------------------------
  659. bool BPersistentGameServerAccount() const
  660. {
  661. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer;
  662. }
  663. //-----------------------------------------------------------------------------
  664. // Purpose: Is this an anonymous game server account id?
  665. //-----------------------------------------------------------------------------
  666. bool BAnonGameServerAccount() const
  667. {
  668. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  669. }
  670. //-----------------------------------------------------------------------------
  671. // Purpose: Is this a content server account id?
  672. //-----------------------------------------------------------------------------
  673. bool BContentServerAccount() const
  674. {
  675. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeContentServer;
  676. }
  677. //-----------------------------------------------------------------------------
  678. // Purpose: Is this a clan account id?
  679. //-----------------------------------------------------------------------------
  680. bool BClanAccount() const
  681. {
  682. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan;
  683. }
  684. //-----------------------------------------------------------------------------
  685. // Purpose: Is this a chat account id?
  686. //-----------------------------------------------------------------------------
  687. bool BChatAccount() const
  688. {
  689. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat;
  690. }
  691. //-----------------------------------------------------------------------------
  692. // Purpose: Is this a chat account id?
  693. //-----------------------------------------------------------------------------
  694. bool IsLobby() const
  695. {
  696. return ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat )
  697. && ( m_steamid.m_comp.m_unAccountInstance & k_EChatInstanceFlagLobby );
  698. }
  699. //-----------------------------------------------------------------------------
  700. // Purpose: Is this an individual user account id?
  701. //-----------------------------------------------------------------------------
  702. bool BIndividualAccount() const
  703. {
  704. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual || m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
  705. }
  706. //-----------------------------------------------------------------------------
  707. // Purpose: Is this an anonymous account?
  708. //-----------------------------------------------------------------------------
  709. bool BAnonAccount() const
  710. {
  711. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer;
  712. }
  713. //-----------------------------------------------------------------------------
  714. // Purpose: Is this an anonymous user account? ( used to create an account or reset a password )
  715. //-----------------------------------------------------------------------------
  716. bool BAnonUserAccount() const
  717. {
  718. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser;
  719. }
  720. //-----------------------------------------------------------------------------
  721. // Purpose: Is this a faked up Steam ID for a PSN friend account?
  722. //-----------------------------------------------------------------------------
  723. bool BConsoleUserAccount() const
  724. {
  725. return m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
  726. }
  727. // simple accessors
  728. void SetAccountID( uint32 unAccountID ) { m_steamid.m_comp.m_unAccountID = unAccountID; }
  729. void SetAccountInstance( uint32 unInstance ){ m_steamid.m_comp.m_unAccountInstance = unInstance; }
  730. void ClearIndividualInstance() { if ( BIndividualAccount() ) m_steamid.m_comp.m_unAccountInstance = 0; }
  731. bool HasNoIndividualInstance() const { return BIndividualAccount() && (m_steamid.m_comp.m_unAccountInstance==0); }
  732. AccountID_t GetAccountID() const { return m_steamid.m_comp.m_unAccountID; }
  733. uint32 GetUnAccountInstance() const { return m_steamid.m_comp.m_unAccountInstance; }
  734. EAccountType GetEAccountType() const { return ( EAccountType ) m_steamid.m_comp.m_EAccountType; }
  735. EUniverse GetEUniverse() const { return m_steamid.m_comp.m_EUniverse; }
  736. void SetEUniverse( EUniverse eUniverse ) { m_steamid.m_comp.m_EUniverse = eUniverse; }
  737. bool IsValid() const;
  738. // this set of functions is hidden, will be moved out of class
  739. explicit CSteamID( const char *pchSteamID, EUniverse eDefaultUniverse = k_EUniverseInvalid );
  740. const char * Render() const; // renders this steam ID to string
  741. static const char * Render( uint64 ulSteamID ); // static method to render a uint64 representation of a steam ID to a string
  742. const char * RenderLink() const; // renders this steam ID to an admin console link string
  743. static const char * RenderLink( uint64 ulSteamID ); // static method to render a uint64 representation of a steam ID to a string
  744. void SetFromString( const char *pchSteamID, EUniverse eDefaultUniverse );
  745. // SetFromString allows many partially-correct strings, constraining how
  746. // we might be able to change things in the future.
  747. // SetFromStringStrict requires the exact string forms that we support
  748. // and is preferred when the caller knows it's safe to be strict.
  749. // Returns whether the string parsed correctly.
  750. bool SetFromStringStrict( const char *pchSteamID, EUniverse eDefaultUniverse );
  751. bool SetFromSteam2String( const char *pchSteam2ID, EUniverse eUniverse );
  752. inline bool operator==( const CSteamID &val ) const { return m_steamid.m_unAll64Bits == val.m_steamid.m_unAll64Bits; }
  753. inline bool operator!=( const CSteamID &val ) const { return !operator==( val ); }
  754. inline bool operator<( const CSteamID &val ) const { return m_steamid.m_unAll64Bits < val.m_steamid.m_unAll64Bits; }
  755. inline bool operator>( const CSteamID &val ) const { return m_steamid.m_unAll64Bits > val.m_steamid.m_unAll64Bits; }
  756. // DEBUG function
  757. bool BValidExternalSteamID() const;
  758. private:
  759. // These are defined here to prevent accidental implicit conversion of a u32AccountID to a CSteamID.
  760. // If you get a compiler error about an ambiguous constructor/function then it may be because you're
  761. // passing a 32-bit int to a function that takes a CSteamID. You should explicitly create the SteamID
  762. // using the correct Universe and account Type/Instance values.
  763. CSteamID( uint32 );
  764. CSteamID( int32 );
  765. // 64 bits total
  766. union SteamID_t
  767. {
  768. struct SteamIDComponent_t
  769. {
  770. #ifdef VALVE_BIG_ENDIAN
  771. EUniverse m_EUniverse : 8; // universe this account belongs to
  772. unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
  773. unsigned int m_unAccountInstance : 20; // dynamic instance ID
  774. uint32 m_unAccountID : 32; // unique account identifier
  775. #else
  776. uint32 m_unAccountID : 32; // unique account identifier
  777. unsigned int m_unAccountInstance : 20; // dynamic instance ID
  778. unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
  779. EUniverse m_EUniverse : 8; // universe this account belongs to
  780. #endif
  781. } m_comp;
  782. uint64 m_unAll64Bits;
  783. } m_steamid;
  784. };
  785. inline bool CSteamID::IsValid() const
  786. {
  787. if ( m_steamid.m_comp.m_EAccountType <= k_EAccountTypeInvalid || m_steamid.m_comp.m_EAccountType >= k_EAccountTypeMax )
  788. return false;
  789. if ( m_steamid.m_comp.m_EUniverse <= k_EUniverseInvalid || m_steamid.m_comp.m_EUniverse >= k_EUniverseMax )
  790. return false;
  791. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual )
  792. {
  793. if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance > k_unSteamUserWebInstance )
  794. return false;
  795. }
  796. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan )
  797. {
  798. if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance != 0 )
  799. return false;
  800. }
  801. if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer )
  802. {
  803. if ( m_steamid.m_comp.m_unAccountID == 0 )
  804. return false;
  805. // Any limit on instances? We use them for local users and bots
  806. }
  807. return true;
  808. }
  809. // generic invalid CSteamID
  810. #define k_steamIDNil CSteamID()
  811. // This steamID comes from a user game connection to an out of date GS that hasnt implemented the protocol
  812. // to provide its steamID
  813. #define k_steamIDOutofDateGS CSteamID( 0, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  814. // This steamID comes from a user game connection to an sv_lan GS
  815. #define k_steamIDLanModeGS CSteamID( 0, 0, k_EUniversePublic, k_EAccountTypeInvalid )
  816. // This steamID can come from a user game connection to a GS that has just booted but hasnt yet even initialized
  817. // its steam3 component and started logging on.
  818. #define k_steamIDNotInitYetGS CSteamID( 1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  819. // This steamID can come from a user game connection to a GS that isn't using the steam authentication system but still
  820. // wants to support the "Join Game" option in the friends list
  821. #define k_steamIDNonSteamGS CSteamID( 2, 0, k_EUniverseInvalid, k_EAccountTypeInvalid )
  822. #ifdef STEAM
  823. // Returns the matching chat steamID, with the default instance of 0
  824. // If the steamID passed in is already of type k_EAccountTypeChat it will be returned with the same instance
  825. CSteamID ChatIDFromSteamID( const CSteamID &steamID );
  826. // Returns the matching clan steamID, with the default instance of 0
  827. // If the steamID passed in is already of type k_EAccountTypeClan it will be returned with the same instance
  828. CSteamID ClanIDFromSteamID( const CSteamID &steamID );
  829. // Asserts steamID type before conversion
  830. CSteamID ChatIDFromClanID( const CSteamID &steamIDClan );
  831. // Asserts steamID type before conversion
  832. CSteamID ClanIDFromChatID( const CSteamID &steamIDChat );
  833. #endif // _STEAM
  834. //-----------------------------------------------------------------------------
  835. // Purpose: encapsulates an appID/modID pair
  836. //-----------------------------------------------------------------------------
  837. class CGameID
  838. {
  839. public:
  840. CGameID()
  841. {
  842. m_gameID.m_nType = k_EGameIDTypeApp;
  843. m_gameID.m_nAppID = k_uAppIdInvalid;
  844. m_gameID.m_nModID = 0;
  845. }
  846. explicit CGameID( uint64 ulGameID )
  847. {
  848. m_ulGameID = ulGameID;
  849. }
  850. #ifdef INT64_DIFFERENT_FROM_INT64_T
  851. CGameID( uint64_t ulGameID )
  852. {
  853. m_ulGameID = (uint64)ulGameID;
  854. }
  855. #endif
  856. explicit CGameID( int32 nAppID )
  857. {
  858. m_ulGameID = 0;
  859. m_gameID.m_nAppID = nAppID;
  860. }
  861. explicit CGameID( uint32 nAppID )
  862. {
  863. m_ulGameID = 0;
  864. m_gameID.m_nAppID = nAppID;
  865. }
  866. CGameID( uint32 nAppID, uint32 nModID )
  867. {
  868. m_ulGameID = 0;
  869. m_gameID.m_nAppID = nAppID;
  870. m_gameID.m_nModID = nModID;
  871. m_gameID.m_nType = k_EGameIDTypeGameMod;
  872. }
  873. // Hidden functions used only by Steam
  874. explicit CGameID( const char *pchGameID );
  875. const char *Render() const; // render this Game ID to string
  876. static const char *Render( uint64 ulGameID ); // static method to render a uint64 representation of a Game ID to a string
  877. // must include checksum_crc.h first to get this functionality
  878. #if defined( CHECKSUM_CRC_H )
  879. CGameID( uint32 nAppID, const char *pchModPath )
  880. {
  881. m_ulGameID = 0;
  882. m_gameID.m_nAppID = nAppID;
  883. m_gameID.m_nType = k_EGameIDTypeGameMod;
  884. char rgchModDir[MAX_PATH];
  885. V_FileBase( pchModPath, rgchModDir, sizeof( rgchModDir ) );
  886. CRC32_t crc32;
  887. CRC32_Init( &crc32 );
  888. CRC32_ProcessBuffer( &crc32, rgchModDir, V_strlen( rgchModDir ) );
  889. CRC32_Final( &crc32 );
  890. // set the high-bit on the mod-id
  891. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  892. // replacement for appID's
  893. m_gameID.m_nModID = crc32 | (0x80000000);
  894. }
  895. CGameID( const char *pchExePath, const char *pchAppName )
  896. {
  897. m_ulGameID = 0;
  898. m_gameID.m_nAppID = k_uAppIdInvalid;
  899. m_gameID.m_nType = k_EGameIDTypeShortcut;
  900. CRC32_t crc32;
  901. CRC32_Init( &crc32 );
  902. if ( pchExePath )
  903. CRC32_ProcessBuffer( &crc32, pchExePath, V_strlen( pchExePath ) );
  904. if ( pchAppName )
  905. CRC32_ProcessBuffer( &crc32, pchAppName, V_strlen( pchAppName ) );
  906. CRC32_Final( &crc32 );
  907. // set the high-bit on the mod-id
  908. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  909. // replacement for appID's
  910. m_gameID.m_nModID = crc32 | (0x80000000);
  911. }
  912. #if defined( VSTFILEID_H )
  913. CGameID( VstFileID vstFileID )
  914. {
  915. m_ulGameID = 0;
  916. m_gameID.m_nAppID = k_uAppIdInvalid;
  917. m_gameID.m_nType = k_EGameIDTypeP2P;
  918. CRC32_t crc32;
  919. CRC32_Init( &crc32 );
  920. const char *pchFileId = vstFileID.Render();
  921. CRC32_ProcessBuffer( &crc32, pchFileId, V_strlen( pchFileId ) );
  922. CRC32_Final( &crc32 );
  923. // set the high-bit on the mod-id
  924. // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique
  925. // replacement for appID's
  926. m_gameID.m_nModID = crc32 | (0x80000000);
  927. }
  928. #endif /* VSTFILEID_H */
  929. #endif /* CHECKSUM_CRC_H */
  930. uint64 ToUint64() const
  931. {
  932. return m_ulGameID;
  933. }
  934. uint64 *GetUint64Ptr()
  935. {
  936. return &m_ulGameID;
  937. }
  938. void Set( uint64 ulGameID )
  939. {
  940. m_ulGameID = ulGameID;
  941. }
  942. bool IsMod() const
  943. {
  944. return ( m_gameID.m_nType == k_EGameIDTypeGameMod );
  945. }
  946. bool IsShortcut() const
  947. {
  948. return ( m_gameID.m_nType == k_EGameIDTypeShortcut );
  949. }
  950. bool IsP2PFile() const
  951. {
  952. return ( m_gameID.m_nType == k_EGameIDTypeP2P );
  953. }
  954. bool IsSteamApp() const
  955. {
  956. return ( m_gameID.m_nType == k_EGameIDTypeApp );
  957. }
  958. uint32 ModID() const
  959. {
  960. return m_gameID.m_nModID;
  961. }
  962. uint32 AppID() const
  963. {
  964. return m_gameID.m_nAppID;
  965. }
  966. bool operator == ( const CGameID &rhs ) const
  967. {
  968. return m_ulGameID == rhs.m_ulGameID;
  969. }
  970. bool operator != ( const CGameID &rhs ) const
  971. {
  972. return !(*this == rhs);
  973. }
  974. bool operator < ( const CGameID &rhs ) const
  975. {
  976. return ( m_ulGameID < rhs.m_ulGameID );
  977. }
  978. bool IsValid() const
  979. {
  980. // each type has it's own invalid fixed point:
  981. switch( m_gameID.m_nType )
  982. {
  983. case k_EGameIDTypeApp:
  984. return m_gameID.m_nAppID != k_uAppIdInvalid;
  985. case k_EGameIDTypeGameMod:
  986. return m_gameID.m_nAppID != k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000;
  987. case k_EGameIDTypeShortcut:
  988. return (m_gameID.m_nModID & 0x80000000) != 0;
  989. case k_EGameIDTypeP2P:
  990. return m_gameID.m_nAppID == k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000;
  991. default:
  992. #if defined(Assert)
  993. Assert(false);
  994. #endif
  995. return false;
  996. }
  997. }
  998. void Reset()
  999. {
  1000. m_ulGameID = 0;
  1001. }
  1002. private:
  1003. enum EGameIDType
  1004. {
  1005. k_EGameIDTypeApp = 0,
  1006. k_EGameIDTypeGameMod = 1,
  1007. k_EGameIDTypeShortcut = 2,
  1008. k_EGameIDTypeP2P = 3,
  1009. };
  1010. struct GameID_t
  1011. {
  1012. #ifdef VALVE_BIG_ENDIAN
  1013. unsigned int m_nModID : 32;
  1014. unsigned int m_nType : 8;
  1015. unsigned int m_nAppID : 24;
  1016. #else
  1017. unsigned int m_nAppID : 24;
  1018. unsigned int m_nType : 8;
  1019. unsigned int m_nModID : 32;
  1020. #endif
  1021. };
  1022. union
  1023. {
  1024. uint64 m_ulGameID;
  1025. GameID_t m_gameID;
  1026. };
  1027. };
  1028. #pragma pack( pop )
  1029. const int k_cchGameExtraInfoMax = 64;
  1030. //-----------------------------------------------------------------------------
  1031. // Constants used for query ports.
  1032. //-----------------------------------------------------------------------------
  1033. #define QUERY_PORT_NOT_INITIALIZED 0xFFFF // We haven't asked the GS for this query port's actual value yet.
  1034. #define QUERY_PORT_ERROR 0xFFFE // We were unable to get the query port for this server.
  1035. //-----------------------------------------------------------------------------
  1036. // Purpose: Passed as argument to SteamAPI_UseBreakpadCrashHandler to enable optional callback
  1037. // just before minidump file is captured after a crash has occurred. (Allows app to append additional comment data to the dump, etc.)
  1038. //-----------------------------------------------------------------------------
  1039. typedef void (*PFNPreMinidumpCallback)(void *context);
  1040. //-----------------------------------------------------------------------------
  1041. // Purpose: Used by ICrashHandler interfaces to reference particular installed crash handlers
  1042. //-----------------------------------------------------------------------------
  1043. typedef void *BREAKPAD_HANDLE;
  1044. #define BREAKPAD_INVALID_HANDLE (BREAKPAD_HANDLE)0
  1045. #endif // STEAMCLIENTPUBLIC_H