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