#define SW_CBID_SteamAPICallCompleted (k_iSteamUtilsCallbacks + 3)
+typedef enum ESteamAPICallFailure
+{
+ k_ESteamAPICallFailureNone = -1, // no failure
+ k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away
+ k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken
+ // SteamServersDisconnected_t callback will be sent around the same time
+ // SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again
+ k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists
+ k_ESteamAPICallFailureMismatchedCallback = 3,// GetAPICallResult() was called with the wrong callback type for this API call
+} ESteamAPICallFailure;
+
typedef u64 UGCHandle_t;
typedef u64 PublishedFileUpdateHandle_t;
typedef u64 PublishedFileId_t;
int SteamAPI_ISteamUserStats_SetAchievement( ISteamUserStats *self, const char *pchName );
+ESteamAPICallFailure SteamAPI_ISteamUtils_GetAPICallFailureReason( ISteamUtils* self, SteamAPICall_t hSteamAPICall );
+
// Leaderboards
SteamAPICall_t SteamAPI_ISteamUserStats_FindOrCreateLeaderboard( ISteamUserStats* self, const char * pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType );
SteamAPICall_t SteamAPI_ISteamUserStats_FindLeaderboard( ISteamUserStats* self, const char * pchLeaderboardName );
ISteamUser *user;
ISteamUserStats *stats;
ISteamNetworking *net;
+ ISteamUtils *utils;
HSteamPipe pipe;
+
} steam_api_classes;
ISteamFriends *SteamAPI_SteamFriends_v017();
ISteamUser *SteamAPI_SteamUser_v021();
ISteamUserStats *SteamAPI_SteamUserStats_v012();
ISteamNetworking *SteamAPI_SteamNetworking_v006();
+ISteamUtils *SteamAPI_SteamUtils_v010();
static void sw_exit(void)
{
steam_api_classes.user = SteamAPI_SteamUser_v021();
steam_api_classes.stats = SteamAPI_SteamUserStats_v012();
steam_api_classes.net = SteamAPI_SteamNetworking_v006();
+ steam_api_classes.utils = SteamAPI_SteamUtils_v010();
- if( !steam_api_classes.friends || !steam_api_classes.user || !steam_api_classes.stats || !steam_api_classes.net )
+ if( !steam_api_classes.friends || !steam_api_classes.user || !steam_api_classes.stats || !steam_api_classes.net || !steam_api_classes.utils )
{
vg_error( "Steamworks interface pointers failed. Steamworks DLL may be old\n" );
SteamAPI_Shutdown();
return 1;
}
+
+void (*sw_leaderboard_found)( LeaderboardFindResult_t *pCallback );
+
static void sw_event_loop(void)
{
SteamAPI_ManualDispatch_RunFrame( steam_api_classes.pipe );
while( SteamAPI_ManualDispatch_GetNextCallback( steam_api_classes.pipe, &callback ) )
{
+ vg_info( "steamworks_event::callback( %i )\n", callback.m_iCallback );
+
// Check for dispatching API call results
if( callback.m_iCallback == SW_CBID_SteamAPICallCompleted ){
- SteamAPICallCompleted_t *pCallCompleted = (SteamAPICallCompleted_t *)&callback;
+ SteamAPICallCompleted_t *pCallCompleted = (SteamAPICallCompleted_t *)callback.m_pubParam;
void *pTmpCallResult = malloc( pCallCompleted->m_cubParam );
int bFailed;
{
// Dispatch the call result to the registered handler(s) for the
// call identified by pCallCompleted->m_hAsyncCall
+
+ vg_info( "steamworks_event::api_call_completed( %lu )\n", pCallCompleted->m_hAsyncCall );
+
+ switch( pCallCompleted->m_iCallback )
+ {
+ case SW_CBID_LeaderboardFindResult:
+ if( sw_leaderboard_found ) sw_leaderboard_found( (LeaderboardFindResult_t*)pTmpCallResult );
+ break;
+ default:break;
+ }
+ }
+ else
+ {
+ typedef enum ESteamAPICallFailure
+ {
+ k_ESteamAPICallFailureNone = -1, // no failure
+ k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away
+ k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken
+ // SteamServersDisconnected_t callback will be sent around the same time
+ // SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again
+ k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists
+ k_ESteamAPICallFailureMismatchedCallback = 3,// GetAPICallResult() was called with the wrong callback type for this API call
+ } ESteamAPICallFailure;
+
+ ESteamAPICallFailure fail_why =
+ SteamAPI_ISteamUtils_GetAPICallFailureReason( steam_api_classes.utils, pCallCompleted->m_hAsyncCall );
+
+ vg_error( "steamworks_event: error getting call result on %lu (code %d)\n", pCallCompleted->m_hAsyncCall, fail_why );
}
free( pTmpCallResult );
{
// Look at callback.m_iCallback to see what kind of callback it is,
// and dispatch to appropriate handler(s)
-
- vg_info( "steamworks_event::callback( %i )\n", callback.m_iCallback );
-
//void *data = callback.m_pubParam;
switch( callback.m_iCallback )
vg_success( "Achievement set: '%s'\n", vg_ach_name );
}
}
+
+static void sw_find_leaderboard( const char *name )
+{
+ SteamAPI_ISteamUserStats_FindLeaderboard( steam_api_classes.stats, name );
+}
+
+static const char *sw_get_leaderboard_name( SteamLeaderboard_t hSteamLeaderboard )
+{
+ return SteamAPI_ISteamUserStats_GetLeaderboardName( steam_api_classes.stats, hSteamLeaderboard );
+}