#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
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; i<steam_async_track_count; i++ )
+ {
+ if( steam_async_trackers[j].id != pCallCompleted->m_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 );
/* Check for dispatching API call results */
if( callback.m_iCallback == k_iSteamAPICallCompleted )
{
- SteamAPICallCompleted_t *pCallCompleted =
- (SteamAPICallCompleted_t *)callback.m_pubParam;
-
- void *pTmpCallResult = vg_alloc( 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; i<steam_async_track_count; i++ )
- {
- if( steam_async_trackers[j].id != pCallCompleted->m_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
- }
-
- vg_free( pTmpCallResult );
+ steamworks_process_api_call( pipe, &callback );
}
else
{