Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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