From: hgn Date: Wed, 9 Jul 2025 14:44:30 +0000 (+0100) Subject: re-implement steamworks X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=a10ac0b591fc7163c2c474abbaf9639ad479e36e;p=vg.git re-implement steamworks --- diff --git a/dep/steam/libsdkencryptedappticket.so b/dep/steam/libsdkencryptedappticket.so index 47426bb..dfbb28f 100644 Binary files a/dep/steam/libsdkencryptedappticket.so and b/dep/steam/libsdkencryptedappticket.so differ diff --git a/dep/steam/libsteam_api.so b/dep/steam/libsteam_api.so index 8bf6762..8783570 100644 Binary files a/dep/steam/libsteam_api.so and b/dep/steam/libsteam_api.so differ diff --git a/dep/steam/steam_api.dll b/dep/steam/steam_api.dll deleted file mode 100755 index 319bb83..0000000 Binary files a/dep/steam/steam_api.dll and /dev/null differ diff --git a/vg_build.h b/vg_build.h index 9069f87..9b768f0 100644 --- a/vg_build.h +++ b/vg_build.h @@ -396,7 +396,8 @@ struct vg_engine_config log_source_info, steam_api, custom_game_settings, - custom_shaders; + custom_shaders, + multiplayer; i32 fixed_update_hz; } vg_engine_default_config = @@ -407,7 +408,8 @@ vg_engine_default_config = .log_source_info = 1, .steam_api = 0, .custom_game_settings = 0, - .custom_shaders = 0 + .custom_shaders = 0, + .multiplayer = 0 }; struct compile_result @@ -442,10 +444,10 @@ vg_make_app( struct vg_project *proj, if( vg_conf->custom_shaders ) vg_strcat( &conf->defines, "-DVG_CUSTOM_SHADERS \\\n" ); - if( env->arch == k_architecture_i386 ) - vg_strcat( &conf->defines, "-DVG_32 \\\n" ); - else - vg_strcat( &conf->defines, "-DVG_64 \\\n" ); + if( vg_conf->multiplayer ) + vg_strcat( &conf->defines, "-DVG_MULTIPLAYER \\\n" ); + + vg_strcat( &conf->defines, "-DVG_ENGINE \\\n" ); vg_strcat( &conf->defines, "\\\n" ); vg_strcat( &conf->include, "-I. -I./vg -I./vg/dep " ); @@ -476,7 +478,7 @@ vg_make_app( struct vg_project *proj, /* steamworks */ if( vg_conf->steam_api ) { - struct compile_result steam = vg_compiler_run( &vg_proj, &denv, conf, "vg/vg_steam.c", "vg_steam", k_obj_type_obj ); + struct compile_result steam = vg_compiler_run( &vg_proj, &denv, conf, "vg/vg_steam2.c", "vg_steam", k_obj_type_obj ); vg_strcatf( &components, "%s ", steam.path ); if( env->platform == k_platform_linux ) diff --git a/vg_db.c b/vg_db.c index 27e71a7..85e72ec 100644 --- a/vg_db.c +++ b/vg_db.c @@ -11,12 +11,11 @@ static void vg_db_abort( vg_db *db, const char *message, ... ) { fclose( db->fp ); db->fp = NULL; - vg_fatal_condition(); va_list args; va_start( args, message ); _vg_logx_va( stderr, NULL, "vg_db fatal", KRED, message, args ); va_end( args ); - vg_fatal_exit(); + vg_fatal_error( "Database error\n" ); } static u32 vg_dbhash( u8 *buf, u32 len ) diff --git a/vg_engine.c b/vg_engine.c index 22e02b7..00847b8 100644 --- a/vg_engine.c +++ b/vg_engine.c @@ -1,5 +1,6 @@ #include "vg_engine.h" #include "vg_async2.h" +#include "vg_steam2.h" struct vg_engine vg = { @@ -236,6 +237,8 @@ static void _vg_process_events(void) vg.mouse_state = SDL_GetMouseState( &vg.mouse_pos[0], &vg.mouse_pos[1] ); vg_process_inputs(); + + vg_steam_frame(); } static void _vg_gameloop_update(void) @@ -669,6 +672,9 @@ void vg_init( int argc, const char *argv[], const char *window_name ) vg_error( "Could not open '%s' for logging.\n", arg ); } + if( vg_long_opt( "no-steam", "Disable Steam integration (Good idea for pirating)" ) ) + _steam_api.disabled = 1; + #ifdef _WIN32 DWORD pid = GetCurrentProcessId(); @@ -745,6 +751,8 @@ void vg_run(void) if( !_vg_opt_check() ) exit(0); + vg_steam_init(); + /* Systems init */ vg_console_init(); vg_magi_init(); @@ -780,6 +788,7 @@ void vg_run(void) _thread_purpose_loader = 0x2; SDL_CreateThread( _vg_loader_thread, "vg: loader", NULL ); _vg_gameloop(); + vg_steam_shutdown(); _vg_terminate(); } diff --git a/vg_engine.h b/vg_engine.h index bbdc93a..9955dbb 100644 --- a/vg_engine.h +++ b/vg_engine.h @@ -16,7 +16,6 @@ #endif #endif -#define VG_ENGINE #include "vg_opengl.h" #define SDL_MAIN_HANDLED diff --git a/vg_log.h b/vg_log.h index 5f10b1a..9781115 100644 --- a/vg_log.h +++ b/vg_log.h @@ -18,6 +18,8 @@ vg_logx(stdout,VG_LOG_WHERE,"error",KRED,__VA_ARGS__) #define vg_low( ... ) \ vg_logx(stdout,VG_LOG_WHERE,"log",KWHT,__VA_ARGS__) +#define vg_logsteam( ... ) \ + vg_logx(stdout,VG_LOG_WHERE,"steam",KBLU,__VA_ARGS__) #define KNRM "\x1B[0m" #define KBLK "\x1B[30m" diff --git a/vg_platform.h b/vg_platform.h index 07ab3aa..5c6e3e6 100644 --- a/vg_platform.h +++ b/vg_platform.h @@ -4,6 +4,7 @@ #include typedef uint8_t u8; +typedef char c8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; diff --git a/vg_steam.c b/vg_steam.c deleted file mode 100644 index 6a6599b..0000000 --- a/vg_steam.c +++ /dev/null @@ -1,126 +0,0 @@ -#include "vg_steam.h" -#include "vg_log.h" -#include - -struct vg_steam vg_steam; - -vg_steam_async_call *vg_alloc_async_steam_api_call(void) -{ - if( vg_steam.call_count == VG_ARRAY_LEN(vg_steam.calls) ) - vg_fatal_error( "Maximum concurrent API calls exceeded (%u)\n", vg_steam.call_count ); - - return &vg_steam.calls[ vg_steam.call_count ++ ]; -} - -void steam_register_callback( u32 id, void (*p_handler)( CallbackMsg_t *msg ) ) -{ - if( vg_steam.callback_handler_count == VG_ARRAY_LEN(vg_steam.callback_handlers) ) - vg_fatal_error( "Too many steam callback handlers registered (%u)\n", vg_steam.callback_handler_count ); - - vg_steam_callback_handler *handler = &vg_steam.callback_handlers[ vg_steam.callback_handler_count ++ ]; - handler->p_handler = p_handler; - handler->callback_id = id; -} - -void steamworks_process_api_call( HSteamPipe pipe, CallbackMsg_t *callback ) -{ - SteamAPICallCompleted_t *pCallCompleted = (SteamAPICallCompleted_t *)callback->m_pubParam; - - steamapi_bool bFailed; - void *call_data = alloca( pCallCompleted->m_cubParam ); - - if( SteamAPI_ManualDispatch_GetAPICallResult( - pipe, - pCallCompleted->m_hAsyncCall, - call_data, - 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 ) - vg_steam.calls[j ++] = vg_steam.calls[i]; - else - { - vg_steam_async_call *call = &vg_steam.calls[i]; - call->p_handler( call_data, call->userdata ); - } - } - - if( vg_steam.call_count == j ) - vg_error( "No tracker was register for API call\n" ); - - vg_steam.call_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 - } -} - -void steamworks_event_loop( HSteamPipe pipe ) -{ - SteamAPI_ManualDispatch_RunFrame( pipe ); - CallbackMsg_t callback; - - while( SteamAPI_ManualDispatch_GetNextCallback( pipe, &callback ) ){ - vg_low( "steamworks_event::callback( %i )\n", callback.m_iCallback ); - - /* Check for dispatching API call results */ - if( callback.m_iCallback == k_iSteamAPICallCompleted ){ - steamworks_process_api_call( pipe, &callback ); - } - else { - /* - * Look at callback.m_iCallback to see what kind of callback it is, - * and dispatch to appropriate handler(s) - * void *data = callback.m_pubParam; - */ - - for( int i=0; icallback_id == callback.m_iCallback ){ - handler->p_handler( &callback ); - break; - } - } - } - - SteamAPI_ManualDispatch_FreeLastCallback( pipe ); - } -} - -void steamworks_ensure_txt( const char *appid_str ) -{ - FILE *txt = fopen("steam_appid.txt", "w"); - fputs( appid_str, txt ); - fclose( txt ); -} diff --git a/vg_steam.h b/vg_steam.h deleted file mode 100644 index db0e84d..0000000 --- a/vg_steam.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "vg_steam_api.h" - -typedef struct vg_steam_async_call vg_steam_async_call; -typedef struct vg_steam_callback_handler vg_steam_callback_handler; - -struct vg_steam -{ - struct vg_steam_async_call{ - SteamAPICall_t id; - void *userdata; - void (*p_handler)( void *result, void *userdata ); - } - calls[4]; - u32 call_count; - - struct vg_steam_callback_handler{ - u32 callback_id; - void (*p_handler)( CallbackMsg_t *msg ); - } - callback_handlers[32]; - u32 callback_handler_count; -} -extern vg_steam; - -void steamworks_process_api_call( HSteamPipe pipe, CallbackMsg_t *callback ); -void steamworks_event_loop( HSteamPipe pipe ); -vg_steam_async_call *vg_alloc_async_steam_api_call(void); -void steam_register_callback( u32 id, void (*p_handler)( CallbackMsg_t *msg ) ); - -/* - * This is required to run the server outside of steamcmd environment. - * It can be any appid but idealy the one that is actually your game - */ -void steamworks_ensure_txt( const char *appid_str ); diff --git a/vg_steam2.c b/vg_steam2.c new file mode 100644 index 0000000..e8eb9ef --- /dev/null +++ b/vg_steam2.c @@ -0,0 +1,336 @@ +#include "vg_steam2.h" +#include "vg_log.h" +#include "vg_string.h" +#include +#include + +struct vg_steam_api _steam_api; + +static void cb_steam_warning( i32 severity, const c8 *pchMessage ) +{ + if( severity == 0 ) + vg_logsteam( "[message]" KBLK " '%s'\n", pchMessage ); + else + vg_logsteam( "[message]" KYEL " '%s'\n", pchMessage ); +} + +#if defined( VG_ENGINE ) +static void cb_auth_ticket_recieved( void *result, void *context ) +{ + EncryptedAppTicketResponse_t *response = result; + + if( response->m_eResult == k_EResultOK ) + vg_logsteam( " New app ticket ready\n" ); + else + vg_logsteam( KYEL " Could not request new encrypted app ticket (%u)\n", response->m_eResult ); + + if( SteamAPI_ISteamUser_GetEncryptedAppTicket( _steam_api.pSteamUser, _steam_api.app_symmetric_key, + VG_ARRAY_LEN(_steam_api.app_symmetric_key), &_steam_api.app_key_length )) + { + vg_logsteam( KGRN " Loaded app ticket\n" ); + } + else + { + vg_logsteam( KRED " No ticket availible\n" ); + _steam_api.app_key_length = 0; + } +} +#endif + +#if defined( VG_SERVER ) +bool vg_steam_init( u32 unIP, u16 usGamePort, u16 usQueryPort, EServerMode eServerMode, const c8 *pchVersionString, + const c8 *appid_str ) +#else +bool vg_steam_init(void) +#endif +{ + if( _steam_api.disabled ) + return 0; + + SteamErrMsg err; + + /* Steamworks init step + * ---------------------------------------------------------------------------- */ +#if defined( VG_ENGINE ) + + const char *pszInternalCheckInterfaceVersions = + STEAMUTILS_INTERFACE_VERSION "\0" + STEAMNETWORKINGUTILS_INTERFACE_VERSION "\0" + STEAMAPPS_INTERFACE_VERSION "\0" + STEAMCONTROLLER_INTERFACE_VERSION "\0" + STEAMFRIENDS_INTERFACE_VERSION "\0" + STEAMGAMESEARCH_INTERFACE_VERSION "\0" + STEAMHTMLSURFACE_INTERFACE_VERSION "\0" + STEAMHTTP_INTERFACE_VERSION "\0" + STEAMINPUT_INTERFACE_VERSION "\0" + STEAMINVENTORY_INTERFACE_VERSION "\0" + STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION "\0" + STEAMMATCHMAKING_INTERFACE_VERSION "\0" + STEAMMUSICREMOTE_INTERFACE_VERSION "\0" + STEAMMUSIC_INTERFACE_VERSION "\0" + STEAMNETWORKINGMESSAGES_INTERFACE_VERSION "\0" + STEAMNETWORKINGSOCKETS_INTERFACE_VERSION "\0" + STEAMNETWORKING_INTERFACE_VERSION "\0" + STEAMPARENTALSETTINGS_INTERFACE_VERSION "\0" + STEAMPARTIES_INTERFACE_VERSION "\0" + STEAMREMOTEPLAY_INTERFACE_VERSION "\0" + STEAMREMOTESTORAGE_INTERFACE_VERSION "\0" + STEAMSCREENSHOTS_INTERFACE_VERSION "\0" + STEAMUGC_INTERFACE_VERSION "\0" + STEAMUSERSTATS_INTERFACE_VERSION "\0" + STEAMUSER_INTERFACE_VERSION "\0" + STEAMVIDEO_INTERFACE_VERSION "\0" + + "\0"; + + if( SteamInternal_SteamAPI_Init( pszInternalCheckInterfaceVersions, &err ) != k_ESteamAPIInitResult_OK ) + { + _steam_api.disabled = 1; + vg_logsteam( KRED "SteamInternal_SteamAPI_Init() failed: '%s'\nAll steam interactions disabled for this session\n", err ); + return 0; + } +#endif + +#if defined( VG_SERVER ) + FILE *txt = fopen( "steam_appid.txt", "w" ); + fputs( appid_str, txt ); + fclose( txt ); + + const char *pszInternalCheckInterfaceVersions = + STEAMUTILS_INTERFACE_VERSION "\0" + STEAMNETWORKINGUTILS_INTERFACE_VERSION "\0" + + STEAMGAMESERVER_INTERFACE_VERSION "\0" + STEAMGAMESERVERSTATS_INTERFACE_VERSION "\0" + STEAMHTTP_INTERFACE_VERSION "\0" + STEAMINVENTORY_INTERFACE_VERSION "\0" + STEAMNETWORKING_INTERFACE_VERSION "\0" + STEAMNETWORKINGMESSAGES_INTERFACE_VERSION "\0" + STEAMNETWORKINGSOCKETS_INTERFACE_VERSION "\0" + STEAMUGC_INTERFACE_VERSION "\0" + "\0"; + + ESteamAPIInitResult init_result = SteamInternal_GameServer_Init_V2( + unIP, usGamePort, usQueryPort, eServerMode, pchVersionString, pszInternalCheckInterfaceVersions, &err ); + + if( init_result != k_ESteamAPIInitResult_OK ) + { + _steam_api.disabled = 1; + vg_logsteam( KRED "SteamInternal_GameServer_Init_V2() failed: '%s'\n", err ); + return 0; + } +#endif + + /* Manual dispatch step + * ----------------------------------------------------------------------------- */ + SteamAPI_ManualDispatch_Init(); + + /* + * Interface Init + * ----------------------------------------------------------------------------- */ + +#if defined( VG_ENGINE ) + _steam_api.hPipe = SteamAPI_GetHSteamPipe(); + _steam_api.pSteamUtils = SteamAPI_SteamUtils_v010(); + _steam_api.pSteamFriends = SteamAPI_SteamFriends_v018(); + _steam_api.pSteamUGC = SteamAPI_SteamUGC_v021(); + _steam_api.pSteamUser = SteamAPI_SteamUser_v023(); + _steam_api.pSteamUserStats = SteamAPI_SteamUserStats_v013(); + _steam_api.pSteamNetworkingSockets = SteamAPI_SteamNetworkingSockets_SteamAPI_v012(); +#endif + +#if defined( VG_SERVER ) + _steam_api.hPipe = SteamGameServer_GetHSteamPipe(); + _steam_api.pSteamGameServer = SteamAPI_SteamGameServer_v015(); + _steam_api.pSteamUtils = SteamAPI_SteamGameServerUtils_v010(); + _steam_api.pSteamUGC = SteamAPI_SteamGameServerUGC_v021(); + _steam_api.pSteamNetworkingSockets = SteamAPI_SteamGameServerNetworkingSockets_SteamAPI_v012(); +#endif + + _steam_api.pSteamNetworkingUtils = SteamAPI_SteamNetworkingUtils_SteamAPI_v004(); + + SteamAPI_ISteamUtils_SetWarningMessageHook( _steam_api.pSteamUtils, cb_steam_warning ); + +#if defined( VG_SERVER ) + SteamAPI_ISteamGameServer_LogOnAnonymous( _steam_api.pSteamGameServer ); +#endif + + +#if defined( VG_ENGINE ) + strcpy( _steam_api.username_at_startup, "[unassigned]" ); + const c8 *username = SteamAPI_ISteamFriends_GetPersonaName( _steam_api.pSteamFriends ); + str_utf8_collapse( username, _steam_api.username_at_startup, VG_ARRAY_LEN(_steam_api.username_at_startup) ); + +# if defined( VG_MULTIPLAYER ) + vg_logsteam( "Requesting new authorization ticket\n" ); + + vg_steam_api_call *call = vg_alloc_async_steam_api_call(); + if( call ) + { + call->userdata = NULL; + call->cb = cb_auth_ticket_recieved; + call->id = SteamAPI_ISteamUser_RequestEncryptedAppTicket( _steam_api.pSteamUser, NULL, 0 ); + } +# endif +#endif + + return 1; +} + +static const c8 *string_ESteamNetworkingConnectionState( ESteamNetworkingConnectionState s ) +{ + if( s == k_ESteamNetworkingConnectionState_None ) return "None"; + if( s == k_ESteamNetworkingConnectionState_Connecting) return "Connecting"; + if( s == k_ESteamNetworkingConnectionState_FindingRoute) return "Finding route"; + if( s == k_ESteamNetworkingConnectionState_Connected) return "Connected"; + if( s == k_ESteamNetworkingConnectionState_ClosedByPeer) return "Closed By Peer"; + if( s == k_ESteamNetworkingConnectionState_ProblemDetectedLocally) return "Problem detected locally"; + if( s == k_ESteamNetworkingConnectionState_FinWait) return "Finwait"; + if( s == k_ESteamNetworkingConnectionState_Linger) return "Linger"; + if( s == k_ESteamNetworkingConnectionState_Dead) return "Dead"; + return "enum-out-of-range"; +} + +static const c8 *string_ESteamAPICallFailure( ESteamAPICallFailure e ) +{ + if( e == k_ESteamAPICallFailureNone ) return "None"; + if( e == k_ESteamAPICallFailureSteamGone ) return "Steam Gone"; + if( e == k_ESteamAPICallFailureNetworkFailure ) return "Network Failure"; + if( e == k_ESteamAPICallFailureInvalidHandle ) return KBLK "Invalid Handle"; + if( e == k_ESteamAPICallFailureMismatchedCallback ) return "Mismatched Callback"; + return "enum-out-of-range"; +} + +void vg_steam_frame(void) +{ + if( _steam_api.disabled ) + return; + + SteamAPI_ManualDispatch_RunFrame( _steam_api.hPipe ); + + CallbackMsg_t callback; + while( SteamAPI_ManualDispatch_GetNextCallback( _steam_api.hPipe, &callback ) ) + { + /* Check for dispatching API call results */ + i32 type = callback.m_iCallback; + if( type == k_iSteamUtils_SteamAPICallCompleted ) + { + SteamAPICallCompleted_t *inf = callback.m_pubParam; + + bool bFailed; + void *call_data = alloca( inf->m_cubParam ); + + if( SteamAPI_ManualDispatch_GetAPICallResult( _steam_api.hPipe, inf->m_hAsyncCall, + call_data, inf->m_cubParam, + inf->m_iCallback, &bFailed ) ) + { + vg_logsteam( "api_call_completed %lu\n", inf->m_hAsyncCall ); + + int j=0; + for( int i=0; i<_steam_api.api_call_count; i++ ) + { + if( _steam_api.api_calls[i].id != inf->m_hAsyncCall ) + _steam_api.api_calls[j ++] = _steam_api.api_calls[i]; + else + _steam_api.api_calls[i].cb( call_data, _steam_api.api_calls[i].userdata ); + } + + if( _steam_api.api_call_count == j ) + vg_error( "No tracker was register for API call\n" ); + + _steam_api.api_call_count = j; + } + else + { + enum ESteamAPICallFailure e = + SteamAPI_ISteamUtils_GetAPICallFailureReason( _steam_api.pSteamUtils, inf->m_hAsyncCall ); + const c8 *fail_str = string_ESteamAPICallFailure( e ); + vg_logsteam( KRED "Error getting call result on %lu (code %d)\n", inf->m_hAsyncCall, fail_str ); + } + } + else + { + /* + * Look at callback.m_iCallback to see what kind of callback it is, + * and dispatch to appropriate handler(s) + * void *data = callback.m_pubParam; + */ + if( type == k_iSteamUser_SteamServersConnected ) + vg_success( "Steam servers connected" ); + else if( type == k_iSteamUser_SteamConnectFailure ) + { + SteamServerConnectFailure_t *inf = callback.m_pubParam; + vg_logsteam( KRED "Steam server connect failure, code %d, retrying: %d\n", inf->m_eResult, inf->m_bStillRetrying ); + } + else if( type == k_iSteamUser_SteamServersDisconnected ) + { + SteamServersDisconnected_t *inf = callback.m_pubParam; + vg_logsteam( "Steam servers disconnect, code %d\n", inf->m_eResult ); + } + else if( type == k_iSteamNetworkingSockets_SteamNetConnectionStatusChangedCallback ) + { + SteamNetConnectionStatusChangedCallback_t *inf = callback.m_pubParam; + const c8 *status_string = string_ESteamNetworkingConnectionState( inf->m_info.m_eState ); + vg_logsteam( "Connection status changed: %x -> %s\n Debug: '%s'\n EndDebug: '%s'\n", + inf->m_hConn, status_string, inf->m_info.m_szConnectionDescription, + inf->m_info.m_szEndDebug ); + + if( _steam_api.cb_connection_changed ) + _steam_api.cb_connection_changed( inf ); + } + else if( type == k_iSteamNetworkingSockets_SteamNetAuthenticationStatus ) + { + SteamNetAuthenticationStatus_t *inf = callback.m_pubParam; + vg_logsteam( "Steam Authentication Status: %d\n Debug: '%s'\n", inf->m_eAvail, inf->m_debugMsg ); + } + } + + SteamAPI_ManualDispatch_FreeLastCallback( _steam_api.hPipe ); + } +} + +void vg_steam_shutdown(void) +{ +#if defined( VG_SERVER ) + if( _steam_api.is_connected ) + { + SteamAPI_ISteamGameServer_LogOff( _steam_api.pSteamGameServer ); + _steam_api.is_connected = 0; + } + SteamGameServer_Shutdown(); +#else + SteamAPI_Shutdown(); +#endif +} + +vg_steam_api_call *vg_alloc_async_steam_api_call(void) +{ + if( _steam_api.api_call_count == VG_ARRAY_LEN(_steam_api.api_calls) ) + return NULL; + return &_steam_api.api_calls[ _steam_api.api_call_count ++ ]; +} + +#if defined( VG_ENGINE ) +void vg_steam_set_achievement( const c8 *name, bool yes ) +{ + if( _steam_api.disabled || _steam_api.demo_mode ) + return; + + if( yes ) + { + if( SteamAPI_ISteamUserStats_SetAchievement( _steam_api.pSteamUserStats, name ) ) + { + vg_logsteam( KGRN "Set achievement '%s'\n", name ); + SteamAPI_ISteamUserStats_StoreStats( _steam_api.pSteamUserStats ); + } + } + else + { + if( SteamAPI_ISteamUserStats_ClearAchievement( _steam_api.pSteamUserStats, name ) ) + { + vg_logsteam( KBLK "Clear achievement '%s'\n", name ); + SteamAPI_ISteamUserStats_StoreStats( _steam_api.pSteamUserStats ); + } + } +} +#endif diff --git a/vg_steam2.h b/vg_steam2.h new file mode 100644 index 0000000..8647a8a --- /dev/null +++ b/vg_steam2.h @@ -0,0 +1,1203 @@ +#pragma once +#include "vg_platform.h" + +#if defined( VG_ENGINE ) || defined( VG_SERVER ) +# if defined( VG_ENGINE ) && defined( VG_SERVER ) +# error Can't be both! +# endif +#else +# error Must define VG_ENGINE or VG_SERVER +#endif + +#define STEAMTIMELINE_INTERFACE_VERSION "STEAMTIMELINE_INTERFACE_V004" +#define STEAMUTILS_INTERFACE_VERSION "SteamUtils010" +#define STEAMGAMECOORDINATOR_INTERFACE_VERSION "SteamGameCoordinator001" +#define STEAMHTTP_INTERFACE_VERSION "STEAMHTTP_INTERFACE_VERSION003" +#define STEAMREMOTESTORAGE_INTERFACE_VERSION "STEAMREMOTESTORAGE_INTERFACE_VERSION016" +#define STEAMAPPS_INTERFACE_VERSION "STEAMAPPS_INTERFACE_VERSION008" +#define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION021" +#define STEAMAPPTICKET_INTERFACE_VERSION "STEAMAPPTICKET_INTERFACE_VERSION001" +#define STEAMSCREENSHOTS_INTERFACE_VERSION "STEAMSCREENSHOTS_INTERFACE_VERSION003" +#define STEAMHTMLSURFACE_INTERFACE_VERSION "STEAMHTMLSURFACE_INTERFACE_VERSION_005" +#define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking006" +#define STEAMMUSICREMOTE_INTERFACE_VERSION "STEAMMUSICREMOTE_INTERFACE_VERSION001" +#define STEAMREMOTEPLAY_INTERFACE_VERSION "STEAMREMOTEPLAY_INTERFACE_VERSION003" +#define STEAMNETWORKINGMESSAGES_INTERFACE_VERSION "SteamNetworkingMessages002" +#define STEAMCONTROLLER_INTERFACE_VERSION "SteamController008" +#define STEAMUSERSTATS_INTERFACE_VERSION "STEAMUSERSTATS_INTERFACE_VERSION013" +#define STEAMINPUT_INTERFACE_VERSION "SteamInput006" +#define STEAMVIDEO_INTERFACE_VERSION "STEAMVIDEO_INTERFACE_V007" +#define STEAMINVENTORY_INTERFACE_VERSION "STEAMINVENTORY_INTERFACE_V003" +#define STEAMMUSIC_INTERFACE_VERSION "STEAMMUSIC_INTERFACE_VERSION001" +#define STEAMUSER_INTERFACE_VERSION "SteamUser023" +#define STEAMGAMESERVERSTATS_INTERFACE_VERSION "SteamGameServerStats001" +#define STEAMNETWORKINGUTILS_INTERFACE_VERSION "SteamNetworkingUtils004" +#define STEAMGAMESERVER_INTERFACE_VERSION "SteamGameServer015" +#define STEAMFRIENDS_INTERFACE_VERSION "SteamFriends018" +#define STEAMNETWORKINGSOCKETS_INTERFACE_VERSION "SteamNetworkingSockets012" +#define STEAMPARENTALSETTINGS_INTERFACE_VERSION "STEAMPARENTALSETTINGS_INTERFACE_VERSION001" +#define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking009" +#define STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION "SteamMatchMakingServers002" +#define STEAMGAMESEARCH_INTERFACE_VERSION "SteamMatchGameSearch001" +#define STEAMPARTIES_INTERFACE_VERSION "SteamParties002" + +typedef i32 HSteamPipe; +typedef i32 HSteamUser; +typedef u64 SteamAPICall_t; +typedef u64 uint64_steamid; +typedef u32 AppId_t; +typedef u32 SteamNetworkingPOPID; +typedef u32 AccountID_t; + +typedef enum EResult EResult; +enum EResult +{ + k_EResultNone = 0, + k_EResultOK = 1, + k_EResultFail = 2, + k_EResultNoConnection = 3, +// k_EResultNoConnectionRetry = 4, + k_EResultInvalidPassword = 5, + k_EResultLoggedInElsewhere = 6, + k_EResultInvalidProtocolVer = 7, + k_EResultInvalidParam = 8, + k_EResultFileNotFound = 9, + k_EResultBusy = 10, + k_EResultInvalidState = 11, + k_EResultInvalidName = 12, + k_EResultInvalidEmail = 13, + k_EResultDuplicateName = 14, + k_EResultAccessDenied = 15, + k_EResultTimeout = 16, + k_EResultBanned = 17, + k_EResultAccountNotFound = 18, + k_EResultInvalidSteamID = 19, + k_EResultServiceUnavailable = 20, + k_EResultNotLoggedOn = 21, + k_EResultPending = 22, + k_EResultEncryptionFailure = 23, + k_EResultInsufficientPrivilege = 24, + k_EResultLimitExceeded = 25, + k_EResultRevoked = 26, + k_EResultExpired = 27, + k_EResultAlreadyRedeemed = 28, + k_EResultDuplicateRequest = 29, + k_EResultAlreadyOwned = 30, + k_EResultIPNotFound = 31, + k_EResultPersistFailed = 32, + k_EResultLockingFailed = 33, + k_EResultLogonSessionReplaced = 34, + k_EResultConnectFailed = 35, + k_EResultHandshakeFailed = 36, + k_EResultIOFailure = 37, + k_EResultRemoteDisconnect = 38, + k_EResultShoppingCartNotFound = 39, + k_EResultBlocked = 40, + k_EResultIgnored = 41, + k_EResultNoMatch = 42, + k_EResultAccountDisabled = 43, + k_EResultServiceReadOnly = 44, + k_EResultAccountNotFeatured = 45, + k_EResultAdministratorOK = 46, + k_EResultContentVersion = 47, + k_EResultTryAnotherCM = 48, + k_EResultPasswordRequiredToKickSession = 49, + k_EResultAlreadyLoggedInElsewhere = 50, + k_EResultSuspended = 51, + k_EResultCancelled = 52, + k_EResultDataCorruption = 53, + k_EResultDiskFull = 54, + k_EResultRemoteCallFailed = 55, + k_EResultPasswordUnset = 56, + k_EResultExternalAccountUnlinked = 57, + k_EResultPSNTicketInvalid = 58, + k_EResultExternalAccountAlreadyLinked = 59, + k_EResultRemoteFileConflict = 60, + k_EResultIllegalPassword = 61, + k_EResultSameAsPreviousValue = 62, + k_EResultAccountLogonDenied = 63, + k_EResultCannotUseOldPassword = 64, + k_EResultInvalidLoginAuthCode = 65, + k_EResultAccountLogonDeniedNoMail = 66, + k_EResultHardwareNotCapableOfIPT = 67, + k_EResultIPTInitError = 68, + k_EResultParentalControlRestricted = 69, + k_EResultFacebookQueryError = 70, + k_EResultExpiredLoginAuthCode = 71, + k_EResultIPLoginRestrictionFailed = 72, + k_EResultAccountLockedDown = 73, + k_EResultAccountLogonDeniedVerifiedEmailRequired = 74, + k_EResultNoMatchingURL = 75, + k_EResultBadResponse = 76, + k_EResultRequirePasswordReEntry = 77, + k_EResultValueOutOfRange = 78, + k_EResultUnexpectedError = 79, + k_EResultDisabled = 80, + k_EResultInvalidCEGSubmission = 81, + k_EResultRestrictedDevice = 82, + k_EResultRegionLocked = 83, + k_EResultRateLimitExceeded = 84, + k_EResultAccountLoginDeniedNeedTwoFactor = 85, + k_EResultItemDeleted = 86, + k_EResultAccountLoginDeniedThrottle = 87, + k_EResultTwoFactorCodeMismatch = 88, + k_EResultTwoFactorActivationCodeMismatch = 89, + k_EResultAccountAssociatedToMultiplePartners = 90, + k_EResultNotModified = 91, + k_EResultNoMobileDevice = 92, + k_EResultTimeNotSynced = 93, + k_EResultSmsCodeFailed = 94, + k_EResultAccountLimitExceeded = 95, + k_EResultAccountActivityLimitExceeded = 96, + k_EResultPhoneActivityLimitExceeded = 97, + k_EResultRefundToWallet = 98, + k_EResultEmailSendFailure = 99, + k_EResultNotSettled = 100, + k_EResultNeedCaptcha = 101, + k_EResultGSLTDenied = 102, + k_EResultGSOwnerDenied = 103, + k_EResultInvalidItemType = 104, + k_EResultIPBanned = 105, + k_EResultGSLTExpired = 106, + k_EResultInsufficientFunds = 107, + k_EResultTooManyPending = 108, + k_EResultNoSiteLicensesFound = 109, + k_EResultWGNetworkSendExceeded = 110, + k_EResultAccountNotFriends = 111, + k_EResultLimitedUserAccount = 112, + k_EResultCantRemoveItem = 113, + k_EResultAccountDeleted = 114, + k_EResultExistingUserCancelledLicense = 115, + k_EResultCommunityCooldown = 116, + k_EResultNoLauncherSpecified = 117, + k_EResultMustAgreeToSSA = 118, + k_EResultLauncherMigrated = 119, + k_EResultSteamRealmMismatch = 120, + k_EResultInvalidSignature = 121, + k_EResultParseFailure = 122, + k_EResultNoVerifiedPhone = 123, +}; + +#if defined(__linux__) || defined(__APPLE__) +# pragma pack( push, 4 ) +#else +# pragma pack( push, 8 ) +#endif + +typedef struct CallbackMsg_t CallbackMsg_t; +struct CallbackMsg_t +{ + HSteamUser m_hSteamUser; // Specific user to whom this callback applies. + i32 m_iCallback; // Callback identifier. (Corresponds to the k_iCallback enum in the callback structure.) + void *m_pubParam; // Points to the callback structure + i32 m_cubParam; // Size of the data pointed to by m_pubParam +}; + +typedef struct SteamAPICallCompleted_t SteamAPICallCompleted_t; +struct SteamAPICallCompleted_t +{ + SteamAPICall_t m_hAsyncCall; + i32 m_iCallback; + u32 m_cubParam; +}; + +// Steam universes. Each universe is a self-contained Steam instance. +typedef enum EUniverse EUniverse; +enum EUniverse +{ + k_EUniverseInvalid = 0, + k_EUniversePublic = 1, + k_EUniverseBeta = 2, + k_EUniverseInternal = 3, + k_EUniverseDev = 4, + // k_EUniverseRC = 5, // no such universe anymore + k_EUniverseMax +}; + +#pragma pack( push, 1 ) +typedef struct SteamIDComponent_t SteamIDComponent_t; +struct SteamIDComponent_t +{ + u32 m_unAccountID : 32; + u32 m_unAccountInstance : 20; + u32 m_EAccountType : 4; + EUniverse m_EUniverse : 8; +}; + +typedef struct CSteamID CSteamID; +struct CSteamID +{ + union + { + SteamIDComponent_t m_comp; + u64 m_unAll64Bits; + }; +}; + +typedef struct GameID_t GameID_t; +struct GameID_t +{ + u32 m_nAppID : 24; + u32 m_nType : 8; + u32 m_nModID : 32; +}; +#pragma pack(pop) + +enum +{ + k_iSteamUserCallbacks = 100, + k_iSteamUser_SteamServersConnected = 101, + k_iSteamUser_SteamConnectFailure = 102, + k_iSteamUser_SteamServersDisconnected = 103, + k_iSteamUser_EncryptedAppTicketReponse = 154, + + k_iSteamGameServerCallbacks = 200, + + k_iSteamFriendsCallbacks = 300, + k_iSteamFriends_GameOverlayActivated = 331, + k_iSteamFriends_PersonaStateChange = 304, + + k_iSteamUtilsCallbacks = 700, + k_iSteamUtils_SteamAPICallCompleted = 703, + + k_iSteamUserStatsCallbacks = 1100, + k_iSteamUserStats_UserStatsReceived = 1101, + + k_iSteamNetworkingCallbacks = 1200, + + k_iSteamNetworkingSocketsCallbacks = 1220, + k_iSteamNetworkingSockets_SteamNetConnectionStatusChangedCallback = 1221, + k_iSteamNetworkingSockets_SteamNetAuthenticationStatus = 1222, + + k_iSteamNetworkingMessagesCallbacks = 1250, + k_iSteamNetworkingUtilsCallbacks = 1280, + + k_iSteamUGCCallbacks = 3400, + k_iSteamUGC_QueryCompleted = 3401, + k_iSteamUGC_CreateItemResult = 3403, + k_iSteamUGC_SubmitItemUpdateResult = 3404, +}; + +typedef struct SteamServerConnectFailure_t SteamServerConnectFailure_t; +struct SteamServerConnectFailure_t +{ + EResult m_eResult; + bool m_bStillRetrying; +}; + +typedef struct SteamServersDisconnected_t SteamServersDisconnected_t; +struct SteamServersDisconnected_t +{ + EResult m_eResult; +}; + +/* + * ------------------------------------------------------------------------------------------------------------------ + * MAIN + * ------------------------------------------------------------------------------------------------------------------ + */ + +typedef c8 SteamErrMsg[ 1024 ]; + +typedef enum EServerMode EServerMode; +enum EServerMode +{ + eServerModeInvalid = 0, + eServerModeNoAuthentication = 1, // Don't authenticate user logins and don't list on the server list + eServerModeAuthentication = 2, // Authenticate users, list on the server list, don't run VAC on clients that connect + eServerModeAuthenticationAndSecure = 3, // Authenticate users, list on the server list and VAC protect clients +}; + +typedef enum ESteamAPIInitResult ESteamAPIInitResult; +enum ESteamAPIInitResult +{ + k_ESteamAPIInitResult_OK = 0, + k_ESteamAPIInitResult_FailedGeneric = 1, // Some other failure + k_ESteamAPIInitResult_NoSteamClient = 2, // We cannot connect to Steam, steam probably isn't running + k_ESteamAPIInitResult_VersionMismatch = 3, // Steam client appears to be out of date +}; + + +#if defined( VG_ENGINE ) +extern ESteamAPIInitResult SteamInternal_SteamAPI_Init( const char *pszInternalCheckInterfaceVersions, SteamErrMsg *pOutErrMsg ); +extern void SteamAPI_Shutdown(); +extern HSteamPipe SteamAPI_GetHSteamPipe(); +extern HSteamUser SteamAPI_GetHSteamUser(); +#else + +/* usLegacySteamPort must be 0 */ + +extern ESteamAPIInitResult SteamInternal_GameServer_Init_V2( + u32 unIP, u16 usGamePort, u16 usQueryPort, EServerMode eServerMode, const c8 *pchVersionString, + const c8 *pszInternalCheckInterfaceVersions, SteamErrMsg *pOutErrMsg ); + +typedef void ISteamGameServer; +extern ISteamGameServer *SteamAPI_SteamGameServer_v015(); +extern void SteamAPI_ISteamGameServer_LogOn( ISteamGameServer *self, const c8 *pszToken ); +extern void SteamAPI_ISteamGameServer_LogOnAnonymous( ISteamGameServer *self ); +extern void SteamAPI_ISteamGameServer_LogOff( ISteamGameServer *self ); + +extern void SteamGameServer_Shutdown(); +HSteamPipe SteamGameServer_GetHSteamPipe(); +HSteamUser SteamGameServer_GetHSteamUser(); + +enum { k_nSteamEncryptedAppTicketSymmetricKeyLen = 32 }; +extern bool SteamEncryptedAppTicket_BDecryptTicket( const u8 *rgubTicketEncrypted, u32 cubTicketEncrypted, + u8 *rgubTicketDecrypted, u32 *pcubTicketDecrypted, + const u8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], i32 cubKey ); + +extern bool SteamEncryptedAppTicket_BIsTicketForApp( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, AppId_t nAppID ); +extern u32 SteamEncryptedAppTicket_GetTicketIssueTime( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); +extern void SteamEncryptedAppTicket_GetTicketSteamID( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, CSteamID *psteamID ); +extern AppId_t SteamEncryptedAppTicket_GetTicketAppID( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); +extern bool SteamEncryptedAppTicket_BUserOwnsAppInTicket( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, AppId_t nAppID ); +extern bool SteamEncryptedAppTicket_BUserIsVacBanned( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); +extern bool SteamEncryptedAppTicket_BGetAppDefinedValue( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, u32 *pValue ); +extern const u8 *SteamEncryptedAppTicket_GetUserVariableData( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, u32 *pcubUserData ); +extern bool SteamEncryptedAppTicket_BIsTicketSigned( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, const u8 *pubRSAKey, u32 cubRSAKey ); +extern bool SteamEncryptedAppTicket_BIsLicenseBorrowed( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); +extern bool SteamEncryptedAppTicket_BIsLicenseTemporary( u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); + +#endif + +/* LOOP (PUT IT THREAD 0) + * ------------------------------------------------------------------------------------------------------------------ */ +extern void SteamAPI_ManualDispatch_Init(); +extern void SteamAPI_ManualDispatch_RunFrame( HSteamPipe hSteamPipe ); +extern bool SteamAPI_ManualDispatch_GetNextCallback( HSteamPipe hSteamPipe, CallbackMsg_t *pCallbackMsg ); +extern void SteamAPI_ManualDispatch_FreeLastCallback( HSteamPipe hSteamPipe ); +extern bool SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, + void *pCallback, i32 cubCallback, i32 iCallbackExpected, bool *pbFailed ); + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamFriends + * ------------------------------------------------------------------------------------------------------------------ + */ +#if defined( VG_ENGINE ) + +typedef void ISteamFriends; +extern ISteamFriends *SteamAPI_SteamFriends_v018(); + +typedef enum EActivateGameOverlayToWebPageMode EActivateGameOverlayToWebPageMode; +enum EActivateGameOverlayToWebPageMode +{ + k_EActivateGameOverlayToWebPageMode_Default = 0, + k_EActivateGameOverlayToWebPageMode_Modal = 1 +}; +extern void SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage( ISteamFriends *self, const c8 *pchURL, + EActivateGameOverlayToWebPageMode eMode ); + +void SteamFriends_ActivateGameOverlayToWebPage( const c8 *pchURL, EActivateGameOverlayToWebPageMode eMode ); + +typedef enum EOverlayToStoreFlag EOverlayToStoreFlag; +enum EOverlayToStoreFlag +{ + k_EOverlayToStoreFlag_None = 0, + k_EOverlayToStoreFlag_AddToCart = 1, + k_EOverlayToStoreFlag_AddToCartAndShow = 2, +}; +extern void SteamAPI_ISteamFriends_ActivateGameOverlayToStore( ISteamFriends *self, AppId_t nAppID, EOverlayToStoreFlag eFlag ); + +extern i32 SteamAPI_ISteamFriends_GetSmallFriendAvatar( ISteamFriends *self, uint64_steamid steamIDFriend ); +extern i32 SteamAPI_ISteamFriends_GetMediumFriendAvatar( ISteamFriends *self, uint64_steamid steamIDFriend ); +extern i32 SteamAPI_ISteamFriends_GetLargeFriendAvatar( ISteamFriends *self, uint64_steamid steamIDFriend ); +extern const c8 *SteamAPI_ISteamFriends_GetPersonaName( ISteamFriends *self ); + +typedef struct GameOverlayActivated_t GameOverlayActivated_t; +struct GameOverlayActivated_t +{ + bool m_bActive; +}; + +typedef struct PersonaStateChange_t PersonaStateChange_t; +struct PersonaStateChange_t +{ + u64 m_ulSteamID; // steamID of the friend who changed + int m_nChangeFlags; // what's changed +}; + +typedef enum EPersonaChange EPersonaChange; +enum EPersonaChange +{ + k_EPersonaChangeName = 0x0001, + k_EPersonaChangeStatus = 0x0002, + k_EPersonaChangeComeOnline = 0x0004, + k_EPersonaChangeGoneOffline = 0x0008, + k_EPersonaChangeGamePlayed = 0x0010, + k_EPersonaChangeGameServer = 0x0020, + k_EPersonaChangeAvatar = 0x0040, + k_EPersonaChangeJoinedSource= 0x0080, + k_EPersonaChangeLeftSource = 0x0100, + k_EPersonaChangeRelationshipChanged = 0x0200, + k_EPersonaChangeNameFirstSet = 0x0400, + k_EPersonaChangeBroadcast = 0x0800, + k_EPersonaChangeNickname = 0x1000, + k_EPersonaChangeSteamLevel = 0x2000, + k_EPersonaChangeRichPresence = 0x4000, +}; + +typedef enum EFriendFlags EFriendFlags; +enum EFriendFlags +{ + k_EFriendFlagNone = 0x00, + k_EFriendFlagBlocked = 0x01, + k_EFriendFlagFriendshipRequested = 0x02, + k_EFriendFlagImmediate = 0x04, // "regular" friend + k_EFriendFlagClanMember = 0x08, + k_EFriendFlagOnGameServer = 0x10, + // k_EFriendFlagHasPlayedWith = 0x20, // not currently used + // k_EFriendFlagFriendOfFriend = 0x40, // not currently used + k_EFriendFlagRequestingFriendship = 0x80, + k_EFriendFlagRequestingInfo = 0x100, + k_EFriendFlagIgnored = 0x200, + k_EFriendFlagIgnoredFriend = 0x400, + // k_EFriendFlagSuggested = 0x800, // not used + k_EFriendFlagChatMember = 0x1000, + k_EFriendFlagAll = 0xFFFF, +}; +extern bool SteamAPI_ISteamFriends_HasFriend( ISteamFriends *self, uint64_steamid steamIDFriend, i32 iFriendFlags ); + +#endif + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamUGC + * ------------------------------------------------------------------------------------------------------------------ + */ + +typedef void ISteamUGC; +typedef u64 PublishedFileId_t; +typedef u64 UGCQueryHandle_t; +typedef u64 UGCUpdateHandle_t; +typedef u64 UGCHandle_t; +typedef u64 PublishedFileUpdateHandle_t; + +typedef enum EItemUpdateStatus EItemUpdateStatus; +enum EItemUpdateStatus +{ + k_EItemUpdateStatusInvalid = 0, + k_EItemUpdateStatusPreparingConfig = 1, + k_EItemUpdateStatusPreparingContent = 2, + k_EItemUpdateStatusUploadingContent = 3, + k_EItemUpdateStatusUploadingPreviewFile= 4, + k_EItemUpdateStatusCommittingChanges = 5 +}; + +typedef enum EItemState EItemState; +enum EItemState +{ + k_EItemStateNone = 0, + k_EItemStateSubscribed = 1, + k_EItemStateLegacyItem = 2, + k_EItemStateInstalled = 4, + k_EItemStateNeedsUpdate = 8, + k_EItemStateDownloading = 16, + k_EItemStateDownloadPending= 32, + k_EItemStateDisabledLocally = 64, +}; + +typedef enum EWorkshopFileType EWorkshopFileType; +enum EWorkshopFileType +{ + k_EWorkshopFileTypeFirst = 0, + k_EWorkshopFileTypeCommunity = 0, + k_EWorkshopFileTypeMicrotransaction = 1, + k_EWorkshopFileTypeCollection = 2, + k_EWorkshopFileTypeArt = 3, + k_EWorkshopFileTypeVideo = 4, + k_EWorkshopFileTypeScreenshot = 5, + k_EWorkshopFileTypeGame = 6, + k_EWorkshopFileTypeSoftware = 7, + k_EWorkshopFileTypeConcept = 8, + k_EWorkshopFileTypeWebGuide = 9, + k_EWorkshopFileTypeIntegratedGuide = 10, + k_EWorkshopFileTypeMerch = 11, + k_EWorkshopFileTypeControllerBinding = 12, + k_EWorkshopFileTypeSteamworksAccessInvite = 13, + k_EWorkshopFileTypeSteamVideo = 14, + k_EWorkshopFileTypeGameManagedItem = 15, + k_EWorkshopFileTypeMax = 16 +}; + +typedef enum ERemoteStoragePublishedFileVisibility ERemoteStoragePublishedFileVisibility; +enum ERemoteStoragePublishedFileVisibility +{ + k_ERemoteStoragePublishedFileVisibilityPublic = 0, + k_ERemoteStoragePublishedFileVisibilityFriendsOnly = 1, + k_ERemoteStoragePublishedFileVisibilityPrivate = 2, + k_ERemoteStoragePublishedFileVisibilityUnlisted = 3, +}; + +typedef enum EUGCMatchingUGCType EUGCMatchingUGCType; +enum EUGCMatchingUGCType +{ + k_EUGCMatchingUGCType_Items = 0, + k_EUGCMatchingUGCType_Items_Mtx = 1, + k_EUGCMatchingUGCType_Items_ReadyToUse = 2, + k_EUGCMatchingUGCType_Collections = 3, + k_EUGCMatchingUGCType_Artwork = 4, + k_EUGCMatchingUGCType_Videos = 5, + k_EUGCMatchingUGCType_Screenshots = 6, + k_EUGCMatchingUGCType_AllGuides = 7, + k_EUGCMatchingUGCType_WebGuides = 8, + k_EUGCMatchingUGCType_IntegratedGuides = 9, + k_EUGCMatchingUGCType_UsableInGame = 10, + k_EUGCMatchingUGCType_ControllerBindings = 11, + k_EUGCMatchingUGCType_GameManagedItems = 12, + k_EUGCMatchingUGCType_All = ~0, +}; + +typedef enum EUserUGCList EUserUGCList; +enum EUserUGCList +{ + k_EUserUGCList_Published, + k_EUserUGCList_VotedOn, + k_EUserUGCList_VotedUp, + k_EUserUGCList_VotedDown, + k_EUserUGCList_WillVoteLater, + k_EUserUGCList_Favorited, + k_EUserUGCList_Subscribed, + k_EUserUGCList_UsedOrPlayed, + k_EUserUGCList_Followed, +}; + +// Sort order for user published UGC lists (defaults to creation order descending) +typedef enum EUserUGCListSortOrder EUserUGCListSortOrder; +enum EUserUGCListSortOrder +{ + k_EUserUGCListSortOrder_CreationOrderDesc, + k_EUserUGCListSortOrder_CreationOrderAsc, + k_EUserUGCListSortOrder_TitleAsc, + k_EUserUGCListSortOrder_LastUpdatedDesc, + k_EUserUGCListSortOrder_SubscriptionDateDesc, + k_EUserUGCListSortOrder_VoteScoreDesc, + k_EUserUGCListSortOrder_ForModeration, +}; + +// Combination of sorting and filtering for queries across all UGC +typedef enum EUGCQuery EUGCQuery; +enum EUGCQuery +{ + k_EUGCQuery_RankedByVote = 0, + k_EUGCQuery_RankedByPublicationDate = 1, + k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2, + k_EUGCQuery_RankedByTrend = 3, + k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4, + k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5, + k_EUGCQuery_RankedByNumTimesReported = 6, + k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate = 7, + k_EUGCQuery_NotYetRated = 8, + k_EUGCQuery_RankedByTotalVotesAsc = 9, + k_EUGCQuery_RankedByVotesUp = 10, + k_EUGCQuery_RankedByTextSearch = 11, + k_EUGCQuery_RankedByTotalUniqueSubscriptions = 12, + k_EUGCQuery_RankedByPlaytimeTrend = 13, + k_EUGCQuery_RankedByTotalPlaytime = 14, + k_EUGCQuery_RankedByAveragePlaytimeTrend = 15, + k_EUGCQuery_RankedByLifetimeAveragePlaytime = 16, + k_EUGCQuery_RankedByPlaytimeSessionsTrend = 17, + k_EUGCQuery_RankedByLifetimePlaytimeSessions = 18, + k_EUGCQuery_RankedByLastUpdatedDate = 19, +}; + +typedef struct SteamUGCDetails_t SteamUGCDetails_t; +struct SteamUGCDetails_t +{ + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; + EWorkshopFileType m_eFileType; + AppId_t m_nCreatorAppID; + AppId_t m_nConsumerAppID; + c8 m_rgchTitle[ 128+1 ]; + c8 m_rgchDescription[ 8000 ]; + u64 m_ulSteamIDOwner; + u32 m_rtimeCreated; + u32 m_rtimeUpdated; + u32 m_rtimeAddedToUserList; + ERemoteStoragePublishedFileVisibility m_eVisibility; + bool m_bBanned; + bool m_bAcceptedForUse; + bool m_bTagsTruncated; + c8 m_rgchTags[ 1024 + 1 ]; + UGCHandle_t m_hFile; + UGCHandle_t m_hPreviewFile; + c8 m_pchFileName[ 260 ]; + i32 m_nFileSize; + i32 m_nPreviewFileSize; + c8 m_rgchURL[ 256 ]; + u32 m_unVotesUp; + u32 m_unVotesDown; + f32 m_flScore; + u32 m_unNumChildren; +}; + +typedef struct CreateItemResult_t CreateItemResult_t; +struct CreateItemResult_t +{ + EResult m_eResult; + PublishedFileId_t m_nPublishedFileId; + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; +}; + +typedef struct SubmitItemUpdateResult_t SubmitItemUpdateResult_t; +struct SubmitItemUpdateResult_t +{ + EResult m_eResult; + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; + PublishedFileId_t m_nPublishedFileId; +}; + +typedef struct SteamUGCQueryCompleted_t SteamUGCQueryCompleted_t; +struct SteamUGCQueryCompleted_t +{ + UGCQueryHandle_t m_handle; + EResult m_eResult; + u32 m_unNumResultsReturned; + u32 m_unTotalMatchingResults; + bool m_bCachedData; + c8 m_rgchNextCursor[256]; +}; + +#if defined( VG_ENGINE ) +extern ISteamUGC *SteamAPI_SteamUGC_v021(); +#else +extern ISteamUGC *SteamAPI_SteamGameServerUGC_v021(); +#endif +extern SteamAPICall_t SteamAPI_ISteamUGC_CreateItem( ISteamUGC *self, AppId_t nConsumerAppId, + EWorkshopFileType eFileType ); + +extern bool SteamAPI_ISteamUGC_GetItemInstallInfo( ISteamUGC *self, PublishedFileId_t nPublishedFileID, + u64 *punSizeOnDisk, c8 *pchFolder, u32 cchFolderSize, + u32 *punTimeStamp ); + +extern u32 SteamAPI_ISteamUGC_GetItemState( ISteamUGC *self, PublishedFileId_t nPublishedFileID ); + +extern bool SteamAPI_ISteamUGC_GetQueryUGCMetadata( ISteamUGC *self, UGCQueryHandle_t handle, u32 index, + c8 *pchMetadata, u32 cchMetadatasize ); + +extern bool SteamAPI_ISteamUGC_GetQueryUGCResult( ISteamUGC *self, UGCQueryHandle_t handle, u32 index, + SteamUGCDetails_t *pDetails ); + +extern u32 SteamAPI_ISteamUGC_GetSubscribedItems( ISteamUGC *self, PublishedFileId_t *pvecPublishedFileID, + u32 cMaxEntries, bool bIncludeLocallyDisabled ); + +extern bool SteamAPI_ISteamUGC_ReleaseQueryUGCRequest( ISteamUGC *self, UGCQueryHandle_t handle ); +extern SteamAPICall_t SteamAPI_ISteamUGC_SendQueryUGCRequest( ISteamUGC *self, UGCQueryHandle_t handle ); +extern bool SteamAPI_ISteamUGC_SetItemContent( ISteamUGC *self, UGCUpdateHandle_t handle, const c8 *pszContentFolder ); +extern bool SteamAPI_ISteamUGC_SetItemDescription( ISteamUGC *self, UGCUpdateHandle_t handle, const c8 *pchDescription ); +extern bool SteamAPI_ISteamUGC_SetItemMetadata( ISteamUGC *self, UGCUpdateHandle_t handle, const c8 *pchMetaData ); +extern bool SteamAPI_ISteamUGC_SetItemPreview( ISteamUGC *self, UGCUpdateHandle_t handle, const c8 *pszPreviewFile ); +extern bool SteamAPI_ISteamUGC_SetItemTitle( ISteamUGC *self, UGCUpdateHandle_t handle, const c8 *pchTitle ); + +extern bool SteamAPI_ISteamUGC_SetItemVisibility( ISteamUGC *self, UGCUpdateHandle_t handle, + ERemoteStoragePublishedFileVisibility eVisibility ); + +extern bool SteamAPI_ISteamUGC_SetReturnMetadata( ISteamUGC *self, UGCQueryHandle_t handle, bool bReturnMetadata ); + +extern UGCUpdateHandle_t SteamAPI_ISteamUGC_StartItemUpdate( ISteamUGC *self, AppId_t nConsumerAppId, + PublishedFileId_t nPublishedFileID ); + +extern SteamAPICall_t SteamAPI_ISteamUGC_SubmitItemUpdate( ISteamUGC *self, UGCUpdateHandle_t handle, + const c8* pchChangeNote ); + +extern UGCQueryHandle_t SteamAPI_ISteamUGC_CreateQueryUserUGCRequest( + ISteamUGC *self, AccountID_t unAccountID, EUserUGCList eListType, + EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, + AppId_t nCreatorAppID, AppId_t nConsumerAppID, u32 unPage ); +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamNetworkingSockets + * ------------------------------------------------------------------------------------------------------------------ + */ + +typedef void ISteamNetworkingSockets; +typedef u32 HSteamNetConnection; +typedef u32 HSteamListenSocket; +typedef u32 HSteamNetPollGroup; +typedef i64 SteamNetworkingMicroseconds; + +#pragma pack(push,1) +typedef struct SteamNetworkingIPAddr SteamNetworkingIPAddr; +struct SteamNetworkingIPAddr +{ + union + { + u8 m_ipv6[ 16 ]; + + /* RFC4038, section 4.2 */ + struct IPv4MappedAddress + { + u64 m_8zeros; + u16 m_0000; + u16 m_ffff; + u8 m_ip[ 4 ]; /* NOTE: As bytes, i.e. network byte order */ + } + m_ipv4; + }; + + u16 m_port; // Host byte order +}; + +typedef enum ESteamNetworkingIdentityType ESteamNetworkingIdentityType; +enum ESteamNetworkingIdentityType +{ + k_ESteamNetworkingIdentityType_Invalid = 0, + k_ESteamNetworkingIdentityType_SteamID = 16, // 64-bit CSteamID + k_ESteamNetworkingIdentityType_IPAddress = 1, + k_ESteamNetworkingIdentityType_GenericString = 2, + k_ESteamNetworkingIdentityType_GenericBytes = 3, + k_ESteamNetworkingIdentityType_UnknownType = 4, + k_ESteamNetworkingIdentityType__Force32bit = 0x7fffffff, +}; + +typedef struct SteamNetworkingIdentity SteamNetworkingIdentity; +struct SteamNetworkingIdentity +{ + ESteamNetworkingIdentityType m_eType; + + i32 m_cbSize; + union + { + u64 m_steamID64; + c8 m_szGenericString[ 32 ]; + u8 m_genericBytes[ 32 ]; + c8 m_szUnknownRawString[ 128 ]; + SteamNetworkingIPAddr m_ip; + u32 m_reserved[ 32 ]; + }; +}; +#pragma pack(pop) + +typedef enum ESteamNetworkingConfigValue ESteamNetworkingConfigValue; +enum ESteamNetworkingConfigValue +{ + k_ESteamNetworkingConfig_Invalid = 0, + k_ESteamNetworkingConfig_TimeoutInitial = 24, + k_ESteamNetworkingConfig_TimeoutConnected = 25, + k_ESteamNetworkingConfig_SendBufferSize = 9, + k_ESteamNetworkingConfig_ConnectionUserData = 40, + k_ESteamNetworkingConfig_SendRateMin = 10, + k_ESteamNetworkingConfig_SendRateMax = 11, + k_ESteamNetworkingConfig_NagleTime = 12, + k_ESteamNetworkingConfig_IP_AllowWithoutAuth = 23, + k_ESteamNetworkingConfig_MTU_PacketSize = 32, + k_ESteamNetworkingConfig_MTU_DataSize = 33, + k_ESteamNetworkingConfig_Unencrypted = 34, + k_ESteamNetworkingConfig_LocalVirtualPort = 38, + k_ESteamNetworkingConfig_DualWifi_Enable = 39, + k_ESteamNetworkingConfig_EnableDiagnosticsUI = 46, + k_ESteamNetworkingConfig_FakePacketLoss_Send = 2, + k_ESteamNetworkingConfig_FakePacketLoss_Recv = 3, + k_ESteamNetworkingConfig_FakePacketLag_Send = 4, + k_ESteamNetworkingConfig_FakePacketLag_Recv = 5, + k_ESteamNetworkingConfig_FakePacketReorder_Send = 6, + k_ESteamNetworkingConfig_FakePacketReorder_Recv = 7, + k_ESteamNetworkingConfig_FakePacketReorder_Time = 8, + k_ESteamNetworkingConfig_FakePacketDup_Send = 26, + k_ESteamNetworkingConfig_FakePacketDup_Recv = 27, + k_ESteamNetworkingConfig_FakePacketDup_TimeMax = 28, + k_ESteamNetworkingConfig_PacketTraceMaxBytes = 41, + k_ESteamNetworkingConfig_FakeRateLimit_Send_Rate = 42, + k_ESteamNetworkingConfig_FakeRateLimit_Send_Burst = 43, + k_ESteamNetworkingConfig_FakeRateLimit_Recv_Rate = 44, + k_ESteamNetworkingConfig_FakeRateLimit_Recv_Burst = 45, + k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged = 201, + k_ESteamNetworkingConfig_Callback_AuthStatusChanged = 202, + k_ESteamNetworkingConfig_Callback_RelayNetworkStatusChanged = 203, + k_ESteamNetworkingConfig_Callback_MessagesSessionRequest = 204, + k_ESteamNetworkingConfig_Callback_MessagesSessionFailed = 205, + k_ESteamNetworkingConfig_Callback_CreateConnectionSignaling = 206, + k_ESteamNetworkingConfig_Callback_FakeIPResult = 207, + k_ESteamNetworkingConfig_P2P_STUN_ServerList = 103, + k_ESteamNetworkingConfig_P2P_Transport_ICE_Enable = 104, + k_ESteamNetworkingConfig_P2P_Transport_ICE_Penalty = 105, + k_ESteamNetworkingConfig_P2P_Transport_SDR_Penalty = 106, + k_ESteamNetworkingConfig_SDRClient_ConsecutitivePingTimeoutsFailInitial = 19, + k_ESteamNetworkingConfig_SDRClient_ConsecutitivePingTimeoutsFail = 20, + k_ESteamNetworkingConfig_SDRClient_MinPingsBeforePingAccurate = 21, + k_ESteamNetworkingConfig_SDRClient_SingleSocket = 22, + k_ESteamNetworkingConfig_SDRClient_ForceRelayCluster = 29, + k_ESteamNetworkingConfig_SDRClient_DebugTicketAddress = 30, + k_ESteamNetworkingConfig_SDRClient_ForceProxyAddr = 31, + k_ESteamNetworkingConfig_SDRClient_FakeClusterPing = 36, + k_ESteamNetworkingConfig_LogLevel_AckRTT = 13, // [connection int32] RTT calculations for inline pings and replies + k_ESteamNetworkingConfig_LogLevel_PacketDecode = 14, // [connection int32] log SNP packets send/recv + k_ESteamNetworkingConfig_LogLevel_Message = 15, // [connection int32] log each message send/recv + k_ESteamNetworkingConfig_LogLevel_PacketGaps = 16, // [connection int32] dropped packets + k_ESteamNetworkingConfig_LogLevel_P2PRendezvous = 17, // [connection int32] P2P rendezvous messages + k_ESteamNetworkingConfig_LogLevel_SDRRelayPings = 18, // [global int32] Ping relays + k_ESteamNetworkingConfig_DELETED_EnumerateDevVars = 35, + k_ESteamNetworkingConfigValue__Force32Bit = 0x7fffffff +}; + +typedef enum ESteamNetworkingConfigDataType ESteamNetworkingConfigDataType; +enum ESteamNetworkingConfigDataType +{ + k_ESteamNetworkingConfig_Int32 = 1, + k_ESteamNetworkingConfig_Int64 = 2, + k_ESteamNetworkingConfig_Float = 3, + k_ESteamNetworkingConfig_String = 4, + k_ESteamNetworkingConfig_Ptr = 5, + k_ESteamNetworkingConfigDataType__Force32Bit = 0x7fffffff +}; + +#pragma pack(push,8) +typedef struct SteamNetworkingConfigValue_t SteamNetworkingConfigValue_t; +struct SteamNetworkingConfigValue_t +{ + ESteamNetworkingConfigValue m_eValue; + ESteamNetworkingConfigDataType m_eDataType; + + /// Option value + union + { + i32 m_int32; + i64 m_int64; + f32 m_float; + const c8 *m_string; // Points to your '\0'-terminated buffer + void *m_ptr; + } + m_val; +}; + +typedef struct SteamNetworkingMessage_t SteamNetworkingMessage_t; +struct SteamNetworkingMessage_t +{ + void *m_pData; + i32 m_cbSize; + HSteamNetConnection m_conn; + SteamNetworkingIdentity m_identityPeer; + i64 m_nConnUserData; + SteamNetworkingMicroseconds m_usecTimeReceived; + i64 m_nMessageNumber; + void (*m_pfnFreeData)( SteamNetworkingMessage_t *pMsg ); + void (*m_pfnRelease)( SteamNetworkingMessage_t *pMsg ); + i32 m_nChannel; + i32 m_nFlags; + i64 m_nUserData; + u16 m_idxLane; + u16 _pad1__; +}; +#pragma pack(pop) + +#if defined( VG_ENGINE ) +extern ISteamNetworkingSockets *SteamAPI_SteamNetworkingSockets_SteamAPI_v012(); +#else +extern ISteamNetworkingSockets *SteamAPI_SteamGameServerNetworkingSockets_SteamAPI_v012(); +#endif + +extern EResult SteamAPI_ISteamNetworkingSockets_AcceptConnection( ISteamNetworkingSockets *self, HSteamNetConnection hConn ); +extern bool SteamAPI_ISteamNetworkingSockets_CloseConnection( ISteamNetworkingSockets *self, HSteamNetConnection hPeer, + i32 nReason, const c8 *pszDebug, bool bEnableLinger ); + +extern bool SteamAPI_ISteamNetworkingSockets_CloseListenSocket( ISteamNetworkingSockets *self, HSteamListenSocket hSocket ); +extern EResult SteamAPI_ISteamNetworkingSockets_ConfigureConnectionLanes( + ISteamNetworkingSockets *self, HSteamNetConnection hConn, i32 nNumLanes, const i32 *pLanePriorities, + const u16 *pLaneWeights ); + +extern HSteamNetConnection SteamAPI_ISteamNetworkingSockets_ConnectByIPAddress( + ISteamNetworkingSockets *self, + SteamNetworkingIPAddr *address, i32 nOptions, + SteamNetworkingConfigValue_t *pOptions ); + +extern HSteamListenSocket SteamAPI_ISteamNetworkingSockets_CreateListenSocketIP( + ISteamNetworkingSockets *self, SteamNetworkingIPAddr *localAddress, + i32 nOptions, const SteamNetworkingConfigValue_t *pOptions ); + +extern HSteamNetPollGroup SteamAPI_ISteamNetworkingSockets_CreatePollGroup( ISteamNetworkingSockets *self ); +extern bool SteamAPI_ISteamNetworkingSockets_DestroyPollGroup( + ISteamNetworkingSockets *self, HSteamNetPollGroup hPollGroup ); + +extern i64 SteamAPI_ISteamNetworkingSockets_GetConnectionUserData( + ISteamNetworkingSockets *self, HSteamNetConnection hPeer ); + +extern i32 SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection( + ISteamNetworkingSockets *self, HSteamNetConnection hConn, + SteamNetworkingMessage_t **ppOutMessages, i32 nMaxMessages ); +extern i32 SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnPollGroup( + ISteamNetworkingSockets *self, HSteamNetPollGroup hPollGroup, + SteamNetworkingMessage_t **ppOutMessages, i32 nMaxMessages ); + +enum +{ + k_nSteamNetworkingSend_Unreliable = 0, + k_nSteamNetworkingSend_NoNagle = 1, + k_nSteamNetworkingSend_UnreliableNoNagle = k_nSteamNetworkingSend_Unreliable|k_nSteamNetworkingSend_NoNagle, + k_nSteamNetworkingSend_NoDelay = 4, + k_nSteamNetworkingSend_UnreliableNoDelay = k_nSteamNetworkingSend_Unreliable|k_nSteamNetworkingSend_NoDelay| + k_nSteamNetworkingSend_NoNagle, + k_nSteamNetworkingSend_Reliable = 8, + k_nSteamNetworkingSend_ReliableNoNagle = k_nSteamNetworkingSend_Reliable|k_nSteamNetworkingSend_NoNagle, + k_nSteamNetworkingSend_UseCurrentThread = 16, + k_nSteamNetworkingSend_AutoRestartBrokenSession = 32 +}; + +extern void SteamAPI_ISteamNetworkingSockets_SendMessages( + ISteamNetworkingSockets *self, i32 nMessages, + SteamNetworkingMessage_t *const *pMessages, i64 *pOutMessageNumberOrResult ); + +extern EResult SteamAPI_ISteamNetworkingSockets_SendMessageToConnection( + ISteamNetworkingSockets *self, HSteamNetConnection hConn, const void *pData, + u32 cbData, i32 nSendFlags, i64 *pOutMessageNumber ); + +extern bool SteamAPI_ISteamNetworkingSockets_SetConnectionPollGroup( + ISteamNetworkingSockets *self, HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup ); +extern bool SteamAPI_ISteamNetworkingSockets_SetConnectionUserData( + ISteamNetworkingSockets *self, HSteamNetConnection hPeer, i64 nUserData ); + +typedef enum ESteamNetworkingConnectionState ESteamNetworkingConnectionState; +enum ESteamNetworkingConnectionState +{ + k_ESteamNetworkingConnectionState_None = 0, + k_ESteamNetworkingConnectionState_Connecting = 1, + k_ESteamNetworkingConnectionState_FindingRoute = 2, + k_ESteamNetworkingConnectionState_Connected = 3, + k_ESteamNetworkingConnectionState_ClosedByPeer = 4, + k_ESteamNetworkingConnectionState_ProblemDetectedLocally = 5, + k_ESteamNetworkingConnectionState_FinWait = -1, + k_ESteamNetworkingConnectionState_Linger = -2, + k_ESteamNetworkingConnectionState_Dead = -3, + k_ESteamNetworkingConnectionState__Force32Bit = 0x7fffffff +}; + +/// Enumerate various causes of connection termination. These are designed to work similar +/// to HTTP error codes: the numeric range gives you a rough classification as to the source +/// of the problem. +typedef enum ESteamNetConnectionEnd ESteamNetConnectionEnd; +enum ESteamNetConnectionEnd +{ + // Invalid/sentinel value + k_ESteamNetConnectionEnd_Invalid = 0, + k_ESteamNetConnectionEnd_App_Min = 1000, + k_ESteamNetConnectionEnd_App_Generic = k_ESteamNetConnectionEnd_App_Min, + k_ESteamNetConnectionEnd_App_Max = 1999, + k_ESteamNetConnectionEnd_AppException_Min = 2000, + k_ESteamNetConnectionEnd_AppException_Generic = k_ESteamNetConnectionEnd_AppException_Min, + k_ESteamNetConnectionEnd_AppException_Max = 2999, + k_ESteamNetConnectionEnd_Local_Min = 3000, + k_ESteamNetConnectionEnd_Local_OfflineMode = 3001, + k_ESteamNetConnectionEnd_Local_ManyRelayConnectivity = 3002, + k_ESteamNetConnectionEnd_Local_HostedServerPrimaryRelay = 3003, + k_ESteamNetConnectionEnd_Local_NetworkConfig = 3004, + k_ESteamNetConnectionEnd_Local_Rights = 3005, + k_ESteamNetConnectionEnd_Local_P2P_ICE_NoPublicAddresses = 3006, + k_ESteamNetConnectionEnd_Local_Max = 3999, + k_ESteamNetConnectionEnd_Remote_Min = 4000, + k_ESteamNetConnectionEnd_Remote_Timeout = 4001, + k_ESteamNetConnectionEnd_Remote_BadCrypt = 4002, + k_ESteamNetConnectionEnd_Remote_BadCert = 4003, + k_ESteamNetConnectionEnd_Remote_BadProtocolVersion = 4006, + k_ESteamNetConnectionEnd_Remote_P2P_ICE_NoPublicAddresses = 4007, + k_ESteamNetConnectionEnd_Remote_Max = 4999, + k_ESteamNetConnectionEnd_Misc_Min = 5000, + k_ESteamNetConnectionEnd_Misc_Generic = 5001, + k_ESteamNetConnectionEnd_Misc_InternalError = 5002, + k_ESteamNetConnectionEnd_Misc_Timeout = 5003, + k_ESteamNetConnectionEnd_Misc_SteamConnectivity = 5005, + k_ESteamNetConnectionEnd_Misc_NoRelaySessionsToClient = 5006, + k_ESteamNetConnectionEnd_Misc_P2P_Rendezvous = 5008, + k_ESteamNetConnectionEnd_Misc_P2P_NAT_Firewall = 5009, + k_ESteamNetConnectionEnd_Misc_PeerSentNoConnection = 5010, + k_ESteamNetConnectionEnd_Misc_Max = 5999, + k_ESteamNetConnectionEnd__Force32Bit = 0x7fffffff +}; + +typedef enum ESteamNetworkingAvailability ESteamNetworkingAvailability; +enum ESteamNetworkingAvailability +{ + k_ESteamNetworkingAvailability_CannotTry = -102, + k_ESteamNetworkingAvailability_Failed = -101, + k_ESteamNetworkingAvailability_Previously = -100, + k_ESteamNetworkingAvailability_Retrying = -10, + k_ESteamNetworkingAvailability_NeverTried = 1, + k_ESteamNetworkingAvailability_Waiting = 2, + k_ESteamNetworkingAvailability_Attempting = 3, + k_ESteamNetworkingAvailability_Current = 100, + k_ESteamNetworkingAvailability_Unknown = 0, + k_ESteamNetworkingAvailability__Force32bit = 0x7fffffff, +}; + +typedef struct SteamNetConnectionInfo_t SteamNetConnectionInfo_t; +struct SteamNetConnectionInfo_t +{ + SteamNetworkingIdentity m_identityRemote; + i64 m_nUserData; + HSteamListenSocket m_hListenSocket; + SteamNetworkingIPAddr m_addrRemote; + u16 m__pad1; + SteamNetworkingPOPID m_idPOPRemote; + SteamNetworkingPOPID m_idPOPRelay; + ESteamNetworkingConnectionState m_eState; + i32 m_eEndReason; + c8 m_szEndDebug[ 128 ]; + c8 m_szConnectionDescription[ 128 ]; + i32 m_nFlags; + u32 reserved[63]; +}; + +typedef struct SteamNetConnectionStatusChangedCallback_t SteamNetConnectionStatusChangedCallback_t; +struct SteamNetConnectionStatusChangedCallback_t +{ + HSteamNetConnection m_hConn; + SteamNetConnectionInfo_t m_info; + ESteamNetworkingConnectionState m_eOldState; +}; + +typedef struct SteamNetAuthenticationStatus_t SteamNetAuthenticationStatus_t; +struct SteamNetAuthenticationStatus_t +{ + ESteamNetworkingAvailability m_eAvail; + c8 m_debugMsg[ 256 ]; +}; + + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamNetworkingUtils + * ------------------------------------------------------------------------------------------------------------------ + */ + +typedef void ISteamNetworkingUtils; +extern ISteamNetworkingUtils *SteamAPI_SteamNetworkingUtils_SteamAPI_v004(); +extern SteamNetworkingMessage_t *SteamAPI_ISteamNetworkingUtils_AllocateMessage( + ISteamNetworkingUtils *self, i32 cbAllocateBuffer ); + + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamUser + * ------------------------------------------------------------------------------------------------------------------ + */ +#if defined( VG_ENGINE ) +typedef void ISteamUser; +extern ISteamUser *SteamAPI_SteamUser_v023(); +extern bool SteamAPI_ISteamUser_GetEncryptedAppTicket( ISteamUser *self, void *pTicket, i32 cbMaxTicket, u32 *pcbTicket ); +extern uint64_steamid SteamAPI_ISteamUser_GetSteamID( ISteamUser *self ); +extern SteamAPICall_t SteamAPI_ISteamUser_RequestEncryptedAppTicket( ISteamUser *self, void *pDataToInclude, i32 cbDataToInclude ); + +typedef struct EncryptedAppTicketResponse_t EncryptedAppTicketResponse_t; +struct EncryptedAppTicketResponse_t +{ + EResult m_eResult; +}; + +#endif + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamUserStats + * ------------------------------------------------------------------------------------------------------------------ + */ + +#if defined( VG_ENGINE ) +typedef void ISteamUserStats; +extern ISteamUserStats *SteamAPI_SteamUserStats_v013(); +extern bool SteamAPI_ISteamUserStats_GetAchievement( ISteamUserStats *self, const c8 *pchName, bool *pbAchieved ); +extern bool SteamAPI_ISteamUserStats_SetAchievement( ISteamUserStats *self, const c8 *pchName ); +extern bool SteamAPI_ISteamUserStats_ClearAchievement( ISteamUserStats *self, const c8 *pchName ); +extern SteamAPICall_t SteamAPI_ISteamUserStats_RequestUserStats( ISteamUserStats *self, uint64_steamid steamIDUser ); +extern bool SteamAPI_ISteamUserStats_StoreStats( ISteamUserStats *self ); + +typedef struct UserStatsReceived_t UserStatsReceived_t; +struct UserStatsReceived_t +{ + u64 m_nGameID; + EResult m_eResult; + CSteamID m_steamIDUser; +}; +#endif + +/* + * ------------------------------------------------------------------------------------------------------------------ + * ISteamUtils + * ------------------------------------------------------------------------------------------------------------------ + */ +typedef void ISteamUtils; +#if defined( VG_ENGINE ) +extern ISteamUtils *SteamAPI_SteamUtils_v010(); +#else +extern ISteamUtils *SteamAPI_SteamGameServerUtils_v010(); +#endif + +typedef void (*SteamAPIWarningMessageHook_t)(i32, const c8 *); +extern bool SteamAPI_ISteamUtils_GetImageSize( ISteamUtils *self, i32 iImage, u32 *pnWidth, u32 *pnHeight ); +extern bool SteamAPI_ISteamUtils_GetImageRGBA( ISteamUtils *self, i32 iImage, u8 *pubDest, i32 nDestBufferSize ); +extern void SteamAPI_ISteamUtils_SetWarningMessageHook( ISteamUtils *self, SteamAPIWarningMessageHook_t pFunction ); + +typedef enum ESteamAPICallFailure ESteamAPICallFailure; +enum ESteamAPICallFailure +{ + k_ESteamAPICallFailureNone = -1, + k_ESteamAPICallFailureSteamGone = 0, + k_ESteamAPICallFailureNetworkFailure = 1, + k_ESteamAPICallFailureInvalidHandle = 2, + k_ESteamAPICallFailureMismatchedCallback = 3, +}; +extern ESteamAPICallFailure SteamAPI_ISteamUtils_GetAPICallFailureReason( ISteamUtils *self, SteamAPICall_t hSteamAPICall ); + +extern void SteamAPI_SteamNetworkingIPAddr_Clear( SteamNetworkingIPAddr *self ); +extern bool SteamAPI_SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *self, const c8 *pszStr ); +extern void SteamAPI_SteamNetworkingMessage_t_Release( SteamNetworkingMessage_t *self ); + +#pragma pack( pop ) + + +/* + * ------------------------------------------------------------------------------------------------------------------ + * VG STEAM API + * ------------------------------------------------------------------------------------------------------------------ + */ + +typedef struct vg_steam_api_call vg_steam_api_call; +struct vg_steam_api +{ + bool disabled, demo_mode; + void (*cb_connection_changed)( SteamNetConnectionStatusChangedCallback_t *info ); + + HSteamPipe hPipe; + ISteamNetworkingSockets *pSteamNetworkingSockets; + ISteamUtils *pSteamUtils; + ISteamUGC *pSteamUGC; + ISteamNetworkingUtils *pSteamNetworkingUtils; + +#if defined( VG_ENGINE ) + void (*cb_persona_changed)( PersonaStateChange_t *info ); + + ISteamUtils *pSteamUser; + ISteamFriends *pSteamFriends; + ISteamUserStats *pSteamUserStats; + + c8 username_at_startup[ 128 ]; +#endif + +#if defined( VG_SERVER ) + ISteamGameServer *pSteamGameServer; + bool is_connected; +#endif + + struct vg_steam_api_call + { + SteamAPICall_t id; + void *userdata; + void( *cb )( void *result, void *userdata ); + } + api_calls[ 32 ]; + u32 api_call_count; + + u8 app_symmetric_key[ 1024 ]; + u32 app_key_length; +} +extern _steam_api; + +#if defined( VG_SERVER ) +bool vg_steam_init( u32 unIP, u16 usGamePort, u16 usQueryPort, EServerMode eServerMode, const c8 *pchVersionString, + const c8 *appid_str ); +#else +bool vg_steam_init(void); +#endif +void vg_steam_frame(void); +void vg_steam_shutdown(void); + +vg_steam_api_call *vg_alloc_async_steam_api_call(void); +void vg_steam_set_achievement( const c8 *name, bool yes ); diff --git a/vg_steam_api.h b/vg_steam_api.h deleted file mode 100644 index 2680b5b..0000000 --- a/vg_steam_api.h +++ /dev/null @@ -1,456 +0,0 @@ -#pragma once -#include "vg_platform.h" - -#if defined(__linux__) || defined(__APPLE__) -/* - * The 32-bit version of gcc has the alignment requirement for u64 and double - * set to 4 meaning that even with #pragma pack(8) these types will only be - * four-byte aligned. The 64-bit version of gcc has the alignment requirement - * for these types set to 8 meaning that unless we use #pragma pack(4) our - * structures will get bigger. The 64-bit structure packing has to match the - * 32-bit structure packing for each platform. - */ - #define VALVE_CALLBACK_PACK_SMALL -; - #pragma pack( push, 4 ) -#else - #define VALVE_CALLBACK_PACK_LARGE - #pragma pack( push, 8 ) -#endif - -typedef i32 HSteamPipe; -typedef i32 HSteamUser; - -typedef int E_iCallBack_t; - -typedef u64 u64_steamid; -typedef u64 SteamAPICall_t; - -typedef u32 AppId_t; -enum { k_uAppIdInvalid = 0x0 }; - -typedef u32 DepotId_t; -enum { k_uDepotIdInvalid = 0x0 }; - -typedef u32 RTime32; -typedef u32 AccountID_t; -typedef i8 steamapi_bool; - -enum { k_iSteamUserCallbacks = 100 }; -enum { k_iSteamGameServerCallbacks = 200 }; -enum { k_iSteamFriendsCallbacks = 300 }; -enum { k_iSteamBillingCallbacks = 400 }; -enum { k_iSteamMatchmakingCallbacks = 500 }; -enum { k_iSteamContentServerCallbacks = 600 }; -enum { k_iSteamUtilsCallbacks = 700 }; -enum { k_iClientFriendsCallbacks = 800 }; -enum { k_iClientUserCallbacks = 900 }; -enum { k_iSteamAppsCallbacks = 1000 }; -enum { k_iSteamUserStatsCallbacks = 1100 }; -enum { k_iSteamNetworkingCallbacks = 1200 }; -enum { k_iSteamNetworkingSocketsCallbacks = 1220 }; -enum { k_iSteamNetworkingMessagesCallbacks = 1250 }; -enum { k_iSteamNetworkingUtilsCallbacks = 1280 }; -enum { k_iSteamRemoteStorageCallbacks = 1300 }; -enum { k_iClientDepotBuilderCallbacks = 1400 }; -enum { k_iSteamGameServerItemsCallbacks = 1500 }; -enum { k_iClientUtilsCallbacks = 1600 }; -enum { k_iSteamGameCoordinatorCallbacks = 1700 }; -enum { k_iSteamGameServerStatsCallbacks = 1800 }; -enum { k_iSteam2AsyncCallbacks = 1900 }; -enum { k_iSteamGameStatsCallbacks = 2000 }; -enum { k_iClientHTTPCallbacks = 2100 }; -enum { k_iClientScreenshotsCallbacks = 2200 }; -enum { k_iSteamScreenshotsCallbacks = 2300 }; -enum { k_iClientAudioCallbacks = 2400 }; -enum { k_iClientUnifiedMessagesCallbacks = 2500 }; -enum { k_iSteamStreamLauncherCallbacks = 2600 }; -enum { k_iClientControllerCallbacks = 2700 }; -enum { k_iSteamControllerCallbacks = 2800 }; -enum { k_iClientParentalSettingsCallbacks = 2900 }; -enum { k_iClientDeviceAuthCallbacks = 3000 }; -enum { k_iClientNetworkDeviceManagerCallbacks = 3100 }; -enum { k_iClientMusicCallbacks = 3200 }; -enum { k_iClientRemoteClientManagerCallbacks = 3300 }; -enum { k_iClientUGCCallbacks = 3400 }; -enum { k_iSteamUGCCallbacks = 3400 }; -enum { k_iSteamStreamClientCallbacks = 3500 }; -enum { k_IClientProductBuilderCallbacks = 3600 }; -enum { k_iClientShortcutsCallbacks = 3700 }; -enum { k_iClientRemoteControlManagerCallbacks = 3800 }; -enum { k_iSteamAppListCallbacks = 3900 }; -enum { k_iSteamMusicCallbacks = 4000 }; -enum { k_iSteamMusicRemoteCallbacks = 4100 }; -enum { k_iClientVRCallbacks = 4200 }; -enum { k_iClientGameNotificationCallbacks = 4300 }; -enum { k_iSteamGameNotificationCallbacks = 4400 }; -enum { k_iSteamHTMLSurfaceCallbacks = 4500 }; -enum { k_iClientVideoCallbacks = 4600 }; -enum { k_iClientInventoryCallbacks = 4700 }; -enum { k_iClientBluetoothManagerCallbacks = 4800 }; -enum { k_iClientSharedConnectionCallbacks = 4900 }; -enum { k_ISteamParentalSettingsCallbacks = 5000 }; -enum { k_iClientShaderCallbacks = 5100 }; -enum { k_iSteamGameSearchCallbacks = 5200 }; -enum { k_iSteamPartiesCallbacks = 5300 }; -enum { k_iClientPartiesCallbacks = 5400 }; -enum { k_iSteamSTARCallbacks = 5500 }; -enum { k_iClientSTARCallbacks = 5600 }; -enum { k_iSteamRemotePlayCallbacks = 5700 }; -enum { k_iClientCompatCallbacks = 5800 }; -enum { k_iSteamChatCallbacks = 5900 }; - -// General result codes -typedef enum EResult -{ - k_EResultNone = 0, // no result - k_EResultOK = 1, // success - k_EResultFail = 2, // generic failure - k_EResultNoConnection = 3, // no/failed network connection -// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed - k_EResultInvalidPassword = 5, // password/ticket is invalid - k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere - k_EResultInvalidProtocolVer = 7, // protocol version is incorrect - k_EResultInvalidParam = 8, // a parameter is incorrect - k_EResultFileNotFound = 9, // file was not found - k_EResultBusy = 10, // called method busy - action not taken - k_EResultInvalidState = 11, // called object was in an invalid state - k_EResultInvalidName = 12, // name is invalid - k_EResultInvalidEmail = 13, // email is invalid - k_EResultDuplicateName = 14, // name is not unique - k_EResultAccessDenied = 15, // access is denied - k_EResultTimeout = 16, // operation timed out - k_EResultBanned = 17, // VAC2 banned - k_EResultAccountNotFound = 18, // account not found - k_EResultInvalidSteamID = 19, // steamID is invalid - k_EResultServiceUnavailable = 20,// The requested service is currently - // unavailable - k_EResultNotLoggedOn = 21, // The user is not logged on - k_EResultPending = 22, // Request is pending (may be in process, or - // waiting on third party) - k_EResultEncryptionFailure = 23, // Encryption or Decryption failed - k_EResultInsufficientPrivilege = 24,// Insufficient privilege - k_EResultLimitExceeded = 25, // Too much of a good thing - k_EResultRevoked = 26, // Access has been revoked (used for revoked - // guest passes) - k_EResultExpired = 27, // License/Guest pass the user is trying to - // access is expired - k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by - // account, cannot be acked again - k_EResultDuplicateRequest = 29, // The request is a duplicate and the action - // has already occurred in the past, ignored - // this time - k_EResultAlreadyOwned = 30, // All the games in this guest pass - // redemption request are already owned by - // the user - k_EResultIPNotFound = 31, // IP address not found - k_EResultPersistFailed = 32, // failed to write change to the data store - k_EResultLockingFailed = 33, // failed to acquire access lock for this - // operation - k_EResultLogonSessionReplaced = 34, - k_EResultConnectFailed = 35, - k_EResultHandshakeFailed = 36, - k_EResultIOFailure = 37, - k_EResultRemoteDisconnect = 38, - k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart - // requested - k_EResultBlocked = 40, // a user didn't allow it - k_EResultIgnored = 41, // target is ignoring sender - k_EResultNoMatch = 42, // nothing matching the request found - k_EResultAccountDisabled = 43, - k_EResultServiceReadOnly = 44, // this service is not accepting content - // changes right now - k_EResultAccountNotFeatured = 45, // account doesn't have value, so this - // feature isn't available - k_EResultAdministratorOK = 46, // allowed to take this action, but only - // because requester is admin - k_EResultContentVersion = 47, // A Version mismatch in content - // transmitted within the Steam protocol. - k_EResultTryAnotherCM = 48, // The current CM can't service the user - // making a request, user should try - // another. - k_EResultPasswordRequiredToKickSession = 49, // You are already logged in - // elsewhere, this cached credential - // login has failed. - k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in - // elsewhere, you must wait - k_EResultSuspended = 51, // Long running operation (content download) - // suspended/paused - k_EResultCancelled = 52, // Operation canceled (typically by user: - // content download) - k_EResultDataCorruption = 53, // Operation canceled because data is ill - // formed or unrecoverable - k_EResultDiskFull = 54, // Operation canceled - not enough disk space. - k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed - k_EResultPasswordUnset = 56, // Password could not be verified as it's - // unset server side - k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) - // is not linked to a Steam account - k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid - k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, - // Facebook...) is already linked to some other account, - // must explicitly request to replace/delete the link first - k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict - // between the local and remote files - k_EResultIllegalPassword = 61, // The requested new password is not legal - k_EResultSameAsPreviousValue = 62,// new value is the same as the old one ( - // secret question and answer ) - k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor - // authentication failure - k_EResultCannotUseOldPassword = 64, // The requested new password is not - // legal - k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code - // invalid - k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd - // factor auth failure - and no mail - // has been sent - k_EResultHardwareNotCapableOfIPT = 67, - k_EResultIPTInitError = 68, - k_EResultParentalControlRestricted = 69,// operation failed due to parental - // control restrictions for current - // user - k_EResultFacebookQueryError = 70, // Facebook query returned an error - k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth - // code expired - k_EResultIPLoginRestrictionFailed = 72, - k_EResultAccountLockedDown = 73, - k_EResultAccountLogonDeniedVerifiedEmailRequired = 74, - k_EResultNoMatchingURL = 75, - k_EResultBadResponse = 76, // parse failure, missing field, etc. - k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action - // until they re-enter their password - k_EResultValueOutOfRange = 78, // the value entered is outside the - // acceptable range - k_EResultUnexpectedError = 79, // something happened that we didn't expect - // to ever happen - k_EResultDisabled = 80, // The requested service has been configured - // to be unavailable - k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG - // server are not valid ! - k_EResultRestrictedDevice = 82, // The device being used is not allowed - // to perform this action - k_EResultRegionLocked = 83, // The action could not be complete - // because it is region restricted - k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try - // again later, different from - // k_EResultLimitExceeded which may be - // permanent - k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to - // login - k_EResultItemDeleted = 86, // The thing we're trying to access has been - // deleted - k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to - // throttle response to possible - // attacker - k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch - k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for - // two-factor didn't match - k_EResultAccountAssociatedToMultiplePartners = 90, // account has been - // associated with multiple partners - k_EResultNotModified = 91, // data not modified - k_EResultNoMobileDevice = 92, // the account does not have a mobile - // device associated with it - k_EResultTimeNotSynced = 93, // the time presented is out of range or - // tolerance - k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending, - // etc.) - k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource - k_EResultAccountActivityLimitExceeded = 96,// Too many changes to - // this account - k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone - k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use - // wallet - k_EResultEmailSendFailure = 99, // Cannot send an email - k_EResultNotSettled = 100, // Can't perform operation till payment - // has settled - k_EResultNeedCaptcha = 101,// Needs to provide a valid captcha - k_EResultGSLTDenied = 102, // a game server login token owned by this token's - // owner has been banned - k_EResultGSOwnerDenied = 103, // game server owner is denied for other reason - // (account lock, community ban, vac ban, missing phone) - k_EResultInvalidItemType = 104,// the type of thing we were requested to act - // on is invalid - k_EResultIPBanned = 105,// the ip address has been banned from taking this - // action - k_EResultGSLTExpired = 106,// this token has expired from disuse; can be - // reset for use - k_EResultInsufficientFunds = 107,// user doesn't have enough wallet funds to - // complete the action - k_EResultTooManyPending = 108, // There are too many of this thing pending - // already - k_EResultNoSiteLicensesFound = 109, // No site licenses found - k_EResultWGNetworkSendExceeded = 110,// the WG couldn't send a response - // because we exceeded max network send size - k_EResultAccountNotFriends = 111, // the user is not mutually friends - k_EResultLimitedUserAccount = 112,// the user is limited - k_EResultCantRemoveItem = 113, // item can't be removed - k_EResultAccountDeleted = 114, // account has been deleted - k_EResultExistingUserCancelledLicense = 115, - // A license for this already exists, but cancelled - k_EResultCommunityCooldown = 116, // access is denied because of a - // community cooldown (probably from support profile data resets) - k_EResultNoLauncherSpecified = 117, // No launcher was specified, but a - // launcher was needed to choose correct realm for operation. - k_EResultMustAgreeToSSA = 118,// User must agree to china SSA or global SSA - // before login - k_EResultLauncherMigrated = 119, // The specified launcher type is no longer - // supported; the user should be directed elsewhere - k_EResultSteamRealmMismatch = 120, // The user's realm does not match the - // realm of the requested resource - k_EResultInvalidSignature = 121, // signature check did not match - k_EResultParseFailure = 122, // Failed to parse input - k_EResultNoVerifiedPhone = 123, // account does not have a verified phone - // number -} EResult; - -typedef struct { - - HSteamUser m_hSteamUser; // Specific user to whom this callback applies. - int m_iCallback; - u8 *m_pubParam; // Points to the callback structure - int m_cubParam; // Size of the data pointed to by m_pubParam - -} CallbackMsg_t; - -typedef struct { - - SteamAPICall_t m_hAsyncCall; - int m_iCallback; - u32 m_cubParam; - -} SteamAPICallCompleted_t; -enum { k_iSteamAPICallCompleted = k_iSteamUtilsCallbacks + 3 }; - -// Steam universes. Each universe is a self-contained Steam instance. -typedef enum EUniverse { - k_EUniverseInvalid = 0, - k_EUniversePublic = 1, - k_EUniverseBeta = 2, - k_EUniverseInternal = 3, - k_EUniverseDev = 4, - // k_EUniverseRC = 5, // no such universe anymore - k_EUniverseMax -} EUniverse_t; - -#pragma pack( push, 1 ) -struct SteamIDComponent_t -{ -#ifdef VALVE_BIG_ENDIAN - EUniverse_t m_EUniverse : 8 - unsigned int m_EAccountType : 4; - unsigned int m_unAccountInstance : 20; - u32 m_unAccountID : 32; -#else - u32 m_unAccountID : 32; - unsigned int m_unAccountInstance : 20; - unsigned int m_EAccountType : 4; - EUniverse_t m_EUniverse : 8; -#endif -}; - -typedef struct -{ - // 64 bits total - union - { - struct SteamIDComponent_t m_comp; - u64 m_unAll64Bits; - }; -} -CSteamID; - -typedef struct GameID_t -{ -#ifdef VALVE_BIG_ENDIAN - unsigned int m_nModID : 32; - unsigned int m_nType : 8; - unsigned int m_nAppID : 24; -#else - unsigned int m_nAppID : 24; - unsigned int m_nType : 8; - unsigned int m_nModID : 32; -#endif -} CGameID; -#pragma pack( pop ) -#pragma pack( pop ) - -/* - * Standard login - * ============================================================================= - */ - -int SteamAPI_RestartAppIfNecessary( u32 unOwnAppID ); -int SteamAPI_Init(void); -void SteamAPI_Shutdown(void); - -/* - * Server mode login - * ============================================================================= - */ - -typedef enum EServerMode EServerMode; -enum EServerMode -{ - eServerModeInvalid = 0, - eServerModeNoAuthentication = 1, - eServerModeAuthentication = 2, - eServerModeAuthenticationAndSecure = 3, -}; - -int SteamInternal_GameServer_Init( u32 unIP, u16 usLegacySteamPort, - u16 usGamePort, u16 usQueryPort, - EServerMode eServerMode, - const char *pchVersionString ); - -/* Initialize SteamGameServer client and interface objects, and set server - * properties which may not be changed. - * After calling this function, you should set any additional server parameters, - * and then call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn() - * - * - unIP will usually be zero. If you are on a machine with multiple IP - * addresses, you can pass a non-zero value here and the relevant sockets will - * be bound to that IP. This can be used to ensure that the IP you desire is - * the one used in the server browser. - * - usGamePort is the port that clients will connect to for gameplay. You will - * usually open up your own socket bound to this port. - * - usQueryPort is the port that will manage server browser related duties and - * info pings from clients. If you pass STEAMGAMESERVER_QUERY_PORT_SHARED for - * usQueryPort, then it will use "GameSocketShare" mode, which means that the - * game is responsible for sending and receiving UDP packets for the master - * server updater. (See ISteamGameServer::HandleIncomingPacket and - * ISteamGameServer::GetNextOutgoingPacket.) - * - The version string should be in the form x.x.x.x, and is used by the master - * server to detect when the server is out of date. (Only servers with the - * latest version will be listed.) - */ -static inline int SteamGameServer_Init( - u32 unIP, u16 usGamePort, u16 usQueryPort, - EServerMode eServerMode, - const char *pchVersionString ) -{ - return SteamInternal_GameServer_Init( unIP, 0, usGamePort, usQueryPort, - eServerMode, pchVersionString ); -} - -void *SteamAPI_SteamGameServer_v014(void); -static inline void *SteamAPI_SteamGameServer(void) -{ - return SteamAPI_SteamGameServer_v014(); -} - -void SteamAPI_ISteamGameServer_LogOnAnonymous( void* self ); -void SteamGameServer_Shutdown(void); -int SteamGameServer_BSecure(void); -u64 SteamGameServer_GetSteamID(void); -HSteamPipe SteamAPI_GetHSteamPipe(void); -HSteamPipe SteamGameServer_GetHSteamPipe(void); -HSteamUser SteamAPI_GetHSteamUser(void); -void SteamAPI_ManualDispatch_Init(void); -void SteamAPI_ManualDispatch_RunFrame( HSteamPipe hSteamPipe ); -steamapi_bool SteamAPI_ManualDispatch_GetNextCallback( HSteamPipe hSteamPipe, - CallbackMsg_t *pCallbackMsg ); -void SteamAPI_ManualDispatch_FreeLastCallback( HSteamPipe hSteamPipe ); -steamapi_bool SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe, - SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, - int iCallbackExpected, steamapi_bool *pbFailed ); -void SteamAPI_ReleaseCurrentThreadMemory(void); diff --git a/vg_steam_auth.h b/vg_steam_auth.h deleted file mode 100644 index ca97b0f..0000000 --- a/vg_steam_auth.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include "vg/vg_platform.h" -#include "vg/vg_io.h" -#include "vg_steam.h" - -typedef u32 HAuthTicket; -enum{ k_HAuthTicketInvalid = 0 }; - -#if defined( VALVE_CALLBACK_PACK_SMALL ) - #pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) - #pragma pack( push, 8 ) -#endif - -typedef struct EncryptedAppTicketResponse_t EncryptedAppTicketResponse_t; -struct EncryptedAppTicketResponse_t -{ - EResult m_eResult; -}; -enum{ k_iEncryptedAppTicketResponse = k_iSteamUserCallbacks + 54 }; - -typedef struct GetAuthSessionTicketResponse_t GetAuthSessionTicketResponse_t; -struct GetAuthSessionTicketResponse_t -{ - HAuthTicket m_hAuthTicket; - EResult m_eResult; -}; -enum{ k_iGetAuthSessionTicketResponse = k_iSteamUserCallbacks + 63 }; - -#pragma pack(pop) - -/* - * Regular authentication - */ - -typedef void ISteamUser; -ISteamUser *SteamAPI_SteamUser_v021(void); -static inline ISteamUser *SteamAPI_SteamUser(void) -{ - return SteamAPI_SteamUser_v021(); -} - -HAuthTicket SteamAPI_ISteamUser_GetAuthSessionTicket( - ISteamUser *self, void *pTicket, - int cbMaxTicket, u32 *pcbTicket ); - -/* - * Application symetric-key ticket (Client) - */ - -SteamAPICall_t SteamAPI_ISteamUser_RequestEncryptedAppTicket( - ISteamUser *self, void *pDataToInclude, int cbDataToInclude ); - -steamapi_bool SteamAPI_ISteamUser_GetEncryptedAppTicket( - ISteamUser *self, void *pTicket, - int cbMaxTicket, u32 *pcbTicket ); - -u64_steamid SteamAPI_ISteamUser_GetSteamID( ISteamUser *self ); diff --git a/vg_steam_auth_server.h b/vg_steam_auth_server.h deleted file mode 100644 index 7d4ce4f..0000000 --- a/vg_steam_auth_server.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once -#include "vg/vg_platform.h" -#include "vg/vg_io.h" -#include "vg_steam.h" - -/* - * Application symetric-key ticket method (Server) - */ - -enum { k_nSteamEncryptedAppTicketSymmetricKeyLen = 32 }; - -steamapi_bool SteamEncryptedAppTicket_BDecryptTicket( u8 *rgubTicketEncrypted, - u32 cubTicketEncrypted, u8 *rgubTicketDecrypted, - u32 *pcubTicketDecrypted, - u8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], - int cubKey ); - -steamapi_bool SteamEncryptedAppTicket_BIsTicketForApp( u8 *rgubTicketDecrypted, - u32 cubTicketDecrypted, AppId_t nAppID ); - -RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( u8 *rgubTicketDecrypted, - u32 cubTicketDecrypted ); - -void SteamEncryptedAppTicket_GetTicketSteamID( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, CSteamID *psteamID ); - -AppId_t SteamEncryptedAppTicket_GetTicketAppID( u8 *rgubTicketDecrypted, - u32 cubTicketDecrypted ); - -steamapi_bool SteamEncryptedAppTicket_BUserOwnsAppInTicket( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, AppId_t nAppID ); - -steamapi_bool SteamEncryptedAppTicket_BUserIsVacBanned( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); - -steamapi_bool SteamEncryptedAppTicket_BGetAppDefinedValue( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, u32 *pValue ); - -u8 *SteamEncryptedAppTicket_GetUserVariableData( u8 *rgubTicketDecrypted, - u32 cubTicketDecrypted, u32 *pcubUserData ); - -steamapi_bool SteamEncryptedAppTicket_BIsTicketSigned( u8 *rgubTicketDecrypted, - u32 cubTicketDecrypted, u8 *pubRSAKey, u32 cubRSAKey ); - -steamapi_bool SteamEncryptedAppTicket_BIsLicenseBorrowed( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); - -steamapi_bool SteamEncryptedAppTicket_BIsLicenseTemporary( - u8 *rgubTicketDecrypted, u32 cubTicketDecrypted ); - -static inline u8 vg_char_base16( char c ) -{ - if( c >= '0' && c <= '9' ) - return c-'0'; - if( c >= 'a' && c <= 'f' ) - return (c-'a') + 10; - - return 0; -} - -static inline int vg_load_steam_symetric_key( const char *path, u8 *buf ) -{ - vg_stack_allocator stack; - vg_stack_init( &stack, NULL, VG_KB(256), NULL ); - - u32 size; - char *src = vg_file_read( &stack, path, &size, 0 ); - - if( src ) - { - if( size < k_nSteamEncryptedAppTicketSymmetricKeyLen ) - { - vg_error( "Application key was invalid size\n" ); - return 0; - } - - for( int i=0; i IPv6 ::ffff:aabb:ccdd - * (RFC 4291 section 2.5.5.2.) - */ -typedef struct SteamNetworkingIPAddr SteamNetworkingIPAddr; -struct SteamNetworkingIPAddr -{ - union - { - u8 m_ipv6[ 16 ]; - - /* RFC4038, section 4.2 */ - struct IPv4MappedAddress - { - u64 m_8zeros; - u16 m_0000; - u16 m_ffff; - u8 m_ip[ 4 ]; /* NOTE: As bytes, i.e. network byte order */ - } - m_ipv4; - }; - - u16 m_port; // Host byte order -}; - -typedef struct SteamNetworkingIdentity SteamNetworkingIdentity; -struct SteamNetworkingIdentity -{ - ESteamNetworkingIdentityType m_eType; - - int m_cbSize; - union - { - u64 m_steamID64; - char m_szGenericString[ 32 ]; - u8 m_genericBytes[ 32 ]; - char m_szUnknownRawString[ 128 ]; - SteamNetworkingIPAddr m_ip; - u32 m_reserved[ 32 ]; - }; -}; - -#pragma pack(pop) - -/* - * "Fake IPs" are assigned to hosts, to make it easier to interface with - * older code that assumed all hosts will have an IPv4 address - */ -enum ESteamNetworkingFakeIPType -{ - k_ESteamNetworkingFakeIPType_Invalid, - k_ESteamNetworkingFakeIPType_NotFake, - k_ESteamNetworkingFakeIPType_GlobalIPv4, - k_ESteamNetworkingFakeIPType_LocalIPv4, - k_ESteamNetworkingFakeIPType__Force32Bit = 0x7fffffff -}; -typedef enum ESteamNetworkingFakeIPType ESteamNetworkingFakeIPType; - -/* Set everything to zero. E.g. [::]:0 */ -void SteamAPI_SteamNetworkingIPAddr_Clear( SteamNetworkingIPAddr* self ); - -/* Returns true if the IP is ::0. (Doesn't check port.) */ -int SteamAPI_SteamNetworkingIPAddr_IsIPv6AllZeros( - SteamNetworkingIPAddr* self ); - -/* - * Set IPv6 address. IP is interpreted as bytes, so there are no endian issues. - * (Same as inaddr_in6.) The IP can be a mapped IPv4 address - */ -void SteamAPI_SteamNetworkingIPAddr_SetIPv6( SteamNetworkingIPAddr* self, - u8 *ipv6, u16 nPort ); - -/* Sets to IPv4 mapped address. IP and port are in host byte order. */ -void SteamAPI_SteamNetworkingIPAddr_SetIPv4( SteamNetworkingIPAddr* self, - u32 nIP, u16 nPort ); - -/* Return true if IP is mapped IPv4 */ -steamapi_bool -SteamAPI_SteamNetworkingIPAddr_IsIPv4( SteamNetworkingIPAddr *self ); - -/* - * Returns IP in host byte order (e.g. aa.bb.cc.dd as 0xaabbccdd). - * Returns 0 if IP is not mapped IPv4. - */ -u32 SteamAPI_SteamNetworkingIPAddr_GetIPv4( SteamNetworkingIPAddr* self ); - -/* Set to the IPv6 localhost address ::1, and the specified port. */ -void SteamAPI_SteamNetworkingIPAddr_SetIPv6LocalHost( - SteamNetworkingIPAddr* self, u16 nPort ); - -/* - * Return true if this identity is localhost. - * (Either IPv6 ::1, or IPv4 127.0.0.1) - */ -steamapi_bool SteamAPI_SteamNetworkingIPAddr_IsLocalHost( - SteamNetworkingIPAddr* self ); - -/* - * Print to a string, with or without the port. Mapped IPv4 addresses are - * printed as dotted decimal (12.34.56.78), otherwise this will print the - * canonical form according to RFC5952. If you include the port, IPv6 will be - * surrounded by brackets, e.g. [::1:2]:80. Your buffer should be at least - * k_cchMaxString bytes to avoid truncation - * - * See also SteamNetworkingIdentityRender - */ -void SteamAPI_SteamNetworkingIPAddr_ToString( SteamNetworkingIPAddr* self, - char *buf, u32 cbBuf, steamapi_bool bWithPort ); - -/* - * Parse an IP address and optional port. If a port is not present, it is set - * to 0. - * (This means that you cannot tell if a zero port was explicitly specified.) - */ -steamapi_bool SteamAPI_SteamNetworkingIPAddr_ParseString( - SteamNetworkingIPAddr* self, const char *pszStr ); - -/* See if two addresses are identical */ -steamapi_bool SteamAPI_SteamNetworkingIPAddr_IsEqualTo( - SteamNetworkingIPAddr *self, SteamNetworkingIPAddr *x ); - -/* - * Classify address as FakeIP. This function never returns - * k_ESteamNetworkingFakeIPType_Invalid. - */ -ESteamNetworkingFakeIPType SteamAPI_SteamNetworkingIPAddr_GetFakeIPType( - SteamNetworkingIPAddr* self ); - -/* Return true if we are a FakeIP */ -steamapi_bool SteamAPI_SteamNetworkingIPAddr_IsFakeIP( SteamNetworkingIPAddr* self ); - -/* - * In a few places we need to set configuration options on listen sockets and - * connections, and have them take effect *before* the listen socket or - * connection really starts doing anything. Creating the object and then setting - * the options "immediately" after creation doesn't work completely, because - * network packets could be received between the time the object is created and - * when the options are applied. To set options at creation time in a reliable - * way, they must be passed to the creation function. This structure is used to - * pass those options. - * - * For the meaning of these fields, see ISteamNetworkingUtils::SetConfigValue. - * Basically when the object is created, we just iterate over the list of - * options and call ISteamNetworkingUtils::SetConfigValueStruct, where the scope - * arguments are supplied by the object being created. - */ -typedef struct SteamNetworkingConfigValue_t SteamNetworkingConfigValue_t; -struct SteamNetworkingConfigValue_t -{ - /* Which option is being set */ - ESteamNetworkingConfigValue m_eValue; - - /// Which field below did you fill in? - ESteamNetworkingConfigDataType m_eDataType; - - /// Option value - union - { - i32 m_int32; - i64 m_int64; - float m_float; - const char *m_string; // Points to your '\0'-terminated buffer - void *m_ptr; - } m_val; -}; - -void SteamAPI_SteamNetworkingConfigValue_t_SetInt32( - SteamNetworkingConfigValue_t* self, - ESteamNetworkingConfigValue eVal, i32 data ); - -void SteamAPI_SteamNetworkingConfigValue_t_SetInt64( - SteamNetworkingConfigValue_t* self, - ESteamNetworkingConfigValue eVal, i64 data ); - -void SteamAPI_SteamNetworkingConfigValue_t_SetFloat( - SteamNetworkingConfigValue_t* self, - ESteamNetworkingConfigValue eVal, float data ); - -void SteamAPI_SteamNetworkingConfigValue_t_SetPtr( - SteamNetworkingConfigValue_t* self, - ESteamNetworkingConfigValue eVal, void *data ); - -void SteamAPI_SteamNetworkingConfigValue_t_SetString( - SteamNetworkingConfigValue_t* self, ESteamNetworkingConfigValue eVal, - const char * data ); - -typedef void ISteamNetworkingSockets; -typedef void ISteamNetworkingUtils; -typedef struct SteamNetworkingMessage_t SteamNetworkingMessage_t; -typedef struct SteamNetConnectionInfo_t SteamNetConnectionInfo_t; - -ISteamNetworkingUtils *SteamAPI_SteamNetworkingUtils_SteamAPI_v004(); -static inline ISteamNetworkingUtils *SteamAPI_SteamNetworkingUtils_SteamAPI() -{ - return SteamAPI_SteamNetworkingUtils_SteamAPI_v004(); -} - -/* - * Handle used to identify a poll group, used to query many - * connections at once efficiently. - */ -typedef u32 HSteamNetPollGroup; -static HSteamNetPollGroup const k_HSteamNetPollGroup_Invalid = 0; - -ISteamNetworkingSockets *SteamAPI_SteamGameServerNetworkingSockets_SteamAPI_v012(void); -static inline ISteamNetworkingSockets *SteamAPI_SteamGameServerNetworkingSockets_SteamAPI(void) -{ - return SteamAPI_SteamGameServerNetworkingSockets_SteamAPI_v012(); -} - -ISteamNetworkingSockets *SteamAPI_SteamNetworkingSockets_SteamAPI_v012(); -static inline ISteamNetworkingSockets *SteamAPI_SteamNetworkingSockets_SteamAPI() -{ - return SteamAPI_SteamNetworkingSockets_SteamAPI_v012(); -} - - -/* - * Send the message unreliably. Can be lost. Messages *can* be larger than a - * single MTU (UDP packet), but there is no retransmission, so if any piece - * of the message is lost, the entire message will be dropped. - - * The sending API does have some knowledge of the underlying connection, so - * if there is no NAT-traversal accomplished or there is a recognized adjustment - * happening on the connection, the packet will be batched until the connection - * is open again. - - * Migration note: This is not exactly the same as k_EP2PSendUnreliable! You - * probably want k_ESteamNetworkingSendType_UnreliableNoNagle - */ -static const int k_nSteamNetworkingSend_Unreliable = 0; - -/* - * Disable Nagle's algorithm. - * By default, Nagle's algorithm is applied to all outbound messages. This means - * that the message will NOT be sent immediately, in case further messages are - * sent soon after you send this, which can be grouped together. Any time there - * is enough buffered data to fill a packet, the packets will be pushed out - * immediately, but partially-full packets not be sent until the Nagle timer - * expires. See ISteamNetworkingSockets::FlushMessagesOnConnection, - * ISteamNetworkingMessages::FlushMessagesToUser - * - * NOTE: Don't just send every message without Nagle because you want packets to - * get there quicker. Make sure you understand the problem that Nagle is - * solving before disabling it. If you are sending small messages, often many at - * the same time, then it is very likely that it will be more efficient to leave - * Nagle enabled. A typical proper use of this flag is when you are sending - * what you know will be the last message sent for a while (e.g. the last in the - * server simulation tick to a particular client), and you use this flag to - * flush all messages. - */ -static const int k_nSteamNetworkingSend_NoNagle = 1; - -/* - * Send a message unreliably, bypassing Nagle's algorithm for this message and - * any messages currently pending on the Nagle timer. This is equivalent to - * using k_ESteamNetworkingSend_Unreliable and then immediately flushing the - * messages using ISteamNetworkingSockets::FlushMessagesOnConnection or - * ISteamNetworkingMessages::FlushMessagesToUser. (But using this flag is more - * efficient since you only make one API call.) - */ -static const int k_nSteamNetworkingSend_UnreliableNoNagle = - k_nSteamNetworkingSend_Unreliable | - k_nSteamNetworkingSend_NoNagle; -/* - * If the message cannot be sent very soon (because the connection is still - * doing some initial handshaking, route negotiations, etc), then just drop it. - * This is only applicable for unreliable messages. Using this flag on reliable - * messages is invalid. - */ -static const int k_nSteamNetworkingSend_NoDelay = 4; - -/* - * Send an unreliable message, but if it cannot be sent relatively quickly, just - * drop it instead of queuing it. This is useful for messages that are not - * useful if they are excessively delayed, such as voice data. - * NOTE: The Nagle algorithm is not used, and if the message is not dropped, any - * messages waiting on the Nagle timer are immediately flushed. - * - * A message will be dropped under the following circumstances: - * - the connection is not fully connected. (E.g. the "Connecting" or - * "FindingRoute" states) - * - there is a sufficiently large number of messages queued up already such - * that the current message will not be placed on the wire in the next - * ~200ms or so. - * - * If a message is dropped for these reasons, k_EResultIgnored will be returned. - */ -static const int k_nSteamNetworkingSend_UnreliableNoDelay = - k_nSteamNetworkingSend_Unreliable | - k_nSteamNetworkingSend_NoDelay | - k_nSteamNetworkingSend_NoNagle; - -/* - * Reliable message send. Can send up to - * k_cbMaxSteamNetworkingSocketsMessageSizeSend bytes in a single message. - * Does fragmentation/re-assembly of messages under the hood, as well as a - * sliding window for efficient sends of large chunks of data. - * The Nagle algorithm is used. See notes on - * k_ESteamNetworkingSendType_Unreliable for more details. - * See k_ESteamNetworkingSendType_ReliableNoNagle, - * ISteamNetworkingSockets::FlushMessagesOnConnection, - * ISteamNetworkingMessages::FlushMessagesToUser - * - * Migration note: This is NOT the same as k_EP2PSendReliable, it's more like - * k_EP2PSendReliableWithBuffering - */ -static const int k_nSteamNetworkingSend_Reliable = 8; - -/* - * Send a message reliably, but bypass Nagle's algorithm. - * - * Migration note: This is equivalent to k_EP2PSendReliable - */ -static const int k_nSteamNetworkingSend_ReliableNoNagle = - k_nSteamNetworkingSend_Reliable | - k_nSteamNetworkingSend_NoNagle; -enum{ k_cchSteamNetworkingMaxConnectionCloseReason = 128 }; -enum{ k_cchSteamNetworkingMaxConnectionDescription = 128 }; -enum{ k_cchSteamNetworkingMaxConnectionAppName = 32 }; -enum{ k_nSteamNetworkConnectionInfoFlags_Unauthenticated = 1 }; -enum{ k_nSteamNetworkConnectionInfoFlags_Unencrypted = 2 }; -enum{ k_nSteamNetworkConnectionInfoFlags_LoopbackBuffers = 4 }; -enum{ k_nSteamNetworkConnectionInfoFlags_Fast = 8 }; -enum{ k_nSteamNetworkConnectionInfoFlags_Relayed = 16 }; -enum{ k_nSteamNetworkConnectionInfoFlags_DualWifi = 32 }; - -/* Describe the state of a connection. */ -struct SteamNetConnectionInfo_t -{ - /* - * Who is on the other end? Depending on the connection type and phase of the - * connection, we might not know - */ - SteamNetworkingIdentity m_identityRemote; - - /* Arbitrary user data set by the local application code */ - i64 m_nUserData; - - /* - * Handle to listen socket this was connected on, or - * k_HSteamListenSocket_Invalid if we initiated the connection - */ - HSteamListenSocket m_hListenSocket; - - /* - * Remote address. Might be all 0's if we don't know it, or if this is N/A. - * (E.g. Basically everything except direct UDP connection.) - */ - SteamNetworkingIPAddr m_addrRemote; - u16 m__pad1; - - /* What data center is the remote host in? (0 if we don't know.) */ - SteamNetworkingPOPID m_idPOPRemote; - - /* - * What relay are we using to communicate with the remote host? - * (0 if not applicable.) - */ - SteamNetworkingPOPID m_idPOPRelay; - - /* High level state of the connection */ - ESteamNetworkingConnectionState m_eState; - - /* - * Basic cause of the connection termination or problem. - * See ESteamNetConnectionEnd for the values used - */ - int m_eEndReason; - - /* - * Human-readable, but non-localized explanation for connection - * termination or problem. This is intended for debugging / - * diagnostic purposes only, not to display to users. It might - * have some details specific to the issue. - */ - char m_szEndDebug[ k_cchSteamNetworkingMaxConnectionCloseReason ]; - - /* - * Debug description. This includes the internal connection ID, - * connection type (and peer information), and any name - * given to the connection by the app. This string is used in various - * internal logging messages. - * - * Note that the connection ID *usually* matches the HSteamNetConnection - * handle, but in certain cases with symmetric connections it might not. - */ - char m_szConnectionDescription - [ k_cchSteamNetworkingMaxConnectionDescription ]; - - /* Misc flags. Bitmask of k_nSteamNetworkConnectionInfoFlags_Xxxx */ - int m_nFlags; - - /* Internal stuff, room to change API easily */ - u32 reserved[63]; -}; - -/* - * Quick connection state, pared down to something you could call - * more frequently without it being too big of a perf hit. - */ -typedef struct SteamNetConnectionRealTimeStatus_t SteamNetConnectionRealTimeStatus_t; -struct SteamNetConnectionRealTimeStatus_t -{ - /* High level state of the connection */ - ESteamNetworkingConnectionState m_eState; - - /* Current ping (ms) */ - int m_nPing; - - /* - * Connection quality measured locally, 0...1. - * (Percentage of packets delivered end-to-end in order). - */ - float m_flConnectionQualityLocal; - - /* Packet delivery success rate as observed from remote host */ - float m_flConnectionQualityRemote; - - /* Current data rates from recent history. */ - float m_flOutPacketsPerSec; - float m_flOutBytesPerSec; - float m_flInPacketsPerSec; - float m_flInBytesPerSec; - - /* - * Estimate rate that we believe that we can send data to our peer. - * Note that this could be significantly higher than m_flOutBytesPerSec, - * meaning the capacity of the channel is higher than you are sending data. - * (That's OK!) - */ - int m_nSendRateBytesPerSecond; - - /* - * Number of bytes pending to be sent. This is data that you have recently - * requested to be sent but has not yet actually been put on the wire. The - * reliable number ALSO includes data that was previously placed on the wire, - * but has now been scheduled for re-transmission. Thus, it's possible to - * observe m_cbPendingReliable increasing between two checks, even if no - * calls were made to send reliable data between the checks. Data that is - * awaiting the Nagle delay will appear in these numbers. - */ - int m_cbPendingUnreliable; - int m_cbPendingReliable; - - /* - * Number of bytes of reliable data that has been placed the wire, but - * for which we have not yet received an acknowledgment, and thus we may - * have to re-transmit. - */ - int m_cbSentUnackedReliable; - - /* - * If you queued a message right now, approximately how long would that - * message wait in the queue before we actually started putting its data on - * the wire in a packet? - * - * In general, data that is sent by the application is limited by the - * bandwidth of the channel. If you send data faster than this, it must be - * queued and put on the wire at a metered rate. Even sending a small amount - * of data (e.g. a few MTU, say ~3k) will require some of the data to be - * delayed a bit. - * - * Ignoring multiple lanes,the estimated delay will be approximately equal to - * - * ( m_cbPendingUnreliable+m_cbPendingReliable ) / - * m_nSendRateBytesPerSecond - * - * plus or minus one MTU. It depends on how much time has elapsed since the - * last packet was put on the wire. For example, the queue might have *just* - * been emptied, and the last packet placed on the wire, and we are exactly - * up against the send rate limit. In that case we might need to wait for - * one packet's worth of time to elapse before we can send again. On the - * other extreme, the queue might have data in it waiting for Nagle. (This - * will always be less than one packet, because as soon as we have a complete - * packet we would send it.) In that case, we might be ready to send data - * now, and this value will be 0. - * - * This value is only valid if multiple lanes are not used. If multiple lanes - * are in use, then the queue time will be different for each lane, and you - * must use the value in SteamNetConnectionRealTimeLaneStatus_t. - * - * Nagle delay is ignored for the purposes of this calculation. - */ - SteamNetworkingMicroseconds m_usecQueueTime; - - // Internal stuff, room to change API easily - u32 reserved[16]; -}; - -/* Quick status of a particular lane */ -typedef struct SteamNetConnectionRealTimeLaneStatus_t SteamNetConnectionRealTimeLaneStatus_t; -struct SteamNetConnectionRealTimeLaneStatus_t -{ - /* Counters for this particular lane. See the corresponding variables - * in SteamNetConnectionRealTimeStatus_t */ - int m_cbPendingUnreliable; - int m_cbPendingReliable; - int m_cbSentUnackedReliable; - int _reservePad1; // Reserved for future use - - /* Lane-specific queue time. This value takes into consideration lane priorities - * and weights, and how much data is queued in each lane, and attempts to predict - * how any data currently queued will be sent out. */ - SteamNetworkingMicroseconds m_usecQueueTime; - - // Internal stuff, room to change API easily - u32 reserved[10]; -}; - -/* - * Callbacks - */ - -enum { k_iSteamNetConnectionStatusChangedCallBack = - k_iSteamNetworkingSocketsCallbacks + 1 }; - -typedef struct SteamNetConnectionStatusChangedCallback_t - SteamNetConnectionStatusChangedCallback_t; -struct SteamNetConnectionStatusChangedCallback_t -{ - /// Connection handle - HSteamNetConnection m_hConn; - - /// Full connection info - SteamNetConnectionInfo_t m_info; - - /// Previous state. (Current state is in m_info.m_eState) - ESteamNetworkingConnectionState m_eOldState; -}; - -enum { k_iSteamNetAuthenticationStatus = - k_iSteamNetworkingSocketsCallbacks + 2 }; - -typedef struct SteamNetAuthenticationStatus_t SteamNetAuthenticationStatus_t; -struct SteamNetAuthenticationStatus_t -{ - /// Status - ESteamNetworkingAvailability m_eAvail; - - /// Non-localized English language status. For diagnostic/debugging - /// purposes only. - char m_debugMsg[ 256 ]; -}; - -#pragma pack(pop) - -/* This does not have packing specified in the steamnetworkingtypes.h, it seems - * to use default */ -struct SteamNetworkingMessage_t -{ - /* - * Message payload - */ - void *m_pData; - - /* - * Size of the payload. - */ - int m_cbSize; - - HSteamNetConnection m_conn; - - /* - * For inbound messages: Who sent this to us? - * For outbound messages on connections: not used. - * For outbound messages on the ad-hoc ISteamNetworkingMessages interface: - * who should we send this to? - */ - SteamNetworkingIdentity m_identityPeer; - - /* - * For messages received on connections, this is the user data - * associated with the connection. - * - * This is *usually* the same as calling GetConnection() and then - * fetching the user data associated with that connection, but for - * the following subtle differences: - * - * - This user data will match the connection's user data at the time - * is captured at the time the message is returned by the API. - * If you subsequently change the userdata on the connection, - * this won't be updated. - * - This is an inline call, so it's *much* faster. - * - You might have closed the connection, so fetching the user data - * would not be possible. - * - * Not used when sending messages. - */ - i64 m_nConnUserData; - - /* - * Local timestamp when the message was received - * Not used for outbound messages. - */ - SteamNetworkingMicroseconds m_usecTimeReceived; - - /* - * Message number assigned by the sender. This is not used for outbound - * messages. Note that if multiple lanes are used, each lane has its own - * message numbers, which are assigned sequentially, so messages from - * different lanes will share the same numbers. - */ - i64 m_nMessageNumber; - - /* - * Function used to free up m_pData. This mechanism exists so that - * apps can create messages with buffers allocated from their own - * heap, and pass them into the library. This function will - * usually be something like: - * - * free( pMsg->m_pData ); - */ - void (*m_pfnFreeData)( SteamNetworkingMessage_t *pMsg ); - - /* - * Function to used to decrement the internal reference count and, if - * it's zero, release the message. You should not set this function pointer, - * or need to access this directly! Use the Release() function instead! - */ - void (*m_pfnRelease)( SteamNetworkingMessage_t *pMsg ); - - /* - * When using ISteamNetworkingMessages, the channel number the message was - * received on (Not used for messages sent or received on "connections") - */ - int m_nChannel; - - /* - * Bitmask of k_nSteamNetworkingSend_xxx flags. - * For received messages, only the k_nSteamNetworkingSend_Reliable bit is - * valid. - * For outbound messages, all bits are relevant - */ - int m_nFlags; - - /* - * Arbitrary user data that you can use when sending messages using - * ISteamNetworkingUtils::AllocateMessage and - * ISteamNetworkingSockets::SendMessage. - * (The callback you set in m_pfnFreeData might use this field.) - * - * Not used for received messages. - */ - i64 m_nUserData; - - /* - * For outbound messages, which lane to use? See - * ISteamNetworkingSockets::ConfigureConnectionLanes. - * For inbound messages, what lane was the message received on? - */ - u16 m_idxLane; - u16 _pad1__; -}; - -void SteamAPI_SteamNetworkingMessage_t_Release(SteamNetworkingMessage_t* self); - - - - -/* - * Utility - */ - -static inline const char *string_ESteamNetworkingConnectionState( - ESteamNetworkingConnectionState s ) -{ - switch(s) - { - case k_ESteamNetworkingConnectionState_None: - return "None"; - break; - case k_ESteamNetworkingConnectionState_Connecting: - return "Connecting"; - break; - case k_ESteamNetworkingConnectionState_FindingRoute: - return "Finding route"; - break; - case k_ESteamNetworkingConnectionState_Connected: - return "Connected"; - break; - case k_ESteamNetworkingConnectionState_ClosedByPeer: - return "Closed By Peer"; - break; - case k_ESteamNetworkingConnectionState_ProblemDetectedLocally: - return "Problem detected locally"; - break; - case k_ESteamNetworkingConnectionState_FinWait: - return "Finwait"; - break; - case k_ESteamNetworkingConnectionState_Linger: - return "Linger"; - break; - case k_ESteamNetworkingConnectionState_Dead: - return "Dead"; - break; - case k_ESteamNetworkingConnectionState__Force32Bit: - return "Force 32 Bit"; - break; - } - - return "Error"; -} - -static inline const char *string_ESteamNetworkingAvailability( - ESteamNetworkingAvailability s ) -{ - switch(s) - { - case k_ESteamNetworkingAvailability_CannotTry: - return "Cannot Try"; - break; - case k_ESteamNetworkingAvailability_Failed: - return "Failed"; - break; - case k_ESteamNetworkingAvailability_Previously: - return "Previously"; - break; - case k_ESteamNetworkingAvailability_Retrying: - return "Retrying"; - break; - case k_ESteamNetworkingAvailability_NeverTried: - return "Never tried"; - break; - case k_ESteamNetworkingAvailability_Waiting: - return "Waiting"; - break; - case k_ESteamNetworkingAvailability_Attempting: - return "Attempting"; - break; - case k_ESteamNetworkingAvailability_Current: - return "Current"; - break; - case k_ESteamNetworkingAvailability_Unknown: - return "Unknown"; - break; - default: - return "Error"; - break; - } -} - - -HSteamListenSocket SteamAPI_ISteamNetworkingSockets_CreateListenSocketIP( - ISteamNetworkingSockets *self, - SteamNetworkingIPAddr *localAddress, int nOptions, - SteamNetworkingConfigValue_t *pOptions ); - -HSteamNetConnection SteamAPI_ISteamNetworkingSockets_ConnectByIPAddress( - ISteamNetworkingSockets *self, - SteamNetworkingIPAddr *address, int nOptions, - SteamNetworkingConfigValue_t *pOptions ); - - -EResult SteamAPI_ISteamNetworkingSockets_AcceptConnection( - ISteamNetworkingSockets *self, - HSteamNetConnection hConn ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_CloseConnection( - ISteamNetworkingSockets *self, - HSteamNetConnection hPeer, int nReason, const char *pszDebug, - steamapi_bool bEnableLinger ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_GetListenSocketAddress( - ISteamNetworkingSockets *self, HSteamListenSocket hSocket, - SteamNetworkingIPAddr *address ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_CloseConnection( - ISteamNetworkingSockets *self, - HSteamNetConnection hPeer, int nReason, const char *pszDebug, - steamapi_bool bEnableLinger ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_CloseListenSocket( - ISteamNetworkingSockets *self, HSteamListenSocket hSocket ); - -EResult SteamAPI_ISteamNetworkingSockets_SendMessageToConnection( - ISteamNetworkingSockets* self, - HSteamNetConnection hConn, const void *pData, u32 cbData, int nSendFlags, - i64 * pOutMessageNumber ); - -SteamNetworkingMessage_t *SteamAPI_ISteamNetworkingUtils_AllocateMessage( - ISteamNetworkingUtils *self, - int cbAllocateBuffer ); - -void SteamAPI_ISteamNetworkingSockets_SendMessages( - ISteamNetworkingSockets* self, - int nMessages, SteamNetworkingMessage_t *const *pMessages, - i64 *pOutMessageNumberOrResult ); - -EResult SteamAPI_ISteamNetworkingSockets_FlushMessagesOnConnection( - ISteamNetworkingSockets* self, - HSteamNetConnection hConn ); - -int SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection( - ISteamNetworkingSockets* self, - HSteamNetConnection hConn, - SteamNetworkingMessage_t **ppOutMessages, - int nMaxMessages ); - -EResult SteamAPI_ISteamNetworkingSockets_GetConnectionRealTimeStatus( - ISteamNetworkingSockets *self, - HSteamNetConnection hConn, - SteamNetConnectionRealTimeStatus_t *pStatus, - int nLanes, - SteamNetConnectionRealTimeLaneStatus_t *pLanes ); - -EResult SteamAPI_ISteamNetworkingSockets_ConfigureConnectionLanes( - ISteamNetworkingSockets *self, - HSteamNetConnection hConn, - int nNumLanes, - const int *pLanePriorities, - const u16 *pLaneWeights ); - -/* - * Poll Groups - */ - -HSteamNetPollGroup SteamAPI_ISteamNetworkingSockets_CreatePollGroup( - ISteamNetworkingSockets *self ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_DestroyPollGroup( - ISteamNetworkingSockets *self, - HSteamNetPollGroup hPollGroup ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_SetConnectionPollGroup( - ISteamNetworkingSockets *self, - HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup ); - -int SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnPollGroup( - ISteamNetworkingSockets *self, - HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, - int nMaxMessages ); -/* - * Returns basic information about the high-level state of the connection. - * Returns false if the connection handle is invalid. - */ -steamapi_bool SteamAPI_ISteamNetworkingSockets_GetConnectionInfo( - ISteamNetworkingSockets* self, - HSteamNetConnection hConn, SteamNetConnectionInfo_t * pInfo ); - -int SteamAPI_ISteamNetworkingSockets_GetDetailedConnectionStatus( - ISteamNetworkingSockets* self, - HSteamNetConnection hConn, char *pszBuf, int cbBuf ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_SetConnectionUserData( - ISteamNetworkingSockets* self, HSteamNetConnection hPeer, i64 nUserData ); - -i64 SteamAPI_ISteamNetworkingSockets_GetConnectionUserData( - ISteamNetworkingSockets* self, HSteamNetConnection hPeer ); - -steamapi_bool SteamAPI_ISteamNetworkingSockets_GetListenSocketAddress( - ISteamNetworkingSockets* self, - HSteamListenSocket hSocket, SteamNetworkingIPAddr *address ); - diff --git a/vg_steam_remote_storage.h b/vg_steam_remote_storage.h deleted file mode 100644 index c7980e2..0000000 --- a/vg_steam_remote_storage.h +++ /dev/null @@ -1,582 +0,0 @@ -#pragma once -#include "vg_steam.h" - -static const u32 k_unMaxCloudFileChunkSize = 100 * 1024 * 1024; - -#if defined( VALVE_CALLBACK_PACK_SMALL ) -#pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) -#pragma pack( push, 8 ) -#else -#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx -#endif -typedef struct SteamParamStringArray_t SteamParamStringArray_t; -struct SteamParamStringArray_t{ - const char **m_ppStrings; - i32 m_nNumStrings; -}; -#pragma pack( pop ) - -/* A handle to a piece of user generated content */ -typedef void ISteamRemoteStorage; -typedef u64 UGCHandle_t; -typedef u64 PublishedFileUpdateHandle_t; -typedef u64 PublishedFileId_t; -static const PublishedFileId_t k_PublishedFileIdInvalid = 0; -static const UGCHandle_t k_UGCHandleInvalid = 0xffffffffffffffffull; -static const PublishedFileUpdateHandle_t -k_PublishedFileUpdateHandleInvalid = 0xffffffffffffffffull; - -/* Handle for writing to Steam Cloud */ -typedef u64 UGCFileWriteStreamHandle_t; -static const UGCFileWriteStreamHandle_t -k_UGCFileStreamHandleInvalid = 0xffffffffffffffffull; - -enum{ k_cchPublishedDocumentTitleMax = 128 + 1 }; -enum{ k_cchPublishedDocumentDescriptionMax = 8000 }; -enum{ k_cchPublishedDocumentChangeDescriptionMax = 8000 }; -enum{ k_unEnumeratePublishedFilesMaxResults = 50 }; -enum{ k_cchTagListMax = 1024 + 1 }; -enum{ k_cchFilenameMax = 260 }; -enum{ k_cchPublishedFileURLMax = 256 }; - -typedef enum ERemoteStoragePlatform ERemoteStoragePlatform; -enum ERemoteStoragePlatform{ - k_ERemoteStoragePlatformNone = 0, - k_ERemoteStoragePlatformWindows = (1 << 0), - k_ERemoteStoragePlatformOSX = (1 << 1), - k_ERemoteStoragePlatformPS3 = (1 << 2), - k_ERemoteStoragePlatformLinux = (1 << 3), - k_ERemoteStoragePlatformSwitch = (1 << 4), - k_ERemoteStoragePlatformAndroid = (1 << 5), - k_ERemoteStoragePlatformIOS = (1 << 6), - - /* NB we get one more before we need to widen some things */ - k_ERemoteStoragePlatformAll = 0xffffffff -}; - -typedef enum ERemoteStoragePublishedFileVisibility - ERemoteStoragePublishedFileVisibility; -enum ERemoteStoragePublishedFileVisibility{ - k_ERemoteStoragePublishedFileVisibilityPublic = 0, - k_ERemoteStoragePublishedFileVisibilityFriendsOnly = 1, - k_ERemoteStoragePublishedFileVisibilityPrivate = 2, - k_ERemoteStoragePublishedFileVisibilityUnlisted = 3, -}; - - -typedef enum EWorkshopFileType EWorkshopFileType; -enum EWorkshopFileType{ - k_EWorkshopFileTypeFirst = 0, - k_EWorkshopFileTypeCommunity = 0, - k_EWorkshopFileTypeMicrotransaction = 1, - k_EWorkshopFileTypeCollection = 2, - k_EWorkshopFileTypeArt = 3, - k_EWorkshopFileTypeVideo = 4, - k_EWorkshopFileTypeScreenshot = 5, - k_EWorkshopFileTypeGame = 6, - k_EWorkshopFileTypeSoftware = 7, - k_EWorkshopFileTypeConcept = 8, - k_EWorkshopFileTypeWebGuide = 9, - k_EWorkshopFileTypeIntegratedGuide = 10, - k_EWorkshopFileTypeMerch = 11, - k_EWorkshopFileTypeControllerBinding = 12, - k_EWorkshopFileTypeSteamworksAccessInvite = 13, - k_EWorkshopFileTypeSteamVideo = 14, - k_EWorkshopFileTypeGameManagedItem = 15, - k_EWorkshopFileTypeMax = 16 -}; - -typedef enum EWorkshopVote EWorkshopVote; -enum EWorkshopVote{ - k_EWorkshopVoteUnvoted = 0, - k_EWorkshopVoteFor = 1, - k_EWorkshopVoteAgainst = 2, - k_EWorkshopVoteLater = 3, -}; - -typedef enum EWorkshopFileAction EWorkshopFileAction; -enum EWorkshopFileAction{ - k_EWorkshopFileActionPlayed = 0, - k_EWorkshopFileActionCompleted = 1, -}; - -typedef enum EWorkshopEnumerationType EWorkshopEnumerationType; -enum EWorkshopEnumerationType{ - k_EWorkshopEnumerationTypeRankedByVote = 0, - k_EWorkshopEnumerationTypeRecent = 1, - k_EWorkshopEnumerationTypeTrending = 2, - k_EWorkshopEnumerationTypeFavoritesOfFriends = 3, - k_EWorkshopEnumerationTypeVotedByFriends = 4, - k_EWorkshopEnumerationTypeContentByFriends = 5, - k_EWorkshopEnumerationTypeRecentFromFollowedUsers = 6, -}; - -typedef enum EWorkshopVideoProvider EWorkshopVideoProvider; -enum EWorkshopVideoProvider{ - k_EWorkshopVideoProviderNone = 0, - k_EWorkshopVideoProviderYoutube = 1 -}; - -typedef enum EUGCReadAction EUGCReadAction; -enum EUGCReadAction{ - k_EUGCRead_ContinueReadingUntilFinished = 0, - k_EUGCRead_ContinueReading = 1, - k_EUGCRead_Close = 2, -}; - -typedef enum ERemoteStorageLocalFileChange ERemoteStorageLocalFileChange; -enum ERemoteStorageLocalFileChange{ - k_ERemoteStorageLocalFileChange_Invalid = 0, - k_ERemoteStorageLocalFileChange_FileUpdated = 1, - k_ERemoteStorageLocalFileChange_FileDeleted = 2, -}; - -typedef enum ERemoteStorageFilePathType ERemoteStorageFilePathType; -enum ERemoteStorageFilePathType{ - k_ERemoteStorageFilePathType_Invalid = 0, - k_ERemoteStorageFilePathType_Absolute = 1, - k_ERemoteStorageFilePathType_APIFilename = 2, -}; - -#define STEAMREMOTESTORAGE_INTERFACE_VERSION \ - "STEAMREMOTESTORAGE_INTERFACE_VERSION016" - -#if defined( VALVE_CALLBACK_PACK_SMALL ) -#pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) -#pragma pack( push, 8 ) -#else -#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx -#endif - -typedef struct RemoteStorageFileShareResult_t RemoteStorageFileShareResult_t; -struct RemoteStorageFileShareResult_t{ - EResult m_eResult; - UGCHandle_t m_hFile; - char m_rgchFilename[k_cchFilenameMax]; -}; -enum { k_iRemoteStorageFileShareResult = k_iSteamRemoteStorageCallbacks + 7 }; - -typedef struct RemoteStoragePublishFileResult_t - RemoteStoragePublishFileResult_t; -struct RemoteStoragePublishFileResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - steamapi_bool m_bUserNeedsToAcceptWorkshopLegalAgreement; -}; -enum { k_iRemoteStoragePublushFileResult = k_iSteamRemoteStorageCallbacks + 9 }; - -typedef struct RemoteStorageDeletePublishedFileResult_t - RemoteStorageDeletePublishedFileResult_t; -struct RemoteStorageDeletePublishedFileResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iRemoteStorageDeletePublishedFileResult = - k_iSteamRemoteStorageCallbacks + 11 }; - -typedef struct RemoteStorageEnumerateUserPublishedFilesResult_t - RemoteStorageEnumerateUserPublishedFilesResult_t; -struct RemoteStorageEnumerateUserPublishedFilesResult_t{ - EResult m_eResult; - i32 m_nResultsReturned; - i32 m_nTotalResultCount; - PublishedFileId_t m_rgPublishedFileId[k_unEnumeratePublishedFilesMaxResults]; -}; -enum { k_iRemoteStorageEnumerateUserPublishedFilesResult = - k_iSteamRemoteStorageCallbacks + 12 }; - -typedef struct RemoteStorageSubscribePublishedFileResult_t - RemoteStorageSubscribePublishedFileResult_t; -struct RemoteStorageSubscribePublishedFileResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iRemoteStorageSubscribePublishedFileResult = - k_iSteamRemoteStorageCallbacks + 13 }; - - -typedef struct RemoteStorageEnumerateUserSubscribedFilesResult_t - RemoteStorageEnumerateUserSubscribedFilesResult_t; -struct RemoteStorageEnumerateUserSubscribedFilesResult_t{ - EResult m_eResult; - i32 m_nResultsReturned; - i32 m_nTotalResultCount; - PublishedFileId_t m_rgPublishedFileId[k_unEnumeratePublishedFilesMaxResults]; - u32 m_rgRTimeSubscribed[ k_unEnumeratePublishedFilesMaxResults ]; -}; -enum { k_iRemoteStorageEnumerateUserSubscribedFilesResult = - k_iSteamRemoteStorageCallbacks + 14 }; - -typedef struct RemoteStorageUnsubscribePublishedFileResult_t - RemoteStorageUnsubscribePublishedFileResult_t; -struct RemoteStorageUnsubscribePublishedFileResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iRemoteStorageUnsubscribePublishedFileResult = - k_iSteamRemoteStorageCallbacks + 15 }; - -typedef struct RemoteStorageUpdatePublishedFileResult_t - RemoteStorageUpdatePublishedFileResult_t; -struct RemoteStorageUpdatePublishedFileResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - steamapi_bool m_bUserNeedsToAcceptWorkshopLegalAgreement; -}; -enum { k_iRemoteStorageUpdatePublishedFileResult = - k_iSteamRemoteStorageCallbacks + 16 }; - - -typedef struct RemoteStorageDownloadUGCResult_t - RemoteStorageDownloadUGCResult_t; -struct RemoteStorageDownloadUGCResult_t{ - EResult m_eResult; - UGCHandle_t m_hFile; - AppId_t m_nAppID; - i32 m_nSizeInBytes; - char m_pchFileName[k_cchFilenameMax]; - u64 m_ulSteamIDOwner; -}; -enum { k_iRemoteStorageDownloadUGCResult = - k_iSteamRemoteStorageCallbacks + 17 }; - - -typedef struct RemoteStorageGetPublishedFileDetailsResult_t - RemoteStorageGetPublishedFileDetailsResult_t; -struct RemoteStorageGetPublishedFileDetailsResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nCreatorAppID; - AppId_t m_nConsumerAppID; - char m_rgchTitle[k_cchPublishedDocumentTitleMax]; - char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; - UGCHandle_t m_hFile; - UGCHandle_t m_hPreviewFile; - u64 m_ulSteamIDOwner; - u32 m_rtimeCreated; - u32 m_rtimeUpdated; - ERemoteStoragePublishedFileVisibility m_eVisibility; - steamapi_bool m_bBanned; - char m_rgchTags[k_cchTagListMax]; - steamapi_bool m_bTagsTruncated; - char m_pchFileName[k_cchFilenameMax]; - i32 m_nFileSize; - i32 m_nPreviewFileSize; - char m_rgchURL[k_cchPublishedFileURLMax]; - EWorkshopFileType m_eFileType; - steamapi_bool m_bAcceptedForUse; -}; -enum { k_iRemoteStorageGetPublishedFileDetailsResult = - k_iSteamRemoteStorageCallbacks + 18 }; - -typedef struct RemoteStorageEnumerateWorkshopFilesResult_t - RemoteStorageEnumerateWorkshopFilesResult_t; -struct RemoteStorageEnumerateWorkshopFilesResult_t{ - EResult m_eResult; - i32 m_nResultsReturned; - i32 m_nTotalResultCount; - PublishedFileId_t m_rgPublishedFileId[k_unEnumeratePublishedFilesMaxResults]; - float m_rgScore[ k_unEnumeratePublishedFilesMaxResults ]; - AppId_t m_nAppId; - u32 m_unStartIndex; -}; -enum { k_iRemoteStorageEnumerateWorkshopFilesResult_t = - k_iSteamRemoteStorageCallbacks + 19 }; - - -typedef struct RemoteStorageGetPublishedItemVoteDetailsResult_t - RemoteStorageGetPublishedItemVoteDetailsResult_t; -struct RemoteStorageGetPublishedItemVoteDetailsResult_t{ - EResult m_eResult; - PublishedFileId_t m_unPublishedFileId; - i32 m_nVotesFor; - i32 m_nVotesAgainst; - i32 m_nReports; - float m_fScore; -}; -enum { k_iRemoteStorageGetPublishedItemVoteDetailsResult_t = - k_iSteamRemoteStorageCallbacks + 20 }; - - -typedef struct RemoteStoragePublishedFileSubscribed_t - RemoteStoragePublishedFileSubscribed_t; -struct RemoteStoragePublishedFileSubscribed_t{ - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; -}; -enum { k_iRemoteStoragePublishedFileSubscribed_t = - k_iSteamRemoteStorageCallbacks + 21 }; - -typedef struct RemoteStoragePublishedFileUnsubscribed_t - RemoteStoragePublishedFileUnsubscribed_t; -struct RemoteStoragePublishedFileUnsubscribed_t{ - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; -}; -enum { k_iRemoteStoragePublishedFileUnsubscribed_t = - k_iSteamRemoteStorageCallbacks + 22 }; - - -typedef struct RemoteStoragePublishedFileDeleted_t - RemoteStoragePublishedFileDeleted_t; -struct RemoteStoragePublishedFileDeleted_t{ - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; -}; -enum { k_iRemoteStoragePublishedFileDeleted_t = - k_iSteamRemoteStorageCallbacks + 23 }; - -typedef struct RemoteStorageUpdateUserPublishedItemVoteResult_t - RemoteStorageUpdateUserPublishedItemVoteResult_t; -struct RemoteStorageUpdateUserPublishedItemVoteResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iRemoteStorageUpdateUserPublishedItemVoteResult_t = - k_iSteamRemoteStorageCallbacks + 24 }; - -typedef struct RemoteStorageUserVoteDetails_t RemoteStorageUserVoteDetails_t; -struct RemoteStorageUserVoteDetails_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - EWorkshopVote m_eVote; -}; -enum { k_iRemoteStorageUserVoteDetails_t = - k_iSteamRemoteStorageCallbacks + 25 }; - -typedef struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t - RemoteStorageEnumerateUserSharedWorkshopFilesResult_t; -struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t{ - EResult m_eResult; - i32 m_nResultsReturned; - i32 m_nTotalResultCount; - PublishedFileId_t m_rgPublishedFileId[k_unEnumeratePublishedFilesMaxResults]; -}; -enum { k_iRemoteStorageEnumerateUserSharedWorkshopFilesResult_t = - k_iSteamRemoteStorageCallbacks + 26 }; - -typedef struct RemoteStorageSetUserPublishedFileActionResult_t - RemoteStorageSetUserPublishedFileActionResult_t; -struct RemoteStorageSetUserPublishedFileActionResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - EWorkshopFileAction m_eAction; -}; -enum { k_iRemoteStorageSetUserPublishedFileActionResult_t = - k_iSteamRemoteStorageCallbacks + 27 }; - -typedef struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t - RemoteStorageEnumeratePublishedFilesByUserActionResult_t; -struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t{ - EResult m_eResult; - EWorkshopFileAction m_eAction; - i32 m_nResultsReturned; - i32 m_nTotalResultCount; - PublishedFileId_t m_rgPublishedFileId[k_unEnumeratePublishedFilesMaxResults]; - u32 m_rgRTimeUpdated[ k_unEnumeratePublishedFilesMaxResults ]; -}; -enum { k_iRemoteStorageEnumeratePublishedFilesByUserActionResult_t = - k_iSteamRemoteStorageCallbacks + 28 }; - -typedef struct RemoteStoragePublishFileProgress_t - RemoteStoragePublishFileProgress_t; -struct RemoteStoragePublishFileProgress_t{ - double m_dPercentFile; - steamapi_bool m_bPreview; -}; -enum { k_iRemoteStoragePublishFileProgress_t = - k_iSteamRemoteStorageCallbacks + 29 }; - -typedef struct RemoteStoragePublishedFileUpdated_t - RemoteStoragePublishedFileUpdated_t; -struct RemoteStoragePublishedFileUpdated_t{ - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; - u64 m_ulUnused; -}; -enum { k_iRemoteStoragePublishedFileUpdated_t = - k_iSteamRemoteStorageCallbacks + 30 }; - -typedef struct RemoteStorageFileWriteAsyncComplete_t - RemoteStorageFileWriteAsyncComplete_t; -struct RemoteStorageFileWriteAsyncComplete_t{ - EResult m_eResult; -}; -enum { k_iRemoteStorageFileWriteAsyncComplete_t = - k_iSteamRemoteStorageCallbacks + 31 }; - -typedef struct RemoteStorageFileReadAsyncComplete_t - RemoteStorageFileReadAsyncComplete_t; -struct RemoteStorageFileReadAsyncComplete_t{ - SteamAPICall_t m_hFileReadAsync; - EResult m_eResult; - u32 m_nOffset; - u32 m_cubRead; -}; -enum { k_iRemoteStorageFileReadAsyncComplete_t = - k_iSteamRemoteStorageCallbacks + 32 }; - -#pragma pack( pop ) - -ISteamRemoteStorage *SteamAPI_SteamRemoteStorage_v016(); -static inline ISteamRemoteStorage *SteamAPI_SteamRemoteStorage() -{ - return SteamAPI_SteamRemoteStorage_v016(); -} - -steamapi_bool SteamAPI_ISteamRemoteStorage_FileWrite( ISteamRemoteStorage* self, - const char * pchFile, const void * pvData, i32 cubData ); -i32 SteamAPI_ISteamRemoteStorage_FileRead( ISteamRemoteStorage* self, - const char * pchFile, void * pvData, i32 cubDataToRead ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_FileWriteAsync( - ISteamRemoteStorage* self, const char * pchFile, const void * pvData, - u32 cubData ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_FileReadAsync( - ISteamRemoteStorage* self, const char * pchFile, u32 nOffset, - u32 cubToRead ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileReadAsyncComplete( - ISteamRemoteStorage* self, SteamAPICall_t hReadCall, void * pvBuffer, - u32 cubToRead ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileForget( - ISteamRemoteStorage *self, const char * pchFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileDelete( - ISteamRemoteStorage *self, const char * pchFile ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_FileShare( - ISteamRemoteStorage* self, const char * pchFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_SetSyncPlatforms( - ISteamRemoteStorage* self, const char * pchFile, - ERemoteStoragePlatform eRemoteStoragePlatform ); -UGCFileWriteStreamHandle_t SteamAPI_ISteamRemoteStorage_FileWriteStreamOpen( - ISteamRemoteStorage* self, const char * pchFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileWriteStreamWriteChunk( - ISteamRemoteStorage* self, UGCFileWriteStreamHandle_t writeHandle, - const void * pvData, i32 cubData ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileWriteStreamClose( - ISteamRemoteStorage* self, UGCFileWriteStreamHandle_t writeHandle ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileWriteStreamCancel( - ISteamRemoteStorage* self, UGCFileWriteStreamHandle_t writeHandle ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FileExists( - ISteamRemoteStorage* self, const char * pchFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_FilePersisted( - ISteamRemoteStorage* self, const char * pchFile ); -i32 SteamAPI_ISteamRemoteStorage_GetFileSize( ISteamRemoteStorage* self, - const char * pchFile ); -i64 SteamAPI_ISteamRemoteStorage_GetFileTimestamp( ISteamRemoteStorage* self, - const char * pchFile ); -ERemoteStoragePlatform SteamAPI_ISteamRemoteStorage_GetSyncPlatforms( - ISteamRemoteStorage* self, const char * pchFile ); -i32 SteamAPI_ISteamRemoteStorage_GetFileCount( ISteamRemoteStorage* self ); -const char * SteamAPI_ISteamRemoteStorage_GetFileNameAndSize( - ISteamRemoteStorage* self, int iFile, i32 * pnFileSizeInBytes ); -steamapi_bool SteamAPI_ISteamRemoteStorage_GetQuota( ISteamRemoteStorage* self, - u64 * pnTotalBytes, u64 * puAvailableBytes ); -steamapi_bool SteamAPI_ISteamRemoteStorage_IsCloudEnabledForAccount( - ISteamRemoteStorage* self ); -steamapi_bool SteamAPI_ISteamRemoteStorage_IsCloudEnabledForApp( - ISteamRemoteStorage* self ); -void SteamAPI_ISteamRemoteStorage_SetCloudEnabledForApp( - ISteamRemoteStorage* self, steamapi_bool bEnabled ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_UGCDownload( - ISteamRemoteStorage* self, UGCHandle_t hContent, u32 unPriority ); -steamapi_bool SteamAPI_ISteamRemoteStorage_GetUGCDownloadProgress( - ISteamRemoteStorage* self, UGCHandle_t hContent, i32 * pnBytesDownloaded, - i32 * pnBytesExpected ); -steamapi_bool SteamAPI_ISteamRemoteStorage_GetUGCDetails( - ISteamRemoteStorage* self, - UGCHandle_t hContent, AppId_t * pnAppID, char ** ppchName, - i32 * pnFileSizeInBytes, CSteamID * pSteamIDOwner ); -i32 SteamAPI_ISteamRemoteStorage_UGCRead( ISteamRemoteStorage* self, - UGCHandle_t hContent, void * pvData, i32 cubDataToRead, u32 cOffset, - EUGCReadAction eAction ); -i32 SteamAPI_ISteamRemoteStorage_GetCachedUGCCount( ISteamRemoteStorage* self ); -UGCHandle_t SteamAPI_ISteamRemoteStorage_GetCachedUGCHandle( - ISteamRemoteStorage* self, i32 iCachedContent ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_PublishWorkshopFile( - ISteamRemoteStorage* self, const char * pchFile, - const char * pchPreviewFile, AppId_t nConsumerAppId, - const char * pchTitle, const char * pchDescription, - ERemoteStoragePublishedFileVisibility eVisibility, - SteamParamStringArray_t * pTags, EWorkshopFileType eWorkshopFileType ); -PublishedFileUpdateHandle_t -SteamAPI_ISteamRemoteStorage_CreatePublishedFileUpdateRequest( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFileFile( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - const char * pchFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFilePreviewFile( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - const char * pchPreviewFile ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFileTitle( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - const char * pchTitle ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFileDescription( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - const char * pchDescription ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFileVisibility( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - ERemoteStoragePublishedFileVisibility eVisibility ); -steamapi_bool SteamAPI_ISteamRemoteStorage_UpdatePublishedFileTags( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - SteamParamStringArray_t * pTags ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_CommitPublishedFileUpdate( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_GetPublishedFileDetails( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId, - u32 unMaxSecondsOld ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_DeletePublishedFile( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_EnumerateUserPublishedFiles( - ISteamRemoteStorage* self, u32 unStartIndex ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_SubscribePublishedFile( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_EnumerateUserSubscribedFiles( - ISteamRemoteStorage* self, u32 unStartIndex ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_UnsubscribePublishedFile( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -steamapi_bool -SteamAPI_ISteamRemoteStorage_UpdatePublishedFileSetChangeDescription( - ISteamRemoteStorage* self, PublishedFileUpdateHandle_t updateHandle, - const char * pchChangeDescription ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_GetPublishedItemVoteDetails( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_UpdateUserPublishedItemVote( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId, - steamapi_bool bVoteUp ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_GetUserPublishedItemVoteDetails( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_EnumerateUserSharedWorkshopFiles( - ISteamRemoteStorage* self, u64_steamid steamId, u32 unStartIndex, - SteamParamStringArray_t * pRequiredTags, - SteamParamStringArray_t * pExcludedTags ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_PublishVideo( - ISteamRemoteStorage* self, EWorkshopVideoProvider eVideoProvider, - const char * pchVideoAccount, const char * pchVideoIdentifier, - const char * pchPreviewFile, AppId_t nConsumerAppId, - const char * pchTitle, const char * pchDescription, - ERemoteStoragePublishedFileVisibility eVisibility, - SteamParamStringArray_t * pTags ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_SetUserPublishedFileAction( - ISteamRemoteStorage* self, PublishedFileId_t unPublishedFileId, - EWorkshopFileAction eAction ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_EnumeratePublishedFilesByUserAction( - ISteamRemoteStorage* self, EWorkshopFileAction eAction, - u32 unStartIndex ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_EnumeratePublishedWorkshopFiles( - ISteamRemoteStorage* self, EWorkshopEnumerationType eEnumerationType, - u32 unStartIndex, u32 unCount, u32 unDays, - SteamParamStringArray_t * pTags, SteamParamStringArray_t * pUserTags ); -SteamAPICall_t SteamAPI_ISteamRemoteStorage_UGCDownloadToLocation( - ISteamRemoteStorage* self, UGCHandle_t hContent, - const char * pchLocation, u32 unPriority ); -i32 SteamAPI_ISteamRemoteStorage_GetLocalFileChangeCount( - ISteamRemoteStorage* self ); -const char * SteamAPI_ISteamRemoteStorage_GetLocalFileChange( - ISteamRemoteStorage* self, int iFile, - ERemoteStorageLocalFileChange * pEChangeType, - ERemoteStorageFilePathType * pEFilePathType ); -steamapi_bool SteamAPI_ISteamRemoteStorage_BeginFileWriteBatch( - ISteamRemoteStorage *self ); -steamapi_bool SteamAPI_ISteamRemoteStorage_EndFileWriteBatch( - ISteamRemoteStorage *self ); diff --git a/vg_steam_ugc.h b/vg_steam_ugc.h deleted file mode 100644 index d8c2776..0000000 --- a/vg_steam_ugc.h +++ /dev/null @@ -1,775 +0,0 @@ -#pragma once -#include "vg_steam.h" -#include "vg_steam_remote_storage.h" - -#if defined( VALVE_CALLBACK_PACK_SMALL ) - ; - #pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) - #pragma pack( push, 8 ) -#endif - -typedef void ISteamUGC; -typedef u64 UGCQueryHandle_t; -typedef u64 UGCUpdateHandle_t; - -static const UGCQueryHandle_t k_UGCQueryHandleInvalid = 0xffffffffffffffffull; -static const UGCUpdateHandle_t k_UGCUpdateHandleInvalid = 0xffffffffffffffffull; - -/* Matching UGC types for queries */ -typedef enum EUGCMatchingUGCType EUGCMatchingUGCType; -enum EUGCMatchingUGCType{ - /* both mtx items and ready-to-use items */ - k_EUGCMatchingUGCType_Items = 0, - k_EUGCMatchingUGCType_Items_Mtx = 1, - k_EUGCMatchingUGCType_Items_ReadyToUse = 2, - k_EUGCMatchingUGCType_Collections = 3, - k_EUGCMatchingUGCType_Artwork = 4, - k_EUGCMatchingUGCType_Videos = 5, - k_EUGCMatchingUGCType_Screenshots = 6, - - /* both web guides and integrated guides */ - k_EUGCMatchingUGCType_AllGuides = 7, - k_EUGCMatchingUGCType_WebGuides = 8, - k_EUGCMatchingUGCType_IntegratedGuides = 9, - - /* ready-to-use items and integrated guides */ - k_EUGCMatchingUGCType_UsableInGame = 10, - k_EUGCMatchingUGCType_ControllerBindings= 11, - - /* game managed items (not managed by users) */ - k_EUGCMatchingUGCType_GameManagedItems = 12, - - /* @note: will only be valid for CreateQueryUserUGCRequest requests */ - k_EUGCMatchingUGCType_All = ~0, -}; - -/* - * Different lists of published UGC for a user. - * If the current logged in user is different than the specified user, then some - * options may not be allowed. - */ -typedef enum EUserUGCList EUserUGCList; -enum EUserUGCList{ - k_EUserUGCList_Published, - k_EUserUGCList_VotedOn, - k_EUserUGCList_VotedUp, - k_EUserUGCList_VotedDown, - k_EUserUGCList_WillVoteLater, - k_EUserUGCList_Favorited, - k_EUserUGCList_Subscribed, - k_EUserUGCList_UsedOrPlayed, - k_EUserUGCList_Followed, -}; - -/* - * Sort order for user published UGC lists (defaults to creation order - * descending) - */ -typedef enum EUserUGCListSortOrder EUserUGCListSortOrder; -enum EUserUGCListSortOrder{ - k_EUserUGCListSortOrder_CreationOrderDesc, - k_EUserUGCListSortOrder_CreationOrderAsc, - k_EUserUGCListSortOrder_TitleAsc, - k_EUserUGCListSortOrder_LastUpdatedDesc, - k_EUserUGCListSortOrder_SubscriptionDateDesc, - k_EUserUGCListSortOrder_VoteScoreDesc, - k_EUserUGCListSortOrder_ForModeration, -}; - -/* - * Combination of sorting and filtering for queries across all UGC - */ -typedef enum EUGCQuery EUGCQuery; -enum EUGCQuery{ - k_EUGCQuery_RankedByVote = 0, - k_EUGCQuery_RankedByPublicationDate = 1, - k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2, - k_EUGCQuery_RankedByTrend = 3, - k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4, - k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5, - k_EUGCQuery_RankedByNumTimesReported = 6, - k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate= 7, - k_EUGCQuery_NotYetRated = 8, - k_EUGCQuery_RankedByTotalVotesAsc = 9, - k_EUGCQuery_RankedByVotesUp = 10, - k_EUGCQuery_RankedByTextSearch = 11, - k_EUGCQuery_RankedByTotalUniqueSubscriptions = 12, - k_EUGCQuery_RankedByPlaytimeTrend = 13, - k_EUGCQuery_RankedByTotalPlaytime = 14, - k_EUGCQuery_RankedByAveragePlaytimeTrend = 15, - k_EUGCQuery_RankedByLifetimeAveragePlaytime = 16, - k_EUGCQuery_RankedByPlaytimeSessionsTrend = 17, - k_EUGCQuery_RankedByLifetimePlaytimeSessions = 18, - k_EUGCQuery_RankedByLastUpdatedDate = 19, -}; - -typedef enum EItemUpdateStatus EItemUpdateStatus; -enum EItemUpdateStatus{ - /* The item update handle was invalid, job might be finished, listen too - * SubmitItemUpdateResult_t */ - k_EItemUpdateStatusInvalid = 0, - - /* The item update is processing configuration data */ - k_EItemUpdateStatusPreparingConfig = 1, - - /* The item update is reading and processing content files */ - k_EItemUpdateStatusPreparingContent= 2, - - /* The item update is uploading content changes to Steam */ - k_EItemUpdateStatusUploadingContent= 3, - - /* The item update is uploading new preview file image */ - k_EItemUpdateStatusUploadingPreviewFile= 4, - - /* The item update is committing all changes */ - k_EItemUpdateStatusCommittingChanges = 5 -}; - -typedef enum EItemState EItemState; -enum EItemState{ - /* item not tracked on client */ - k_EItemStateNone = 0, - - /* current user is subscribed to this item. Not just cached. */ - k_EItemStateSubscribed = 1, - - /* item was created with ISteamRemoteStorage */ - k_EItemStateLegacyItem = 2, - - /* item is installed and usable (but maybe out of date) */ - k_EItemStateInstalled = 4, - - /* items needs an update. Either because it's not installed yet or creator - * updated content */ - k_EItemStateNeedsUpdate = 8, - - /* item update is currently downloading */ - k_EItemStateDownloading = 16, - - /* DownloadItem() was called for this item, content isn't available until - * DownloadItemResult_t is fired */ - k_EItemStateDownloadPending= 32, -}; - -typedef enum EItemStatistic EItemStatistic; -enum EItemStatistic{ - k_EItemStatistic_NumSubscriptions = 0, - k_EItemStatistic_NumFavorites = 1, - k_EItemStatistic_NumFollowers = 2, - k_EItemStatistic_NumUniqueSubscriptions = 3, - k_EItemStatistic_NumUniqueFavorites = 4, - k_EItemStatistic_NumUniqueFollowers = 5, - k_EItemStatistic_NumUniqueWebsiteViews = 6, - k_EItemStatistic_ReportScore = 7, - k_EItemStatistic_NumSecondsPlayed = 8, - k_EItemStatistic_NumPlaytimeSessions = 9, - k_EItemStatistic_NumComments = 10, - k_EItemStatistic_NumSecondsPlayedDuringTimePeriod = 11, - k_EItemStatistic_NumPlaytimeSessionsDuringTimePeriod = 12, -}; - -typedef enum EItemPreviewType EItemPreviewType; -enum EItemPreviewType{ - /* standard image file expected (e.g. jpg, png, gif, etc.) */ - k_EItemPreviewType_Image = 0, - - k_EItemPreviewType_YouTubeVideo = 1, /* video id is stored */ - k_EItemPreviewType_Sketchfab = 2, /* model id is stored */ - - /* - * standard image file expected - cube map in the layout - * +---+---+-------+ - * | |Up | | - * +---+---+---+---+ - * | L | F | R | B | - * +---+---+---+---+ - * | |Dn | | - * +---+---+---+---+ - */ - k_EItemPreviewType_EnvironmentMap_HorizontalCross = 3, - - /* standard image file expected */ - k_EItemPreviewType_EnvironmentMap_LatLong = 4, - - /* you can specify your own types above this value */ - k_EItemPreviewType_ReservedMax = 255, -}; - -static const u32 kNumUGCResultsPerPage = 50; -static const u32 k_cchDeveloperMetadataMax = 5000; - -/* Details for a single published file/UGC */ -typedef struct SteamUGCDetails_t SteamUGCDetails_t; -struct SteamUGCDetails_t{ - PublishedFileId_t m_nPublishedFileId; - EResult m_eResult; /* The result of the operation. */ - EWorkshopFileType m_eFileType; /* Type of the file */ - AppId_t m_nCreatorAppID; /*ID of the app that created this file. */ - AppId_t m_nConsumerAppID; /* ID of the app that will consume this file. */ - char m_rgchTitle[k_cchPublishedDocumentTitleMax]; /* title of document */ - - /* description of document */ - char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; - u64 m_ulSteamIDOwner; /* Steam ID of the user who created this content. */ - u32 m_rtimeCreated; /* time when the published file was created */ - u32 m_rtimeUpdated; /* time when the published file was last updated */ - - /* time when the user added the published file to their list (not always - * applicable) */ - u32 m_rtimeAddedToUserList; - ERemoteStoragePublishedFileVisibility m_eVisibility; /* visibility */ - steamapi_bool m_bBanned; /* whether the file was banned */ - - /* developer has specifically flagged this item as accepted in the Workshop*/ - steamapi_bool m_bAcceptedForUse; - - /* whether the list of tags was too long to be returned in the provided - * buffer */ - steamapi_bool m_bTagsTruncated; - - /* comma separated list of all tags associated with this file */ - char m_rgchTags[k_cchTagListMax]; - - /* file/url information */ - UGCHandle_t m_hFile; /* The handle of the primary file */ - UGCHandle_t m_hPreviewFile; /* The handle of the preview file */ - - /* The cloud filename of the primary file */ - char m_pchFileName[k_cchFilenameMax]; - - /* Size of the primary file */ - i32 m_nFileSize; - i32 m_nPreviewFileSize; /* Size of the preview file */ - char m_rgchURL[k_cchPublishedFileURLMax]; /* URL (for a video or a website)*/ - - /* voting information */ - u32 m_unVotesUp; /* number of votes up */ - u32 m_unVotesDown; /* number of votes down */ - float m_flScore; /* calculated score */ - - /* collection details */ - u32 m_unNumChildren; -}; - -/* - * Callback for querying UGC - */ -typedef struct SteamUGCQueryCompleted_t SteamUGCQueryCompleted_t; -struct SteamUGCQueryCompleted_t{ - UGCQueryHandle_t m_handle; - EResult m_eResult; - u32 m_unNumResultsReturned; - u32 m_unTotalMatchingResults; - - /* indicates whether this data was retrieved from the local on-disk cache */ - steamapi_bool m_bCachedData; - - /* If a paging cursor was used, then this will be the next cursor to get the - * next result set. */ - char m_rgchNextCursor[k_cchPublishedFileURLMax]; -}; -enum { k_iSteamUGCQueryCompleted = k_iSteamUGCCallbacks + 31 }; - -/* - * Callback for requesting details on one piece of UGC - */ -typedef struct SteamUGCRequestUGCDetailsResult_t - SteamUGCRequestUGCDetailsResult_t; -struct SteamUGCRequestUGCDetailsResult_t{ - SteamUGCDetails_t m_details; - - /* indicates whether this data was retrieved from the local on-disk cache */ - steamapi_bool m_bCachedData; -}; -enum { k_iSteamUGCRequestUGCDetailsResult = k_iSteamUGCCallbacks + 2 }; - - -/* - * Purpose: result for ISteamUGC::CreateItem() - */ -typedef struct CreateItemResult_t CreateItemResult_t; -struct CreateItemResult_t{ - EResult m_eResult; - - /* new item got this UGC PublishFileID */ - PublishedFileId_t m_nPublishedFileId; - steamapi_bool m_bUserNeedsToAcceptWorkshopLegalAgreement; -}; -enum { k_iCreateItemResult = k_iSteamUGCCallbacks + 3 }; - - -/* - * Purpose: result for ISteamUGC::SubmitItemUpdate() - */ -typedef struct SubmitItemUpdateResult_t SubmitItemUpdateResult_t; -struct SubmitItemUpdateResult_t{ - EResult m_eResult; - steamapi_bool m_bUserNeedsToAcceptWorkshopLegalAgreement; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iSubmitItemUpdateResult = k_iSteamUGCCallbacks + 4 }; - - -/* - * Purpose: a Workshop item has been installed or updated - */ -typedef struct ItemInstalled_t ItemInstalled_t; -struct ItemInstalled_t{ - AppId_t m_unAppID; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iItemInstalled = k_iSteamUGCCallbacks + 5 }; - - -/* - * Purpose: result of DownloadItem(), existing item files can be accessed again - */ -typedef struct DownloadItemResult_t DownloadItemResult_t; -struct DownloadItemResult_t{ - AppId_t m_unAppID; - PublishedFileId_t m_nPublishedFileId; - EResult m_eResult; -}; -enum { k_iDownloadItemResult = k_iSteamUGCCallbacks + 6 }; - -/* - * Purpose: result of AddItemToFavorites() or RemoveItemFromFavorites() - */ -typedef struct UserFavoriteItemsListChanged_t UserFavoriteItemsListChanged_t; -struct UserFavoriteItemsListChanged_t{ - PublishedFileId_t m_nPublishedFileId; - EResult m_eResult; - steamapi_bool m_bWasAddRequest; -}; -enum { k_iUserFavoriteItemsListChanged = k_iSteamUGCCallbacks + 7 }; - -/* - * Purpose: The result of a call to SetUserItemVote() - */ -typedef struct SetUserItemVoteResult_t SetUserItemVoteResult_t; -struct SetUserItemVoteResult_t{ - PublishedFileId_t m_nPublishedFileId; - EResult m_eResult; - steamapi_bool m_bVoteUp; -}; -enum { k_iSetUserItemVoteResult = k_iSteamUGCCallbacks + 8 }; - -/* - * Purpose: The result of a call to GetUserItemVote() - */ -typedef struct GetUserItemVoteResult_t GetUserItemVoteResult_t; -struct GetUserItemVoteResult_t{ - PublishedFileId_t m_nPublishedFileId; - EResult m_eResult; - steamapi_bool m_bVotedUp; - steamapi_bool m_bVotedDown; - steamapi_bool m_bVoteSkipped; -}; -enum { k_iGetUserItemVoteResult = k_iSteamUGCCallbacks + 9 }; - -/* - * Purpose: The result of a call to StartPlaytimeTracking() - */ -typedef struct StartPlaytimeTrackingResult_t StartPlaytimeTrackingResult_t; -struct StartPlaytimeTrackingResult_t{ - EResult m_eResult; -}; -enum { k_iStartPlaytimeTrackingResult = k_iSteamUGCCallbacks + 10 }; - -/* - * Purpose: The result of a call to StopPlaytimeTracking() - */ -typedef struct StopPlaytimeTrackingResult_t StopPlaytimeTrackingResult_t; -struct StopPlaytimeTrackingResult_t{ - EResult m_eResult; -}; -enum { k_iStopPlaytimeTrackingResult = k_iSteamUGCCallbacks + 11 }; - -/* - * Purpose: The result of a call to AddDependency - */ -typedef struct AddUGCDependencyResult_t AddUGCDependencyResult_t; -struct AddUGCDependencyResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - PublishedFileId_t m_nChildPublishedFileId; -}; -enum { k_iAddUGCDependecyResult = k_iSteamUGCCallbacks + 12 }; - -/* - * Purpose: The result of a call to RemoveDependency - */ -typedef struct RemoveUGCDependencyResult_t RemoveUGCDependencyResult_t; -struct RemoveUGCDependencyResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - PublishedFileId_t m_nChildPublishedFileId; -}; -enum { k_iRemoveUGCDependecyResult = k_iSteamUGCCallbacks + 13 }; - - -/* - * Purpose: The result of a call to AddAppDependency - */ -typedef struct AddAppDependencyResult_t AddAppDependencyResult_t; -struct AddAppDependencyResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; -}; -enum { k_iAddAppDependencyResult = k_iSteamUGCCallbacks + 14 }; - -/* - * Purpose: The result of a call to RemoveAppDependency - */ -typedef struct RemoveAppDependencyResult_t RemoveAppDependencyResult_t; -struct RemoveAppDependencyResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - AppId_t m_nAppID; -}; -enum { k_iRemoveAppDependencyResult = k_iSteamUGCCallbacks + 15 }; - -/* - * Purpose: The result of a call to GetAppDependencies. Callback may be called - * multiple times until all app dependencies have been returned. - */ -typedef struct GetAppDependenciesResult_t GetAppDependenciesResult_t; -struct GetAppDependenciesResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; - AppId_t m_rgAppIDs[32]; - u32 m_nNumAppDependencies; // number returned in this struct - u32 m_nTotalNumAppDependencies; // total found -}; -enum { k_iGetAppDependeniesResult = k_iSteamUGCCallbacks + 16 }; - -/* - * Purpose: The result of a call to DeleteItem - */ -typedef struct DeleteItemResult_t DeleteItemResult_t; -struct DeleteItemResult_t{ - EResult m_eResult; - PublishedFileId_t m_nPublishedFileId; -}; -enum { k_iDeleteItemResult = k_iSteamUGCCallbacks + 17 }; - - -/* - * Purpose: signal that the list of subscribed items changed - */ -typedef struct UserSubscribedItemsListChanged_t - UserSubscribedItemsListChanged_t; -struct UserSubscribedItemsListChanged_t{ - AppId_t m_nAppID; -}; -enum { k_iUserSubscribedItemsListChanged = k_iSteamUGCCallbacks + 18 }; - - -/* - * Purpose: Status of the user's acceptable/rejection of the app's specific - * Workshop EULA - */ -typedef struct WorkshopEULAStatus_t WorkshopEULAStatus_t; -struct WorkshopEULAStatus_t{ - EResult m_eResult; - AppId_t m_nAppID; - u32 m_unVersion; - RTime32 m_rtAction; - steamapi_bool m_bAccepted; - steamapi_bool m_bNeedsAction; -}; -enum { k_iWorkshopEULAStatus = k_iSteamUGCCallbacks + 20 }; - -#pragma pack( pop ) - -#define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION016" - -ISteamUGC *SteamAPI_SteamUGC_v016(); -static inline ISteamUGC *SteamAPI_SteamUGC() -{ - return SteamAPI_SteamUGC_v016(); -} -ISteamUGC *SteamAPI_SteamGameServerUGC_v016(); -static inline ISteamUGC *SteamAPI_SteamGameServerUGC() -{ - return SteamAPI_SteamGameServerUGC_v016(); -} -UGCQueryHandle_t SteamAPI_ISteamUGC_CreateQueryUserUGCRequest( - ISteamUGC *self, AccountID_t unAccountID, EUserUGCList eListType, - EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, - AppId_t nCreatorAppID, AppId_t nConsumerAppID, u32 unPage ); - -UGCQueryHandle_t SteamAPI_ISteamUGC_CreateQueryAllUGCRequestPage( - ISteamUGC *self, EUGCQuery eQueryType, - EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, - AppId_t nCreatorAppID, AppId_t nConsumerAppID, u32 unPage ); - -UGCQueryHandle_t SteamAPI_ISteamUGC_CreateQueryAllUGCRequestCursor( - ISteamUGC *self, EUGCQuery eQueryType, - EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, - AppId_t nCreatorAppID, AppId_t nConsumerAppID, const char * pchCursor ); - -UGCQueryHandle_t SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest( - ISteamUGC *self, PublishedFileId_t *pvecPublishedFileID, - u32 unNumPublishedFileIDs ); - -SteamAPICall_t SteamAPI_ISteamUGC_SendQueryUGCRequest( ISteamUGC* self, - UGCQueryHandle_t handle ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCResult( - ISteamUGC *self, UGCQueryHandle_t handle, u32 index, - SteamUGCDetails_t *pDetails ); - -u32 SteamAPI_ISteamUGC_GetQueryUGCNumTags( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCTag( - ISteamUGC* self, UGCQueryHandle_t handle, u32 index, u32 indexTag, - char * pchValue, u32 cchValueSize ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCTagDisplayName( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, u32 indexTag, char * pchValue, - u32 cchValueSize ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCPreviewURL( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, char * pchURL, u32 cchURLSize ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCMetadata( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, char * pchMetadata, - u32 cchMetadatasize ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCChildren( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, - PublishedFileId_t *pvecPublishedFileID, u32 cMaxEntries ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCStatistic( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, EItemStatistic eStatType, - u64 *pStatValue ); - -u32 SteamAPI_ISteamUGC_GetQueryUGCNumAdditionalPreviews( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCAdditionalPreview( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, u32 previewIndex, - char *pchURLOrVideoID, u32 cchURLSize, char *pchOriginalFileName, - u32 cchOriginalFileNameSize, EItemPreviewType *pPreviewType ); - -u32 SteamAPI_ISteamUGC_GetQueryUGCNumKeyValueTags( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryUGCKeyValueTag( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, u32 keyValueTagIndex, char *pchKey, - u32 cchKeySize, char * pchValue, u32 cchValueSize ); - -steamapi_bool SteamAPI_ISteamUGC_GetQueryFirstUGCKeyValueTag( ISteamUGC* self, - UGCQueryHandle_t handle, u32 index, const char *pchKey, char *pchValue, - u32 cchValueSize ); - -steamapi_bool SteamAPI_ISteamUGC_ReleaseQueryUGCRequest( ISteamUGC* self, - UGCQueryHandle_t handle ); - -steamapi_bool SteamAPI_ISteamUGC_AddRequiredTag( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pTagName ); - -steamapi_bool SteamAPI_ISteamUGC_AddRequiredTagGroup( ISteamUGC* self, - UGCQueryHandle_t handle, const SteamParamStringArray_t * pTagGroups ); - -steamapi_bool SteamAPI_ISteamUGC_AddExcludedTag( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pTagName ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnOnlyIDs( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnOnlyIDs ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnKeyValueTags( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnKeyValueTags ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnLongDescription( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnLongDescription ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnMetadata( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnMetadata ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnChildren( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnChildren ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnAdditionalPreviews( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnAdditionalPreviews ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnTotalOnly( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bReturnTotalOnly ); - -steamapi_bool SteamAPI_ISteamUGC_SetReturnPlaytimeStats( ISteamUGC* self, - UGCQueryHandle_t handle, u32 unDays ); - -steamapi_bool SteamAPI_ISteamUGC_SetLanguage( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pchLanguage ); - -steamapi_bool SteamAPI_ISteamUGC_SetAllowCachedResponse( ISteamUGC* self, - UGCQueryHandle_t handle, u32 unMaxAgeSeconds ); - -steamapi_bool SteamAPI_ISteamUGC_SetCloudFileNameFilter( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pMatchCloudFileName ); - -steamapi_bool SteamAPI_ISteamUGC_SetMatchAnyTag( ISteamUGC* self, - UGCQueryHandle_t handle, steamapi_bool bMatchAnyTag ); - -steamapi_bool SteamAPI_ISteamUGC_SetSearchText( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pSearchText ); - -steamapi_bool SteamAPI_ISteamUGC_SetRankedByTrendDays( ISteamUGC* self, - UGCQueryHandle_t handle, u32 unDays ); - -steamapi_bool SteamAPI_ISteamUGC_SetTimeCreatedDateRange( ISteamUGC* self, - UGCQueryHandle_t handle, RTime32 rtStart, RTime32 rtEnd ); - -steamapi_bool SteamAPI_ISteamUGC_SetTimeUpdatedDateRange( ISteamUGC* self, - UGCQueryHandle_t handle, RTime32 rtStart, RTime32 rtEnd ); - -steamapi_bool SteamAPI_ISteamUGC_AddRequiredKeyValueTag( ISteamUGC* self, - UGCQueryHandle_t handle, const char * pKey, const char * pValue ); - -SteamAPICall_t SteamAPI_ISteamUGC_RequestUGCDetails( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, u32 unMaxAgeSeconds ); - -SteamAPICall_t SteamAPI_ISteamUGC_CreateItem( ISteamUGC* self, - AppId_t nConsumerAppId, EWorkshopFileType eFileType ); - -UGCUpdateHandle_t SteamAPI_ISteamUGC_StartItemUpdate( ISteamUGC* self, - AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemTitle( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchTitle ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemDescription( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchDescription ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemUpdateLanguage( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchLanguage ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemMetadata( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchMetaData ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemVisibility( ISteamUGC* self, - UGCUpdateHandle_t handle, - ERemoteStoragePublishedFileVisibility eVisibility ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemTags( ISteamUGC* self, - UGCUpdateHandle_t updateHandle, const SteamParamStringArray_t * pTags ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemContent( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pszContentFolder ); - -steamapi_bool SteamAPI_ISteamUGC_SetItemPreview( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pszPreviewFile ); - -steamapi_bool SteamAPI_ISteamUGC_SetAllowLegacyUpload( ISteamUGC* self, - UGCUpdateHandle_t handle, steamapi_bool bAllowLegacyUpload ); - -steamapi_bool SteamAPI_ISteamUGC_RemoveAllItemKeyValueTags( ISteamUGC* self, - UGCUpdateHandle_t handle ); - -steamapi_bool SteamAPI_ISteamUGC_RemoveItemKeyValueTags( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchKey ); - -steamapi_bool SteamAPI_ISteamUGC_AddItemKeyValueTag( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchKey, const char * pchValue ); - -steamapi_bool SteamAPI_ISteamUGC_AddItemPreviewFile( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pszPreviewFile, - EItemPreviewType type ); - -steamapi_bool SteamAPI_ISteamUGC_AddItemPreviewVideo( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pszVideoID ); - -steamapi_bool SteamAPI_ISteamUGC_UpdateItemPreviewFile( ISteamUGC* self, - UGCUpdateHandle_t handle, u32 index, const char * pszPreviewFile ); - -steamapi_bool SteamAPI_ISteamUGC_UpdateItemPreviewVideo( ISteamUGC* self, - UGCUpdateHandle_t handle, u32 index, const char * pszVideoID ); - -steamapi_bool SteamAPI_ISteamUGC_RemoveItemPreview( ISteamUGC* self, - UGCUpdateHandle_t handle, u32 index ); - -SteamAPICall_t SteamAPI_ISteamUGC_SubmitItemUpdate( ISteamUGC* self, - UGCUpdateHandle_t handle, const char * pchChangeNote ); - -EItemUpdateStatus SteamAPI_ISteamUGC_GetItemUpdateProgress( ISteamUGC* self, - UGCUpdateHandle_t handle, u64 * punBytesProcessed, u64 * punBytesTotal ); - -SteamAPICall_t SteamAPI_ISteamUGC_SetUserItemVote( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, steamapi_bool bVoteUp ); - -SteamAPICall_t SteamAPI_ISteamUGC_GetUserItemVote( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_AddItemToFavorites( ISteamUGC* self, - AppId_t nAppId, PublishedFileId_t nPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_RemoveItemFromFavorites( ISteamUGC* self, - AppId_t nAppId, PublishedFileId_t nPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_SubscribeItem( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_UnsubscribeItem( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -u32 SteamAPI_ISteamUGC_GetNumSubscribedItems( ISteamUGC* self ); - -u32 SteamAPI_ISteamUGC_GetSubscribedItems( ISteamUGC* self, - PublishedFileId_t * pvecPublishedFileID, u32 cMaxEntries ); - -u32 SteamAPI_ISteamUGC_GetItemState( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -steamapi_bool SteamAPI_ISteamUGC_GetItemInstallInfo( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, u64 * punSizeOnDisk, char * pchFolder, - u32 cchFolderSize, u32 * punTimeStamp ); - -steamapi_bool SteamAPI_ISteamUGC_GetItemDownloadInfo( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, u64 * punBytesDownloaded, - u64 * punBytesTotal ); - -steamapi_bool SteamAPI_ISteamUGC_DownloadItem( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, steamapi_bool bHighPriority ); - -steamapi_bool SteamAPI_ISteamUGC_BInitWorkshopForGameServer( ISteamUGC* self, - DepotId_t unWorkshopDepotID, const char * pszFolder ); - -void SteamAPI_ISteamUGC_SuspendDownloads( ISteamUGC* self, - steamapi_bool bSuspend ); - -SteamAPICall_t SteamAPI_ISteamUGC_StartPlaytimeTracking( ISteamUGC* self, - PublishedFileId_t * pvecPublishedFileID, u32 unNumPublishedFileIDs ); - -SteamAPICall_t SteamAPI_ISteamUGC_StopPlaytimeTracking( ISteamUGC* self, - PublishedFileId_t * pvecPublishedFileID, u32 unNumPublishedFileIDs ); - -SteamAPICall_t SteamAPI_ISteamUGC_StopPlaytimeTrackingForAllItems( - ISteamUGC* self ); - -SteamAPICall_t SteamAPI_ISteamUGC_AddDependency( ISteamUGC* self, - PublishedFileId_t nParentPublishedFileID, - PublishedFileId_t nChildPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_RemoveDependency( ISteamUGC* self, - PublishedFileId_t nParentPublishedFileID, - PublishedFileId_t nChildPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_AddAppDependency( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, AppId_t nAppID ); - -SteamAPICall_t SteamAPI_ISteamUGC_RemoveAppDependency( ISteamUGC* self, - PublishedFileId_t nPublishedFileID, AppId_t nAppID ); - -SteamAPICall_t SteamAPI_ISteamUGC_GetAppDependencies( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -SteamAPICall_t SteamAPI_ISteamUGC_DeleteItem( ISteamUGC* self, - PublishedFileId_t nPublishedFileID ); - -steamapi_bool SteamAPI_ISteamUGC_ShowWorkshopEULA( ISteamUGC* self ); - -SteamAPICall_t SteamAPI_ISteamUGC_GetWorkshopEULAStatus( ISteamUGC* self ); diff --git a/vg_steam_user_stats.h b/vg_steam_user_stats.h deleted file mode 100644 index 6f5774e..0000000 --- a/vg_steam_user_stats.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "vg_steam.h" - -#if defined( VALVE_CALLBACK_PACK_SMALL ) -; - #pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) - #pragma pack( push, 8 ) -#endif - -typedef struct UserStatsReceived_t UserStatsReceived_t; -struct UserStatsReceived_t -{ - u64 m_nGameID; // Game these stats are for - EResult m_eResult; // Success / error fetching the stats - CSteamID m_steamIDUser; // The user for whom the stats are retrieved for -}; -enum { k_iUserStatsReceived = k_iSteamUserStatsCallbacks + 1 }; - -#pragma pack(pop) - -typedef void ISteamUserStats; -ISteamUserStats *SteamAPI_SteamUserStats_v012(void); -static inline ISteamUserStats *SteamAPI_SteamUserStats(void) -{ - return SteamAPI_SteamUserStats_v012(); -} - -steamapi_bool -SteamAPI_ISteamUserStats_RequestCurrentStats( ISteamUserStats* self ); -steamapi_bool -SteamAPI_ISteamUserStats_GetAchievement( ISteamUserStats *self, - const char *pchName, - steamapi_bool *pbAchieved ); -steamapi_bool -SteamAPI_ISteamUserStats_SetAchievement( ISteamUserStats *self, - const char *pchName ); -steamapi_bool -SteamAPI_ISteamUserStats_ClearAchievement( ISteamUserStats *self, - const char *pchName ); -steamapi_bool SteamAPI_ISteamUserStats_StoreStats( ISteamUserStats* self ); diff --git a/vg_steam_utils.h b/vg_steam_utils.h deleted file mode 100644 index 966b38b..0000000 --- a/vg_steam_utils.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include "vg_steam.h" - -#if defined( VALVE_CALLBACK_PACK_SMALL ) - #pragma pack( push, 4 ) -#elif defined( VALVE_CALLBACK_PACK_LARGE ) - #pragma pack( push, 8 ) -#endif - -/* ... */ - -#pragma pack(pop) - -typedef void ISteamUtils; -typedef void ISteamInput; - -ISteamUtils *SteamAPI_SteamUtils_v010(void); -static inline ISteamUtils *SteamAPI_SteamUtils(void) -{ - return SteamAPI_SteamUtils_v010(); -} - -steamapi_bool SteamAPI_ISteamUtils_SetWarningMessageHook( - ISteamUtils *self, void( *fn_print )(int, const char *) ); - - -ISteamInput *SteamAPI_SteamInput_v006(void); -static inline ISteamInput *SteamAPI_SteamInput(void) -{ - return SteamAPI_SteamInput_v006(); -} - -typedef u64 InputHandle_t; - -typedef enum ESteamInputType ESteamInputType; -enum ESteamInputType -{ - k_ESteamInputType_Unknown, - k_ESteamInputType_SteamController, - k_ESteamInputType_XBox360Controller, - k_ESteamInputType_XBoxOneController, - k_ESteamInputType_GenericGamepad, - k_ESteamInputType_PS4Controller, - k_ESteamInputType_AppleMFiController, - k_ESteamInputType_AndroidController, - k_ESteamInputType_SwitchJoyConPair, - k_ESteamInputType_SwitchJoyConSingle, - k_ESteamInputType_SwitchProController, - k_ESteamInputType_MobileTouch, - k_ESteamInputType_PS3Controller, - k_ESteamInputType_PS5Controller, - k_ESteamInputType_SteamDeckController, // Added in SDK 153 - k_ESteamInputType_Count, - k_ESteamInputType_MaximumPossibleValue = 255, -}; - -steamapi_bool SteamAPI_ISteamInput_Init( ISteamInput *self, - steamapi_bool bExplicitlyCallRunFrame ); -steamapi_bool SteamAPI_ISteamInput_Shutdown( ISteamInput* self ); -InputHandle_t SteamAPI_ISteamInput_GetControllerForGamepadIndex( - ISteamInput* self, int nIndex ); -ESteamInputType SteamAPI_ISteamInput_GetInputTypeForHandle( - ISteamInput* self, InputHandle_t inputHandle ); -void SteamAPI_ISteamInput_RunFrame( ISteamInput* self, - steamapi_bool bReservedValue ); - -steamapi_bool SteamAPI_ISteamUtils_GetImageSize( ISteamUtils* self, int iImage, u32 *pnWidth, u32 *pnHeight ); -steamapi_bool SteamAPI_ISteamUtils_GetImageRGBA( ISteamUtils* self, int iImage, u8 *pubDest, int nDestBufferSize ); diff --git a/vg_string.c b/vg_string.c index 12546bd..48d58c6 100644 --- a/vg_string.c +++ b/vg_string.c @@ -4,6 +4,7 @@ #include #include #include +#include "submodules/anyascii/impl/c/anyascii.c" i32 vg_str_storage( vg_str *str ) { @@ -270,3 +271,55 @@ bool vg_str_eq( const char *s1, const char *s2 ) return 0; } + +static u32 utf8_byte0_byte_count( u8 char0 ) +{ + for( u32 k=2; k<4; k++ ) + { + if( !(char0 & (0x80 >> k)) ) + return k; + } + + return 0; +} + +u32 str_utf8_collapse( const char *str, char *buf, u32 length ) +{ + u8 *ustr = (u8 *)str; + u32 utf32_code = 0x00000000; + u32 i=0, j=0, utf32_byte_ct=0; + for(;j < length-1;) + { + if( ustr[i] == 0x00 ) + break; + if( ustr[i] & 0x80 ) + { + if( utf32_byte_ct ) + { + utf32_byte_ct --; + utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6); + if( !utf32_byte_ct ) + { + const char *match; + size_t chars = anyascii( utf32_code, &match ); + for( u32 k=0; k> utf32_byte_ct); + utf32_code <<= utf32_byte_ct*6; + } + } + else + { + utf32_byte_ct = 0x00; + buf[j ++] = str[i]; + } + i++; + } + buf[j] = 0x00; + return j; +} diff --git a/vg_string.h b/vg_string.h index 0e4710d..bb72ff9 100644 --- a/vg_string.h +++ b/vg_string.h @@ -69,3 +69,5 @@ int vg_strdjb2_eq( const char *s1, u32 h1, const char *s2, u32 h2 ); bool vg_str_eq( const char *s1, const char *s2 ); bool vg_str_flushfd( vg_str *str, int fd ); + +u32 str_utf8_collapse( const char *str, char *buf, u32 length );