bad char
[vg.git] / vg_steam_api.h
1 #pragma once
2 #include "vg_platform.h"
3
4 #if defined(__linux__) || defined(__APPLE__)
5 /*
6 * The 32-bit version of gcc has the alignment requirement for u64 and double
7 * set to 4 meaning that even with #pragma pack(8) these types will only be
8 * four-byte aligned. The 64-bit version of gcc has the alignment requirement
9 * for these types set to 8 meaning that unless we use #pragma pack(4) our
10 * structures will get bigger. The 64-bit structure packing has to match the
11 * 32-bit structure packing for each platform.
12 */
13 #define VALVE_CALLBACK_PACK_SMALL
14 ;
15 #pragma pack( push, 4 )
16 #else
17 #define VALVE_CALLBACK_PACK_LARGE
18 #pragma pack( push, 8 )
19 #endif
20
21 typedef i32 HSteamPipe;
22 typedef i32 HSteamUser;
23
24 typedef int E_iCallBack_t;
25
26 typedef u64 u64_steamid;
27 typedef u64 SteamAPICall_t;
28
29 typedef u32 AppId_t;
30 enum { k_uAppIdInvalid = 0x0 };
31
32 typedef u32 DepotId_t;
33 enum { k_uDepotIdInvalid = 0x0 };
34
35 typedef u32 RTime32;
36 typedef u32 AccountID_t;
37 typedef i8 steamapi_bool;
38
39 enum { k_iSteamUserCallbacks = 100 };
40 enum { k_iSteamGameServerCallbacks = 200 };
41 enum { k_iSteamFriendsCallbacks = 300 };
42 enum { k_iSteamBillingCallbacks = 400 };
43 enum { k_iSteamMatchmakingCallbacks = 500 };
44 enum { k_iSteamContentServerCallbacks = 600 };
45 enum { k_iSteamUtilsCallbacks = 700 };
46 enum { k_iClientFriendsCallbacks = 800 };
47 enum { k_iClientUserCallbacks = 900 };
48 enum { k_iSteamAppsCallbacks = 1000 };
49 enum { k_iSteamUserStatsCallbacks = 1100 };
50 enum { k_iSteamNetworkingCallbacks = 1200 };
51 enum { k_iSteamNetworkingSocketsCallbacks = 1220 };
52 enum { k_iSteamNetworkingMessagesCallbacks = 1250 };
53 enum { k_iSteamNetworkingUtilsCallbacks = 1280 };
54 enum { k_iSteamRemoteStorageCallbacks = 1300 };
55 enum { k_iClientDepotBuilderCallbacks = 1400 };
56 enum { k_iSteamGameServerItemsCallbacks = 1500 };
57 enum { k_iClientUtilsCallbacks = 1600 };
58 enum { k_iSteamGameCoordinatorCallbacks = 1700 };
59 enum { k_iSteamGameServerStatsCallbacks = 1800 };
60 enum { k_iSteam2AsyncCallbacks = 1900 };
61 enum { k_iSteamGameStatsCallbacks = 2000 };
62 enum { k_iClientHTTPCallbacks = 2100 };
63 enum { k_iClientScreenshotsCallbacks = 2200 };
64 enum { k_iSteamScreenshotsCallbacks = 2300 };
65 enum { k_iClientAudioCallbacks = 2400 };
66 enum { k_iClientUnifiedMessagesCallbacks = 2500 };
67 enum { k_iSteamStreamLauncherCallbacks = 2600 };
68 enum { k_iClientControllerCallbacks = 2700 };
69 enum { k_iSteamControllerCallbacks = 2800 };
70 enum { k_iClientParentalSettingsCallbacks = 2900 };
71 enum { k_iClientDeviceAuthCallbacks = 3000 };
72 enum { k_iClientNetworkDeviceManagerCallbacks = 3100 };
73 enum { k_iClientMusicCallbacks = 3200 };
74 enum { k_iClientRemoteClientManagerCallbacks = 3300 };
75 enum { k_iClientUGCCallbacks = 3400 };
76 enum { k_iSteamUGCCallbacks = 3400 };
77 enum { k_iSteamStreamClientCallbacks = 3500 };
78 enum { k_IClientProductBuilderCallbacks = 3600 };
79 enum { k_iClientShortcutsCallbacks = 3700 };
80 enum { k_iClientRemoteControlManagerCallbacks = 3800 };
81 enum { k_iSteamAppListCallbacks = 3900 };
82 enum { k_iSteamMusicCallbacks = 4000 };
83 enum { k_iSteamMusicRemoteCallbacks = 4100 };
84 enum { k_iClientVRCallbacks = 4200 };
85 enum { k_iClientGameNotificationCallbacks = 4300 };
86 enum { k_iSteamGameNotificationCallbacks = 4400 };
87 enum { k_iSteamHTMLSurfaceCallbacks = 4500 };
88 enum { k_iClientVideoCallbacks = 4600 };
89 enum { k_iClientInventoryCallbacks = 4700 };
90 enum { k_iClientBluetoothManagerCallbacks = 4800 };
91 enum { k_iClientSharedConnectionCallbacks = 4900 };
92 enum { k_ISteamParentalSettingsCallbacks = 5000 };
93 enum { k_iClientShaderCallbacks = 5100 };
94 enum { k_iSteamGameSearchCallbacks = 5200 };
95 enum { k_iSteamPartiesCallbacks = 5300 };
96 enum { k_iClientPartiesCallbacks = 5400 };
97 enum { k_iSteamSTARCallbacks = 5500 };
98 enum { k_iClientSTARCallbacks = 5600 };
99 enum { k_iSteamRemotePlayCallbacks = 5700 };
100 enum { k_iClientCompatCallbacks = 5800 };
101 enum { k_iSteamChatCallbacks = 5900 };
102
103 // General result codes
104 typedef enum EResult
105 {
106 k_EResultNone = 0, // no result
107 k_EResultOK = 1, // success
108 k_EResultFail = 2, // generic failure
109 k_EResultNoConnection = 3, // no/failed network connection
110 // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
111 k_EResultInvalidPassword = 5, // password/ticket is invalid
112 k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
113 k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
114 k_EResultInvalidParam = 8, // a parameter is incorrect
115 k_EResultFileNotFound = 9, // file was not found
116 k_EResultBusy = 10, // called method busy - action not taken
117 k_EResultInvalidState = 11, // called object was in an invalid state
118 k_EResultInvalidName = 12, // name is invalid
119 k_EResultInvalidEmail = 13, // email is invalid
120 k_EResultDuplicateName = 14, // name is not unique
121 k_EResultAccessDenied = 15, // access is denied
122 k_EResultTimeout = 16, // operation timed out
123 k_EResultBanned = 17, // VAC2 banned
124 k_EResultAccountNotFound = 18, // account not found
125 k_EResultInvalidSteamID = 19, // steamID is invalid
126 k_EResultServiceUnavailable = 20,// The requested service is currently
127 // unavailable
128 k_EResultNotLoggedOn = 21, // The user is not logged on
129 k_EResultPending = 22, // Request is pending (may be in process, or
130 // waiting on third party)
131 k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
132 k_EResultInsufficientPrivilege = 24,// Insufficient privilege
133 k_EResultLimitExceeded = 25, // Too much of a good thing
134 k_EResultRevoked = 26, // Access has been revoked (used for revoked
135 // guest passes)
136 k_EResultExpired = 27, // License/Guest pass the user is trying to
137 // access is expired
138 k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by
139 // account, cannot be acked again
140 k_EResultDuplicateRequest = 29, // The request is a duplicate and the action
141 // has already occurred in the past, ignored
142 // this time
143 k_EResultAlreadyOwned = 30, // All the games in this guest pass
144 // redemption request are already owned by
145 // the user
146 k_EResultIPNotFound = 31, // IP address not found
147 k_EResultPersistFailed = 32, // failed to write change to the data store
148 k_EResultLockingFailed = 33, // failed to acquire access lock for this
149 // operation
150 k_EResultLogonSessionReplaced = 34,
151 k_EResultConnectFailed = 35,
152 k_EResultHandshakeFailed = 36,
153 k_EResultIOFailure = 37,
154 k_EResultRemoteDisconnect = 38,
155 k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart
156 // requested
157 k_EResultBlocked = 40, // a user didn't allow it
158 k_EResultIgnored = 41, // target is ignoring sender
159 k_EResultNoMatch = 42, // nothing matching the request found
160 k_EResultAccountDisabled = 43,
161 k_EResultServiceReadOnly = 44, // this service is not accepting content
162 // changes right now
163 k_EResultAccountNotFeatured = 45, // account doesn't have value, so this
164 // feature isn't available
165 k_EResultAdministratorOK = 46, // allowed to take this action, but only
166 // because requester is admin
167 k_EResultContentVersion = 47, // A Version mismatch in content
168 // transmitted within the Steam protocol.
169 k_EResultTryAnotherCM = 48, // The current CM can't service the user
170 // making a request, user should try
171 // another.
172 k_EResultPasswordRequiredToKickSession = 49, // You are already logged in
173 // elsewhere, this cached credential
174 // login has failed.
175 k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in
176 // elsewhere, you must wait
177 k_EResultSuspended = 51, // Long running operation (content download)
178 // suspended/paused
179 k_EResultCancelled = 52, // Operation canceled (typically by user:
180 // content download)
181 k_EResultDataCorruption = 53, // Operation canceled because data is ill
182 // formed or unrecoverable
183 k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
184 k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
185 k_EResultPasswordUnset = 56, // Password could not be verified as it's
186 // unset server side
187 k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...)
188 // is not linked to a Steam account
189 k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
190 k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN,
191 // Facebook...) is already linked to some other account,
192 // must explicitly request to replace/delete the link first
193 k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict
194 // between the local and remote files
195 k_EResultIllegalPassword = 61, // The requested new password is not legal
196 k_EResultSameAsPreviousValue = 62,// new value is the same as the old one (
197 // secret question and answer )
198 k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor
199 // authentication failure
200 k_EResultCannotUseOldPassword = 64, // The requested new password is not
201 // legal
202 k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code
203 // invalid
204 k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd
205 // factor auth failure - and no mail
206 // has been sent
207 k_EResultHardwareNotCapableOfIPT = 67,
208 k_EResultIPTInitError = 68,
209 k_EResultParentalControlRestricted = 69,// operation failed due to parental
210 // control restrictions for current
211 // user
212 k_EResultFacebookQueryError = 70, // Facebook query returned an error
213 k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth
214 // code expired
215 k_EResultIPLoginRestrictionFailed = 72,
216 k_EResultAccountLockedDown = 73,
217 k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
218 k_EResultNoMatchingURL = 75,
219 k_EResultBadResponse = 76, // parse failure, missing field, etc.
220 k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action
221 // until they re-enter their password
222 k_EResultValueOutOfRange = 78, // the value entered is outside the
223 // acceptable range
224 k_EResultUnexpectedError = 79, // something happened that we didn't expect
225 // to ever happen
226 k_EResultDisabled = 80, // The requested service has been configured
227 // to be unavailable
228 k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG
229 // server are not valid !
230 k_EResultRestrictedDevice = 82, // The device being used is not allowed
231 // to perform this action
232 k_EResultRegionLocked = 83, // The action could not be complete
233 // because it is region restricted
234 k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try
235 // again later, different from
236 // k_EResultLimitExceeded which may be
237 // permanent
238 k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to
239 // login
240 k_EResultItemDeleted = 86, // The thing we're trying to access has been
241 // deleted
242 k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to
243 // throttle response to possible
244 // attacker
245 k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
246 k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for
247 // two-factor didn't match
248 k_EResultAccountAssociatedToMultiplePartners = 90, // account has been
249 // associated with multiple partners
250 k_EResultNotModified = 91, // data not modified
251 k_EResultNoMobileDevice = 92, // the account does not have a mobile
252 // device associated with it
253 k_EResultTimeNotSynced = 93, // the time presented is out of range or
254 // tolerance
255 k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending,
256 // etc.)
257 k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource
258 k_EResultAccountActivityLimitExceeded = 96,// Too many changes to
259 // this account
260 k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone
261 k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use
262 // wallet
263 k_EResultEmailSendFailure = 99, // Cannot send an email
264 k_EResultNotSettled = 100, // Can't perform operation till payment
265 // has settled
266 k_EResultNeedCaptcha = 101,// Needs to provide a valid captcha
267 k_EResultGSLTDenied = 102, // a game server login token owned by this token's
268 // owner has been banned
269 k_EResultGSOwnerDenied = 103, // game server owner is denied for other reason
270 // (account lock, community ban, vac ban, missing phone)
271 k_EResultInvalidItemType = 104,// the type of thing we were requested to act
272 // on is invalid
273 k_EResultIPBanned = 105,// the ip address has been banned from taking this
274 // action
275 k_EResultGSLTExpired = 106,// this token has expired from disuse; can be
276 // reset for use
277 k_EResultInsufficientFunds = 107,// user doesn't have enough wallet funds to
278 // complete the action
279 k_EResultTooManyPending = 108, // There are too many of this thing pending
280 // already
281 k_EResultNoSiteLicensesFound = 109, // No site licenses found
282 k_EResultWGNetworkSendExceeded = 110,// the WG couldn't send a response
283 // because we exceeded max network send size
284 k_EResultAccountNotFriends = 111, // the user is not mutually friends
285 k_EResultLimitedUserAccount = 112,// the user is limited
286 k_EResultCantRemoveItem = 113, // item can't be removed
287 k_EResultAccountDeleted = 114, // account has been deleted
288 k_EResultExistingUserCancelledLicense = 115,
289 // A license for this already exists, but cancelled
290 k_EResultCommunityCooldown = 116, // access is denied because of a
291 // community cooldown (probably from support profile data resets)
292 k_EResultNoLauncherSpecified = 117, // No launcher was specified, but a
293 // launcher was needed to choose correct realm for operation.
294 k_EResultMustAgreeToSSA = 118,// User must agree to china SSA or global SSA
295 // before login
296 k_EResultLauncherMigrated = 119, // The specified launcher type is no longer
297 // supported; the user should be directed elsewhere
298 k_EResultSteamRealmMismatch = 120, // The user's realm does not match the
299 // realm of the requested resource
300 k_EResultInvalidSignature = 121, // signature check did not match
301 k_EResultParseFailure = 122, // Failed to parse input
302 k_EResultNoVerifiedPhone = 123, // account does not have a verified phone
303 // number
304 } EResult;
305
306 typedef struct {
307
308 HSteamUser m_hSteamUser; // Specific user to whom this callback applies.
309 int m_iCallback;
310 u8 *m_pubParam; // Points to the callback structure
311 int m_cubParam; // Size of the data pointed to by m_pubParam
312
313 } CallbackMsg_t;
314
315 typedef struct {
316
317 SteamAPICall_t m_hAsyncCall;
318 int m_iCallback;
319 u32 m_cubParam;
320
321 } SteamAPICallCompleted_t;
322 enum { k_iSteamAPICallCompleted = k_iSteamUtilsCallbacks + 3 };
323
324 // Steam universes. Each universe is a self-contained Steam instance.
325 typedef enum EUniverse {
326 k_EUniverseInvalid = 0,
327 k_EUniversePublic = 1,
328 k_EUniverseBeta = 2,
329 k_EUniverseInternal = 3,
330 k_EUniverseDev = 4,
331 // k_EUniverseRC = 5, // no such universe anymore
332 k_EUniverseMax
333 } EUniverse_t;
334
335 #pragma pack( push, 1 )
336 struct SteamIDComponent_t
337 {
338 #ifdef VALVE_BIG_ENDIAN
339 EUniverse_t m_EUniverse : 8
340 unsigned int m_EAccountType : 4;
341 unsigned int m_unAccountInstance : 20;
342 u32 m_unAccountID : 32;
343 #else
344 u32 m_unAccountID : 32;
345 unsigned int m_unAccountInstance : 20;
346 unsigned int m_EAccountType : 4;
347 EUniverse_t m_EUniverse : 8;
348 #endif
349 };
350
351 typedef struct
352 {
353 // 64 bits total
354 union
355 {
356 struct SteamIDComponent_t m_comp;
357 u64 m_unAll64Bits;
358 };
359 }
360 CSteamID;
361
362 typedef struct GameID_t
363 {
364 #ifdef VALVE_BIG_ENDIAN
365 unsigned int m_nModID : 32;
366 unsigned int m_nType : 8;
367 unsigned int m_nAppID : 24;
368 #else
369 unsigned int m_nAppID : 24;
370 unsigned int m_nType : 8;
371 unsigned int m_nModID : 32;
372 #endif
373 } CGameID;
374 #pragma pack( pop )
375 #pragma pack( pop )
376
377 /*
378 * Standard login
379 * =============================================================================
380 */
381
382 int SteamAPI_RestartAppIfNecessary( u32 unOwnAppID );
383 int SteamAPI_Init(void);
384 void SteamAPI_Shutdown(void);
385
386 /*
387 * Server mode login
388 * =============================================================================
389 */
390
391 typedef enum EServerMode EServerMode;
392 enum EServerMode
393 {
394 eServerModeInvalid = 0,
395 eServerModeNoAuthentication = 1,
396 eServerModeAuthentication = 2,
397 eServerModeAuthenticationAndSecure = 3,
398 };
399
400 int SteamInternal_GameServer_Init( u32 unIP, u16 usLegacySteamPort,
401 u16 usGamePort, u16 usQueryPort,
402 EServerMode eServerMode,
403 const char *pchVersionString );
404
405 /* Initialize SteamGameServer client and interface objects, and set server
406 * properties which may not be changed.
407 * After calling this function, you should set any additional server parameters,
408 * and then call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn()
409 *
410 * - unIP will usually be zero. If you are on a machine with multiple IP
411 * addresses, you can pass a non-zero value here and the relevant sockets will
412 * be bound to that IP. This can be used to ensure that the IP you desire is
413 * the one used in the server browser.
414 * - usGamePort is the port that clients will connect to for gameplay. You will
415 * usually open up your own socket bound to this port.
416 * - usQueryPort is the port that will manage server browser related duties and
417 * info pings from clients. If you pass STEAMGAMESERVER_QUERY_PORT_SHARED for
418 * usQueryPort, then it will use "GameSocketShare" mode, which means that the
419 * game is responsible for sending and receiving UDP packets for the master
420 * server updater. (See ISteamGameServer::HandleIncomingPacket and
421 * ISteamGameServer::GetNextOutgoingPacket.)
422 * - The version string should be in the form x.x.x.x, and is used by the master
423 * server to detect when the server is out of date. (Only servers with the
424 * latest version will be listed.)
425 */
426 static inline int SteamGameServer_Init(
427 u32 unIP, u16 usGamePort, u16 usQueryPort,
428 EServerMode eServerMode,
429 const char *pchVersionString )
430 {
431 return SteamInternal_GameServer_Init( unIP, 0, usGamePort, usQueryPort,
432 eServerMode, pchVersionString );
433 }
434
435 void *SteamAPI_SteamGameServer_v014(void);
436 static inline void *SteamAPI_SteamGameServer(void)
437 {
438 return SteamAPI_SteamGameServer_v014();
439 }
440
441 void SteamAPI_ISteamGameServer_LogOnAnonymous( void* self );
442 void SteamGameServer_Shutdown(void);
443 int SteamGameServer_BSecure(void);
444 u64 SteamGameServer_GetSteamID(void);
445 HSteamPipe SteamAPI_GetHSteamPipe(void);
446 HSteamPipe SteamGameServer_GetHSteamPipe(void);
447 HSteamUser SteamAPI_GetHSteamUser(void);
448 void SteamAPI_ManualDispatch_Init(void);
449 void SteamAPI_ManualDispatch_RunFrame( HSteamPipe hSteamPipe );
450 steamapi_bool SteamAPI_ManualDispatch_GetNextCallback( HSteamPipe hSteamPipe,
451 CallbackMsg_t *pCallbackMsg );
452 void SteamAPI_ManualDispatch_FreeLastCallback( HSteamPipe hSteamPipe );
453 steamapi_bool SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe,
454 SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback,
455 int iCallbackExpected, steamapi_bool *pbFailed );
456 void SteamAPI_ReleaseCurrentThreadMemory(void);