X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=src%2Fvg%2Fvg_steam.h;h=740ffdaa076aef8f8b4864be8473eedb5ba2676f;hb=3dd767bb10e6fee9cbffeb185d1a9685810c17b5;hp=05fe1acaeea72e69968d8b7261e6fa48cb4e6d1b;hpb=6aeba08ad9ad8bdecafcfd9f946173e99a84fc59;p=vg.git diff --git a/src/vg/vg_steam.h b/src/vg/vg_steam.h index 05fe1ac..740ffda 100644 --- a/src/vg/vg_steam.h +++ b/src/vg/vg_steam.h @@ -3,6 +3,10 @@ #include "vg.h" +/* + * TODO: Combine interfaces and stuff here instead of having them in client code + */ + #if defined(__linux__) || defined(__APPLE__) /* * The 32-bit version of gcc has the alignment requirement for u64 and double @@ -522,6 +526,78 @@ int SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe, void SteamAPI_ReleaseCurrentThreadMemory(void); +static void steamworks_process_api_call( HSteamPipe pipe, + CallbackMsg_t *callback ) +{ + SteamAPICallCompleted_t *pCallCompleted = + (SteamAPICallCompleted_t *)callback->m_pubParam; + + int bFailed; + + void *temp = alloca( pCallCompleted->m_cubParam ); + + if( SteamAPI_ManualDispatch_GetAPICallResult( + pipe, + pCallCompleted->m_hAsyncCall, + temp, + pCallCompleted->m_cubParam, + pCallCompleted->m_iCallback, + &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 ); + + int j=0; + for( int i=0; im_hAsyncCall ) + { + steam_async_trackers[j ++] = steam_async_trackers[i]; + } + else + { + steam_async *pasync = &steam_async_trackers[j]; + pasync->p_handler( temp, pasync->data ); + } + } + + if( steam_async_track_count == j ) + { + vg_error( "No tracker was register for API call\n" ); + } + + steam_async_track_count = j; + } + else + { +#if 0 + typedef enum ESteamAPICallFailure + { + k_ESteamAPICallFailureNone = -1, + k_ESteamAPICallFailureSteamGone = 0, + k_ESteamAPICallFailureNetworkFailure = 1, + k_ESteamAPICallFailureInvalidHandle = 2, + k_ESteamAPICallFailureMismatchedCallback = 3, + } + + 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 ); +#endif + } +} + static void steamworks_event_loop( HSteamPipe pipe ) { SteamAPI_ManualDispatch_RunFrame( pipe ); @@ -534,74 +610,7 @@ static void steamworks_event_loop( HSteamPipe pipe ) /* Check for dispatching API call results */ if( callback.m_iCallback == k_iSteamAPICallCompleted ) { - SteamAPICallCompleted_t *pCallCompleted = - (SteamAPICallCompleted_t *)callback.m_pubParam; - - void *pTmpCallResult = malloc( pCallCompleted->m_cubParam ); - int bFailed; - - if( SteamAPI_ManualDispatch_GetAPICallResult( - pipe, - pCallCompleted->m_hAsyncCall, - pTmpCallResult, - pCallCompleted->m_cubParam, - pCallCompleted->m_iCallback, - &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 ); - - int j=0; - for( int i=0; im_hAsyncCall ) - { - steam_async_trackers[j ++] = steam_async_trackers[i]; - } - else - { - steam_async *pasync = &steam_async_trackers[j]; - pasync->p_handler( pTmpCallResult, pasync->data ); - } - } - - if( steam_async_track_count == j ) - { - vg_error( "No tracker was register for API call\n" ); - } - - steam_async_track_count = j; - } - else - { -#if 0 - typedef enum ESteamAPICallFailure - { - k_ESteamAPICallFailureNone = -1, - k_ESteamAPICallFailureSteamGone = 0, - k_ESteamAPICallFailureNetworkFailure = 1, - k_ESteamAPICallFailureInvalidHandle = 2, - k_ESteamAPICallFailureMismatchedCallback = 3, - } - - 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 ); -#endif - } - - free( pTmpCallResult ); + steamworks_process_api_call( pipe, &callback ); } else {