From 93d20de83b076ec8597fffff7bdba8b7d0782bbb Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 30 Apr 2019 16:43:27 +0100 Subject: [PATCH] ISteamCallback was a nice idea but IL2CPP support makes it unfeasible --- .../Callbacks/{Events.cs => Event.cs} | 0 .../Callbacks/ISteamCallback.cs | 11 - Facepunch.Steamworks/Callbacks/Result.cs | 41 - .../Generated/Interfaces/ISteamApps.cs | 2 +- .../Generated/Interfaces/ISteamFriends.cs | 14 +- .../Generated/Interfaces/ISteamGameServer.cs | 6 +- .../Generated/Interfaces/ISteamInventory.cs | 6 +- .../Interfaces/ISteamMatchmakingServers.cs | 2 +- .../Interfaces/ISteamRemoteStorage.cs | 10 +- .../Generated/Interfaces/ISteamUGC.cs | 38 +- .../Generated/Interfaces/ISteamUser.cs | 6 +- .../Generated/Interfaces/ISteamUserStats.cs | 20 +- .../Generated/Interfaces/ISteamUtils.cs | 2 +- .../Generated/SteamConstants.cs | 1 + Facepunch.Steamworks/Generated/SteamEnums.cs | 1 + .../Generated/SteamStructs.cs | 7912 +++++++++++++---- Facepunch.Steamworks/Generated/SteamTypes.cs | 1 + Facepunch.Steamworks/SteamUtils.cs | 28 - Generator/CodeWriter/CodeWriter.cs | 1 + Generator/CodeWriter/Struct.cs | 60 +- Generator/CodeWriter/Types/BaseType.cs | 4 +- 21 files changed, 6293 insertions(+), 1873 deletions(-) rename Facepunch.Steamworks/Callbacks/{Events.cs => Event.cs} (100%) delete mode 100644 Facepunch.Steamworks/Callbacks/ISteamCallback.cs delete mode 100644 Facepunch.Steamworks/Callbacks/Result.cs diff --git a/Facepunch.Steamworks/Callbacks/Events.cs b/Facepunch.Steamworks/Callbacks/Event.cs similarity index 100% rename from Facepunch.Steamworks/Callbacks/Events.cs rename to Facepunch.Steamworks/Callbacks/Event.cs diff --git a/Facepunch.Steamworks/Callbacks/ISteamCallback.cs b/Facepunch.Steamworks/Callbacks/ISteamCallback.cs deleted file mode 100644 index 33e296a..0000000 --- a/Facepunch.Steamworks/Callbacks/ISteamCallback.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Steamworks -{ - public interface ISteamCallback - { - int GetCallbackId(); - int GetStructSize(); - ISteamCallback Fill( IntPtr ptr ); - } -} \ No newline at end of file diff --git a/Facepunch.Steamworks/Callbacks/Result.cs b/Facepunch.Steamworks/Callbacks/Result.cs deleted file mode 100644 index e25f8a3..0000000 --- a/Facepunch.Steamworks/Callbacks/Result.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace Steamworks -{ - /// - /// Results are Steam Callbacks that are direct responses to function calls - /// - public struct Result where T : struct, ISteamCallback - { - public ulong CallHandle; - - public Result( ulong callbackHandle ) - { - CallHandle = callbackHandle; - } - - public bool IsComplete( out bool failed ) - { - return SteamUtils.IsCallComplete( CallHandle, out failed ); - } - - public async Task GetResult() - { - bool failed = false; - - while ( !IsComplete( out failed ) ) - { - await Task.Delay( 1 ); - } - - if ( failed ) - return null; - - return SteamUtils.GetResult( CallHandle ); - } - } -} \ No newline at end of file diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs index cc553cf..73f8171 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs @@ -352,7 +352,7 @@ internal void RequestAllProofOfPurchaseKeys() #endregion internal async Task GetFileDetails( string pszFileName ) { - return await (new Result( _GetFileDetails( Self, pszFileName ) )).GetResult(); + return await FileDetailsResult_t.GetResultAsync( _GetFileDetails( Self, pszFileName ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs index cae65e0..1ec2f66 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs @@ -118,7 +118,7 @@ internal string GetPersonaName() #endregion internal async Task SetPersonaName( string pchPersonaName ) { - return await (new Result( _SetPersonaName( Self, pchPersonaName ) )).GetResult(); + return await SetPersonaNameResponse_t.GetResultAsync( _SetPersonaName( Self, pchPersonaName ) ); } #region FunctionMeta @@ -381,7 +381,7 @@ internal bool GetClanActivityCounts( SteamId steamIDClan, ref int pnOnline, ref #endregion internal async Task DownloadClanActivityCounts( [In,Out] SteamId[] psteamIDClans, int cClansToRequest ) { - return await (new Result( _DownloadClanActivityCounts( Self, psteamIDClans, cClansToRequest ) )).GetResult(); + return await DownloadClanActivityCountsResult_t.GetResultAsync( _DownloadClanActivityCounts( Self, psteamIDClans, cClansToRequest ) ); } #region FunctionMeta @@ -557,7 +557,7 @@ internal bool RequestUserInformation( SteamId steamIDUser, [MarshalAs( Unmanaged #endregion internal async Task RequestClanOfficerList( SteamId steamIDClan ) { - return await (new Result( _RequestClanOfficerList( Self, steamIDClan ) )).GetResult(); + return await ClanOfficerListResponse_t.GetResultAsync( _RequestClanOfficerList( Self, steamIDClan ) ); } #region FunctionMeta @@ -762,7 +762,7 @@ internal AppId GetFriendCoplayGame( SteamId steamIDFriend ) #endregion internal async Task JoinClanChatRoom( SteamId steamIDClan ) { - return await (new Result( _JoinClanChatRoom( Self, steamIDClan ) )).GetResult(); + return await JoinClanChatRoomCompletionResult_t.GetResultAsync( _JoinClanChatRoom( Self, steamIDClan ) ); } #region FunctionMeta @@ -922,7 +922,7 @@ internal int GetFriendMessage( SteamId steamIDFriend, int iMessageID, IntPtr pvD #endregion internal async Task GetFollowerCount( SteamId steamID ) { - return await (new Result( _GetFollowerCount( Self, steamID ) )).GetResult(); + return await FriendsGetFollowerCount_t.GetResultAsync( _GetFollowerCount( Self, steamID ) ); } #region FunctionMeta @@ -933,7 +933,7 @@ internal int GetFriendMessage( SteamId steamIDFriend, int iMessageID, IntPtr pvD #endregion internal async Task IsFollowing( SteamId steamID ) { - return await (new Result( _IsFollowing( Self, steamID ) )).GetResult(); + return await FriendsIsFollowing_t.GetResultAsync( _IsFollowing( Self, steamID ) ); } #region FunctionMeta @@ -944,7 +944,7 @@ internal int GetFriendMessage( SteamId steamIDFriend, int iMessageID, IntPtr pvD #endregion internal async Task EnumerateFollowingList( uint unStartIndex ) { - return await (new Result( _EnumerateFollowingList( Self, unStartIndex ) )).GetResult(); + return await FriendsEnumerateFollowingList_t.GetResultAsync( _EnumerateFollowingList( Self, unStartIndex ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs index 1df0c81..3833745 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs @@ -483,7 +483,7 @@ internal void GetGameplayStats() #endregion internal async Task GetServerReputation() { - return await (new Result( _GetServerReputation( Self ) )).GetResult(); + return await GSReputation_t.GetResultAsync( _GetServerReputation( Self ) ); } #region FunctionMeta @@ -561,7 +561,7 @@ internal void ForceHeartbeat() #endregion internal async Task AssociateWithClan( SteamId steamIDClan ) { - return await (new Result( _AssociateWithClan( Self, steamIDClan ) )).GetResult(); + return await AssociateWithClanResult_t.GetResultAsync( _AssociateWithClan( Self, steamIDClan ) ); } #region FunctionMeta @@ -572,7 +572,7 @@ internal void ForceHeartbeat() #endregion internal async Task ComputeNewPlayerCompatibility( SteamId steamIDNewPlayer ) { - return await (new Result( _ComputeNewPlayerCompatibility( Self, steamIDNewPlayer ) )).GetResult(); + return await ComputeNewPlayerCompatibilityResult_t.GetResultAsync( _ComputeNewPlayerCompatibility( Self, steamIDNewPlayer ) ); } } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs index f1551ae..a465e07 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs @@ -336,7 +336,7 @@ internal bool GetItemDefinitionProperty( InventoryDefId iDefinition, string pchP #endregion internal async Task RequestEligiblePromoItemDefinitionsIDs( SteamId steamID ) { - return await (new Result( _RequestEligiblePromoItemDefinitionsIDs( Self, steamID ) )).GetResult(); + return await SteamInventoryEligiblePromoItemDefIDs_t.GetResultAsync( _RequestEligiblePromoItemDefinitionsIDs( Self, steamID ) ); } #region FunctionMeta @@ -359,7 +359,7 @@ internal bool GetEligiblePromoItemDefinitionIDs( SteamId steamID, [In,Out] Inven #endregion internal async Task StartPurchase( [In,Out] InventoryDefId[] pArrayItemDefs, [In,Out] uint[] punArrayQuantity, uint unArrayLength ) { - return await (new Result( _StartPurchase( Self, pArrayItemDefs, punArrayQuantity, unArrayLength ) )).GetResult(); + return await SteamInventoryStartPurchaseResult_t.GetResultAsync( _StartPurchase( Self, pArrayItemDefs, punArrayQuantity, unArrayLength ) ); } #region FunctionMeta @@ -370,7 +370,7 @@ internal bool GetEligiblePromoItemDefinitionIDs( SteamId steamID, [In,Out] Inven #endregion internal async Task RequestPrices() { - return await (new Result( _RequestPrices( Self ) )).GetResult(); + return await SteamInventoryRequestPricesResult_t.GetResultAsync( _RequestPrices( Self ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs index 4d89041..58a65d5 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs @@ -121,7 +121,7 @@ internal void ReleaseRequest( HServerListRequest hServerListRequest ) #endregion internal gameserveritem_t GetServerDetails( HServerListRequest hRequest, int iServer ) { - return new gameserveritem_t().Fill( _GetServerDetails( Self, hRequest, iServer ) ); + return gameserveritem_t.Fill( _GetServerDetails( Self, hRequest, iServer ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs index 606a230..c48783f 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs @@ -104,7 +104,7 @@ internal int FileRead( string pchFile, IntPtr pvData, int cubDataToRead ) #endregion internal async Task FileWriteAsync( string pchFile, IntPtr pvData, uint cubData ) { - return await (new Result( _FileWriteAsync( Self, pchFile, pvData, cubData ) )).GetResult(); + return await RemoteStorageFileWriteAsyncComplete_t.GetResultAsync( _FileWriteAsync( Self, pchFile, pvData, cubData ) ); } #region FunctionMeta @@ -115,7 +115,7 @@ internal int FileRead( string pchFile, IntPtr pvData, int cubDataToRead ) #endregion internal async Task FileReadAsync( string pchFile, uint nOffset, uint cubToRead ) { - return await (new Result( _FileReadAsync( Self, pchFile, nOffset, cubToRead ) )).GetResult(); + return await RemoteStorageFileReadAsyncComplete_t.GetResultAsync( _FileReadAsync( Self, pchFile, nOffset, cubToRead ) ); } #region FunctionMeta @@ -162,7 +162,7 @@ internal bool FileDelete( string pchFile ) #endregion internal async Task FileShare( string pchFile ) { - return await (new Result( _FileShare( Self, pchFile ) )).GetResult(); + return await RemoteStorageFileShareResult_t.GetResultAsync( _FileShare( Self, pchFile ) ); } #region FunctionMeta @@ -358,7 +358,7 @@ internal void SetCloudEnabledForApp( [MarshalAs( UnmanagedType.U1 )] bool bEnabl #endregion internal async Task UGCDownload( UGCHandle_t hContent, uint unPriority ) { - return await (new Result( _UGCDownload( Self, hContent, unPriority ) )).GetResult(); + return await RemoteStorageDownloadUGCResult_t.GetResultAsync( _UGCDownload( Self, hContent, unPriority ) ); } #region FunctionMeta @@ -415,7 +415,7 @@ internal int GetCachedUGCCount() #endregion internal async Task UGCDownloadToLocation( UGCHandle_t hContent, string pchLocation, uint unPriority ) { - return await (new Result( _UGCDownloadToLocation( Self, hContent, pchLocation, unPriority ) )).GetResult(); + return await RemoteStorageDownloadUGCResult_t.GetResultAsync( _UGCDownloadToLocation( Self, hContent, pchLocation, unPriority ) ); } } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs index 15ea52a..7c6cef3 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs @@ -147,7 +147,7 @@ internal UGCQueryHandle_t CreateQueryUGCDetailsRequest( [In,Out] PublishedFileId #endregion internal async Task SendQueryUGCRequest( UGCQueryHandle_t handle ) { - return await (new Result( _SendQueryUGCRequest( Self, handle ) )).GetResult(); + return await SteamUGCQueryCompleted_t.GetResultAsync( _SendQueryUGCRequest( Self, handle ) ); } #region FunctionMeta @@ -480,7 +480,7 @@ internal bool AddRequiredKeyValueTag( UGCQueryHandle_t handle, string pKey, stri #endregion internal async Task RequestUGCDetails( PublishedFileId nPublishedFileID, uint unMaxAgeSeconds ) { - return await (new Result( _RequestUGCDetails( Self, nPublishedFileID, unMaxAgeSeconds ) )).GetResult(); + return await SteamUGCRequestUGCDetailsResult_t.GetResultAsync( _RequestUGCDetails( Self, nPublishedFileID, unMaxAgeSeconds ) ); } #region FunctionMeta @@ -491,7 +491,7 @@ internal bool AddRequiredKeyValueTag( UGCQueryHandle_t handle, string pKey, stri #endregion internal async Task CreateItem( AppId nConsumerAppId, WorkshopFileType eFileType ) { - return await (new Result( _CreateItem( Self, nConsumerAppId, eFileType ) )).GetResult(); + return await CreateItemResult_t.GetResultAsync( _CreateItem( Self, nConsumerAppId, eFileType ) ); } #region FunctionMeta @@ -705,7 +705,7 @@ internal bool RemoveItemPreview( UGCUpdateHandle_t handle, uint index ) #endregion internal async Task SubmitItemUpdate( UGCUpdateHandle_t handle, string pchChangeNote ) { - return await (new Result( _SubmitItemUpdate( Self, handle, pchChangeNote ) )).GetResult(); + return await SubmitItemUpdateResult_t.GetResultAsync( _SubmitItemUpdate( Self, handle, pchChangeNote ) ); } #region FunctionMeta @@ -727,7 +727,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task SetUserItemVote( PublishedFileId nPublishedFileID, [MarshalAs( UnmanagedType.U1 )] bool bVoteUp ) { - return await (new Result( _SetUserItemVote( Self, nPublishedFileID, bVoteUp ) )).GetResult(); + return await SetUserItemVoteResult_t.GetResultAsync( _SetUserItemVote( Self, nPublishedFileID, bVoteUp ) ); } #region FunctionMeta @@ -738,7 +738,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task GetUserItemVote( PublishedFileId nPublishedFileID ) { - return await (new Result( _GetUserItemVote( Self, nPublishedFileID ) )).GetResult(); + return await GetUserItemVoteResult_t.GetResultAsync( _GetUserItemVote( Self, nPublishedFileID ) ); } #region FunctionMeta @@ -749,7 +749,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task AddItemToFavorites( AppId nAppId, PublishedFileId nPublishedFileID ) { - return await (new Result( _AddItemToFavorites( Self, nAppId, nPublishedFileID ) )).GetResult(); + return await UserFavoriteItemsListChanged_t.GetResultAsync( _AddItemToFavorites( Self, nAppId, nPublishedFileID ) ); } #region FunctionMeta @@ -760,7 +760,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task RemoveItemFromFavorites( AppId nAppId, PublishedFileId nPublishedFileID ) { - return await (new Result( _RemoveItemFromFavorites( Self, nAppId, nPublishedFileID ) )).GetResult(); + return await UserFavoriteItemsListChanged_t.GetResultAsync( _RemoveItemFromFavorites( Self, nAppId, nPublishedFileID ) ); } #region FunctionMeta @@ -771,7 +771,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task SubscribeItem( PublishedFileId nPublishedFileID ) { - return await (new Result( _SubscribeItem( Self, nPublishedFileID ) )).GetResult(); + return await RemoteStorageSubscribePublishedFileResult_t.GetResultAsync( _SubscribeItem( Self, nPublishedFileID ) ); } #region FunctionMeta @@ -782,7 +782,7 @@ internal ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, ref u #endregion internal async Task UnsubscribeItem( PublishedFileId nPublishedFileID ) { - return await (new Result( _UnsubscribeItem( Self, nPublishedFileID ) )).GetResult(); + return await RemoteStorageUnsubscribePublishedFileResult_t.GetResultAsync( _UnsubscribeItem( Self, nPublishedFileID ) ); } #region FunctionMeta @@ -885,7 +885,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task StartPlaytimeTracking( [In,Out] PublishedFileId[] pvecPublishedFileID, uint unNumPublishedFileIDs ) { - return await (new Result( _StartPlaytimeTracking( Self, pvecPublishedFileID, unNumPublishedFileIDs ) )).GetResult(); + return await StartPlaytimeTrackingResult_t.GetResultAsync( _StartPlaytimeTracking( Self, pvecPublishedFileID, unNumPublishedFileIDs ) ); } #region FunctionMeta @@ -896,7 +896,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task StopPlaytimeTracking( [In,Out] PublishedFileId[] pvecPublishedFileID, uint unNumPublishedFileIDs ) { - return await (new Result( _StopPlaytimeTracking( Self, pvecPublishedFileID, unNumPublishedFileIDs ) )).GetResult(); + return await StopPlaytimeTrackingResult_t.GetResultAsync( _StopPlaytimeTracking( Self, pvecPublishedFileID, unNumPublishedFileIDs ) ); } #region FunctionMeta @@ -907,7 +907,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task StopPlaytimeTrackingForAllItems() { - return await (new Result( _StopPlaytimeTrackingForAllItems( Self ) )).GetResult(); + return await StopPlaytimeTrackingResult_t.GetResultAsync( _StopPlaytimeTrackingForAllItems( Self ) ); } #region FunctionMeta @@ -918,7 +918,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task AddDependency( PublishedFileId nParentPublishedFileID, PublishedFileId nChildPublishedFileID ) { - return await (new Result( _AddDependency( Self, nParentPublishedFileID, nChildPublishedFileID ) )).GetResult(); + return await AddUGCDependencyResult_t.GetResultAsync( _AddDependency( Self, nParentPublishedFileID, nChildPublishedFileID ) ); } #region FunctionMeta @@ -929,7 +929,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task RemoveDependency( PublishedFileId nParentPublishedFileID, PublishedFileId nChildPublishedFileID ) { - return await (new Result( _RemoveDependency( Self, nParentPublishedFileID, nChildPublishedFileID ) )).GetResult(); + return await RemoveUGCDependencyResult_t.GetResultAsync( _RemoveDependency( Self, nParentPublishedFileID, nChildPublishedFileID ) ); } #region FunctionMeta @@ -940,7 +940,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task AddAppDependency( PublishedFileId nPublishedFileID, AppId nAppID ) { - return await (new Result( _AddAppDependency( Self, nPublishedFileID, nAppID ) )).GetResult(); + return await AddAppDependencyResult_t.GetResultAsync( _AddAppDependency( Self, nPublishedFileID, nAppID ) ); } #region FunctionMeta @@ -951,7 +951,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task RemoveAppDependency( PublishedFileId nPublishedFileID, AppId nAppID ) { - return await (new Result( _RemoveAppDependency( Self, nPublishedFileID, nAppID ) )).GetResult(); + return await RemoveAppDependencyResult_t.GetResultAsync( _RemoveAppDependency( Self, nPublishedFileID, nAppID ) ); } #region FunctionMeta @@ -962,7 +962,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task GetAppDependencies( PublishedFileId nPublishedFileID ) { - return await (new Result( _GetAppDependencies( Self, nPublishedFileID ) )).GetResult(); + return await GetAppDependenciesResult_t.GetResultAsync( _GetAppDependencies( Self, nPublishedFileID ) ); } #region FunctionMeta @@ -973,7 +973,7 @@ internal void SuspendDownloads( [MarshalAs( UnmanagedType.U1 )] bool bSuspend ) #endregion internal async Task DeleteItem( PublishedFileId nPublishedFileID ) { - return await (new Result( _DeleteItem( Self, nPublishedFileID ) )).GetResult(); + return await DeleteItemResult_t.GetResultAsync( _DeleteItem( Self, nPublishedFileID ) ); } } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs index affd6eb..231a131 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs @@ -290,7 +290,7 @@ internal void AdvertiseGame( SteamId steamIDGameServer, uint unIPServer, ushort #endregion internal async Task RequestEncryptedAppTicket( IntPtr pDataToInclude, int cbDataToInclude ) { - return await (new Result( _RequestEncryptedAppTicket( Self, pDataToInclude, cbDataToInclude ) )).GetResult(); + return await EncryptedAppTicketResponse_t.GetResultAsync( _RequestEncryptedAppTicket( Self, pDataToInclude, cbDataToInclude ) ); } #region FunctionMeta @@ -335,7 +335,7 @@ internal int GetPlayerSteamLevel() #endregion internal async Task RequestStoreAuthURL( string pchRedirectURL ) { - return await (new Result( _RequestStoreAuthURL( Self, pchRedirectURL ) )).GetResult(); + return await StoreAuthURLResponse_t.GetResultAsync( _RequestStoreAuthURL( Self, pchRedirectURL ) ); } #region FunctionMeta @@ -394,7 +394,7 @@ internal bool BIsPhoneRequiringVerification() #endregion internal async Task GetMarketEligibility() { - return await (new Result( _GetMarketEligibility( Self ) )).GetResult(); + return await MarketEligibilityResponse_t.GetResultAsync( _GetMarketEligibility( Self ) ); } } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs index 9cc996f..33b9d77 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs @@ -258,7 +258,7 @@ internal string GetAchievementName( uint iAchievement ) #endregion internal async Task RequestUserStats( SteamId steamIDUser ) { - return await (new Result( _RequestUserStats( Self, steamIDUser ) )).GetResult(); + return await UserStatsReceived_t.GetResultAsync( _RequestUserStats( Self, steamIDUser ) ); } #region FunctionMeta @@ -329,7 +329,7 @@ internal bool ResetAllStats( [MarshalAs( UnmanagedType.U1 )] bool bAchievementsT #endregion internal async Task FindOrCreateLeaderboard( string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType ) { - return await (new Result( _FindOrCreateLeaderboard( Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ) )).GetResult(); + return await LeaderboardFindResult_t.GetResultAsync( _FindOrCreateLeaderboard( Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ) ); } #region FunctionMeta @@ -340,7 +340,7 @@ internal bool ResetAllStats( [MarshalAs( UnmanagedType.U1 )] bool bAchievementsT #endregion internal async Task FindLeaderboard( string pchLeaderboardName ) { - return await (new Result( _FindLeaderboard( Self, pchLeaderboardName ) )).GetResult(); + return await LeaderboardFindResult_t.GetResultAsync( _FindLeaderboard( Self, pchLeaderboardName ) ); } #region FunctionMeta @@ -395,7 +395,7 @@ internal LeaderboardDisplay GetLeaderboardDisplayType( SteamLeaderboard_t hSteam #endregion internal async Task DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, LeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd ) { - return await (new Result( _DownloadLeaderboardEntries( Self, hSteamLeaderboard, eLeaderboardDataRequest, nRangeStart, nRangeEnd ) )).GetResult(); + return await LeaderboardScoresDownloaded_t.GetResultAsync( _DownloadLeaderboardEntries( Self, hSteamLeaderboard, eLeaderboardDataRequest, nRangeStart, nRangeEnd ) ); } #region FunctionMeta @@ -406,7 +406,7 @@ internal LeaderboardDisplay GetLeaderboardDisplayType( SteamLeaderboard_t hSteam #endregion internal async Task DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard, [In,Out] SteamId[] prgUsers, int cUsers ) { - return await (new Result( _DownloadLeaderboardEntriesForUsers( Self, hSteamLeaderboard, prgUsers, cUsers ) )).GetResult(); + return await LeaderboardScoresDownloaded_t.GetResultAsync( _DownloadLeaderboardEntriesForUsers( Self, hSteamLeaderboard, prgUsers, cUsers ) ); } #region FunctionMeta @@ -429,7 +429,7 @@ internal bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLea #endregion internal async Task UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int nScore, [In,Out] int[] pScoreDetails, int cScoreDetailsCount ) { - return await (new Result( _UploadLeaderboardScore( Self, hSteamLeaderboard, eLeaderboardUploadScoreMethod, nScore, pScoreDetails, cScoreDetailsCount ) )).GetResult(); + return await LeaderboardScoreUploaded_t.GetResultAsync( _UploadLeaderboardScore( Self, hSteamLeaderboard, eLeaderboardUploadScoreMethod, nScore, pScoreDetails, cScoreDetailsCount ) ); } #region FunctionMeta @@ -440,7 +440,7 @@ internal bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLea #endregion internal async Task AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC ) { - return await (new Result( _AttachLeaderboardUGC( Self, hSteamLeaderboard, hUGC ) )).GetResult(); + return await LeaderboardUGCSet_t.GetResultAsync( _AttachLeaderboardUGC( Self, hSteamLeaderboard, hUGC ) ); } #region FunctionMeta @@ -451,7 +451,7 @@ internal bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLea #endregion internal async Task GetNumberOfCurrentPlayers() { - return await (new Result( _GetNumberOfCurrentPlayers( Self ) )).GetResult(); + return await NumberOfCurrentPlayers_t.GetResultAsync( _GetNumberOfCurrentPlayers( Self ) ); } #region FunctionMeta @@ -462,7 +462,7 @@ internal bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLea #endregion internal async Task RequestGlobalAchievementPercentages() { - return await (new Result( _RequestGlobalAchievementPercentages( Self ) )).GetResult(); + return await GlobalAchievementPercentagesReady_t.GetResultAsync( _RequestGlobalAchievementPercentages( Self ) ); } #region FunctionMeta @@ -507,7 +507,7 @@ internal bool GetAchievementAchievedPercent( string pchName, ref float pflPercen #endregion internal async Task RequestGlobalStats( int nHistoryDays ) { - return await (new Result( _RequestGlobalStats( Self, nHistoryDays ) )).GetResult(); + return await GlobalStatsReceived_t.GetResultAsync( _RequestGlobalStats( Self, nHistoryDays ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs index 56a3bc2..005d0de 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs @@ -273,7 +273,7 @@ internal bool BOverlayNeedsPresent() #endregion internal async Task CheckFileSignature( string szFileName ) { - return await (new Result( _CheckFileSignature( Self, szFileName ) )).GetResult(); + return await CheckFileSignature_t.GetResultAsync( _CheckFileSignature( Self, szFileName ) ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/SteamConstants.cs b/Facepunch.Steamworks/Generated/SteamConstants.cs index 7042556..35c3b45 100644 --- a/Facepunch.Steamworks/Generated/SteamConstants.cs +++ b/Facepunch.Steamworks/Generated/SteamConstants.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Linq; using Steamworks.Data; +using System.Threading.Tasks; namespace Steamworks.Data { diff --git a/Facepunch.Steamworks/Generated/SteamEnums.cs b/Facepunch.Steamworks/Generated/SteamEnums.cs index 4383f57..69b336e 100644 --- a/Facepunch.Steamworks/Generated/SteamEnums.cs +++ b/Facepunch.Steamworks/Generated/SteamEnums.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Linq; using Steamworks.Data; +using System.Threading.Tasks; namespace Steamworks { diff --git a/Facepunch.Steamworks/Generated/SteamStructs.cs b/Facepunch.Steamworks/Generated/SteamStructs.cs index 724899b..2801a14 100644 --- a/Facepunch.Steamworks/Generated/SteamStructs.cs +++ b/Facepunch.Steamworks/Generated/SteamStructs.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Linq; using Steamworks.Data; +using System.Threading.Tasks; namespace Steamworks.Data { @@ -14,8 +15,7 @@ internal struct CallbackMsg_t internal int ParamCount; // m_cubParam int #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CallbackMsg_t) : typeof(Pack8) ); - public CallbackMsg_t Fill( IntPtr p ) => Config.PackSmall ? ((CallbackMsg_t)(CallbackMsg_t) Marshal.PtrToStructure( p, typeof(CallbackMsg_t) )) : ((CallbackMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static CallbackMsg_t Fill( IntPtr p ) => Config.PackSmall ? ((CallbackMsg_t)(CallbackMsg_t) Marshal.PtrToStructure( p, typeof(CallbackMsg_t) )) : ((CallbackMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -33,33 +33,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamServerConnectFailure_t : Steamworks.ISteamCallback + internal struct SteamServerConnectFailure_t { internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool StillRetrying; // m_bStillRetrying _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServerConnectFailure_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamServerConnectFailure_t)(SteamServerConnectFailure_t) Marshal.PtrToStructure( p, typeof(SteamServerConnectFailure_t) )) : ((SteamServerConnectFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServerConnectFailure_t) : typeof(Pack8) ); + internal static SteamServerConnectFailure_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamServerConnectFailure_t)(SteamServerConnectFailure_t) Marshal.PtrToStructure( p, typeof(SteamServerConnectFailure_t) )) : ((SteamServerConnectFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamServerConnectFailure_t)default(SteamServerConnectFailure_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamServerConnectFailure_t)default(SteamServerConnectFailure_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamServerConnectFailure_t).GetStructSize(), CallbackIdentifiers.SteamUser + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamServerConnectFailure_t).GetStructSize(), CallbackIdentifiers.SteamUser + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -76,31 +100,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamServersDisconnected_t : Steamworks.ISteamCallback + internal struct SteamServersDisconnected_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServersDisconnected_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamServersDisconnected_t)(SteamServersDisconnected_t) Marshal.PtrToStructure( p, typeof(SteamServersDisconnected_t) )) : ((SteamServersDisconnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServersDisconnected_t) : typeof(Pack8) ); + internal static SteamServersDisconnected_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamServersDisconnected_t)(SteamServersDisconnected_t) Marshal.PtrToStructure( p, typeof(SteamServersDisconnected_t) )) : ((SteamServersDisconnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamServersDisconnected_t)default(SteamServersDisconnected_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamServersDisconnected_t)default(SteamServersDisconnected_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamServersDisconnected_t).GetStructSize(), CallbackIdentifiers.SteamUser + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamServersDisconnected_t).GetStructSize(), CallbackIdentifiers.SteamUser + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -115,7 +163,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ClientGameServerDeny_t : Steamworks.ISteamCallback + internal struct ClientGameServerDeny_t { internal uint AppID; // m_uAppID uint32 internal uint GameServerIP; // m_unGameServerIP uint32 @@ -123,27 +171,51 @@ internal struct ClientGameServerDeny_t : Steamworks.ISteamCallback internal ushort Secure; // m_bSecure uint16 internal uint Reason; // m_uReason uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ClientGameServerDeny_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((ClientGameServerDeny_t)(ClientGameServerDeny_t) Marshal.PtrToStructure( p, typeof(ClientGameServerDeny_t) )) : ((ClientGameServerDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ClientGameServerDeny_t) : typeof(Pack8) ); + internal static ClientGameServerDeny_t Fill( IntPtr p ) => Config.PackSmall ? ((ClientGameServerDeny_t)(ClientGameServerDeny_t) Marshal.PtrToStructure( p, typeof(ClientGameServerDeny_t) )) : ((ClientGameServerDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ClientGameServerDeny_t)default(ClientGameServerDeny_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ClientGameServerDeny_t)default(ClientGameServerDeny_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ClientGameServerDeny_t).GetStructSize(), CallbackIdentifiers.SteamUser + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(ClientGameServerDeny_t).GetStructSize(), CallbackIdentifiers.SteamUser + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -162,64 +234,112 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ValidateAuthTicketResponse_t : Steamworks.ISteamCallback + internal struct ValidateAuthTicketResponse_t { internal ulong SteamID; // m_SteamID class CSteamID internal AuthResponse AuthSessionResponse; // m_eAuthSessionResponse enum EAuthSessionResponse internal ulong OwnerSteamID; // m_OwnerSteamID class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 43; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(ValidateAuthTicketResponse_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((ValidateAuthTicketResponse_t)(ValidateAuthTicketResponse_t) Marshal.PtrToStructure( p, typeof(ValidateAuthTicketResponse_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(ValidateAuthTicketResponse_t) ); + internal static ValidateAuthTicketResponse_t Fill( IntPtr p ) => ((ValidateAuthTicketResponse_t)(ValidateAuthTicketResponse_t) Marshal.PtrToStructure( p, typeof(ValidateAuthTicketResponse_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ValidateAuthTicketResponse_t)default(ValidateAuthTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ValidateAuthTicketResponse_t)default(ValidateAuthTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ValidateAuthTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 43, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 43, true ); actionServer = action; } else { - Event.Register( OnClient, default(ValidateAuthTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 43, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 43, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 43, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MicroTxnAuthorizationResponse_t : Steamworks.ISteamCallback + internal struct MicroTxnAuthorizationResponse_t { internal uint AppID; // m_unAppID uint32 internal ulong OrderID; // m_ulOrderID uint64 internal byte Authorized; // m_bAuthorized uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 52; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MicroTxnAuthorizationResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MicroTxnAuthorizationResponse_t)(MicroTxnAuthorizationResponse_t) Marshal.PtrToStructure( p, typeof(MicroTxnAuthorizationResponse_t) )) : ((MicroTxnAuthorizationResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MicroTxnAuthorizationResponse_t) : typeof(Pack8) ); + internal static MicroTxnAuthorizationResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((MicroTxnAuthorizationResponse_t)(MicroTxnAuthorizationResponse_t) Marshal.PtrToStructure( p, typeof(MicroTxnAuthorizationResponse_t) )) : ((MicroTxnAuthorizationResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MicroTxnAuthorizationResponse_t)default(MicroTxnAuthorizationResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MicroTxnAuthorizationResponse_t)default(MicroTxnAuthorizationResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MicroTxnAuthorizationResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 52, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 52, true ); actionServer = action; } else { - Event.Register( OnClient, default(MicroTxnAuthorizationResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 52, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 52, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 52, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -236,31 +356,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct EncryptedAppTicketResponse_t : Steamworks.ISteamCallback + internal struct EncryptedAppTicketResponse_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 54; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(EncryptedAppTicketResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((EncryptedAppTicketResponse_t)(EncryptedAppTicketResponse_t) Marshal.PtrToStructure( p, typeof(EncryptedAppTicketResponse_t) )) : ((EncryptedAppTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(EncryptedAppTicketResponse_t) : typeof(Pack8) ); + internal static EncryptedAppTicketResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((EncryptedAppTicketResponse_t)(EncryptedAppTicketResponse_t) Marshal.PtrToStructure( p, typeof(EncryptedAppTicketResponse_t) )) : ((EncryptedAppTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (EncryptedAppTicketResponse_t)default(EncryptedAppTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (EncryptedAppTicketResponse_t)default(EncryptedAppTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(EncryptedAppTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 54, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 54, true ); actionServer = action; } else { - Event.Register( OnClient, default(EncryptedAppTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 54, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 54, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 54, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -275,32 +419,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GetAuthSessionTicketResponse_t : Steamworks.ISteamCallback + internal struct GetAuthSessionTicketResponse_t { internal uint AuthTicket; // m_hAuthTicket HAuthTicket internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 63; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetAuthSessionTicketResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GetAuthSessionTicketResponse_t)(GetAuthSessionTicketResponse_t) Marshal.PtrToStructure( p, typeof(GetAuthSessionTicketResponse_t) )) : ((GetAuthSessionTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetAuthSessionTicketResponse_t) : typeof(Pack8) ); + internal static GetAuthSessionTicketResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((GetAuthSessionTicketResponse_t)(GetAuthSessionTicketResponse_t) Marshal.PtrToStructure( p, typeof(GetAuthSessionTicketResponse_t) )) : ((GetAuthSessionTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GetAuthSessionTicketResponse_t)default(GetAuthSessionTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GetAuthSessionTicketResponse_t)default(GetAuthSessionTicketResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GetAuthSessionTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 63, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 63, true ); actionServer = action; } else { - Event.Register( OnClient, default(GetAuthSessionTicketResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 63, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 63, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 63, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -316,32 +484,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameWebCallback_t : Steamworks.ISteamCallback + internal struct GameWebCallback_t { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string URL; // m_szURL char [256] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 64; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameWebCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GameWebCallback_t)(GameWebCallback_t) Marshal.PtrToStructure( p, typeof(GameWebCallback_t) )) : ((GameWebCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameWebCallback_t) : typeof(Pack8) ); + internal static GameWebCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((GameWebCallback_t)(GameWebCallback_t) Marshal.PtrToStructure( p, typeof(GameWebCallback_t) )) : ((GameWebCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameWebCallback_t)default(GameWebCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameWebCallback_t)default(GameWebCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameWebCallback_t).GetStructSize(), CallbackIdentifiers.SteamUser + 64, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 64, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameWebCallback_t).GetStructSize(), CallbackIdentifiers.SteamUser + 64, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 64, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 64, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -357,32 +549,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct StoreAuthURLResponse_t : Steamworks.ISteamCallback + internal struct StoreAuthURLResponse_t { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] internal string URL; // m_szURL char [512] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 65; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StoreAuthURLResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((StoreAuthURLResponse_t)(StoreAuthURLResponse_t) Marshal.PtrToStructure( p, typeof(StoreAuthURLResponse_t) )) : ((StoreAuthURLResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StoreAuthURLResponse_t) : typeof(Pack8) ); + internal static StoreAuthURLResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((StoreAuthURLResponse_t)(StoreAuthURLResponse_t) Marshal.PtrToStructure( p, typeof(StoreAuthURLResponse_t) )) : ((StoreAuthURLResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (StoreAuthURLResponse_t)default(StoreAuthURLResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (StoreAuthURLResponse_t)default(StoreAuthURLResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(StoreAuthURLResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 65, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 65, true ); actionServer = action; } else { - Event.Register( OnClient, default(StoreAuthURLResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 65, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 65, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 65, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -398,7 +614,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MarketEligibilityResponse_t : Steamworks.ISteamCallback + internal struct MarketEligibilityResponse_t { [MarshalAs(UnmanagedType.I1)] internal bool Allowed; // m_bAllowed _Bool @@ -407,27 +623,51 @@ internal struct MarketEligibilityResponse_t : Steamworks.ISteamCallback internal int CdaySteamGuardRequiredDays; // m_cdaySteamGuardRequiredDays int internal int CdayNewDeviceCooldown; // m_cdayNewDeviceCooldown int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 66; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MarketEligibilityResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MarketEligibilityResponse_t)(MarketEligibilityResponse_t) Marshal.PtrToStructure( p, typeof(MarketEligibilityResponse_t) )) : ((MarketEligibilityResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MarketEligibilityResponse_t) : typeof(Pack8) ); + internal static MarketEligibilityResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((MarketEligibilityResponse_t)(MarketEligibilityResponse_t) Marshal.PtrToStructure( p, typeof(MarketEligibilityResponse_t) )) : ((MarketEligibilityResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MarketEligibilityResponse_t)default(MarketEligibilityResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MarketEligibilityResponse_t)default(MarketEligibilityResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MarketEligibilityResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 66, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 66, true ); actionServer = action; } else { - Event.Register( OnClient, default(MarketEligibilityResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 66, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 66, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 66, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -456,8 +696,7 @@ internal struct FriendGameInfo_t internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendGameInfo_t) ); - public FriendGameInfo_t Fill( IntPtr p ) => ((FriendGameInfo_t)(FriendGameInfo_t) Marshal.PtrToStructure( p, typeof(FriendGameInfo_t) ) ); + internal static FriendGameInfo_t Fill( IntPtr p ) => ((FriendGameInfo_t)(FriendGameInfo_t) Marshal.PtrToStructure( p, typeof(FriendGameInfo_t) ) ); #endregion } @@ -468,8 +707,7 @@ internal struct FriendSessionStateInfo_t internal byte IPublishedToFriendsSessionInstance; // m_uiPublishedToFriendsSessionInstance uint8 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FriendSessionStateInfo_t) : typeof(Pack8) ); - public FriendSessionStateInfo_t Fill( IntPtr p ) => Config.PackSmall ? ((FriendSessionStateInfo_t)(FriendSessionStateInfo_t) Marshal.PtrToStructure( p, typeof(FriendSessionStateInfo_t) )) : ((FriendSessionStateInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static FriendSessionStateInfo_t Fill( IntPtr p ) => Config.PackSmall ? ((FriendSessionStateInfo_t)(FriendSessionStateInfo_t) Marshal.PtrToStructure( p, typeof(FriendSessionStateInfo_t) )) : ((FriendSessionStateInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -485,32 +723,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FriendStateChange_t : Steamworks.ISteamCallback + internal struct FriendStateChange_t { internal ulong SteamID; // m_ulSteamID uint64 internal int ChangeFlags; // m_nChangeFlags int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FriendStateChange_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((FriendStateChange_t)(FriendStateChange_t) Marshal.PtrToStructure( p, typeof(FriendStateChange_t) )) : ((FriendStateChange_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FriendStateChange_t) : typeof(Pack8) ); + internal static FriendStateChange_t Fill( IntPtr p ) => Config.PackSmall ? ((FriendStateChange_t)(FriendStateChange_t) Marshal.PtrToStructure( p, typeof(FriendStateChange_t) )) : ((FriendStateChange_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FriendStateChange_t)default(FriendStateChange_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FriendStateChange_t)default(FriendStateChange_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FriendStateChange_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(FriendStateChange_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -526,31 +788,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameOverlayActivated_t : Steamworks.ISteamCallback + internal struct GameOverlayActivated_t { internal byte Active; // m_bActive uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 31; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameOverlayActivated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GameOverlayActivated_t)(GameOverlayActivated_t) Marshal.PtrToStructure( p, typeof(GameOverlayActivated_t) )) : ((GameOverlayActivated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameOverlayActivated_t) : typeof(Pack8) ); + internal static GameOverlayActivated_t Fill( IntPtr p ) => Config.PackSmall ? ((GameOverlayActivated_t)(GameOverlayActivated_t) Marshal.PtrToStructure( p, typeof(GameOverlayActivated_t) )) : ((GameOverlayActivated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameOverlayActivated_t)default(GameOverlayActivated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameOverlayActivated_t)default(GameOverlayActivated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameOverlayActivated_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 31, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 31, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameOverlayActivated_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 31, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 31, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 31, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -565,34 +851,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameServerChangeRequested_t : Steamworks.ISteamCallback + internal struct GameServerChangeRequested_t { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] internal string Server; // m_rgchServer char [64] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] internal string Password; // m_rgchPassword char [64] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 32; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameServerChangeRequested_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GameServerChangeRequested_t)(GameServerChangeRequested_t) Marshal.PtrToStructure( p, typeof(GameServerChangeRequested_t) )) : ((GameServerChangeRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GameServerChangeRequested_t) : typeof(Pack8) ); + internal static GameServerChangeRequested_t Fill( IntPtr p ) => Config.PackSmall ? ((GameServerChangeRequested_t)(GameServerChangeRequested_t) Marshal.PtrToStructure( p, typeof(GameServerChangeRequested_t) )) : ((GameServerChangeRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameServerChangeRequested_t)default(GameServerChangeRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameServerChangeRequested_t)default(GameServerChangeRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameServerChangeRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 32, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 32, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameServerChangeRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 32, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 32, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 32, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -610,222 +920,390 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameLobbyJoinRequested_t : Steamworks.ISteamCallback + internal struct GameLobbyJoinRequested_t { internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 33; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameLobbyJoinRequested_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameLobbyJoinRequested_t)(GameLobbyJoinRequested_t) Marshal.PtrToStructure( p, typeof(GameLobbyJoinRequested_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameLobbyJoinRequested_t) ); + internal static GameLobbyJoinRequested_t Fill( IntPtr p ) => ((GameLobbyJoinRequested_t)(GameLobbyJoinRequested_t) Marshal.PtrToStructure( p, typeof(GameLobbyJoinRequested_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameLobbyJoinRequested_t)default(GameLobbyJoinRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameLobbyJoinRequested_t)default(GameLobbyJoinRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameLobbyJoinRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 33, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 33, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameLobbyJoinRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 33, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 33, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 33, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct AvatarImageLoaded_t : Steamworks.ISteamCallback + internal struct AvatarImageLoaded_t { internal ulong SteamID; // m_steamID class CSteamID internal int Image; // m_iImage int internal int Wide; // m_iWide int internal int Tall; // m_iTall int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 34; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(AvatarImageLoaded_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((AvatarImageLoaded_t)(AvatarImageLoaded_t) Marshal.PtrToStructure( p, typeof(AvatarImageLoaded_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(AvatarImageLoaded_t) ); + internal static AvatarImageLoaded_t Fill( IntPtr p ) => ((AvatarImageLoaded_t)(AvatarImageLoaded_t) Marshal.PtrToStructure( p, typeof(AvatarImageLoaded_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (AvatarImageLoaded_t)default(AvatarImageLoaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (AvatarImageLoaded_t)default(AvatarImageLoaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(AvatarImageLoaded_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 34, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 34, true ); actionServer = action; } else { - Event.Register( OnClient, default(AvatarImageLoaded_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 34, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 34, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 34, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ClanOfficerListResponse_t : Steamworks.ISteamCallback + internal struct ClanOfficerListResponse_t { internal ulong SteamIDClan; // m_steamIDClan class CSteamID internal int COfficers; // m_cOfficers int internal byte Success; // m_bSuccess uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 35; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(ClanOfficerListResponse_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((ClanOfficerListResponse_t)(ClanOfficerListResponse_t) Marshal.PtrToStructure( p, typeof(ClanOfficerListResponse_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(ClanOfficerListResponse_t) ); + internal static ClanOfficerListResponse_t Fill( IntPtr p ) => ((ClanOfficerListResponse_t)(ClanOfficerListResponse_t) Marshal.PtrToStructure( p, typeof(ClanOfficerListResponse_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ClanOfficerListResponse_t)default(ClanOfficerListResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ClanOfficerListResponse_t)default(ClanOfficerListResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ClanOfficerListResponse_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 35, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 35, true ); actionServer = action; } else { - Event.Register( OnClient, default(ClanOfficerListResponse_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 35, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 35, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 35, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FriendRichPresenceUpdate_t : Steamworks.ISteamCallback + internal struct FriendRichPresenceUpdate_t { internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 36; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendRichPresenceUpdate_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((FriendRichPresenceUpdate_t)(FriendRichPresenceUpdate_t) Marshal.PtrToStructure( p, typeof(FriendRichPresenceUpdate_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendRichPresenceUpdate_t) ); + internal static FriendRichPresenceUpdate_t Fill( IntPtr p ) => ((FriendRichPresenceUpdate_t)(FriendRichPresenceUpdate_t) Marshal.PtrToStructure( p, typeof(FriendRichPresenceUpdate_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FriendRichPresenceUpdate_t)default(FriendRichPresenceUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FriendRichPresenceUpdate_t)default(FriendRichPresenceUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FriendRichPresenceUpdate_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 36, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 36, true ); actionServer = action; } else { - Event.Register( OnClient, default(FriendRichPresenceUpdate_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 36, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 36, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 36, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameRichPresenceJoinRequested_t : Steamworks.ISteamCallback + internal struct GameRichPresenceJoinRequested_t { internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string Connect; // m_rgchConnect char [256] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 37; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameRichPresenceJoinRequested_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameRichPresenceJoinRequested_t)(GameRichPresenceJoinRequested_t) Marshal.PtrToStructure( p, typeof(GameRichPresenceJoinRequested_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameRichPresenceJoinRequested_t) ); + internal static GameRichPresenceJoinRequested_t Fill( IntPtr p ) => ((GameRichPresenceJoinRequested_t)(GameRichPresenceJoinRequested_t) Marshal.PtrToStructure( p, typeof(GameRichPresenceJoinRequested_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameRichPresenceJoinRequested_t)default(GameRichPresenceJoinRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameRichPresenceJoinRequested_t)default(GameRichPresenceJoinRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameRichPresenceJoinRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 37, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 37, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameRichPresenceJoinRequested_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 37, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 37, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 37, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameConnectedClanChatMsg_t : Steamworks.ISteamCallback + internal struct GameConnectedClanChatMsg_t { internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID internal int MessageID; // m_iMessageID int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 38; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedClanChatMsg_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameConnectedClanChatMsg_t)(GameConnectedClanChatMsg_t) Marshal.PtrToStructure( p, typeof(GameConnectedClanChatMsg_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedClanChatMsg_t) ); + internal static GameConnectedClanChatMsg_t Fill( IntPtr p ) => ((GameConnectedClanChatMsg_t)(GameConnectedClanChatMsg_t) Marshal.PtrToStructure( p, typeof(GameConnectedClanChatMsg_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameConnectedClanChatMsg_t)default(GameConnectedClanChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameConnectedClanChatMsg_t)default(GameConnectedClanChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameConnectedClanChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 38, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 38, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameConnectedClanChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 38, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 38, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 38, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameConnectedChatJoin_t : Steamworks.ISteamCallback + internal struct GameConnectedChatJoin_t { internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 39; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedChatJoin_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameConnectedChatJoin_t)(GameConnectedChatJoin_t) Marshal.PtrToStructure( p, typeof(GameConnectedChatJoin_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedChatJoin_t) ); + internal static GameConnectedChatJoin_t Fill( IntPtr p ) => ((GameConnectedChatJoin_t)(GameConnectedChatJoin_t) Marshal.PtrToStructure( p, typeof(GameConnectedChatJoin_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameConnectedChatJoin_t)default(GameConnectedChatJoin_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameConnectedChatJoin_t)default(GameConnectedChatJoin_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameConnectedChatJoin_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 39, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 39, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameConnectedChatJoin_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 39, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 39, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 39, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameConnectedChatLeave_t : Steamworks.ISteamCallback + internal struct GameConnectedChatLeave_t { internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID @@ -834,57 +1312,105 @@ internal struct GameConnectedChatLeave_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool Dropped; // m_bDropped _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 40; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedChatLeave_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameConnectedChatLeave_t)(GameConnectedChatLeave_t) Marshal.PtrToStructure( p, typeof(GameConnectedChatLeave_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedChatLeave_t) ); + internal static GameConnectedChatLeave_t Fill( IntPtr p ) => ((GameConnectedChatLeave_t)(GameConnectedChatLeave_t) Marshal.PtrToStructure( p, typeof(GameConnectedChatLeave_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameConnectedChatLeave_t)default(GameConnectedChatLeave_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameConnectedChatLeave_t)default(GameConnectedChatLeave_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameConnectedChatLeave_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 40, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 40, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameConnectedChatLeave_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 40, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 40, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 40, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct DownloadClanActivityCountsResult_t : Steamworks.ISteamCallback + internal struct DownloadClanActivityCountsResult_t { [MarshalAs(UnmanagedType.I1)] internal bool Success; // m_bSuccess _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 41; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DownloadClanActivityCountsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((DownloadClanActivityCountsResult_t)(DownloadClanActivityCountsResult_t) Marshal.PtrToStructure( p, typeof(DownloadClanActivityCountsResult_t) )) : ((DownloadClanActivityCountsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DownloadClanActivityCountsResult_t) : typeof(Pack8) ); + internal static DownloadClanActivityCountsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((DownloadClanActivityCountsResult_t)(DownloadClanActivityCountsResult_t) Marshal.PtrToStructure( p, typeof(DownloadClanActivityCountsResult_t) )) : ((DownloadClanActivityCountsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (DownloadClanActivityCountsResult_t)default(DownloadClanActivityCountsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (DownloadClanActivityCountsResult_t)default(DownloadClanActivityCountsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(DownloadClanActivityCountsResult_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 41, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 41, true ); actionServer = action; } else { - Event.Register( OnClient, default(DownloadClanActivityCountsResult_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 41, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 41, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 41, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -900,130 +1426,226 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct JoinClanChatRoomCompletionResult_t : Steamworks.ISteamCallback + internal struct JoinClanChatRoomCompletionResult_t { internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ChatRoomEnterResponse ChatRoomEnterResponse; // m_eChatRoomEnterResponse enum EChatRoomEnterResponse - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 42; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(JoinClanChatRoomCompletionResult_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((JoinClanChatRoomCompletionResult_t)(JoinClanChatRoomCompletionResult_t) Marshal.PtrToStructure( p, typeof(JoinClanChatRoomCompletionResult_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(JoinClanChatRoomCompletionResult_t) ); + internal static JoinClanChatRoomCompletionResult_t Fill( IntPtr p ) => ((JoinClanChatRoomCompletionResult_t)(JoinClanChatRoomCompletionResult_t) Marshal.PtrToStructure( p, typeof(JoinClanChatRoomCompletionResult_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (JoinClanChatRoomCompletionResult_t)default(JoinClanChatRoomCompletionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (JoinClanChatRoomCompletionResult_t)default(JoinClanChatRoomCompletionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(JoinClanChatRoomCompletionResult_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 42, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 42, true ); actionServer = action; } else { - Event.Register( OnClient, default(JoinClanChatRoomCompletionResult_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 42, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 42, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 42, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GameConnectedFriendChatMsg_t : Steamworks.ISteamCallback + internal struct GameConnectedFriendChatMsg_t { internal ulong SteamIDUser; // m_steamIDUser class CSteamID internal int MessageID; // m_iMessageID int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 43; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedFriendChatMsg_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GameConnectedFriendChatMsg_t)(GameConnectedFriendChatMsg_t) Marshal.PtrToStructure( p, typeof(GameConnectedFriendChatMsg_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GameConnectedFriendChatMsg_t) ); + internal static GameConnectedFriendChatMsg_t Fill( IntPtr p ) => ((GameConnectedFriendChatMsg_t)(GameConnectedFriendChatMsg_t) Marshal.PtrToStructure( p, typeof(GameConnectedFriendChatMsg_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GameConnectedFriendChatMsg_t)default(GameConnectedFriendChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GameConnectedFriendChatMsg_t)default(GameConnectedFriendChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GameConnectedFriendChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 43, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 43, true ); actionServer = action; } else { - Event.Register( OnClient, default(GameConnectedFriendChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 43, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 43, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 43, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FriendsGetFollowerCount_t : Steamworks.ISteamCallback + internal struct FriendsGetFollowerCount_t { internal Result Result; // m_eResult enum EResult internal ulong SteamID; // m_steamID class CSteamID internal int Count; // m_nCount int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 44; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsGetFollowerCount_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((FriendsGetFollowerCount_t)(FriendsGetFollowerCount_t) Marshal.PtrToStructure( p, typeof(FriendsGetFollowerCount_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsGetFollowerCount_t) ); + internal static FriendsGetFollowerCount_t Fill( IntPtr p ) => ((FriendsGetFollowerCount_t)(FriendsGetFollowerCount_t) Marshal.PtrToStructure( p, typeof(FriendsGetFollowerCount_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FriendsGetFollowerCount_t)default(FriendsGetFollowerCount_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FriendsGetFollowerCount_t)default(FriendsGetFollowerCount_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FriendsGetFollowerCount_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 44, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 44, true ); actionServer = action; } else { - Event.Register( OnClient, default(FriendsGetFollowerCount_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 44, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 44, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 44, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FriendsIsFollowing_t : Steamworks.ISteamCallback + internal struct FriendsIsFollowing_t { internal Result Result; // m_eResult enum EResult internal ulong SteamID; // m_steamID class CSteamID [MarshalAs(UnmanagedType.I1)] internal bool IsFollowing; // m_bIsFollowing _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 45; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsIsFollowing_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((FriendsIsFollowing_t)(FriendsIsFollowing_t) Marshal.PtrToStructure( p, typeof(FriendsIsFollowing_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsIsFollowing_t) ); + internal static FriendsIsFollowing_t Fill( IntPtr p ) => ((FriendsIsFollowing_t)(FriendsIsFollowing_t) Marshal.PtrToStructure( p, typeof(FriendsIsFollowing_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FriendsIsFollowing_t)default(FriendsIsFollowing_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FriendsIsFollowing_t)default(FriendsIsFollowing_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FriendsIsFollowing_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 45, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 45, true ); actionServer = action; } else { - Event.Register( OnClient, default(FriendsIsFollowing_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 45, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 45, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 45, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FriendsEnumerateFollowingList_t : Steamworks.ISteamCallback + internal struct FriendsEnumerateFollowingList_t { internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] @@ -1031,32 +1653,56 @@ internal struct FriendsEnumerateFollowingList_t : Steamworks.ISteamCallback internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 46; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsEnumerateFollowingList_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((FriendsEnumerateFollowingList_t)(FriendsEnumerateFollowingList_t) Marshal.PtrToStructure( p, typeof(FriendsEnumerateFollowingList_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(FriendsEnumerateFollowingList_t) ); + internal static FriendsEnumerateFollowingList_t Fill( IntPtr p ) => ((FriendsEnumerateFollowingList_t)(FriendsEnumerateFollowingList_t) Marshal.PtrToStructure( p, typeof(FriendsEnumerateFollowingList_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FriendsEnumerateFollowingList_t)default(FriendsEnumerateFollowingList_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FriendsEnumerateFollowingList_t)default(FriendsEnumerateFollowingList_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FriendsEnumerateFollowingList_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 46, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 46, true ); actionServer = action; } else { - Event.Register( OnClient, default(FriendsEnumerateFollowingList_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 46, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 46, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 46, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SetPersonaNameResponse_t : Steamworks.ISteamCallback + internal struct SetPersonaNameResponse_t { [MarshalAs(UnmanagedType.I1)] internal bool Success; // m_bSuccess _Bool @@ -1064,27 +1710,51 @@ internal struct SetPersonaNameResponse_t : Steamworks.ISteamCallback internal bool LocalSuccess; // m_bLocalSuccess _Bool internal Result Result; // m_result enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 47; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SetPersonaNameResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SetPersonaNameResponse_t)(SetPersonaNameResponse_t) Marshal.PtrToStructure( p, typeof(SetPersonaNameResponse_t) )) : ((SetPersonaNameResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SetPersonaNameResponse_t) : typeof(Pack8) ); + internal static SetPersonaNameResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((SetPersonaNameResponse_t)(SetPersonaNameResponse_t) Marshal.PtrToStructure( p, typeof(SetPersonaNameResponse_t) )) : ((SetPersonaNameResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SetPersonaNameResponse_t)default(SetPersonaNameResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SetPersonaNameResponse_t)default(SetPersonaNameResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SetPersonaNameResponse_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 47, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamFriends + 47, true ); actionServer = action; } else { - Event.Register( OnClient, default(SetPersonaNameResponse_t).GetStructSize(), CallbackIdentifiers.SteamFriends + 47, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamFriends + 47, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamFriends + 47, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1103,31 +1773,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LowBatteryPower_t : Steamworks.ISteamCallback + internal struct LowBatteryPower_t { internal byte MinutesBatteryLeft; // m_nMinutesBatteryLeft uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LowBatteryPower_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LowBatteryPower_t)(LowBatteryPower_t) Marshal.PtrToStructure( p, typeof(LowBatteryPower_t) )) : ((LowBatteryPower_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LowBatteryPower_t) : typeof(Pack8) ); + internal static LowBatteryPower_t Fill( IntPtr p ) => Config.PackSmall ? ((LowBatteryPower_t)(LowBatteryPower_t) Marshal.PtrToStructure( p, typeof(LowBatteryPower_t) )) : ((LowBatteryPower_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LowBatteryPower_t)default(LowBatteryPower_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LowBatteryPower_t)default(LowBatteryPower_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LowBatteryPower_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(LowBatteryPower_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1142,33 +1836,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamAPICallCompleted_t : Steamworks.ISteamCallback + internal struct SteamAPICallCompleted_t { internal ulong AsyncCall; // m_hAsyncCall SteamAPICall_t internal int Callback; // m_iCallback int internal uint ParamCount; // m_cubParam uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAPICallCompleted_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamAPICallCompleted_t)(SteamAPICallCompleted_t) Marshal.PtrToStructure( p, typeof(SteamAPICallCompleted_t) )) : ((SteamAPICallCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAPICallCompleted_t) : typeof(Pack8) ); + internal static SteamAPICallCompleted_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamAPICallCompleted_t)(SteamAPICallCompleted_t) Marshal.PtrToStructure( p, typeof(SteamAPICallCompleted_t) )) : ((SteamAPICallCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamAPICallCompleted_t)default(SteamAPICallCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamAPICallCompleted_t)default(SteamAPICallCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamAPICallCompleted_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamAPICallCompleted_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1185,31 +1903,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct CheckFileSignature_t : Steamworks.ISteamCallback + internal struct CheckFileSignature_t { internal CheckFileSignature CheckFileSignature; // m_eCheckFileSignature enum ECheckFileSignature - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CheckFileSignature_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((CheckFileSignature_t)(CheckFileSignature_t) Marshal.PtrToStructure( p, typeof(CheckFileSignature_t) )) : ((CheckFileSignature_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CheckFileSignature_t) : typeof(Pack8) ); + internal static CheckFileSignature_t Fill( IntPtr p ) => Config.PackSmall ? ((CheckFileSignature_t)(CheckFileSignature_t) Marshal.PtrToStructure( p, typeof(CheckFileSignature_t) )) : ((CheckFileSignature_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (CheckFileSignature_t)default(CheckFileSignature_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (CheckFileSignature_t)default(CheckFileSignature_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(CheckFileSignature_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(CheckFileSignature_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1224,33 +1966,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GamepadTextInputDismissed_t : Steamworks.ISteamCallback + internal struct GamepadTextInputDismissed_t { [MarshalAs(UnmanagedType.I1)] internal bool Submitted; // m_bSubmitted _Bool internal uint SubmittedText; // m_unSubmittedText uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GamepadTextInputDismissed_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GamepadTextInputDismissed_t)(GamepadTextInputDismissed_t) Marshal.PtrToStructure( p, typeof(GamepadTextInputDismissed_t) )) : ((GamepadTextInputDismissed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GamepadTextInputDismissed_t) : typeof(Pack8) ); + internal static GamepadTextInputDismissed_t Fill( IntPtr p ) => Config.PackSmall ? ((GamepadTextInputDismissed_t)(GamepadTextInputDismissed_t) Marshal.PtrToStructure( p, typeof(GamepadTextInputDismissed_t) )) : ((GamepadTextInputDismissed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GamepadTextInputDismissed_t)default(GamepadTextInputDismissed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GamepadTextInputDismissed_t)default(GamepadTextInputDismissed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GamepadTextInputDismissed_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(GamepadTextInputDismissed_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1275,8 +2041,7 @@ internal struct MatchMakingKeyValuePair_t internal string Value; // m_szValue char [256] #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MatchMakingKeyValuePair_t) : typeof(Pack8) ); - public MatchMakingKeyValuePair_t Fill( IntPtr p ) => Config.PackSmall ? ((MatchMakingKeyValuePair_t)(MatchMakingKeyValuePair_t) Marshal.PtrToStructure( p, typeof(MatchMakingKeyValuePair_t) )) : ((MatchMakingKeyValuePair_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static MatchMakingKeyValuePair_t Fill( IntPtr p ) => Config.PackSmall ? ((MatchMakingKeyValuePair_t)(MatchMakingKeyValuePair_t) Marshal.PtrToStructure( p, typeof(MatchMakingKeyValuePair_t) )) : ((MatchMakingKeyValuePair_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -1301,8 +2066,7 @@ internal struct servernetadr_t internal uint IP; // m_unIP uint32 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(servernetadr_t) : typeof(Pack8) ); - public servernetadr_t Fill( IntPtr p ) => Config.PackSmall ? ((servernetadr_t)(servernetadr_t) Marshal.PtrToStructure( p, typeof(servernetadr_t) )) : ((servernetadr_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static servernetadr_t Fill( IntPtr p ) => Config.PackSmall ? ((servernetadr_t)(servernetadr_t) Marshal.PtrToStructure( p, typeof(servernetadr_t) )) : ((servernetadr_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -1350,8 +2114,7 @@ internal struct gameserveritem_t internal ulong SteamID; // m_steamID class CSteamID #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(gameserveritem_t) ); - public gameserveritem_t Fill( IntPtr p ) => ((gameserveritem_t)(gameserveritem_t) Marshal.PtrToStructure( p, typeof(gameserveritem_t) ) ); + internal static gameserveritem_t Fill( IntPtr p ) => ((gameserveritem_t)(gameserveritem_t) Marshal.PtrToStructure( p, typeof(gameserveritem_t) ) ); #endregion } @@ -1362,8 +2125,7 @@ internal struct SteamPartyBeaconLocation_t internal ulong LocationID; // m_ulLocationID uint64 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamPartyBeaconLocation_t) : typeof(Pack8) ); - public SteamPartyBeaconLocation_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamPartyBeaconLocation_t)(SteamPartyBeaconLocation_t) Marshal.PtrToStructure( p, typeof(SteamPartyBeaconLocation_t) )) : ((SteamPartyBeaconLocation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static SteamPartyBeaconLocation_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamPartyBeaconLocation_t)(SteamPartyBeaconLocation_t) Marshal.PtrToStructure( p, typeof(SteamPartyBeaconLocation_t) )) : ((SteamPartyBeaconLocation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -1379,7 +2141,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FavoritesListChanged_t : Steamworks.ISteamCallback + internal struct FavoritesListChanged_t { internal uint IP; // m_nIP uint32 internal uint QueryPort; // m_nQueryPort uint32 @@ -1390,27 +2152,51 @@ internal struct FavoritesListChanged_t : Steamworks.ISteamCallback internal bool Add; // m_bAdd _Bool internal uint AccountId; // m_unAccountId AccountID_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FavoritesListChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((FavoritesListChanged_t)(FavoritesListChanged_t) Marshal.PtrToStructure( p, typeof(FavoritesListChanged_t) )) : ((FavoritesListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FavoritesListChanged_t) : typeof(Pack8) ); + internal static FavoritesListChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((FavoritesListChanged_t)(FavoritesListChanged_t) Marshal.PtrToStructure( p, typeof(FavoritesListChanged_t) )) : ((FavoritesListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FavoritesListChanged_t)default(FavoritesListChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FavoritesListChanged_t)default(FavoritesListChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FavoritesListChanged_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(FavoritesListChanged_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1432,33 +2218,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyInvite_t : Steamworks.ISteamCallback + internal struct LobbyInvite_t { internal ulong SteamIDUser; // m_ulSteamIDUser uint64 internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong GameID; // m_ulGameID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyInvite_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyInvite_t)(LobbyInvite_t) Marshal.PtrToStructure( p, typeof(LobbyInvite_t) )) : ((LobbyInvite_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyInvite_t) : typeof(Pack8) ); + internal static LobbyInvite_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyInvite_t)(LobbyInvite_t) Marshal.PtrToStructure( p, typeof(LobbyInvite_t) )) : ((LobbyInvite_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyInvite_t)default(LobbyInvite_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyInvite_t)default(LobbyInvite_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyInvite_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyInvite_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1475,7 +2285,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyEnter_t : Steamworks.ISteamCallback + internal struct LobbyEnter_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal uint GfChatPermissions; // m_rgfChatPermissions uint32 @@ -1483,27 +2293,51 @@ internal struct LobbyEnter_t : Steamworks.ISteamCallback internal bool Locked; // m_bLocked _Bool internal uint EChatRoomEnterResponse; // m_EChatRoomEnterResponse uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyEnter_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyEnter_t)(LobbyEnter_t) Marshal.PtrToStructure( p, typeof(LobbyEnter_t) )) : ((LobbyEnter_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyEnter_t) : typeof(Pack8) ); + internal static LobbyEnter_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyEnter_t)(LobbyEnter_t) Marshal.PtrToStructure( p, typeof(LobbyEnter_t) )) : ((LobbyEnter_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyEnter_t)default(LobbyEnter_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyEnter_t)default(LobbyEnter_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyEnter_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyEnter_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1522,33 +2356,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyDataUpdate_t : Steamworks.ISteamCallback + internal struct LobbyDataUpdate_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDMember; // m_ulSteamIDMember uint64 internal byte Success; // m_bSuccess uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyDataUpdate_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyDataUpdate_t)(LobbyDataUpdate_t) Marshal.PtrToStructure( p, typeof(LobbyDataUpdate_t) )) : ((LobbyDataUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyDataUpdate_t) : typeof(Pack8) ); + internal static LobbyDataUpdate_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyDataUpdate_t)(LobbyDataUpdate_t) Marshal.PtrToStructure( p, typeof(LobbyDataUpdate_t) )) : ((LobbyDataUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyDataUpdate_t)default(LobbyDataUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyDataUpdate_t)default(LobbyDataUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyDataUpdate_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyDataUpdate_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1565,34 +2423,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyChatUpdate_t : Steamworks.ISteamCallback + internal struct LobbyChatUpdate_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDUserChanged; // m_ulSteamIDUserChanged uint64 internal ulong SteamIDMakingChange; // m_ulSteamIDMakingChange uint64 internal uint GfChatMemberStateChange; // m_rgfChatMemberStateChange uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 6; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyChatUpdate_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyChatUpdate_t)(LobbyChatUpdate_t) Marshal.PtrToStructure( p, typeof(LobbyChatUpdate_t) )) : ((LobbyChatUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyChatUpdate_t) : typeof(Pack8) ); + internal static LobbyChatUpdate_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyChatUpdate_t)(LobbyChatUpdate_t) Marshal.PtrToStructure( p, typeof(LobbyChatUpdate_t) )) : ((LobbyChatUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyChatUpdate_t)default(LobbyChatUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyChatUpdate_t)default(LobbyChatUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyChatUpdate_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 6, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 6, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyChatUpdate_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 6, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 6, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 6, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1610,34 +2492,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyChatMsg_t : Steamworks.ISteamCallback + internal struct LobbyChatMsg_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDUser; // m_ulSteamIDUser uint64 internal byte ChatEntryType; // m_eChatEntryType uint8 internal uint ChatID; // m_iChatID uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyChatMsg_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyChatMsg_t)(LobbyChatMsg_t) Marshal.PtrToStructure( p, typeof(LobbyChatMsg_t) )) : ((LobbyChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyChatMsg_t) : typeof(Pack8) ); + internal static LobbyChatMsg_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyChatMsg_t)(LobbyChatMsg_t) Marshal.PtrToStructure( p, typeof(LobbyChatMsg_t) )) : ((LobbyChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyChatMsg_t)default(LobbyChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyChatMsg_t)default(LobbyChatMsg_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyChatMsg_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1655,34 +2561,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyGameCreated_t : Steamworks.ISteamCallback + internal struct LobbyGameCreated_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDGameServer; // m_ulSteamIDGameServer uint64 internal uint IP; // m_unIP uint32 internal ushort Port; // m_usPort uint16 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyGameCreated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyGameCreated_t)(LobbyGameCreated_t) Marshal.PtrToStructure( p, typeof(LobbyGameCreated_t) )) : ((LobbyGameCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyGameCreated_t) : typeof(Pack8) ); + internal static LobbyGameCreated_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyGameCreated_t)(LobbyGameCreated_t) Marshal.PtrToStructure( p, typeof(LobbyGameCreated_t) )) : ((LobbyGameCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyGameCreated_t)default(LobbyGameCreated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyGameCreated_t)default(LobbyGameCreated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyGameCreated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyGameCreated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1700,31 +2630,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyMatchList_t : Steamworks.ISteamCallback + internal struct LobbyMatchList_t { internal uint LobbiesMatching; // m_nLobbiesMatching uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyMatchList_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyMatchList_t)(LobbyMatchList_t) Marshal.PtrToStructure( p, typeof(LobbyMatchList_t) )) : ((LobbyMatchList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyMatchList_t) : typeof(Pack8) ); + internal static LobbyMatchList_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyMatchList_t)(LobbyMatchList_t) Marshal.PtrToStructure( p, typeof(LobbyMatchList_t) )) : ((LobbyMatchList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyMatchList_t)default(LobbyMatchList_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyMatchList_t)default(LobbyMatchList_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyMatchList_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyMatchList_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1739,33 +2693,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyKicked_t : Steamworks.ISteamCallback + internal struct LobbyKicked_t { internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDAdmin; // m_ulSteamIDAdmin uint64 internal byte KickedDueToDisconnect; // m_bKickedDueToDisconnect uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyKicked_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyKicked_t)(LobbyKicked_t) Marshal.PtrToStructure( p, typeof(LobbyKicked_t) )) : ((LobbyKicked_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyKicked_t) : typeof(Pack8) ); + internal static LobbyKicked_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyKicked_t)(LobbyKicked_t) Marshal.PtrToStructure( p, typeof(LobbyKicked_t) )) : ((LobbyKicked_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyKicked_t)default(LobbyKicked_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyKicked_t)default(LobbyKicked_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyKicked_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyKicked_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1782,32 +2760,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LobbyCreated_t : Steamworks.ISteamCallback + internal struct LobbyCreated_t { internal Result Result; // m_eResult enum EResult internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyCreated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LobbyCreated_t)(LobbyCreated_t) Marshal.PtrToStructure( p, typeof(LobbyCreated_t) )) : ((LobbyCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LobbyCreated_t) : typeof(Pack8) ); + internal static LobbyCreated_t Fill( IntPtr p ) => Config.PackSmall ? ((LobbyCreated_t)(LobbyCreated_t) Marshal.PtrToStructure( p, typeof(LobbyCreated_t) )) : ((LobbyCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LobbyCreated_t)default(LobbyCreated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LobbyCreated_t)default(LobbyCreated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LobbyCreated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(LobbyCreated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1823,62 +2825,110 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct PSNGameBootInviteResult_t : Steamworks.ISteamCallback + internal struct PSNGameBootInviteResult_t { [MarshalAs(UnmanagedType.I1)] internal bool GameBootInviteExists; // m_bGameBootInviteExists _Bool internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(PSNGameBootInviteResult_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((PSNGameBootInviteResult_t)(PSNGameBootInviteResult_t) Marshal.PtrToStructure( p, typeof(PSNGameBootInviteResult_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(PSNGameBootInviteResult_t) ); + internal static PSNGameBootInviteResult_t Fill( IntPtr p ) => ((PSNGameBootInviteResult_t)(PSNGameBootInviteResult_t) Marshal.PtrToStructure( p, typeof(PSNGameBootInviteResult_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (PSNGameBootInviteResult_t)default(PSNGameBootInviteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (PSNGameBootInviteResult_t)default(PSNGameBootInviteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(PSNGameBootInviteResult_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(PSNGameBootInviteResult_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FavoritesListAccountsUpdated_t : Steamworks.ISteamCallback + internal struct FavoritesListAccountsUpdated_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 16; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FavoritesListAccountsUpdated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((FavoritesListAccountsUpdated_t)(FavoritesListAccountsUpdated_t) Marshal.PtrToStructure( p, typeof(FavoritesListAccountsUpdated_t) )) : ((FavoritesListAccountsUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FavoritesListAccountsUpdated_t) : typeof(Pack8) ); + internal static FavoritesListAccountsUpdated_t Fill( IntPtr p ) => Config.PackSmall ? ((FavoritesListAccountsUpdated_t)(FavoritesListAccountsUpdated_t) Marshal.PtrToStructure( p, typeof(FavoritesListAccountsUpdated_t) )) : ((FavoritesListAccountsUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FavoritesListAccountsUpdated_t)default(FavoritesListAccountsUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FavoritesListAccountsUpdated_t)default(FavoritesListAccountsUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FavoritesListAccountsUpdated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 16, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMatchmaking + 16, true ); actionServer = action; } else { - Event.Register( OnClient, default(FavoritesListAccountsUpdated_t).GetStructSize(), CallbackIdentifiers.SteamMatchmaking + 16, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMatchmaking + 16, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMatchmaking + 16, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -1893,7 +2943,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SearchForGameProgressCallback_t : Steamworks.ISteamCallback + internal struct SearchForGameProgressCallback_t { internal ulong LSearchID; // m_ullSearchID uint64 internal Result Result; // m_eResult enum EResult @@ -1902,32 +2952,56 @@ internal struct SearchForGameProgressCallback_t : Steamworks.ISteamCallback internal int SecondsRemainingEstimate; // m_nSecondsRemainingEstimate int32 internal int CPlayersSearching; // m_cPlayersSearching int32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(SearchForGameProgressCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((SearchForGameProgressCallback_t)(SearchForGameProgressCallback_t) Marshal.PtrToStructure( p, typeof(SearchForGameProgressCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(SearchForGameProgressCallback_t) ); + internal static SearchForGameProgressCallback_t Fill( IntPtr p ) => ((SearchForGameProgressCallback_t)(SearchForGameProgressCallback_t) Marshal.PtrToStructure( p, typeof(SearchForGameProgressCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SearchForGameProgressCallback_t)default(SearchForGameProgressCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SearchForGameProgressCallback_t)default(SearchForGameProgressCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SearchForGameProgressCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SearchForGameProgressCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SearchForGameResultCallback_t : Steamworks.ISteamCallback + internal struct SearchForGameResultCallback_t { internal ulong LSearchID; // m_ullSearchID uint64 internal Result Result; // m_eResult enum EResult @@ -1937,57 +3011,105 @@ internal struct SearchForGameResultCallback_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool FinalCallback; // m_bFinalCallback _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(SearchForGameResultCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((SearchForGameResultCallback_t)(SearchForGameResultCallback_t) Marshal.PtrToStructure( p, typeof(SearchForGameResultCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(SearchForGameResultCallback_t) ); + internal static SearchForGameResultCallback_t Fill( IntPtr p ) => ((SearchForGameResultCallback_t)(SearchForGameResultCallback_t) Marshal.PtrToStructure( p, typeof(SearchForGameResultCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SearchForGameResultCallback_t)default(SearchForGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SearchForGameResultCallback_t)default(SearchForGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SearchForGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(SearchForGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RequestPlayersForGameProgressCallback_t : Steamworks.ISteamCallback + internal struct RequestPlayersForGameProgressCallback_t { internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RequestPlayersForGameProgressCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RequestPlayersForGameProgressCallback_t)(RequestPlayersForGameProgressCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameProgressCallback_t) )) : ((RequestPlayersForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RequestPlayersForGameProgressCallback_t) : typeof(Pack8) ); + internal static RequestPlayersForGameProgressCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((RequestPlayersForGameProgressCallback_t)(RequestPlayersForGameProgressCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameProgressCallback_t) )) : ((RequestPlayersForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RequestPlayersForGameProgressCallback_t)default(RequestPlayersForGameProgressCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RequestPlayersForGameProgressCallback_t)default(RequestPlayersForGameProgressCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RequestPlayersForGameProgressCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(RequestPlayersForGameProgressCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2003,7 +3125,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RequestPlayersForGameResultCallback_t : Steamworks.ISteamCallback + internal struct RequestPlayersForGameResultCallback_t { internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 @@ -2016,58 +3138,106 @@ internal struct RequestPlayersForGameResultCallback_t : Steamworks.ISteamCallbac internal int SuggestedTeamIndex; // m_nSuggestedTeamIndex int32 internal ulong LUniqueGameID; // m_ullUniqueGameID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(RequestPlayersForGameResultCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((RequestPlayersForGameResultCallback_t)(RequestPlayersForGameResultCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameResultCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(RequestPlayersForGameResultCallback_t) ); + internal static RequestPlayersForGameResultCallback_t Fill( IntPtr p ) => ((RequestPlayersForGameResultCallback_t)(RequestPlayersForGameResultCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameResultCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RequestPlayersForGameResultCallback_t)default(RequestPlayersForGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RequestPlayersForGameResultCallback_t)default(RequestPlayersForGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RequestPlayersForGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(RequestPlayersForGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RequestPlayersForGameFinalResultCallback_t : Steamworks.ISteamCallback + internal struct RequestPlayersForGameFinalResultCallback_t { internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 internal ulong LUniqueGameID; // m_ullUniqueGameID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RequestPlayersForGameFinalResultCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RequestPlayersForGameFinalResultCallback_t)(RequestPlayersForGameFinalResultCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameFinalResultCallback_t) )) : ((RequestPlayersForGameFinalResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RequestPlayersForGameFinalResultCallback_t) : typeof(Pack8) ); + internal static RequestPlayersForGameFinalResultCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((RequestPlayersForGameFinalResultCallback_t)(RequestPlayersForGameFinalResultCallback_t) Marshal.PtrToStructure( p, typeof(RequestPlayersForGameFinalResultCallback_t) )) : ((RequestPlayersForGameFinalResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RequestPlayersForGameFinalResultCallback_t)default(RequestPlayersForGameFinalResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RequestPlayersForGameFinalResultCallback_t)default(RequestPlayersForGameFinalResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RequestPlayersForGameFinalResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(RequestPlayersForGameFinalResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2084,63 +3254,111 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SubmitPlayerResultResultCallback_t : Steamworks.ISteamCallback + internal struct SubmitPlayerResultResultCallback_t { internal Result Result; // m_eResult enum EResult internal ulong UllUniqueGameID; // ullUniqueGameID uint64 internal ulong SteamIDPlayer; // steamIDPlayer class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(SubmitPlayerResultResultCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((SubmitPlayerResultResultCallback_t)(SubmitPlayerResultResultCallback_t) Marshal.PtrToStructure( p, typeof(SubmitPlayerResultResultCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(SubmitPlayerResultResultCallback_t) ); + internal static SubmitPlayerResultResultCallback_t Fill( IntPtr p ) => ((SubmitPlayerResultResultCallback_t)(SubmitPlayerResultResultCallback_t) Marshal.PtrToStructure( p, typeof(SubmitPlayerResultResultCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SubmitPlayerResultResultCallback_t)default(SubmitPlayerResultResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SubmitPlayerResultResultCallback_t)default(SubmitPlayerResultResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SubmitPlayerResultResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(SubmitPlayerResultResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct EndGameResultCallback_t : Steamworks.ISteamCallback + internal struct EndGameResultCallback_t { internal Result Result; // m_eResult enum EResult internal ulong UllUniqueGameID; // ullUniqueGameID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(EndGameResultCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((EndGameResultCallback_t)(EndGameResultCallback_t) Marshal.PtrToStructure( p, typeof(EndGameResultCallback_t) )) : ((EndGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(EndGameResultCallback_t) : typeof(Pack8) ); + internal static EndGameResultCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((EndGameResultCallback_t)(EndGameResultCallback_t) Marshal.PtrToStructure( p, typeof(EndGameResultCallback_t) )) : ((EndGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (EndGameResultCallback_t)default(EndGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (EndGameResultCallback_t)default(EndGameResultCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(EndGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameSearch + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(EndGameResultCallback_t).GetStructSize(), CallbackIdentifiers.SteamGameSearch + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameSearch + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameSearch + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2156,7 +3374,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct JoinPartyCallback_t : Steamworks.ISteamCallback + internal struct JoinPartyCallback_t { internal Result Result; // m_eResult enum EResult internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t @@ -2164,57 +3382,105 @@ internal struct JoinPartyCallback_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string ConnectString; // m_rgchConnectString char [256] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamParties + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(JoinPartyCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((JoinPartyCallback_t)(JoinPartyCallback_t) Marshal.PtrToStructure( p, typeof(JoinPartyCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(JoinPartyCallback_t) ); + internal static JoinPartyCallback_t Fill( IntPtr p ) => ((JoinPartyCallback_t)(JoinPartyCallback_t) Marshal.PtrToStructure( p, typeof(JoinPartyCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (JoinPartyCallback_t)default(JoinPartyCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (JoinPartyCallback_t)default(JoinPartyCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(JoinPartyCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamParties + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(JoinPartyCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamParties + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamParties + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct CreateBeaconCallback_t : Steamworks.ISteamCallback + internal struct CreateBeaconCallback_t { internal Result Result; // m_eResult enum EResult internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamParties + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CreateBeaconCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((CreateBeaconCallback_t)(CreateBeaconCallback_t) Marshal.PtrToStructure( p, typeof(CreateBeaconCallback_t) )) : ((CreateBeaconCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CreateBeaconCallback_t) : typeof(Pack8) ); + internal static CreateBeaconCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((CreateBeaconCallback_t)(CreateBeaconCallback_t) Marshal.PtrToStructure( p, typeof(CreateBeaconCallback_t) )) : ((CreateBeaconCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (CreateBeaconCallback_t)default(CreateBeaconCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (CreateBeaconCallback_t)default(CreateBeaconCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(CreateBeaconCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamParties + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(CreateBeaconCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamParties + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamParties + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2230,61 +3496,109 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ReservationNotificationCallback_t : Steamworks.ISteamCallback + internal struct ReservationNotificationCallback_t { internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t internal ulong SteamIDJoiner; // m_steamIDJoiner class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamParties + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(ReservationNotificationCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((ReservationNotificationCallback_t)(ReservationNotificationCallback_t) Marshal.PtrToStructure( p, typeof(ReservationNotificationCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(ReservationNotificationCallback_t) ); + internal static ReservationNotificationCallback_t Fill( IntPtr p ) => ((ReservationNotificationCallback_t)(ReservationNotificationCallback_t) Marshal.PtrToStructure( p, typeof(ReservationNotificationCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ReservationNotificationCallback_t)default(ReservationNotificationCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ReservationNotificationCallback_t)default(ReservationNotificationCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ReservationNotificationCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamParties + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(ReservationNotificationCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamParties + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamParties + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ChangeNumOpenSlotsCallback_t : Steamworks.ISteamCallback + internal struct ChangeNumOpenSlotsCallback_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamParties + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ChangeNumOpenSlotsCallback_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((ChangeNumOpenSlotsCallback_t)(ChangeNumOpenSlotsCallback_t) Marshal.PtrToStructure( p, typeof(ChangeNumOpenSlotsCallback_t) )) : ((ChangeNumOpenSlotsCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ChangeNumOpenSlotsCallback_t) : typeof(Pack8) ); + internal static ChangeNumOpenSlotsCallback_t Fill( IntPtr p ) => Config.PackSmall ? ((ChangeNumOpenSlotsCallback_t)(ChangeNumOpenSlotsCallback_t) Marshal.PtrToStructure( p, typeof(ChangeNumOpenSlotsCallback_t) )) : ((ChangeNumOpenSlotsCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ChangeNumOpenSlotsCallback_t)default(ChangeNumOpenSlotsCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ChangeNumOpenSlotsCallback_t)default(ChangeNumOpenSlotsCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ChangeNumOpenSlotsCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamParties + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(ChangeNumOpenSlotsCallback_t).GetStructSize(), CallbackIdentifiers.SteamParties + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamParties + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamParties + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2305,8 +3619,7 @@ internal struct SteamParamStringArray_t internal int NumStrings; // m_nNumStrings int32 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamParamStringArray_t) : typeof(Pack8) ); - public SteamParamStringArray_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamParamStringArray_t)(SteamParamStringArray_t) Marshal.PtrToStructure( p, typeof(SteamParamStringArray_t) )) : ((SteamParamStringArray_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static SteamParamStringArray_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamParamStringArray_t)(SteamParamStringArray_t) Marshal.PtrToStructure( p, typeof(SteamParamStringArray_t) )) : ((SteamParamStringArray_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -2322,33 +3635,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageAppSyncedClient_t : Steamworks.ISteamCallback + internal struct RemoteStorageAppSyncedClient_t { internal AppId AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult internal int NumDownloads; // m_unNumDownloads int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncedClient_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncedClient_t)(RemoteStorageAppSyncedClient_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncedClient_t) )) : ((RemoteStorageAppSyncedClient_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncedClient_t) : typeof(Pack8) ); + internal static RemoteStorageAppSyncedClient_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncedClient_t)(RemoteStorageAppSyncedClient_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncedClient_t) )) : ((RemoteStorageAppSyncedClient_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageAppSyncedClient_t)default(RemoteStorageAppSyncedClient_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageAppSyncedClient_t)default(RemoteStorageAppSyncedClient_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageAppSyncedClient_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageAppSyncedClient_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2365,33 +3702,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageAppSyncedServer_t : Steamworks.ISteamCallback + internal struct RemoteStorageAppSyncedServer_t { internal AppId AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult internal int NumUploads; // m_unNumUploads int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncedServer_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncedServer_t)(RemoteStorageAppSyncedServer_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncedServer_t) )) : ((RemoteStorageAppSyncedServer_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncedServer_t) : typeof(Pack8) ); + internal static RemoteStorageAppSyncedServer_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncedServer_t)(RemoteStorageAppSyncedServer_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncedServer_t) )) : ((RemoteStorageAppSyncedServer_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageAppSyncedServer_t)default(RemoteStorageAppSyncedServer_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageAppSyncedServer_t)default(RemoteStorageAppSyncedServer_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageAppSyncedServer_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageAppSyncedServer_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2408,7 +3769,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageAppSyncProgress_t : Steamworks.ISteamCallback + internal struct RemoteStorageAppSyncProgress_t { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] internal string CurrentFile; // m_rgchCurrentFile char [260] @@ -2418,27 +3779,51 @@ internal struct RemoteStorageAppSyncProgress_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool Uploading; // m_bUploading _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncProgress_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncProgress_t)(RemoteStorageAppSyncProgress_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncProgress_t) )) : ((RemoteStorageAppSyncProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncProgress_t) : typeof(Pack8) ); + internal static RemoteStorageAppSyncProgress_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncProgress_t)(RemoteStorageAppSyncProgress_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncProgress_t) )) : ((RemoteStorageAppSyncProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageAppSyncProgress_t)default(RemoteStorageAppSyncProgress_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageAppSyncProgress_t)default(RemoteStorageAppSyncProgress_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageAppSyncProgress_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageAppSyncProgress_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2459,32 +3844,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageAppSyncStatusCheck_t : Steamworks.ISteamCallback + internal struct RemoteStorageAppSyncStatusCheck_t { internal AppId AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncStatusCheck_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncStatusCheck_t)(RemoteStorageAppSyncStatusCheck_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncStatusCheck_t) )) : ((RemoteStorageAppSyncStatusCheck_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageAppSyncStatusCheck_t) : typeof(Pack8) ); + internal static RemoteStorageAppSyncStatusCheck_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageAppSyncStatusCheck_t)(RemoteStorageAppSyncStatusCheck_t) Marshal.PtrToStructure( p, typeof(RemoteStorageAppSyncStatusCheck_t) )) : ((RemoteStorageAppSyncStatusCheck_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageAppSyncStatusCheck_t)default(RemoteStorageAppSyncStatusCheck_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageAppSyncStatusCheck_t)default(RemoteStorageAppSyncStatusCheck_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageAppSyncStatusCheck_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageAppSyncStatusCheck_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2500,34 +3909,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageFileShareResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageFileShareResult_t { internal Result Result; // m_eResult enum EResult internal ulong File; // m_hFile UGCHandle_t [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] internal string Filename; // m_rgchFilename char [260] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileShareResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileShareResult_t)(RemoteStorageFileShareResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileShareResult_t) )) : ((RemoteStorageFileShareResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileShareResult_t) : typeof(Pack8) ); + internal static RemoteStorageFileShareResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileShareResult_t)(RemoteStorageFileShareResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileShareResult_t) )) : ((RemoteStorageFileShareResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageFileShareResult_t)default(RemoteStorageFileShareResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageFileShareResult_t)default(RemoteStorageFileShareResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageFileShareResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageFileShareResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2545,34 +3978,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishFileResult_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishFileResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishFileResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishFileResult_t)(RemoteStoragePublishFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishFileResult_t) )) : ((RemoteStoragePublishFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishFileResult_t) : typeof(Pack8) ); + internal static RemoteStoragePublishFileResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishFileResult_t)(RemoteStoragePublishFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishFileResult_t) )) : ((RemoteStoragePublishFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishFileResult_t)default(RemoteStoragePublishFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishFileResult_t)default(RemoteStoragePublishFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2590,32 +4047,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageDeletePublishedFileResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageDeletePublishedFileResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageDeletePublishedFileResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageDeletePublishedFileResult_t)(RemoteStorageDeletePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageDeletePublishedFileResult_t) )) : ((RemoteStorageDeletePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageDeletePublishedFileResult_t) : typeof(Pack8) ); + internal static RemoteStorageDeletePublishedFileResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageDeletePublishedFileResult_t)(RemoteStorageDeletePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageDeletePublishedFileResult_t) )) : ((RemoteStorageDeletePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageDeletePublishedFileResult_t)default(RemoteStorageDeletePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageDeletePublishedFileResult_t)default(RemoteStorageDeletePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageDeletePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageDeletePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2631,7 +4112,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageEnumerateUserPublishedFilesResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageEnumerateUserPublishedFilesResult_t { internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 @@ -2639,27 +4120,51 @@ internal struct RemoteStorageEnumerateUserPublishedFilesResult_t : Steamworks.IS [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] internal PublishedFileId[] GPublishedFileId; // m_rgPublishedFileId PublishedFileId_t [50] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserPublishedFilesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserPublishedFilesResult_t)(RemoteStorageEnumerateUserPublishedFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserPublishedFilesResult_t) )) : ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserPublishedFilesResult_t) : typeof(Pack8) ); + internal static RemoteStorageEnumerateUserPublishedFilesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserPublishedFilesResult_t)(RemoteStorageEnumerateUserPublishedFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserPublishedFilesResult_t) )) : ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageEnumerateUserPublishedFilesResult_t)default(RemoteStorageEnumerateUserPublishedFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageEnumerateUserPublishedFilesResult_t)default(RemoteStorageEnumerateUserPublishedFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageEnumerateUserPublishedFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageEnumerateUserPublishedFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2678,32 +4183,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageSubscribePublishedFileResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageSubscribePublishedFileResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageSubscribePublishedFileResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageSubscribePublishedFileResult_t)(RemoteStorageSubscribePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageSubscribePublishedFileResult_t) )) : ((RemoteStorageSubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageSubscribePublishedFileResult_t) : typeof(Pack8) ); + internal static RemoteStorageSubscribePublishedFileResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageSubscribePublishedFileResult_t)(RemoteStorageSubscribePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageSubscribePublishedFileResult_t) )) : ((RemoteStorageSubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageSubscribePublishedFileResult_t)default(RemoteStorageSubscribePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageSubscribePublishedFileResult_t)default(RemoteStorageSubscribePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageSubscribePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageSubscribePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2719,7 +4248,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageEnumerateUserSubscribedFilesResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageEnumerateUserSubscribedFilesResult_t { internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 @@ -2729,27 +4258,51 @@ internal struct RemoteStorageEnumerateUserSubscribedFilesResult_t : Steamworks.I [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U4)] internal uint[] GRTimeSubscribed; // m_rgRTimeSubscribed uint32 [50] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserSubscribedFilesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(RemoteStorageEnumerateUserSubscribedFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserSubscribedFilesResult_t) )) : ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserSubscribedFilesResult_t) : typeof(Pack8) ); + internal static RemoteStorageEnumerateUserSubscribedFilesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(RemoteStorageEnumerateUserSubscribedFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserSubscribedFilesResult_t) )) : ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageEnumerateUserSubscribedFilesResult_t)default(RemoteStorageEnumerateUserSubscribedFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageEnumerateUserSubscribedFilesResult_t)default(RemoteStorageEnumerateUserSubscribedFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageEnumerateUserSubscribedFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageEnumerateUserSubscribedFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2770,32 +4323,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageUnsubscribePublishedFileResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageUnsubscribePublishedFileResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUnsubscribePublishedFileResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUnsubscribePublishedFileResult_t)(RemoteStorageUnsubscribePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUnsubscribePublishedFileResult_t) )) : ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUnsubscribePublishedFileResult_t) : typeof(Pack8) ); + internal static RemoteStorageUnsubscribePublishedFileResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUnsubscribePublishedFileResult_t)(RemoteStorageUnsubscribePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUnsubscribePublishedFileResult_t) )) : ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageUnsubscribePublishedFileResult_t)default(RemoteStorageUnsubscribePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageUnsubscribePublishedFileResult_t)default(RemoteStorageUnsubscribePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageUnsubscribePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageUnsubscribePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2811,34 +4388,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageUpdatePublishedFileResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageUpdatePublishedFileResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 16; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUpdatePublishedFileResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUpdatePublishedFileResult_t)(RemoteStorageUpdatePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUpdatePublishedFileResult_t) )) : ((RemoteStorageUpdatePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUpdatePublishedFileResult_t) : typeof(Pack8) ); + internal static RemoteStorageUpdatePublishedFileResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUpdatePublishedFileResult_t)(RemoteStorageUpdatePublishedFileResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUpdatePublishedFileResult_t) )) : ((RemoteStorageUpdatePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageUpdatePublishedFileResult_t)default(RemoteStorageUpdatePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageUpdatePublishedFileResult_t)default(RemoteStorageUpdatePublishedFileResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageUpdatePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 16, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 16, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageUpdatePublishedFileResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 16, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 16, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 16, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2856,7 +4457,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageDownloadUGCResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageDownloadUGCResult_t { internal Result Result; // m_eResult enum EResult internal ulong File; // m_hFile UGCHandle_t @@ -2866,27 +4467,51 @@ internal struct RemoteStorageDownloadUGCResult_t : Steamworks.ISteamCallback internal string PchFileName; // m_pchFileName char [260] internal ulong SteamIDOwner; // m_ulSteamIDOwner uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 17; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageDownloadUGCResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageDownloadUGCResult_t)(RemoteStorageDownloadUGCResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageDownloadUGCResult_t) )) : ((RemoteStorageDownloadUGCResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageDownloadUGCResult_t) : typeof(Pack8) ); + internal static RemoteStorageDownloadUGCResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageDownloadUGCResult_t)(RemoteStorageDownloadUGCResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageDownloadUGCResult_t) )) : ((RemoteStorageDownloadUGCResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageDownloadUGCResult_t)default(RemoteStorageDownloadUGCResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageDownloadUGCResult_t)default(RemoteStorageDownloadUGCResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageDownloadUGCResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 17, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 17, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageDownloadUGCResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 17, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 17, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 17, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -2907,7 +4532,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageGetPublishedFileDetailsResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageGetPublishedFileDetailsResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t @@ -2939,27 +4564,51 @@ internal struct RemoteStorageGetPublishedFileDetailsResult_t : Steamworks.ISteam [MarshalAs(UnmanagedType.I1)] internal bool AcceptedForUse; // m_bAcceptedForUse _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 18; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageGetPublishedFileDetailsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageGetPublishedFileDetailsResult_t)(RemoteStorageGetPublishedFileDetailsResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageGetPublishedFileDetailsResult_t) )) : ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageGetPublishedFileDetailsResult_t) : typeof(Pack8) ); + internal static RemoteStorageGetPublishedFileDetailsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageGetPublishedFileDetailsResult_t)(RemoteStorageGetPublishedFileDetailsResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageGetPublishedFileDetailsResult_t) )) : ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageGetPublishedFileDetailsResult_t)default(RemoteStorageGetPublishedFileDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageGetPublishedFileDetailsResult_t)default(RemoteStorageGetPublishedFileDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageGetPublishedFileDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 18, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 18, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageGetPublishedFileDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 18, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 18, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 18, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3002,7 +4651,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageEnumerateWorkshopFilesResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageEnumerateWorkshopFilesResult_t { internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 @@ -3014,27 +4663,51 @@ internal struct RemoteStorageEnumerateWorkshopFilesResult_t : Steamworks.ISteamC internal AppId AppId; // m_nAppId AppId_t internal uint StartIndex; // m_unStartIndex uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 19; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateWorkshopFilesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateWorkshopFilesResult_t)(RemoteStorageEnumerateWorkshopFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateWorkshopFilesResult_t) )) : ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateWorkshopFilesResult_t) : typeof(Pack8) ); + internal static RemoteStorageEnumerateWorkshopFilesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateWorkshopFilesResult_t)(RemoteStorageEnumerateWorkshopFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateWorkshopFilesResult_t) )) : ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageEnumerateWorkshopFilesResult_t)default(RemoteStorageEnumerateWorkshopFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageEnumerateWorkshopFilesResult_t)default(RemoteStorageEnumerateWorkshopFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageEnumerateWorkshopFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 19, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 19, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageEnumerateWorkshopFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 19, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 19, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 19, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3057,7 +4730,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageGetPublishedItemVoteDetailsResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageGetPublishedItemVoteDetailsResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_unPublishedFileId PublishedFileId_t @@ -3066,27 +4739,51 @@ internal struct RemoteStorageGetPublishedItemVoteDetailsResult_t : Steamworks.IS internal int Reports; // m_nReports int32 internal float FScore; // m_fScore float - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 20; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageGetPublishedItemVoteDetailsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(RemoteStorageGetPublishedItemVoteDetailsResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageGetPublishedItemVoteDetailsResult_t) )) : ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageGetPublishedItemVoteDetailsResult_t) : typeof(Pack8) ); + internal static RemoteStorageGetPublishedItemVoteDetailsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(RemoteStorageGetPublishedItemVoteDetailsResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageGetPublishedItemVoteDetailsResult_t) )) : ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageGetPublishedItemVoteDetailsResult_t)default(RemoteStorageGetPublishedItemVoteDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageGetPublishedItemVoteDetailsResult_t)default(RemoteStorageGetPublishedItemVoteDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageGetPublishedItemVoteDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 20, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 20, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageGetPublishedItemVoteDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 20, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 20, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 20, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3106,32 +4803,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishedFileSubscribed_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishedFileSubscribed_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 21; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileSubscribed_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileSubscribed_t)(RemoteStoragePublishedFileSubscribed_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileSubscribed_t) )) : ((RemoteStoragePublishedFileSubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileSubscribed_t) : typeof(Pack8) ); + internal static RemoteStoragePublishedFileSubscribed_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileSubscribed_t)(RemoteStoragePublishedFileSubscribed_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileSubscribed_t) )) : ((RemoteStoragePublishedFileSubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishedFileSubscribed_t)default(RemoteStoragePublishedFileSubscribed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishedFileSubscribed_t)default(RemoteStoragePublishedFileSubscribed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishedFileSubscribed_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 21, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 21, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishedFileSubscribed_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 21, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 21, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 21, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3147,32 +4868,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishedFileUnsubscribed_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishedFileUnsubscribed_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 22; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileUnsubscribed_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileUnsubscribed_t)(RemoteStoragePublishedFileUnsubscribed_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileUnsubscribed_t) )) : ((RemoteStoragePublishedFileUnsubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileUnsubscribed_t) : typeof(Pack8) ); + internal static RemoteStoragePublishedFileUnsubscribed_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileUnsubscribed_t)(RemoteStoragePublishedFileUnsubscribed_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileUnsubscribed_t) )) : ((RemoteStoragePublishedFileUnsubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishedFileUnsubscribed_t)default(RemoteStoragePublishedFileUnsubscribed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishedFileUnsubscribed_t)default(RemoteStoragePublishedFileUnsubscribed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishedFileUnsubscribed_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 22, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 22, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishedFileUnsubscribed_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 22, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 22, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 22, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3188,32 +4933,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishedFileDeleted_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishedFileDeleted_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 23; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileDeleted_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileDeleted_t)(RemoteStoragePublishedFileDeleted_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileDeleted_t) )) : ((RemoteStoragePublishedFileDeleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileDeleted_t) : typeof(Pack8) ); + internal static RemoteStoragePublishedFileDeleted_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileDeleted_t)(RemoteStoragePublishedFileDeleted_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileDeleted_t) )) : ((RemoteStoragePublishedFileDeleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishedFileDeleted_t)default(RemoteStoragePublishedFileDeleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishedFileDeleted_t)default(RemoteStoragePublishedFileDeleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishedFileDeleted_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 23, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 23, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishedFileDeleted_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 23, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 23, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 23, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3229,32 +4998,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageUpdateUserPublishedItemVoteResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageUpdateUserPublishedItemVoteResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 24; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUpdateUserPublishedItemVoteResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(RemoteStorageUpdateUserPublishedItemVoteResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUpdateUserPublishedItemVoteResult_t) )) : ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUpdateUserPublishedItemVoteResult_t) : typeof(Pack8) ); + internal static RemoteStorageUpdateUserPublishedItemVoteResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(RemoteStorageUpdateUserPublishedItemVoteResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUpdateUserPublishedItemVoteResult_t) )) : ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageUpdateUserPublishedItemVoteResult_t)default(RemoteStorageUpdateUserPublishedItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageUpdateUserPublishedItemVoteResult_t)default(RemoteStorageUpdateUserPublishedItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageUpdateUserPublishedItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 24, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 24, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageUpdateUserPublishedItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 24, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 24, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 24, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3270,33 +5063,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageUserVoteDetails_t : Steamworks.ISteamCallback + internal struct RemoteStorageUserVoteDetails_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal WorkshopVote Vote; // m_eVote enum EWorkshopVote - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 25; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUserVoteDetails_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUserVoteDetails_t)(RemoteStorageUserVoteDetails_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUserVoteDetails_t) )) : ((RemoteStorageUserVoteDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageUserVoteDetails_t) : typeof(Pack8) ); + internal static RemoteStorageUserVoteDetails_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageUserVoteDetails_t)(RemoteStorageUserVoteDetails_t) Marshal.PtrToStructure( p, typeof(RemoteStorageUserVoteDetails_t) )) : ((RemoteStorageUserVoteDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageUserVoteDetails_t)default(RemoteStorageUserVoteDetails_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageUserVoteDetails_t)default(RemoteStorageUserVoteDetails_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageUserVoteDetails_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 25, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 25, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageUserVoteDetails_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 25, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 25, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 25, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3313,7 +5130,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t { internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 @@ -3321,27 +5138,51 @@ internal struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t : Steamwor [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] internal PublishedFileId[] GPublishedFileId; // m_rgPublishedFileId PublishedFileId_t [50] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 26; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) )) : ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) : typeof(Pack8) ); + internal static RemoteStorageEnumerateUserSharedWorkshopFilesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t) )) : ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)default(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)default(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 26, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 26, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 26, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 26, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 26, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3360,33 +5201,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageSetUserPublishedFileActionResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageSetUserPublishedFileActionResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal WorkshopFileAction Action; // m_eAction enum EWorkshopFileAction - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 27; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageSetUserPublishedFileActionResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageSetUserPublishedFileActionResult_t)(RemoteStorageSetUserPublishedFileActionResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageSetUserPublishedFileActionResult_t) )) : ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageSetUserPublishedFileActionResult_t) : typeof(Pack8) ); + internal static RemoteStorageSetUserPublishedFileActionResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageSetUserPublishedFileActionResult_t)(RemoteStorageSetUserPublishedFileActionResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageSetUserPublishedFileActionResult_t) )) : ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageSetUserPublishedFileActionResult_t)default(RemoteStorageSetUserPublishedFileActionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageSetUserPublishedFileActionResult_t)default(RemoteStorageSetUserPublishedFileActionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageSetUserPublishedFileActionResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 27, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 27, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageSetUserPublishedFileActionResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 27, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 27, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 27, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3403,7 +5268,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t : Steamworks.ISteamCallback + internal struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t { internal Result Result; // m_eResult enum EResult internal WorkshopFileAction Action; // m_eAction enum EWorkshopFileAction @@ -3414,27 +5279,51 @@ internal struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t : Steam [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U4)] internal uint[] GRTimeUpdated; // m_rgRTimeUpdated uint32 [50] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 28; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) )) : ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) : typeof(Pack8) ); + internal static RemoteStorageEnumeratePublishedFilesByUserActionResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) Marshal.PtrToStructure( p, typeof(RemoteStorageEnumeratePublishedFilesByUserActionResult_t) )) : ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageEnumeratePublishedFilesByUserActionResult_t)default(RemoteStorageEnumeratePublishedFilesByUserActionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageEnumeratePublishedFilesByUserActionResult_t)default(RemoteStorageEnumeratePublishedFilesByUserActionResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageEnumeratePublishedFilesByUserActionResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 28, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 28, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageEnumeratePublishedFilesByUserActionResult_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 28, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 28, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 28, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3456,33 +5345,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishFileProgress_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishFileProgress_t { internal double DPercentFile; // m_dPercentFile double [MarshalAs(UnmanagedType.I1)] internal bool Preview; // m_bPreview _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 29; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishFileProgress_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishFileProgress_t)(RemoteStoragePublishFileProgress_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishFileProgress_t) )) : ((RemoteStoragePublishFileProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishFileProgress_t) : typeof(Pack8) ); + internal static RemoteStoragePublishFileProgress_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishFileProgress_t)(RemoteStoragePublishFileProgress_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishFileProgress_t) )) : ((RemoteStoragePublishFileProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishFileProgress_t)default(RemoteStoragePublishFileProgress_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishFileProgress_t)default(RemoteStoragePublishFileProgress_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishFileProgress_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 29, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 29, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishFileProgress_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 29, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 29, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 29, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3499,33 +5412,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStoragePublishedFileUpdated_t : Steamworks.ISteamCallback + internal struct RemoteStoragePublishedFileUpdated_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t internal ulong Unused; // m_ulUnused uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 30; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileUpdated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileUpdated_t)(RemoteStoragePublishedFileUpdated_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileUpdated_t) )) : ((RemoteStoragePublishedFileUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStoragePublishedFileUpdated_t) : typeof(Pack8) ); + internal static RemoteStoragePublishedFileUpdated_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStoragePublishedFileUpdated_t)(RemoteStoragePublishedFileUpdated_t) Marshal.PtrToStructure( p, typeof(RemoteStoragePublishedFileUpdated_t) )) : ((RemoteStoragePublishedFileUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStoragePublishedFileUpdated_t)default(RemoteStoragePublishedFileUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStoragePublishedFileUpdated_t)default(RemoteStoragePublishedFileUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStoragePublishedFileUpdated_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 30, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 30, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStoragePublishedFileUpdated_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 30, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 30, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 30, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3542,31 +5479,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageFileWriteAsyncComplete_t : Steamworks.ISteamCallback + internal struct RemoteStorageFileWriteAsyncComplete_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 31; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileWriteAsyncComplete_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileWriteAsyncComplete_t)(RemoteStorageFileWriteAsyncComplete_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileWriteAsyncComplete_t) )) : ((RemoteStorageFileWriteAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileWriteAsyncComplete_t) : typeof(Pack8) ); + internal static RemoteStorageFileWriteAsyncComplete_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileWriteAsyncComplete_t)(RemoteStorageFileWriteAsyncComplete_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileWriteAsyncComplete_t) )) : ((RemoteStorageFileWriteAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageFileWriteAsyncComplete_t)default(RemoteStorageFileWriteAsyncComplete_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageFileWriteAsyncComplete_t)default(RemoteStorageFileWriteAsyncComplete_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageFileWriteAsyncComplete_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 31, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 31, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageFileWriteAsyncComplete_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 31, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 31, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 31, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3581,34 +5542,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoteStorageFileReadAsyncComplete_t : Steamworks.ISteamCallback + internal struct RemoteStorageFileReadAsyncComplete_t { internal ulong FileReadAsync; // m_hFileReadAsync SteamAPICall_t internal Result Result; // m_eResult enum EResult internal uint Offset; // m_nOffset uint32 internal uint Read; // m_cubRead uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 32; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileReadAsyncComplete_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileReadAsyncComplete_t)(RemoteStorageFileReadAsyncComplete_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileReadAsyncComplete_t) )) : ((RemoteStorageFileReadAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoteStorageFileReadAsyncComplete_t) : typeof(Pack8) ); + internal static RemoteStorageFileReadAsyncComplete_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoteStorageFileReadAsyncComplete_t)(RemoteStorageFileReadAsyncComplete_t) Marshal.PtrToStructure( p, typeof(RemoteStorageFileReadAsyncComplete_t) )) : ((RemoteStorageFileReadAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoteStorageFileReadAsyncComplete_t)default(RemoteStorageFileReadAsyncComplete_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoteStorageFileReadAsyncComplete_t)default(RemoteStorageFileReadAsyncComplete_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoteStorageFileReadAsyncComplete_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 32, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientRemoteStorage + 32, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoteStorageFileReadAsyncComplete_t).GetStructSize(), CallbackIdentifiers.ClientRemoteStorage + 32, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientRemoteStorage + 32, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientRemoteStorage + 32, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3635,8 +5620,7 @@ internal struct LeaderboardEntry_t internal ulong UGC; // m_hUGC UGCHandle_t #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardEntry_t) : typeof(Pack8) ); - public LeaderboardEntry_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardEntry_t)(LeaderboardEntry_t) Marshal.PtrToStructure( p, typeof(LeaderboardEntry_t) )) : ((LeaderboardEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static LeaderboardEntry_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardEntry_t)(LeaderboardEntry_t) Marshal.PtrToStructure( p, typeof(LeaderboardEntry_t) )) : ((LeaderboardEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -3655,63 +5639,111 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserStatsReceived_t : Steamworks.ISteamCallback + internal struct UserStatsReceived_t { internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(UserStatsReceived_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((UserStatsReceived_t)(UserStatsReceived_t) Marshal.PtrToStructure( p, typeof(UserStatsReceived_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(UserStatsReceived_t) ); + internal static UserStatsReceived_t Fill( IntPtr p ) => ((UserStatsReceived_t)(UserStatsReceived_t) Marshal.PtrToStructure( p, typeof(UserStatsReceived_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserStatsReceived_t)default(UserStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserStatsReceived_t)default(UserStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserStatsStored_t : Steamworks.ISteamCallback + internal struct UserStatsStored_t { internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserStatsStored_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((UserStatsStored_t)(UserStatsStored_t) Marshal.PtrToStructure( p, typeof(UserStatsStored_t) )) : ((UserStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserStatsStored_t) : typeof(Pack8) ); + internal static UserStatsStored_t Fill( IntPtr p ) => Config.PackSmall ? ((UserStatsStored_t)(UserStatsStored_t) Marshal.PtrToStructure( p, typeof(UserStatsStored_t) )) : ((UserStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserStatsStored_t)default(UserStatsStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserStatsStored_t)default(UserStatsStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserStatsStored_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserStatsStored_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3727,7 +5759,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserAchievementStored_t : Steamworks.ISteamCallback + internal struct UserAchievementStored_t { internal ulong GameID; // m_nGameID uint64 [MarshalAs(UnmanagedType.I1)] @@ -3737,27 +5769,51 @@ internal struct UserAchievementStored_t : Steamworks.ISteamCallback internal uint CurProgress; // m_nCurProgress uint32 internal uint MaxProgress; // m_nMaxProgress uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserAchievementStored_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((UserAchievementStored_t)(UserAchievementStored_t) Marshal.PtrToStructure( p, typeof(UserAchievementStored_t) )) : ((UserAchievementStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserAchievementStored_t) : typeof(Pack8) ); + internal static UserAchievementStored_t Fill( IntPtr p ) => Config.PackSmall ? ((UserAchievementStored_t)(UserAchievementStored_t) Marshal.PtrToStructure( p, typeof(UserAchievementStored_t) )) : ((UserAchievementStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserAchievementStored_t)default(UserAchievementStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserAchievementStored_t)default(UserAchievementStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserAchievementStored_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserAchievementStored_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3778,32 +5834,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LeaderboardFindResult_t : Steamworks.ISteamCallback + internal struct LeaderboardFindResult_t { internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t internal byte LeaderboardFound; // m_bLeaderboardFound uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardFindResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardFindResult_t)(LeaderboardFindResult_t) Marshal.PtrToStructure( p, typeof(LeaderboardFindResult_t) )) : ((LeaderboardFindResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardFindResult_t) : typeof(Pack8) ); + internal static LeaderboardFindResult_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardFindResult_t)(LeaderboardFindResult_t) Marshal.PtrToStructure( p, typeof(LeaderboardFindResult_t) )) : ((LeaderboardFindResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LeaderboardFindResult_t)default(LeaderboardFindResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LeaderboardFindResult_t)default(LeaderboardFindResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LeaderboardFindResult_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(LeaderboardFindResult_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3819,33 +5899,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LeaderboardScoresDownloaded_t : Steamworks.ISteamCallback + internal struct LeaderboardScoresDownloaded_t { internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t internal ulong SteamLeaderboardEntries; // m_hSteamLeaderboardEntries SteamLeaderboardEntries_t internal int CEntryCount; // m_cEntryCount int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardScoresDownloaded_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardScoresDownloaded_t)(LeaderboardScoresDownloaded_t) Marshal.PtrToStructure( p, typeof(LeaderboardScoresDownloaded_t) )) : ((LeaderboardScoresDownloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardScoresDownloaded_t) : typeof(Pack8) ); + internal static LeaderboardScoresDownloaded_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardScoresDownloaded_t)(LeaderboardScoresDownloaded_t) Marshal.PtrToStructure( p, typeof(LeaderboardScoresDownloaded_t) )) : ((LeaderboardScoresDownloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LeaderboardScoresDownloaded_t)default(LeaderboardScoresDownloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LeaderboardScoresDownloaded_t)default(LeaderboardScoresDownloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LeaderboardScoresDownloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(LeaderboardScoresDownloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3862,7 +5966,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LeaderboardScoreUploaded_t : Steamworks.ISteamCallback + internal struct LeaderboardScoreUploaded_t { internal byte Success; // m_bSuccess uint8 internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t @@ -3871,27 +5975,51 @@ internal struct LeaderboardScoreUploaded_t : Steamworks.ISteamCallback internal int GlobalRankNew; // m_nGlobalRankNew int internal int GlobalRankPrevious; // m_nGlobalRankPrevious int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 6; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardScoreUploaded_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardScoreUploaded_t)(LeaderboardScoreUploaded_t) Marshal.PtrToStructure( p, typeof(LeaderboardScoreUploaded_t) )) : ((LeaderboardScoreUploaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardScoreUploaded_t) : typeof(Pack8) ); + internal static LeaderboardScoreUploaded_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardScoreUploaded_t)(LeaderboardScoreUploaded_t) Marshal.PtrToStructure( p, typeof(LeaderboardScoreUploaded_t) )) : ((LeaderboardScoreUploaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LeaderboardScoreUploaded_t)default(LeaderboardScoreUploaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LeaderboardScoreUploaded_t)default(LeaderboardScoreUploaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LeaderboardScoreUploaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 6, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 6, true ); actionServer = action; } else { - Event.Register( OnClient, default(LeaderboardScoreUploaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 6, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 6, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 6, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3911,32 +6039,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct NumberOfCurrentPlayers_t : Steamworks.ISteamCallback + internal struct NumberOfCurrentPlayers_t { internal byte Success; // m_bSuccess uint8 internal int CPlayers; // m_cPlayers int32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(NumberOfCurrentPlayers_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((NumberOfCurrentPlayers_t)(NumberOfCurrentPlayers_t) Marshal.PtrToStructure( p, typeof(NumberOfCurrentPlayers_t) )) : ((NumberOfCurrentPlayers_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(NumberOfCurrentPlayers_t) : typeof(Pack8) ); + internal static NumberOfCurrentPlayers_t Fill( IntPtr p ) => Config.PackSmall ? ((NumberOfCurrentPlayers_t)(NumberOfCurrentPlayers_t) Marshal.PtrToStructure( p, typeof(NumberOfCurrentPlayers_t) )) : ((NumberOfCurrentPlayers_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (NumberOfCurrentPlayers_t)default(NumberOfCurrentPlayers_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (NumberOfCurrentPlayers_t)default(NumberOfCurrentPlayers_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(NumberOfCurrentPlayers_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(NumberOfCurrentPlayers_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -3952,36 +6104,60 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserStatsUnloaded_t : Steamworks.ISteamCallback + internal struct UserStatsUnloaded_t { internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(UserStatsUnloaded_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((UserStatsUnloaded_t)(UserStatsUnloaded_t) Marshal.PtrToStructure( p, typeof(UserStatsUnloaded_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(UserStatsUnloaded_t) ); + internal static UserStatsUnloaded_t Fill( IntPtr p ) => ((UserStatsUnloaded_t)(UserStatsUnloaded_t) Marshal.PtrToStructure( p, typeof(UserStatsUnloaded_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserStatsUnloaded_t)default(UserStatsUnloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserStatsUnloaded_t)default(UserStatsUnloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserStatsUnloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserStatsUnloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserAchievementIconFetched_t : Steamworks.ISteamCallback + internal struct UserAchievementIconFetched_t { internal GameId GameID; // m_nGameID class CGameID [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] @@ -3990,27 +6166,51 @@ internal struct UserAchievementIconFetched_t : Steamworks.ISteamCallback internal bool Achieved; // m_bAchieved _Bool internal int IconHandle; // m_nIconHandle int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserAchievementIconFetched_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((UserAchievementIconFetched_t)(UserAchievementIconFetched_t) Marshal.PtrToStructure( p, typeof(UserAchievementIconFetched_t) )) : ((UserAchievementIconFetched_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserAchievementIconFetched_t) : typeof(Pack8) ); + internal static UserAchievementIconFetched_t Fill( IntPtr p ) => Config.PackSmall ? ((UserAchievementIconFetched_t)(UserAchievementIconFetched_t) Marshal.PtrToStructure( p, typeof(UserAchievementIconFetched_t) )) : ((UserAchievementIconFetched_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserAchievementIconFetched_t)default(UserAchievementIconFetched_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserAchievementIconFetched_t)default(UserAchievementIconFetched_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserAchievementIconFetched_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserAchievementIconFetched_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4030,32 +6230,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GlobalAchievementPercentagesReady_t : Steamworks.ISteamCallback + internal struct GlobalAchievementPercentagesReady_t { internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GlobalAchievementPercentagesReady_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GlobalAchievementPercentagesReady_t)(GlobalAchievementPercentagesReady_t) Marshal.PtrToStructure( p, typeof(GlobalAchievementPercentagesReady_t) )) : ((GlobalAchievementPercentagesReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GlobalAchievementPercentagesReady_t) : typeof(Pack8) ); + internal static GlobalAchievementPercentagesReady_t Fill( IntPtr p ) => Config.PackSmall ? ((GlobalAchievementPercentagesReady_t)(GlobalAchievementPercentagesReady_t) Marshal.PtrToStructure( p, typeof(GlobalAchievementPercentagesReady_t) )) : ((GlobalAchievementPercentagesReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GlobalAchievementPercentagesReady_t)default(GlobalAchievementPercentagesReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GlobalAchievementPercentagesReady_t)default(GlobalAchievementPercentagesReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GlobalAchievementPercentagesReady_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(GlobalAchievementPercentagesReady_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4071,32 +6295,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LeaderboardUGCSet_t : Steamworks.ISteamCallback + internal struct LeaderboardUGCSet_t { internal Result Result; // m_eResult enum EResult internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardUGCSet_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardUGCSet_t)(LeaderboardUGCSet_t) Marshal.PtrToStructure( p, typeof(LeaderboardUGCSet_t) )) : ((LeaderboardUGCSet_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LeaderboardUGCSet_t) : typeof(Pack8) ); + internal static LeaderboardUGCSet_t Fill( IntPtr p ) => Config.PackSmall ? ((LeaderboardUGCSet_t)(LeaderboardUGCSet_t) Marshal.PtrToStructure( p, typeof(LeaderboardUGCSet_t) )) : ((LeaderboardUGCSet_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LeaderboardUGCSet_t)default(LeaderboardUGCSet_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LeaderboardUGCSet_t)default(LeaderboardUGCSet_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LeaderboardUGCSet_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(LeaderboardUGCSet_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4112,33 +6360,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct PS3TrophiesInstalled_t : Steamworks.ISteamCallback + internal struct PS3TrophiesInstalled_t { internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult internal ulong RequiredDiskSpace; // m_ulRequiredDiskSpace uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(PS3TrophiesInstalled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((PS3TrophiesInstalled_t)(PS3TrophiesInstalled_t) Marshal.PtrToStructure( p, typeof(PS3TrophiesInstalled_t) )) : ((PS3TrophiesInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(PS3TrophiesInstalled_t) : typeof(Pack8) ); + internal static PS3TrophiesInstalled_t Fill( IntPtr p ) => Config.PackSmall ? ((PS3TrophiesInstalled_t)(PS3TrophiesInstalled_t) Marshal.PtrToStructure( p, typeof(PS3TrophiesInstalled_t) )) : ((PS3TrophiesInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (PS3TrophiesInstalled_t)default(PS3TrophiesInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (PS3TrophiesInstalled_t)default(PS3TrophiesInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(PS3TrophiesInstalled_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(PS3TrophiesInstalled_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4155,32 +6427,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GlobalStatsReceived_t : Steamworks.ISteamCallback + internal struct GlobalStatsReceived_t { internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GlobalStatsReceived_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GlobalStatsReceived_t)(GlobalStatsReceived_t) Marshal.PtrToStructure( p, typeof(GlobalStatsReceived_t) )) : ((GlobalStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GlobalStatsReceived_t) : typeof(Pack8) ); + internal static GlobalStatsReceived_t Fill( IntPtr p ) => Config.PackSmall ? ((GlobalStatsReceived_t)(GlobalStatsReceived_t) Marshal.PtrToStructure( p, typeof(GlobalStatsReceived_t) )) : ((GlobalStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GlobalStatsReceived_t)default(GlobalStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GlobalStatsReceived_t)default(GlobalStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GlobalStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(GlobalStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4196,31 +6492,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct DlcInstalled_t : Steamworks.ISteamCallback + internal struct DlcInstalled_t { internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamApps + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DlcInstalled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((DlcInstalled_t)(DlcInstalled_t) Marshal.PtrToStructure( p, typeof(DlcInstalled_t) )) : ((DlcInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DlcInstalled_t) : typeof(Pack8) ); + internal static DlcInstalled_t Fill( IntPtr p ) => Config.PackSmall ? ((DlcInstalled_t)(DlcInstalled_t) Marshal.PtrToStructure( p, typeof(DlcInstalled_t) )) : ((DlcInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (DlcInstalled_t)default(DlcInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (DlcInstalled_t)default(DlcInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(DlcInstalled_t).GetStructSize(), CallbackIdentifiers.SteamApps + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamApps + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(DlcInstalled_t).GetStructSize(), CallbackIdentifiers.SteamApps + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamApps + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamApps + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4235,32 +6555,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RegisterActivationCodeResponse_t : Steamworks.ISteamCallback + internal struct RegisterActivationCodeResponse_t { internal RegisterActivationCodeResult Result; // m_eResult enum ERegisterActivationCodeResult internal uint PackageRegistered; // m_unPackageRegistered uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamApps + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RegisterActivationCodeResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RegisterActivationCodeResponse_t)(RegisterActivationCodeResponse_t) Marshal.PtrToStructure( p, typeof(RegisterActivationCodeResponse_t) )) : ((RegisterActivationCodeResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RegisterActivationCodeResponse_t) : typeof(Pack8) ); + internal static RegisterActivationCodeResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((RegisterActivationCodeResponse_t)(RegisterActivationCodeResponse_t) Marshal.PtrToStructure( p, typeof(RegisterActivationCodeResponse_t) )) : ((RegisterActivationCodeResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RegisterActivationCodeResponse_t)default(RegisterActivationCodeResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RegisterActivationCodeResponse_t)default(RegisterActivationCodeResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RegisterActivationCodeResponse_t).GetStructSize(), CallbackIdentifiers.SteamApps + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamApps + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(RegisterActivationCodeResponse_t).GetStructSize(), CallbackIdentifiers.SteamApps + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamApps + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamApps + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4276,7 +6620,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct AppProofOfPurchaseKeyResponse_t : Steamworks.ISteamCallback + internal struct AppProofOfPurchaseKeyResponse_t { internal Result Result; // m_eResult enum EResult internal uint AppID; // m_nAppID uint32 @@ -4284,27 +6628,51 @@ internal struct AppProofOfPurchaseKeyResponse_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 240)] internal string Key; // m_rgchKey char [240] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamApps + 21; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AppProofOfPurchaseKeyResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((AppProofOfPurchaseKeyResponse_t)(AppProofOfPurchaseKeyResponse_t) Marshal.PtrToStructure( p, typeof(AppProofOfPurchaseKeyResponse_t) )) : ((AppProofOfPurchaseKeyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AppProofOfPurchaseKeyResponse_t) : typeof(Pack8) ); + internal static AppProofOfPurchaseKeyResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((AppProofOfPurchaseKeyResponse_t)(AppProofOfPurchaseKeyResponse_t) Marshal.PtrToStructure( p, typeof(AppProofOfPurchaseKeyResponse_t) )) : ((AppProofOfPurchaseKeyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (AppProofOfPurchaseKeyResponse_t)default(AppProofOfPurchaseKeyResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (AppProofOfPurchaseKeyResponse_t)default(AppProofOfPurchaseKeyResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(AppProofOfPurchaseKeyResponse_t).GetStructSize(), CallbackIdentifiers.SteamApps + 21, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamApps + 21, true ); actionServer = action; } else { - Event.Register( OnClient, default(AppProofOfPurchaseKeyResponse_t).GetStructSize(), CallbackIdentifiers.SteamApps + 21, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamApps + 21, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamApps + 21, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4323,7 +6691,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct FileDetailsResult_t : Steamworks.ISteamCallback + internal struct FileDetailsResult_t { internal Result Result; // m_eResult enum EResult internal ulong FileSize; // m_ulFileSize uint64 @@ -4331,27 +6699,51 @@ internal struct FileDetailsResult_t : Steamworks.ISteamCallback internal byte[] FileSHA; // m_FileSHA uint8 [20] internal uint Flags; // m_unFlags uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamApps + 23; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FileDetailsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((FileDetailsResult_t)(FileDetailsResult_t) Marshal.PtrToStructure( p, typeof(FileDetailsResult_t) )) : ((FileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(FileDetailsResult_t) : typeof(Pack8) ); + internal static FileDetailsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((FileDetailsResult_t)(FileDetailsResult_t) Marshal.PtrToStructure( p, typeof(FileDetailsResult_t) )) : ((FileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (FileDetailsResult_t)default(FileDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (FileDetailsResult_t)default(FileDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(FileDetailsResult_t).GetStructSize(), CallbackIdentifiers.SteamApps + 23, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamApps + 23, true ); actionServer = action; } else { - Event.Register( OnClient, default(FileDetailsResult_t).GetStructSize(), CallbackIdentifiers.SteamApps + 23, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamApps + 23, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamApps + 23, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4382,8 +6774,7 @@ internal struct P2PSessionState_t internal ushort RemotePort; // m_nRemotePort uint16 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(P2PSessionState_t) : typeof(Pack8) ); - public P2PSessionState_t Fill( IntPtr p ) => Config.PackSmall ? ((P2PSessionState_t)(P2PSessionState_t) Marshal.PtrToStructure( p, typeof(P2PSessionState_t) )) : ((P2PSessionState_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static P2PSessionState_t Fill( IntPtr p ) => Config.PackSmall ? ((P2PSessionState_t)(P2PSessionState_t) Marshal.PtrToStructure( p, typeof(P2PSessionState_t) )) : ((P2PSessionState_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -4405,123 +6796,219 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct P2PSessionRequest_t : Steamworks.ISteamCallback + internal struct P2PSessionRequest_t { internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(P2PSessionRequest_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((P2PSessionRequest_t)(P2PSessionRequest_t) Marshal.PtrToStructure( p, typeof(P2PSessionRequest_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(P2PSessionRequest_t) ); + internal static P2PSessionRequest_t Fill( IntPtr p ) => ((P2PSessionRequest_t)(P2PSessionRequest_t) Marshal.PtrToStructure( p, typeof(P2PSessionRequest_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (P2PSessionRequest_t)default(P2PSessionRequest_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (P2PSessionRequest_t)default(P2PSessionRequest_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(P2PSessionRequest_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamNetworking + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(P2PSessionRequest_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamNetworking + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamNetworking + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct P2PSessionConnectFail_t : Steamworks.ISteamCallback + internal struct P2PSessionConnectFail_t { internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID internal byte P2PSessionError; // m_eP2PSessionError uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(P2PSessionConnectFail_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((P2PSessionConnectFail_t)(P2PSessionConnectFail_t) Marshal.PtrToStructure( p, typeof(P2PSessionConnectFail_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(P2PSessionConnectFail_t) ); + internal static P2PSessionConnectFail_t Fill( IntPtr p ) => ((P2PSessionConnectFail_t)(P2PSessionConnectFail_t) Marshal.PtrToStructure( p, typeof(P2PSessionConnectFail_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (P2PSessionConnectFail_t)default(P2PSessionConnectFail_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (P2PSessionConnectFail_t)default(P2PSessionConnectFail_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(P2PSessionConnectFail_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamNetworking + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(P2PSessionConnectFail_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamNetworking + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamNetworking + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SocketStatusCallback_t : Steamworks.ISteamCallback + internal struct SocketStatusCallback_t { internal uint Socket; // m_hSocket SNetSocket_t internal uint ListenSocket; // m_hListenSocket SNetListenSocket_t internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID internal int SNetSocketState; // m_eSNetSocketState int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(SocketStatusCallback_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((SocketStatusCallback_t)(SocketStatusCallback_t) Marshal.PtrToStructure( p, typeof(SocketStatusCallback_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(SocketStatusCallback_t) ); + internal static SocketStatusCallback_t Fill( IntPtr p ) => ((SocketStatusCallback_t)(SocketStatusCallback_t) Marshal.PtrToStructure( p, typeof(SocketStatusCallback_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SocketStatusCallback_t)default(SocketStatusCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SocketStatusCallback_t)default(SocketStatusCallback_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SocketStatusCallback_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamNetworking + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SocketStatusCallback_t).GetStructSize(), CallbackIdentifiers.SteamNetworking + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamNetworking + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamNetworking + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ScreenshotReady_t : Steamworks.ISteamCallback + internal struct ScreenshotReady_t { internal uint Local; // m_hLocal ScreenshotHandle internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamScreenshots + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ScreenshotReady_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((ScreenshotReady_t)(ScreenshotReady_t) Marshal.PtrToStructure( p, typeof(ScreenshotReady_t) )) : ((ScreenshotReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ScreenshotReady_t) : typeof(Pack8) ); + internal static ScreenshotReady_t Fill( IntPtr p ) => Config.PackSmall ? ((ScreenshotReady_t)(ScreenshotReady_t) Marshal.PtrToStructure( p, typeof(ScreenshotReady_t) )) : ((ScreenshotReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ScreenshotReady_t)default(ScreenshotReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ScreenshotReady_t)default(ScreenshotReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ScreenshotReady_t).GetStructSize(), CallbackIdentifiers.SteamScreenshots + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamScreenshots + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(ScreenshotReady_t).GetStructSize(), CallbackIdentifiers.SteamScreenshots + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamScreenshots + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamScreenshots + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4537,31 +7024,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct VolumeHasChanged_t : Steamworks.ISteamCallback + internal struct VolumeHasChanged_t { internal float NewVolume; // m_flNewVolume float - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(VolumeHasChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((VolumeHasChanged_t)(VolumeHasChanged_t) Marshal.PtrToStructure( p, typeof(VolumeHasChanged_t) )) : ((VolumeHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(VolumeHasChanged_t) : typeof(Pack8) ); + internal static VolumeHasChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((VolumeHasChanged_t)(VolumeHasChanged_t) Marshal.PtrToStructure( p, typeof(VolumeHasChanged_t) )) : ((VolumeHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (VolumeHasChanged_t)default(VolumeHasChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (VolumeHasChanged_t)default(VolumeHasChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(VolumeHasChanged_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusic + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(VolumeHasChanged_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusic + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusic + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4576,32 +7087,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerWantsShuffled_t : Steamworks.ISteamCallback + internal struct MusicPlayerWantsShuffled_t { [MarshalAs(UnmanagedType.I1)] internal bool Shuffled; // m_bShuffled _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsShuffled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsShuffled_t)(MusicPlayerWantsShuffled_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsShuffled_t) )) : ((MusicPlayerWantsShuffled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsShuffled_t) : typeof(Pack8) ); + internal static MusicPlayerWantsShuffled_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsShuffled_t)(MusicPlayerWantsShuffled_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsShuffled_t) )) : ((MusicPlayerWantsShuffled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerWantsShuffled_t)default(MusicPlayerWantsShuffled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerWantsShuffled_t)default(MusicPlayerWantsShuffled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerWantsShuffled_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusicRemote + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerWantsShuffled_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusicRemote + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusicRemote + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4617,32 +7152,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerWantsLooped_t : Steamworks.ISteamCallback + internal struct MusicPlayerWantsLooped_t { [MarshalAs(UnmanagedType.I1)] internal bool Looped; // m_bLooped _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsLooped_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsLooped_t)(MusicPlayerWantsLooped_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsLooped_t) )) : ((MusicPlayerWantsLooped_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsLooped_t) : typeof(Pack8) ); + internal static MusicPlayerWantsLooped_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsLooped_t)(MusicPlayerWantsLooped_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsLooped_t) )) : ((MusicPlayerWantsLooped_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerWantsLooped_t)default(MusicPlayerWantsLooped_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerWantsLooped_t)default(MusicPlayerWantsLooped_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerWantsLooped_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusicRemote + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerWantsLooped_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusicRemote + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusicRemote + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4658,31 +7217,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerWantsVolume_t : Steamworks.ISteamCallback + internal struct MusicPlayerWantsVolume_t { internal float NewVolume; // m_flNewVolume float - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsVolume_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsVolume_t)(MusicPlayerWantsVolume_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsVolume_t) )) : ((MusicPlayerWantsVolume_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsVolume_t) : typeof(Pack8) ); + internal static MusicPlayerWantsVolume_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsVolume_t)(MusicPlayerWantsVolume_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsVolume_t) )) : ((MusicPlayerWantsVolume_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerWantsVolume_t)default(MusicPlayerWantsVolume_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerWantsVolume_t)default(MusicPlayerWantsVolume_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerWantsVolume_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusic + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerWantsVolume_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusic + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusic + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4697,31 +7280,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerSelectsQueueEntry_t : Steamworks.ISteamCallback + internal struct MusicPlayerSelectsQueueEntry_t { internal int NID; // nID int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerSelectsQueueEntry_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerSelectsQueueEntry_t)(MusicPlayerSelectsQueueEntry_t) Marshal.PtrToStructure( p, typeof(MusicPlayerSelectsQueueEntry_t) )) : ((MusicPlayerSelectsQueueEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerSelectsQueueEntry_t) : typeof(Pack8) ); + internal static MusicPlayerSelectsQueueEntry_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerSelectsQueueEntry_t)(MusicPlayerSelectsQueueEntry_t) Marshal.PtrToStructure( p, typeof(MusicPlayerSelectsQueueEntry_t) )) : ((MusicPlayerSelectsQueueEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerSelectsQueueEntry_t)default(MusicPlayerSelectsQueueEntry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerSelectsQueueEntry_t)default(MusicPlayerSelectsQueueEntry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerSelectsQueueEntry_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusic + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerSelectsQueueEntry_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusic + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusic + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4736,31 +7343,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerSelectsPlaylistEntry_t : Steamworks.ISteamCallback + internal struct MusicPlayerSelectsPlaylistEntry_t { internal int NID; // nID int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerSelectsPlaylistEntry_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerSelectsPlaylistEntry_t)(MusicPlayerSelectsPlaylistEntry_t) Marshal.PtrToStructure( p, typeof(MusicPlayerSelectsPlaylistEntry_t) )) : ((MusicPlayerSelectsPlaylistEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerSelectsPlaylistEntry_t) : typeof(Pack8) ); + internal static MusicPlayerSelectsPlaylistEntry_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerSelectsPlaylistEntry_t)(MusicPlayerSelectsPlaylistEntry_t) Marshal.PtrToStructure( p, typeof(MusicPlayerSelectsPlaylistEntry_t) )) : ((MusicPlayerSelectsPlaylistEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerSelectsPlaylistEntry_t)default(MusicPlayerSelectsPlaylistEntry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerSelectsPlaylistEntry_t)default(MusicPlayerSelectsPlaylistEntry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerSelectsPlaylistEntry_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusic + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerSelectsPlaylistEntry_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusic + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusic + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4775,31 +7406,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct MusicPlayerWantsPlayingRepeatStatus_t : Steamworks.ISteamCallback + internal struct MusicPlayerWantsPlayingRepeatStatus_t { internal int PlayingRepeatStatus; // m_nPlayingRepeatStatus int - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsPlayingRepeatStatus_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsPlayingRepeatStatus_t)(MusicPlayerWantsPlayingRepeatStatus_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsPlayingRepeatStatus_t) )) : ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(MusicPlayerWantsPlayingRepeatStatus_t) : typeof(Pack8) ); + internal static MusicPlayerWantsPlayingRepeatStatus_t Fill( IntPtr p ) => Config.PackSmall ? ((MusicPlayerWantsPlayingRepeatStatus_t)(MusicPlayerWantsPlayingRepeatStatus_t) Marshal.PtrToStructure( p, typeof(MusicPlayerWantsPlayingRepeatStatus_t) )) : ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (MusicPlayerWantsPlayingRepeatStatus_t)default(MusicPlayerWantsPlayingRepeatStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (MusicPlayerWantsPlayingRepeatStatus_t)default(MusicPlayerWantsPlayingRepeatStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(MusicPlayerWantsPlayingRepeatStatus_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusicRemote + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(MusicPlayerWantsPlayingRepeatStatus_t).GetStructSize(), CallbackIdentifiers.SteamMusicRemote + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusicRemote + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusicRemote + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4814,7 +7469,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTTPRequestCompleted_t : Steamworks.ISteamCallback + internal struct HTTPRequestCompleted_t { internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 @@ -4823,27 +7478,51 @@ internal struct HTTPRequestCompleted_t : Steamworks.ISteamCallback internal HTTPStatusCode StatusCode; // m_eStatusCode enum EHTTPStatusCode internal uint BodySize; // m_unBodySize uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestCompleted_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestCompleted_t)(HTTPRequestCompleted_t) Marshal.PtrToStructure( p, typeof(HTTPRequestCompleted_t) )) : ((HTTPRequestCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestCompleted_t) : typeof(Pack8) ); + internal static HTTPRequestCompleted_t Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestCompleted_t)(HTTPRequestCompleted_t) Marshal.PtrToStructure( p, typeof(HTTPRequestCompleted_t) )) : ((HTTPRequestCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTTPRequestCompleted_t)default(HTTPRequestCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTTPRequestCompleted_t)default(HTTPRequestCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTTPRequestCompleted_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientHTTP + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTTPRequestCompleted_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientHTTP + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientHTTP + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4863,32 +7542,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTTPRequestHeadersReceived_t : Steamworks.ISteamCallback + internal struct HTTPRequestHeadersReceived_t { internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestHeadersReceived_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestHeadersReceived_t)(HTTPRequestHeadersReceived_t) Marshal.PtrToStructure( p, typeof(HTTPRequestHeadersReceived_t) )) : ((HTTPRequestHeadersReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestHeadersReceived_t) : typeof(Pack8) ); + internal static HTTPRequestHeadersReceived_t Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestHeadersReceived_t)(HTTPRequestHeadersReceived_t) Marshal.PtrToStructure( p, typeof(HTTPRequestHeadersReceived_t) )) : ((HTTPRequestHeadersReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTTPRequestHeadersReceived_t)default(HTTPRequestHeadersReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTTPRequestHeadersReceived_t)default(HTTPRequestHeadersReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTTPRequestHeadersReceived_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientHTTP + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTTPRequestHeadersReceived_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientHTTP + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientHTTP + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4904,34 +7607,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTTPRequestDataReceived_t : Steamworks.ISteamCallback + internal struct HTTPRequestDataReceived_t { internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 internal uint COffset; // m_cOffset uint32 internal uint CBytesReceived; // m_cBytesReceived uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestDataReceived_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestDataReceived_t)(HTTPRequestDataReceived_t) Marshal.PtrToStructure( p, typeof(HTTPRequestDataReceived_t) )) : ((HTTPRequestDataReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTTPRequestDataReceived_t) : typeof(Pack8) ); + internal static HTTPRequestDataReceived_t Fill( IntPtr p ) => Config.PackSmall ? ((HTTPRequestDataReceived_t)(HTTPRequestDataReceived_t) Marshal.PtrToStructure( p, typeof(HTTPRequestDataReceived_t) )) : ((HTTPRequestDataReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTTPRequestDataReceived_t)default(HTTPRequestDataReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTTPRequestDataReceived_t)default(HTTPRequestDataReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTTPRequestDataReceived_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientHTTP + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTTPRequestDataReceived_t).GetStructSize(), CallbackIdentifiers.ClientHTTP + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientHTTP + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientHTTP + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -4987,8 +7714,7 @@ internal struct SteamUGCDetails_t internal uint NumChildren; // m_unNumChildren uint32 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamUGCDetails_t) : typeof(Pack8) ); - public SteamUGCDetails_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCDetails_t)(SteamUGCDetails_t) Marshal.PtrToStructure( p, typeof(SteamUGCDetails_t) )) : ((SteamUGCDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static SteamUGCDetails_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCDetails_t)(SteamUGCDetails_t) Marshal.PtrToStructure( p, typeof(SteamUGCDetails_t) )) : ((SteamUGCDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -5036,7 +7762,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamUGCQueryCompleted_t : Steamworks.ISteamCallback + internal struct SteamUGCQueryCompleted_t { internal ulong Handle; // m_handle UGCQueryHandle_t internal Result Result; // m_eResult enum EResult @@ -5047,27 +7773,51 @@ internal struct SteamUGCQueryCompleted_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string NextCursor; // m_rgchNextCursor char [256] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamUGCQueryCompleted_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCQueryCompleted_t)(SteamUGCQueryCompleted_t) Marshal.PtrToStructure( p, typeof(SteamUGCQueryCompleted_t) )) : ((SteamUGCQueryCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamUGCQueryCompleted_t) : typeof(Pack8) ); + internal static SteamUGCQueryCompleted_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCQueryCompleted_t)(SteamUGCQueryCompleted_t) Marshal.PtrToStructure( p, typeof(SteamUGCQueryCompleted_t) )) : ((SteamUGCQueryCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamUGCQueryCompleted_t)default(SteamUGCQueryCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamUGCQueryCompleted_t)default(SteamUGCQueryCompleted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamUGCQueryCompleted_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamUGCQueryCompleted_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5089,33 +7839,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamUGCRequestUGCDetailsResult_t : Steamworks.ISteamCallback + internal struct SteamUGCRequestUGCDetailsResult_t { internal SteamUGCDetails_t Details; // m_details struct SteamUGCDetails_t [MarshalAs(UnmanagedType.I1)] internal bool CachedData; // m_bCachedData _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamUGCRequestUGCDetailsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCRequestUGCDetailsResult_t)(SteamUGCRequestUGCDetailsResult_t) Marshal.PtrToStructure( p, typeof(SteamUGCRequestUGCDetailsResult_t) )) : ((SteamUGCRequestUGCDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamUGCRequestUGCDetailsResult_t) : typeof(Pack8) ); + internal static SteamUGCRequestUGCDetailsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamUGCRequestUGCDetailsResult_t)(SteamUGCRequestUGCDetailsResult_t) Marshal.PtrToStructure( p, typeof(SteamUGCRequestUGCDetailsResult_t) )) : ((SteamUGCRequestUGCDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamUGCRequestUGCDetailsResult_t)default(SteamUGCRequestUGCDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamUGCRequestUGCDetailsResult_t)default(SteamUGCRequestUGCDetailsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamUGCRequestUGCDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamUGCRequestUGCDetailsResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5132,34 +7906,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct CreateItemResult_t : Steamworks.ISteamCallback + internal struct CreateItemResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CreateItemResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((CreateItemResult_t)(CreateItemResult_t) Marshal.PtrToStructure( p, typeof(CreateItemResult_t) )) : ((CreateItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(CreateItemResult_t) : typeof(Pack8) ); + internal static CreateItemResult_t Fill( IntPtr p ) => Config.PackSmall ? ((CreateItemResult_t)(CreateItemResult_t) Marshal.PtrToStructure( p, typeof(CreateItemResult_t) )) : ((CreateItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (CreateItemResult_t)default(CreateItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (CreateItemResult_t)default(CreateItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(CreateItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(CreateItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5177,34 +7975,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SubmitItemUpdateResult_t : Steamworks.ISteamCallback + internal struct SubmitItemUpdateResult_t { internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SubmitItemUpdateResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SubmitItemUpdateResult_t)(SubmitItemUpdateResult_t) Marshal.PtrToStructure( p, typeof(SubmitItemUpdateResult_t) )) : ((SubmitItemUpdateResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SubmitItemUpdateResult_t) : typeof(Pack8) ); + internal static SubmitItemUpdateResult_t Fill( IntPtr p ) => Config.PackSmall ? ((SubmitItemUpdateResult_t)(SubmitItemUpdateResult_t) Marshal.PtrToStructure( p, typeof(SubmitItemUpdateResult_t) )) : ((SubmitItemUpdateResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SubmitItemUpdateResult_t)default(SubmitItemUpdateResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SubmitItemUpdateResult_t)default(SubmitItemUpdateResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SubmitItemUpdateResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(SubmitItemUpdateResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5222,33 +8044,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct DownloadItemResult_t : Steamworks.ISteamCallback + internal struct DownloadItemResult_t { internal AppId AppID; // m_unAppID AppId_t internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 6; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DownloadItemResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((DownloadItemResult_t)(DownloadItemResult_t) Marshal.PtrToStructure( p, typeof(DownloadItemResult_t) )) : ((DownloadItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DownloadItemResult_t) : typeof(Pack8) ); + internal static DownloadItemResult_t Fill( IntPtr p ) => Config.PackSmall ? ((DownloadItemResult_t)(DownloadItemResult_t) Marshal.PtrToStructure( p, typeof(DownloadItemResult_t) )) : ((DownloadItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (DownloadItemResult_t)default(DownloadItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (DownloadItemResult_t)default(DownloadItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(DownloadItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 6, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 6, true ); actionServer = action; } else { - Event.Register( OnClient, default(DownloadItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 6, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 6, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 6, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5265,34 +8111,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct UserFavoriteItemsListChanged_t : Steamworks.ISteamCallback + internal struct UserFavoriteItemsListChanged_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool WasAddRequest; // m_bWasAddRequest _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserFavoriteItemsListChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((UserFavoriteItemsListChanged_t)(UserFavoriteItemsListChanged_t) Marshal.PtrToStructure( p, typeof(UserFavoriteItemsListChanged_t) )) : ((UserFavoriteItemsListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(UserFavoriteItemsListChanged_t) : typeof(Pack8) ); + internal static UserFavoriteItemsListChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((UserFavoriteItemsListChanged_t)(UserFavoriteItemsListChanged_t) Marshal.PtrToStructure( p, typeof(UserFavoriteItemsListChanged_t) )) : ((UserFavoriteItemsListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (UserFavoriteItemsListChanged_t)default(UserFavoriteItemsListChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (UserFavoriteItemsListChanged_t)default(UserFavoriteItemsListChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(UserFavoriteItemsListChanged_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(UserFavoriteItemsListChanged_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5310,34 +8180,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SetUserItemVoteResult_t : Steamworks.ISteamCallback + internal struct SetUserItemVoteResult_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool VoteUp; // m_bVoteUp _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SetUserItemVoteResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SetUserItemVoteResult_t)(SetUserItemVoteResult_t) Marshal.PtrToStructure( p, typeof(SetUserItemVoteResult_t) )) : ((SetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SetUserItemVoteResult_t) : typeof(Pack8) ); + internal static SetUserItemVoteResult_t Fill( IntPtr p ) => Config.PackSmall ? ((SetUserItemVoteResult_t)(SetUserItemVoteResult_t) Marshal.PtrToStructure( p, typeof(SetUserItemVoteResult_t) )) : ((SetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SetUserItemVoteResult_t)default(SetUserItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SetUserItemVoteResult_t)default(SetUserItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SetUserItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(SetUserItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5355,7 +8249,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GetUserItemVoteResult_t : Steamworks.ISteamCallback + internal struct GetUserItemVoteResult_t { internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult @@ -5366,27 +8260,51 @@ internal struct GetUserItemVoteResult_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool VoteSkipped; // m_bVoteSkipped _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetUserItemVoteResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GetUserItemVoteResult_t)(GetUserItemVoteResult_t) Marshal.PtrToStructure( p, typeof(GetUserItemVoteResult_t) )) : ((GetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetUserItemVoteResult_t) : typeof(Pack8) ); + internal static GetUserItemVoteResult_t Fill( IntPtr p ) => Config.PackSmall ? ((GetUserItemVoteResult_t)(GetUserItemVoteResult_t) Marshal.PtrToStructure( p, typeof(GetUserItemVoteResult_t) )) : ((GetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GetUserItemVoteResult_t)default(GetUserItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GetUserItemVoteResult_t)default(GetUserItemVoteResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GetUserItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(GetUserItemVoteResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5408,31 +8326,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct StartPlaytimeTrackingResult_t : Steamworks.ISteamCallback + internal struct StartPlaytimeTrackingResult_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StartPlaytimeTrackingResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((StartPlaytimeTrackingResult_t)(StartPlaytimeTrackingResult_t) Marshal.PtrToStructure( p, typeof(StartPlaytimeTrackingResult_t) )) : ((StartPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StartPlaytimeTrackingResult_t) : typeof(Pack8) ); + internal static StartPlaytimeTrackingResult_t Fill( IntPtr p ) => Config.PackSmall ? ((StartPlaytimeTrackingResult_t)(StartPlaytimeTrackingResult_t) Marshal.PtrToStructure( p, typeof(StartPlaytimeTrackingResult_t) )) : ((StartPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (StartPlaytimeTrackingResult_t)default(StartPlaytimeTrackingResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (StartPlaytimeTrackingResult_t)default(StartPlaytimeTrackingResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(StartPlaytimeTrackingResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(StartPlaytimeTrackingResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5447,31 +8389,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct StopPlaytimeTrackingResult_t : Steamworks.ISteamCallback + internal struct StopPlaytimeTrackingResult_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StopPlaytimeTrackingResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((StopPlaytimeTrackingResult_t)(StopPlaytimeTrackingResult_t) Marshal.PtrToStructure( p, typeof(StopPlaytimeTrackingResult_t) )) : ((StopPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(StopPlaytimeTrackingResult_t) : typeof(Pack8) ); + internal static StopPlaytimeTrackingResult_t Fill( IntPtr p ) => Config.PackSmall ? ((StopPlaytimeTrackingResult_t)(StopPlaytimeTrackingResult_t) Marshal.PtrToStructure( p, typeof(StopPlaytimeTrackingResult_t) )) : ((StopPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (StopPlaytimeTrackingResult_t)default(StopPlaytimeTrackingResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (StopPlaytimeTrackingResult_t)default(StopPlaytimeTrackingResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(StopPlaytimeTrackingResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(StopPlaytimeTrackingResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5486,33 +8452,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct AddUGCDependencyResult_t : Steamworks.ISteamCallback + internal struct AddUGCDependencyResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal PublishedFileId ChildPublishedFileId; // m_nChildPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AddUGCDependencyResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((AddUGCDependencyResult_t)(AddUGCDependencyResult_t) Marshal.PtrToStructure( p, typeof(AddUGCDependencyResult_t) )) : ((AddUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AddUGCDependencyResult_t) : typeof(Pack8) ); + internal static AddUGCDependencyResult_t Fill( IntPtr p ) => Config.PackSmall ? ((AddUGCDependencyResult_t)(AddUGCDependencyResult_t) Marshal.PtrToStructure( p, typeof(AddUGCDependencyResult_t) )) : ((AddUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (AddUGCDependencyResult_t)default(AddUGCDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (AddUGCDependencyResult_t)default(AddUGCDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(AddUGCDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(AddUGCDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5529,33 +8519,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoveUGCDependencyResult_t : Steamworks.ISteamCallback + internal struct RemoveUGCDependencyResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal PublishedFileId ChildPublishedFileId; // m_nChildPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoveUGCDependencyResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoveUGCDependencyResult_t)(RemoveUGCDependencyResult_t) Marshal.PtrToStructure( p, typeof(RemoveUGCDependencyResult_t) )) : ((RemoveUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoveUGCDependencyResult_t) : typeof(Pack8) ); + internal static RemoveUGCDependencyResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoveUGCDependencyResult_t)(RemoveUGCDependencyResult_t) Marshal.PtrToStructure( p, typeof(RemoveUGCDependencyResult_t) )) : ((RemoveUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoveUGCDependencyResult_t)default(RemoveUGCDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoveUGCDependencyResult_t)default(RemoveUGCDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoveUGCDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoveUGCDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5572,33 +8586,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct AddAppDependencyResult_t : Steamworks.ISteamCallback + internal struct AddAppDependencyResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AddAppDependencyResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((AddAppDependencyResult_t)(AddAppDependencyResult_t) Marshal.PtrToStructure( p, typeof(AddAppDependencyResult_t) )) : ((AddAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AddAppDependencyResult_t) : typeof(Pack8) ); + internal static AddAppDependencyResult_t Fill( IntPtr p ) => Config.PackSmall ? ((AddAppDependencyResult_t)(AddAppDependencyResult_t) Marshal.PtrToStructure( p, typeof(AddAppDependencyResult_t) )) : ((AddAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (AddAppDependencyResult_t)default(AddAppDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (AddAppDependencyResult_t)default(AddAppDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(AddAppDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(AddAppDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5615,33 +8653,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct RemoveAppDependencyResult_t : Steamworks.ISteamCallback + internal struct RemoveAppDependencyResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoveAppDependencyResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((RemoveAppDependencyResult_t)(RemoveAppDependencyResult_t) Marshal.PtrToStructure( p, typeof(RemoveAppDependencyResult_t) )) : ((RemoveAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(RemoveAppDependencyResult_t) : typeof(Pack8) ); + internal static RemoveAppDependencyResult_t Fill( IntPtr p ) => Config.PackSmall ? ((RemoveAppDependencyResult_t)(RemoveAppDependencyResult_t) Marshal.PtrToStructure( p, typeof(RemoveAppDependencyResult_t) )) : ((RemoveAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (RemoveAppDependencyResult_t)default(RemoveAppDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (RemoveAppDependencyResult_t)default(RemoveAppDependencyResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(RemoveAppDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(RemoveAppDependencyResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5658,7 +8720,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GetAppDependenciesResult_t : Steamworks.ISteamCallback + internal struct GetAppDependenciesResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t @@ -5667,27 +8729,51 @@ internal struct GetAppDependenciesResult_t : Steamworks.ISteamCallback internal uint NumAppDependencies; // m_nNumAppDependencies uint32 internal uint TotalNumAppDependencies; // m_nTotalNumAppDependencies uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 16; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetAppDependenciesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GetAppDependenciesResult_t)(GetAppDependenciesResult_t) Marshal.PtrToStructure( p, typeof(GetAppDependenciesResult_t) )) : ((GetAppDependenciesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetAppDependenciesResult_t) : typeof(Pack8) ); + internal static GetAppDependenciesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((GetAppDependenciesResult_t)(GetAppDependenciesResult_t) Marshal.PtrToStructure( p, typeof(GetAppDependenciesResult_t) )) : ((GetAppDependenciesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GetAppDependenciesResult_t)default(GetAppDependenciesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GetAppDependenciesResult_t)default(GetAppDependenciesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GetAppDependenciesResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 16, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 16, true ); actionServer = action; } else { - Event.Register( OnClient, default(GetAppDependenciesResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 16, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 16, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 16, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5707,32 +8793,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct DeleteItemResult_t : Steamworks.ISteamCallback + internal struct DeleteItemResult_t { internal Result Result; // m_eResult enum EResult internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 17; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DeleteItemResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((DeleteItemResult_t)(DeleteItemResult_t) Marshal.PtrToStructure( p, typeof(DeleteItemResult_t) )) : ((DeleteItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(DeleteItemResult_t) : typeof(Pack8) ); + internal static DeleteItemResult_t Fill( IntPtr p ) => Config.PackSmall ? ((DeleteItemResult_t)(DeleteItemResult_t) Marshal.PtrToStructure( p, typeof(DeleteItemResult_t) )) : ((DeleteItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (DeleteItemResult_t)default(DeleteItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (DeleteItemResult_t)default(DeleteItemResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(DeleteItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 17, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 17, true ); actionServer = action; } else { - Event.Register( OnClient, default(DeleteItemResult_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 17, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 17, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 17, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5748,31 +8858,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamAppInstalled_t : Steamworks.ISteamCallback + internal struct SteamAppInstalled_t { internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamAppList + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAppInstalled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamAppInstalled_t)(SteamAppInstalled_t) Marshal.PtrToStructure( p, typeof(SteamAppInstalled_t) )) : ((SteamAppInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAppInstalled_t) : typeof(Pack8) ); + internal static SteamAppInstalled_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamAppInstalled_t)(SteamAppInstalled_t) Marshal.PtrToStructure( p, typeof(SteamAppInstalled_t) )) : ((SteamAppInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamAppInstalled_t)default(SteamAppInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamAppInstalled_t)default(SteamAppInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamAppInstalled_t).GetStructSize(), CallbackIdentifiers.SteamAppList + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamAppList + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamAppInstalled_t).GetStructSize(), CallbackIdentifiers.SteamAppList + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamAppList + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamAppList + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5787,31 +8921,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamAppUninstalled_t : Steamworks.ISteamCallback + internal struct SteamAppUninstalled_t { internal AppId AppID; // m_nAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamAppList + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAppUninstalled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamAppUninstalled_t)(SteamAppUninstalled_t) Marshal.PtrToStructure( p, typeof(SteamAppUninstalled_t) )) : ((SteamAppUninstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamAppUninstalled_t) : typeof(Pack8) ); + internal static SteamAppUninstalled_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamAppUninstalled_t)(SteamAppUninstalled_t) Marshal.PtrToStructure( p, typeof(SteamAppUninstalled_t) )) : ((SteamAppUninstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamAppUninstalled_t)default(SteamAppUninstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamAppUninstalled_t)default(SteamAppUninstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamAppUninstalled_t).GetStructSize(), CallbackIdentifiers.SteamAppList + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamAppList + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamAppUninstalled_t).GetStructSize(), CallbackIdentifiers.SteamAppList + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamAppList + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamAppList + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5826,31 +8984,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_BrowserReady_t : Steamworks.ISteamCallback + internal struct HTML_BrowserReady_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_BrowserReady_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_BrowserReady_t)(HTML_BrowserReady_t) Marshal.PtrToStructure( p, typeof(HTML_BrowserReady_t) )) : ((HTML_BrowserReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_BrowserReady_t) : typeof(Pack8) ); + internal static HTML_BrowserReady_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_BrowserReady_t)(HTML_BrowserReady_t) Marshal.PtrToStructure( p, typeof(HTML_BrowserReady_t) )) : ((HTML_BrowserReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_BrowserReady_t)default(HTML_BrowserReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_BrowserReady_t)default(HTML_BrowserReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_BrowserReady_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_BrowserReady_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -5881,8 +9063,7 @@ internal struct HTML_NeedsPaint_t internal uint UnPageSerial; // unPageSerial uint32 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_NeedsPaint_t) : typeof(Pack8) ); - public HTML_NeedsPaint_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_NeedsPaint_t)(HTML_NeedsPaint_t) Marshal.PtrToStructure( p, typeof(HTML_NeedsPaint_t) )) : ((HTML_NeedsPaint_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static HTML_NeedsPaint_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_NeedsPaint_t)(HTML_NeedsPaint_t) Marshal.PtrToStructure( p, typeof(HTML_NeedsPaint_t) )) : ((HTML_NeedsPaint_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -5918,8 +9099,7 @@ internal struct HTML_StartRequest_t internal bool BIsRedirect; // bIsRedirect _Bool #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_StartRequest_t) : typeof(Pack8) ); - public HTML_StartRequest_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_StartRequest_t)(HTML_StartRequest_t) Marshal.PtrToStructure( p, typeof(HTML_StartRequest_t) )) : ((HTML_StartRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static HTML_StartRequest_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_StartRequest_t)(HTML_StartRequest_t) Marshal.PtrToStructure( p, typeof(HTML_StartRequest_t) )) : ((HTML_StartRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -5944,8 +9124,7 @@ internal struct HTML_CloseBrowser_t internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_CloseBrowser_t) : typeof(Pack8) ); - public HTML_CloseBrowser_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_CloseBrowser_t)(HTML_CloseBrowser_t) Marshal.PtrToStructure( p, typeof(HTML_CloseBrowser_t) )) : ((HTML_CloseBrowser_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static HTML_CloseBrowser_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_CloseBrowser_t)(HTML_CloseBrowser_t) Marshal.PtrToStructure( p, typeof(HTML_CloseBrowser_t) )) : ((HTML_CloseBrowser_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -5960,7 +9139,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_URLChanged_t : Steamworks.ISteamCallback + internal struct HTML_URLChanged_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * @@ -5971,27 +9150,51 @@ internal struct HTML_URLChanged_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool BNewNavigation; // bNewNavigation _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_URLChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_URLChanged_t)(HTML_URLChanged_t) Marshal.PtrToStructure( p, typeof(HTML_URLChanged_t) )) : ((HTML_URLChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_URLChanged_t) : typeof(Pack8) ); + internal static HTML_URLChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_URLChanged_t)(HTML_URLChanged_t) Marshal.PtrToStructure( p, typeof(HTML_URLChanged_t) )) : ((HTML_URLChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_URLChanged_t)default(HTML_URLChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_URLChanged_t)default(HTML_URLChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_URLChanged_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_URLChanged_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6013,33 +9216,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_FinishedRequest_t : Steamworks.ISteamCallback + internal struct HTML_FinishedRequest_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * internal string PchPageTitle; // pchPageTitle const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 6; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_FinishedRequest_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_FinishedRequest_t)(HTML_FinishedRequest_t) Marshal.PtrToStructure( p, typeof(HTML_FinishedRequest_t) )) : ((HTML_FinishedRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_FinishedRequest_t) : typeof(Pack8) ); + internal static HTML_FinishedRequest_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_FinishedRequest_t)(HTML_FinishedRequest_t) Marshal.PtrToStructure( p, typeof(HTML_FinishedRequest_t) )) : ((HTML_FinishedRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_FinishedRequest_t)default(HTML_FinishedRequest_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_FinishedRequest_t)default(HTML_FinishedRequest_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_FinishedRequest_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 6, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 6, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_FinishedRequest_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 6, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 6, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 6, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6056,32 +9283,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_OpenLinkInNewTab_t : Steamworks.ISteamCallback + internal struct HTML_OpenLinkInNewTab_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_OpenLinkInNewTab_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_OpenLinkInNewTab_t)(HTML_OpenLinkInNewTab_t) Marshal.PtrToStructure( p, typeof(HTML_OpenLinkInNewTab_t) )) : ((HTML_OpenLinkInNewTab_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_OpenLinkInNewTab_t) : typeof(Pack8) ); + internal static HTML_OpenLinkInNewTab_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_OpenLinkInNewTab_t)(HTML_OpenLinkInNewTab_t) Marshal.PtrToStructure( p, typeof(HTML_OpenLinkInNewTab_t) )) : ((HTML_OpenLinkInNewTab_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_OpenLinkInNewTab_t)default(HTML_OpenLinkInNewTab_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_OpenLinkInNewTab_t)default(HTML_OpenLinkInNewTab_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_OpenLinkInNewTab_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_OpenLinkInNewTab_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6097,32 +9348,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_ChangedTitle_t : Steamworks.ISteamCallback + internal struct HTML_ChangedTitle_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchTitle; // pchTitle const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_ChangedTitle_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_ChangedTitle_t)(HTML_ChangedTitle_t) Marshal.PtrToStructure( p, typeof(HTML_ChangedTitle_t) )) : ((HTML_ChangedTitle_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_ChangedTitle_t) : typeof(Pack8) ); + internal static HTML_ChangedTitle_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_ChangedTitle_t)(HTML_ChangedTitle_t) Marshal.PtrToStructure( p, typeof(HTML_ChangedTitle_t) )) : ((HTML_ChangedTitle_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_ChangedTitle_t)default(HTML_ChangedTitle_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_ChangedTitle_t)default(HTML_ChangedTitle_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_ChangedTitle_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_ChangedTitle_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6138,33 +9413,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_SearchResults_t : Steamworks.ISteamCallback + internal struct HTML_SearchResults_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnResults; // unResults uint32 internal uint UnCurrentMatch; // unCurrentMatch uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_SearchResults_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_SearchResults_t)(HTML_SearchResults_t) Marshal.PtrToStructure( p, typeof(HTML_SearchResults_t) )) : ((HTML_SearchResults_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_SearchResults_t) : typeof(Pack8) ); + internal static HTML_SearchResults_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_SearchResults_t)(HTML_SearchResults_t) Marshal.PtrToStructure( p, typeof(HTML_SearchResults_t) )) : ((HTML_SearchResults_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_SearchResults_t)default(HTML_SearchResults_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_SearchResults_t)default(HTML_SearchResults_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_SearchResults_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_SearchResults_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6181,7 +9480,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_CanGoBackAndForward_t : Steamworks.ISteamCallback + internal struct HTML_CanGoBackAndForward_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser [MarshalAs(UnmanagedType.I1)] @@ -6189,27 +9488,51 @@ internal struct HTML_CanGoBackAndForward_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool BCanGoForward; // bCanGoForward _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_CanGoBackAndForward_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_CanGoBackAndForward_t)(HTML_CanGoBackAndForward_t) Marshal.PtrToStructure( p, typeof(HTML_CanGoBackAndForward_t) )) : ((HTML_CanGoBackAndForward_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_CanGoBackAndForward_t) : typeof(Pack8) ); + internal static HTML_CanGoBackAndForward_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_CanGoBackAndForward_t)(HTML_CanGoBackAndForward_t) Marshal.PtrToStructure( p, typeof(HTML_CanGoBackAndForward_t) )) : ((HTML_CanGoBackAndForward_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_CanGoBackAndForward_t)default(HTML_CanGoBackAndForward_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_CanGoBackAndForward_t)default(HTML_CanGoBackAndForward_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_CanGoBackAndForward_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_CanGoBackAndForward_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6228,7 +9551,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_HorizontalScroll_t : Steamworks.ISteamCallback + internal struct HTML_HorizontalScroll_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnScrollMax; // unScrollMax uint32 @@ -6238,27 +9561,51 @@ internal struct HTML_HorizontalScroll_t : Steamworks.ISteamCallback internal bool BVisible; // bVisible _Bool internal uint UnPageSize; // unPageSize uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_HorizontalScroll_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_HorizontalScroll_t)(HTML_HorizontalScroll_t) Marshal.PtrToStructure( p, typeof(HTML_HorizontalScroll_t) )) : ((HTML_HorizontalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_HorizontalScroll_t) : typeof(Pack8) ); + internal static HTML_HorizontalScroll_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_HorizontalScroll_t)(HTML_HorizontalScroll_t) Marshal.PtrToStructure( p, typeof(HTML_HorizontalScroll_t) )) : ((HTML_HorizontalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_HorizontalScroll_t)default(HTML_HorizontalScroll_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_HorizontalScroll_t)default(HTML_HorizontalScroll_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_HorizontalScroll_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_HorizontalScroll_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6279,7 +9626,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_VerticalScroll_t : Steamworks.ISteamCallback + internal struct HTML_VerticalScroll_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnScrollMax; // unScrollMax uint32 @@ -6289,27 +9636,51 @@ internal struct HTML_VerticalScroll_t : Steamworks.ISteamCallback internal bool BVisible; // bVisible _Bool internal uint UnPageSize; // unPageSize uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 12; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_VerticalScroll_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_VerticalScroll_t)(HTML_VerticalScroll_t) Marshal.PtrToStructure( p, typeof(HTML_VerticalScroll_t) )) : ((HTML_VerticalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_VerticalScroll_t) : typeof(Pack8) ); + internal static HTML_VerticalScroll_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_VerticalScroll_t)(HTML_VerticalScroll_t) Marshal.PtrToStructure( p, typeof(HTML_VerticalScroll_t) )) : ((HTML_VerticalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_VerticalScroll_t)default(HTML_VerticalScroll_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_VerticalScroll_t)default(HTML_VerticalScroll_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_VerticalScroll_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 12, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 12, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_VerticalScroll_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 12, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 12, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 12, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6330,7 +9701,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_LinkAtPosition_t : Steamworks.ISteamCallback + internal struct HTML_LinkAtPosition_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint X; // x uint32 @@ -6341,27 +9712,51 @@ internal struct HTML_LinkAtPosition_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool BLiveLink; // bLiveLink _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 13; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_LinkAtPosition_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_LinkAtPosition_t)(HTML_LinkAtPosition_t) Marshal.PtrToStructure( p, typeof(HTML_LinkAtPosition_t) )) : ((HTML_LinkAtPosition_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_LinkAtPosition_t) : typeof(Pack8) ); + internal static HTML_LinkAtPosition_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_LinkAtPosition_t)(HTML_LinkAtPosition_t) Marshal.PtrToStructure( p, typeof(HTML_LinkAtPosition_t) )) : ((HTML_LinkAtPosition_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_LinkAtPosition_t)default(HTML_LinkAtPosition_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_LinkAtPosition_t)default(HTML_LinkAtPosition_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_LinkAtPosition_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 13, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 13, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_LinkAtPosition_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 13, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 13, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 13, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6383,32 +9778,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_JSAlert_t : Steamworks.ISteamCallback + internal struct HTML_JSAlert_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMessage; // pchMessage const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_JSAlert_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_JSAlert_t)(HTML_JSAlert_t) Marshal.PtrToStructure( p, typeof(HTML_JSAlert_t) )) : ((HTML_JSAlert_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_JSAlert_t) : typeof(Pack8) ); + internal static HTML_JSAlert_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_JSAlert_t)(HTML_JSAlert_t) Marshal.PtrToStructure( p, typeof(HTML_JSAlert_t) )) : ((HTML_JSAlert_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_JSAlert_t)default(HTML_JSAlert_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_JSAlert_t)default(HTML_JSAlert_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_JSAlert_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_JSAlert_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6424,32 +9843,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_JSConfirm_t : Steamworks.ISteamCallback + internal struct HTML_JSConfirm_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMessage; // pchMessage const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_JSConfirm_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_JSConfirm_t)(HTML_JSConfirm_t) Marshal.PtrToStructure( p, typeof(HTML_JSConfirm_t) )) : ((HTML_JSConfirm_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_JSConfirm_t) : typeof(Pack8) ); + internal static HTML_JSConfirm_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_JSConfirm_t)(HTML_JSConfirm_t) Marshal.PtrToStructure( p, typeof(HTML_JSConfirm_t) )) : ((HTML_JSConfirm_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_JSConfirm_t)default(HTML_JSConfirm_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_JSConfirm_t)default(HTML_JSConfirm_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_JSConfirm_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_JSConfirm_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6465,33 +9908,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_FileOpenDialog_t : Steamworks.ISteamCallback + internal struct HTML_FileOpenDialog_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchTitle; // pchTitle const char * internal string PchInitialFile; // pchInitialFile const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 16; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_FileOpenDialog_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_FileOpenDialog_t)(HTML_FileOpenDialog_t) Marshal.PtrToStructure( p, typeof(HTML_FileOpenDialog_t) )) : ((HTML_FileOpenDialog_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_FileOpenDialog_t) : typeof(Pack8) ); + internal static HTML_FileOpenDialog_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_FileOpenDialog_t)(HTML_FileOpenDialog_t) Marshal.PtrToStructure( p, typeof(HTML_FileOpenDialog_t) )) : ((HTML_FileOpenDialog_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_FileOpenDialog_t)default(HTML_FileOpenDialog_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_FileOpenDialog_t)default(HTML_FileOpenDialog_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_FileOpenDialog_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 16, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 16, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_FileOpenDialog_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 16, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 16, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 16, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6508,7 +9975,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_NewWindow_t : Steamworks.ISteamCallback + internal struct HTML_NewWindow_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * @@ -6518,27 +9985,51 @@ internal struct HTML_NewWindow_t : Steamworks.ISteamCallback internal uint UnTall; // unTall uint32 internal uint UnNewWindow_BrowserHandle_IGNORE; // unNewWindow_BrowserHandle_IGNORE HHTMLBrowser - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 21; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_NewWindow_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_NewWindow_t)(HTML_NewWindow_t) Marshal.PtrToStructure( p, typeof(HTML_NewWindow_t) )) : ((HTML_NewWindow_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_NewWindow_t) : typeof(Pack8) ); + internal static HTML_NewWindow_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_NewWindow_t)(HTML_NewWindow_t) Marshal.PtrToStructure( p, typeof(HTML_NewWindow_t) )) : ((HTML_NewWindow_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_NewWindow_t)default(HTML_NewWindow_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_NewWindow_t)default(HTML_NewWindow_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_NewWindow_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 21, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 21, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_NewWindow_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 21, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 21, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 21, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6559,32 +10050,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_SetCursor_t : Steamworks.ISteamCallback + internal struct HTML_SetCursor_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint EMouseCursor; // eMouseCursor uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 22; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_SetCursor_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_SetCursor_t)(HTML_SetCursor_t) Marshal.PtrToStructure( p, typeof(HTML_SetCursor_t) )) : ((HTML_SetCursor_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_SetCursor_t) : typeof(Pack8) ); + internal static HTML_SetCursor_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_SetCursor_t)(HTML_SetCursor_t) Marshal.PtrToStructure( p, typeof(HTML_SetCursor_t) )) : ((HTML_SetCursor_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_SetCursor_t)default(HTML_SetCursor_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_SetCursor_t)default(HTML_SetCursor_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_SetCursor_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 22, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 22, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_SetCursor_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 22, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 22, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 22, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6600,32 +10115,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_StatusText_t : Steamworks.ISteamCallback + internal struct HTML_StatusText_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 23; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_StatusText_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_StatusText_t)(HTML_StatusText_t) Marshal.PtrToStructure( p, typeof(HTML_StatusText_t) )) : ((HTML_StatusText_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_StatusText_t) : typeof(Pack8) ); + internal static HTML_StatusText_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_StatusText_t)(HTML_StatusText_t) Marshal.PtrToStructure( p, typeof(HTML_StatusText_t) )) : ((HTML_StatusText_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_StatusText_t)default(HTML_StatusText_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_StatusText_t)default(HTML_StatusText_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_StatusText_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 23, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 23, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_StatusText_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 23, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 23, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 23, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6641,32 +10180,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_ShowToolTip_t : Steamworks.ISteamCallback + internal struct HTML_ShowToolTip_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 24; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_ShowToolTip_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_ShowToolTip_t)(HTML_ShowToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_ShowToolTip_t) )) : ((HTML_ShowToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_ShowToolTip_t) : typeof(Pack8) ); + internal static HTML_ShowToolTip_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_ShowToolTip_t)(HTML_ShowToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_ShowToolTip_t) )) : ((HTML_ShowToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_ShowToolTip_t)default(HTML_ShowToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_ShowToolTip_t)default(HTML_ShowToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_ShowToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 24, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 24, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_ShowToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 24, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 24, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 24, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6682,32 +10245,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_UpdateToolTip_t : Steamworks.ISteamCallback + internal struct HTML_UpdateToolTip_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 25; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_UpdateToolTip_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_UpdateToolTip_t)(HTML_UpdateToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_UpdateToolTip_t) )) : ((HTML_UpdateToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_UpdateToolTip_t) : typeof(Pack8) ); + internal static HTML_UpdateToolTip_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_UpdateToolTip_t)(HTML_UpdateToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_UpdateToolTip_t) )) : ((HTML_UpdateToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_UpdateToolTip_t)default(HTML_UpdateToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_UpdateToolTip_t)default(HTML_UpdateToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_UpdateToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 25, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 25, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_UpdateToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 25, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 25, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 25, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6723,31 +10310,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_HideToolTip_t : Steamworks.ISteamCallback + internal struct HTML_HideToolTip_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 26; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_HideToolTip_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_HideToolTip_t)(HTML_HideToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_HideToolTip_t) )) : ((HTML_HideToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_HideToolTip_t) : typeof(Pack8) ); + internal static HTML_HideToolTip_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_HideToolTip_t)(HTML_HideToolTip_t) Marshal.PtrToStructure( p, typeof(HTML_HideToolTip_t) )) : ((HTML_HideToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_HideToolTip_t)default(HTML_HideToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_HideToolTip_t)default(HTML_HideToolTip_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_HideToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 26, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 26, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_HideToolTip_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 26, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 26, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 26, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6762,32 +10373,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct HTML_BrowserRestarted_t : Steamworks.ISteamCallback + internal struct HTML_BrowserRestarted_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnOldBrowserHandle; // unOldBrowserHandle HHTMLBrowser - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 27; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_BrowserRestarted_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((HTML_BrowserRestarted_t)(HTML_BrowserRestarted_t) Marshal.PtrToStructure( p, typeof(HTML_BrowserRestarted_t) )) : ((HTML_BrowserRestarted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(HTML_BrowserRestarted_t) : typeof(Pack8) ); + internal static HTML_BrowserRestarted_t Fill( IntPtr p ) => Config.PackSmall ? ((HTML_BrowserRestarted_t)(HTML_BrowserRestarted_t) Marshal.PtrToStructure( p, typeof(HTML_BrowserRestarted_t) )) : ((HTML_BrowserRestarted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (HTML_BrowserRestarted_t)default(HTML_BrowserRestarted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (HTML_BrowserRestarted_t)default(HTML_BrowserRestarted_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(HTML_BrowserRestarted_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 27, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamHTMLSurface + 27, true ); actionServer = action; } else { - Event.Register( OnClient, default(HTML_BrowserRestarted_t).GetStructSize(), CallbackIdentifiers.SteamHTMLSurface + 27, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamHTMLSurface + 27, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamHTMLSurface + 27, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6811,8 +10446,7 @@ internal struct SteamItemDetails_t internal ushort Flags; // m_unFlags uint16 #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamItemDetails_t) : typeof(Pack8) ); - public SteamItemDetails_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamItemDetails_t)(SteamItemDetails_t) Marshal.PtrToStructure( p, typeof(SteamItemDetails_t) )) : ((SteamItemDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static SteamItemDetails_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamItemDetails_t)(SteamItemDetails_t) Marshal.PtrToStructure( p, typeof(SteamItemDetails_t) )) : ((SteamItemDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -6830,32 +10464,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryResultReady_t : Steamworks.ISteamCallback + internal struct SteamInventoryResultReady_t { internal int Handle; // m_handle SteamInventoryResult_t internal Result Result; // m_result enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 0; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryResultReady_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryResultReady_t)(SteamInventoryResultReady_t) Marshal.PtrToStructure( p, typeof(SteamInventoryResultReady_t) )) : ((SteamInventoryResultReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryResultReady_t) : typeof(Pack8) ); + internal static SteamInventoryResultReady_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryResultReady_t)(SteamInventoryResultReady_t) Marshal.PtrToStructure( p, typeof(SteamInventoryResultReady_t) )) : ((SteamInventoryResultReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryResultReady_t)default(SteamInventoryResultReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryResultReady_t)default(SteamInventoryResultReady_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryResultReady_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 0, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 0, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryResultReady_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 0, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 0, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 0, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6871,31 +10529,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryFullUpdate_t : Steamworks.ISteamCallback + internal struct SteamInventoryFullUpdate_t { internal int Handle; // m_handle SteamInventoryResult_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryFullUpdate_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryFullUpdate_t)(SteamInventoryFullUpdate_t) Marshal.PtrToStructure( p, typeof(SteamInventoryFullUpdate_t) )) : ((SteamInventoryFullUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryFullUpdate_t) : typeof(Pack8) ); + internal static SteamInventoryFullUpdate_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryFullUpdate_t)(SteamInventoryFullUpdate_t) Marshal.PtrToStructure( p, typeof(SteamInventoryFullUpdate_t) )) : ((SteamInventoryFullUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryFullUpdate_t)default(SteamInventoryFullUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryFullUpdate_t)default(SteamInventoryFullUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryFullUpdate_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryFullUpdate_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6910,7 +10592,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryEligiblePromoItemDefIDs_t : Steamworks.ISteamCallback + internal struct SteamInventoryEligiblePromoItemDefIDs_t { internal Result Result; // m_result enum EResult internal ulong SteamID; // m_steamID class CSteamID @@ -6918,58 +10600,106 @@ internal struct SteamInventoryEligiblePromoItemDefIDs_t : Steamworks.ISteamCallb [MarshalAs(UnmanagedType.I1)] internal bool CachedData; // m_bCachedData _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(SteamInventoryEligiblePromoItemDefIDs_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((SteamInventoryEligiblePromoItemDefIDs_t)(SteamInventoryEligiblePromoItemDefIDs_t) Marshal.PtrToStructure( p, typeof(SteamInventoryEligiblePromoItemDefIDs_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(SteamInventoryEligiblePromoItemDefIDs_t) ); + internal static SteamInventoryEligiblePromoItemDefIDs_t Fill( IntPtr p ) => ((SteamInventoryEligiblePromoItemDefIDs_t)(SteamInventoryEligiblePromoItemDefIDs_t) Marshal.PtrToStructure( p, typeof(SteamInventoryEligiblePromoItemDefIDs_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryEligiblePromoItemDefIDs_t)default(SteamInventoryEligiblePromoItemDefIDs_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryEligiblePromoItemDefIDs_t)default(SteamInventoryEligiblePromoItemDefIDs_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryEligiblePromoItemDefIDs_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryEligiblePromoItemDefIDs_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryStartPurchaseResult_t : Steamworks.ISteamCallback + internal struct SteamInventoryStartPurchaseResult_t { internal Result Result; // m_result enum EResult internal ulong OrderID; // m_ulOrderID uint64 internal ulong TransID; // m_ulTransID uint64 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryStartPurchaseResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryStartPurchaseResult_t)(SteamInventoryStartPurchaseResult_t) Marshal.PtrToStructure( p, typeof(SteamInventoryStartPurchaseResult_t) )) : ((SteamInventoryStartPurchaseResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryStartPurchaseResult_t) : typeof(Pack8) ); + internal static SteamInventoryStartPurchaseResult_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryStartPurchaseResult_t)(SteamInventoryStartPurchaseResult_t) Marshal.PtrToStructure( p, typeof(SteamInventoryStartPurchaseResult_t) )) : ((SteamInventoryStartPurchaseResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryStartPurchaseResult_t)default(SteamInventoryStartPurchaseResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryStartPurchaseResult_t)default(SteamInventoryStartPurchaseResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryStartPurchaseResult_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryStartPurchaseResult_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -6986,33 +10716,57 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryRequestPricesResult_t : Steamworks.ISteamCallback + internal struct SteamInventoryRequestPricesResult_t { internal Result Result; // m_result enum EResult [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] internal string Currency; // m_rgchCurrency char [4] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryRequestPricesResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryRequestPricesResult_t)(SteamInventoryRequestPricesResult_t) Marshal.PtrToStructure( p, typeof(SteamInventoryRequestPricesResult_t) )) : ((SteamInventoryRequestPricesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryRequestPricesResult_t) : typeof(Pack8) ); + internal static SteamInventoryRequestPricesResult_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryRequestPricesResult_t)(SteamInventoryRequestPricesResult_t) Marshal.PtrToStructure( p, typeof(SteamInventoryRequestPricesResult_t) )) : ((SteamInventoryRequestPricesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryRequestPricesResult_t)default(SteamInventoryRequestPricesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryRequestPricesResult_t)default(SteamInventoryRequestPricesResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryRequestPricesResult_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryRequestPricesResult_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7029,31 +10783,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct BroadcastUploadStop_t : Steamworks.ISteamCallback + internal struct BroadcastUploadStop_t { internal BroadcastUploadResult Result; // m_eResult enum EBroadcastUploadResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(BroadcastUploadStop_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((BroadcastUploadStop_t)(BroadcastUploadStop_t) Marshal.PtrToStructure( p, typeof(BroadcastUploadStop_t) )) : ((BroadcastUploadStop_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(BroadcastUploadStop_t) : typeof(Pack8) ); + internal static BroadcastUploadStop_t Fill( IntPtr p ) => Config.PackSmall ? ((BroadcastUploadStop_t)(BroadcastUploadStop_t) Marshal.PtrToStructure( p, typeof(BroadcastUploadStop_t) )) : ((BroadcastUploadStop_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (BroadcastUploadStop_t)default(BroadcastUploadStop_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (BroadcastUploadStop_t)default(BroadcastUploadStop_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(BroadcastUploadStop_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientVideo + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(BroadcastUploadStop_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientVideo + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientVideo + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7068,34 +10846,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GetVideoURLResult_t : Steamworks.ISteamCallback + internal struct GetVideoURLResult_t { internal Result Result; // m_eResult enum EResult internal AppId VideoAppID; // m_unVideoAppID AppId_t [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string URL; // m_rgchURL char [256] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetVideoURLResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GetVideoURLResult_t)(GetVideoURLResult_t) Marshal.PtrToStructure( p, typeof(GetVideoURLResult_t) )) : ((GetVideoURLResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetVideoURLResult_t) : typeof(Pack8) ); + internal static GetVideoURLResult_t Fill( IntPtr p ) => Config.PackSmall ? ((GetVideoURLResult_t)(GetVideoURLResult_t) Marshal.PtrToStructure( p, typeof(GetVideoURLResult_t) )) : ((GetVideoURLResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GetVideoURLResult_t)default(GetVideoURLResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GetVideoURLResult_t)default(GetVideoURLResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GetVideoURLResult_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientVideo + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(GetVideoURLResult_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientVideo + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientVideo + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7113,32 +10915,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GetOPFSettingsResult_t : Steamworks.ISteamCallback + internal struct GetOPFSettingsResult_t { internal Result Result; // m_eResult enum EResult internal AppId VideoAppID; // m_unVideoAppID AppId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 24; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetOPFSettingsResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GetOPFSettingsResult_t)(GetOPFSettingsResult_t) Marshal.PtrToStructure( p, typeof(GetOPFSettingsResult_t) )) : ((GetOPFSettingsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GetOPFSettingsResult_t) : typeof(Pack8) ); + internal static GetOPFSettingsResult_t Fill( IntPtr p ) => Config.PackSmall ? ((GetOPFSettingsResult_t)(GetOPFSettingsResult_t) Marshal.PtrToStructure( p, typeof(GetOPFSettingsResult_t) )) : ((GetOPFSettingsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GetOPFSettingsResult_t)default(GetOPFSettingsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GetOPFSettingsResult_t)default(GetOPFSettingsResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GetOPFSettingsResult_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 24, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientVideo + 24, true ); actionServer = action; } else { - Event.Register( OnClient, default(GetOPFSettingsResult_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 24, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientVideo + 24, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientVideo + 24, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7154,99 +10980,171 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSClientApprove_t : Steamworks.ISteamCallback + internal struct GSClientApprove_t { internal ulong SteamID; // m_SteamID class CSteamID internal ulong OwnerSteamID; // m_OwnerSteamID class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientApprove_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSClientApprove_t)(GSClientApprove_t) Marshal.PtrToStructure( p, typeof(GSClientApprove_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientApprove_t) ); + internal static GSClientApprove_t Fill( IntPtr p ) => ((GSClientApprove_t)(GSClientApprove_t) Marshal.PtrToStructure( p, typeof(GSClientApprove_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSClientApprove_t)default(GSClientApprove_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSClientApprove_t)default(GSClientApprove_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSClientApprove_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSClientApprove_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSClientDeny_t : Steamworks.ISteamCallback + internal struct GSClientDeny_t { internal ulong SteamID; // m_SteamID class CSteamID internal DenyReason DenyReason; // m_eDenyReason enum EDenyReason [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] internal string OptionalText; // m_rgchOptionalText char [128] - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientDeny_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSClientDeny_t)(GSClientDeny_t) Marshal.PtrToStructure( p, typeof(GSClientDeny_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientDeny_t) ); + internal static GSClientDeny_t Fill( IntPtr p ) => ((GSClientDeny_t)(GSClientDeny_t) Marshal.PtrToStructure( p, typeof(GSClientDeny_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSClientDeny_t)default(GSClientDeny_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSClientDeny_t)default(GSClientDeny_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSClientDeny_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSClientDeny_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSClientKick_t : Steamworks.ISteamCallback + internal struct GSClientKick_t { internal ulong SteamID; // m_SteamID class CSteamID internal DenyReason DenyReason; // m_eDenyReason enum EDenyReason - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 3; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientKick_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSClientKick_t)(GSClientKick_t) Marshal.PtrToStructure( p, typeof(GSClientKick_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientKick_t) ); + internal static GSClientKick_t Fill( IntPtr p ) => ((GSClientKick_t)(GSClientKick_t) Marshal.PtrToStructure( p, typeof(GSClientKick_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSClientKick_t)default(GSClientKick_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSClientKick_t)default(GSClientKick_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSClientKick_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 3, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 3, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSClientKick_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 3, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 3, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 3, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSClientAchievementStatus_t : Steamworks.ISteamCallback + internal struct GSClientAchievementStatus_t { internal ulong SteamID; // m_SteamID uint64 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] @@ -7254,27 +11152,51 @@ internal struct GSClientAchievementStatus_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool Unlocked; // m_bUnlocked _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 6; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSClientAchievementStatus_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GSClientAchievementStatus_t)(GSClientAchievementStatus_t) Marshal.PtrToStructure( p, typeof(GSClientAchievementStatus_t) )) : ((GSClientAchievementStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSClientAchievementStatus_t) : typeof(Pack8) ); + internal static GSClientAchievementStatus_t Fill( IntPtr p ) => Config.PackSmall ? ((GSClientAchievementStatus_t)(GSClientAchievementStatus_t) Marshal.PtrToStructure( p, typeof(GSClientAchievementStatus_t) )) : ((GSClientAchievementStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSClientAchievementStatus_t)default(GSClientAchievementStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSClientAchievementStatus_t)default(GSClientAchievementStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSClientAchievementStatus_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 6, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 6, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSClientAchievementStatus_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 6, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 6, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 6, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7293,31 +11215,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSPolicyResponse_t : Steamworks.ISteamCallback + internal struct GSPolicyResponse_t { internal byte Secure; // m_bSecure uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 15; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSPolicyResponse_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GSPolicyResponse_t)(GSPolicyResponse_t) Marshal.PtrToStructure( p, typeof(GSPolicyResponse_t) )) : ((GSPolicyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSPolicyResponse_t) : typeof(Pack8) ); + internal static GSPolicyResponse_t Fill( IntPtr p ) => Config.PackSmall ? ((GSPolicyResponse_t)(GSPolicyResponse_t) Marshal.PtrToStructure( p, typeof(GSPolicyResponse_t) )) : ((GSPolicyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSPolicyResponse_t)default(GSPolicyResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSPolicyResponse_t)default(GSPolicyResponse_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSPolicyResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 15, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 15, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSPolicyResponse_t).GetStructSize(), CallbackIdentifiers.SteamUser + 15, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 15, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 15, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7332,34 +11278,58 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSGameplayStats_t : Steamworks.ISteamCallback + internal struct GSGameplayStats_t { internal Result Result; // m_eResult enum EResult internal int Rank; // m_nRank int32 internal uint TotalConnects; // m_unTotalConnects uint32 internal uint TotalMinutesPlayed; // m_unTotalMinutesPlayed uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 7; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSGameplayStats_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GSGameplayStats_t)(GSGameplayStats_t) Marshal.PtrToStructure( p, typeof(GSGameplayStats_t) )) : ((GSGameplayStats_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSGameplayStats_t) : typeof(Pack8) ); + internal static GSGameplayStats_t Fill( IntPtr p ) => Config.PackSmall ? ((GSGameplayStats_t)(GSGameplayStats_t) Marshal.PtrToStructure( p, typeof(GSGameplayStats_t) )) : ((GSGameplayStats_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSGameplayStats_t)default(GSGameplayStats_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSGameplayStats_t)default(GSGameplayStats_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSGameplayStats_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 7, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 7, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSGameplayStats_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 7, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 7, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 7, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7377,7 +11347,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSClientGroupStatus_t : Steamworks.ISteamCallback + internal struct GSClientGroupStatus_t { internal ulong SteamIDUser; // m_SteamIDUser class CSteamID internal ulong SteamIDGroup; // m_SteamIDGroup class CSteamID @@ -7386,32 +11356,56 @@ internal struct GSClientGroupStatus_t : Steamworks.ISteamCallback [MarshalAs(UnmanagedType.I1)] internal bool Officer; // m_bOfficer _Bool - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientGroupStatus_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSClientGroupStatus_t)(GSClientGroupStatus_t) Marshal.PtrToStructure( p, typeof(GSClientGroupStatus_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSClientGroupStatus_t) ); + internal static GSClientGroupStatus_t Fill( IntPtr p ) => ((GSClientGroupStatus_t)(GSClientGroupStatus_t) Marshal.PtrToStructure( p, typeof(GSClientGroupStatus_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSClientGroupStatus_t)default(GSClientGroupStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSClientGroupStatus_t)default(GSClientGroupStatus_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSClientGroupStatus_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSClientGroupStatus_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSReputation_t : Steamworks.ISteamCallback + internal struct GSReputation_t { internal Result Result; // m_eResult enum EResult internal uint ReputationScore; // m_unReputationScore uint32 @@ -7422,27 +11416,51 @@ internal struct GSReputation_t : Steamworks.ISteamCallback internal ulong BannedGameID; // m_ulBannedGameID uint64 internal uint BanExpires; // m_unBanExpires uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 9; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSReputation_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GSReputation_t)(GSReputation_t) Marshal.PtrToStructure( p, typeof(GSReputation_t) )) : ((GSReputation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GSReputation_t) : typeof(Pack8) ); + internal static GSReputation_t Fill( IntPtr p ) => Config.PackSmall ? ((GSReputation_t)(GSReputation_t) Marshal.PtrToStructure( p, typeof(GSReputation_t) )) : ((GSReputation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSReputation_t)default(GSReputation_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSReputation_t)default(GSReputation_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSReputation_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 9, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 9, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSReputation_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 9, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 9, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 9, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7464,31 +11482,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct AssociateWithClanResult_t : Steamworks.ISteamCallback + internal struct AssociateWithClanResult_t { internal Result Result; // m_eResult enum EResult - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 10; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AssociateWithClanResult_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((AssociateWithClanResult_t)(AssociateWithClanResult_t) Marshal.PtrToStructure( p, typeof(AssociateWithClanResult_t) )) : ((AssociateWithClanResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(AssociateWithClanResult_t) : typeof(Pack8) ); + internal static AssociateWithClanResult_t Fill( IntPtr p ) => Config.PackSmall ? ((AssociateWithClanResult_t)(AssociateWithClanResult_t) Marshal.PtrToStructure( p, typeof(AssociateWithClanResult_t) )) : ((AssociateWithClanResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (AssociateWithClanResult_t)default(AssociateWithClanResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (AssociateWithClanResult_t)default(AssociateWithClanResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(AssociateWithClanResult_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 10, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 10, true ); actionServer = action; } else { - Event.Register( OnClient, default(AssociateWithClanResult_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 10, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 10, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 10, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7503,7 +11545,7 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ComputeNewPlayerCompatibilityResult_t : Steamworks.ISteamCallback + internal struct ComputeNewPlayerCompatibilityResult_t { internal Result Result; // m_eResult enum EResult internal int CPlayersThatDontLikeCandidate; // m_cPlayersThatDontLikeCandidate int @@ -7511,144 +11553,264 @@ internal struct ComputeNewPlayerCompatibilityResult_t : Steamworks.ISteamCallbac internal int CClanPlayersThatDontLikeCandidate; // m_cClanPlayersThatDontLikeCandidate int internal ulong SteamIDCandidate; // m_SteamIDCandidate class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 11; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(ComputeNewPlayerCompatibilityResult_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((ComputeNewPlayerCompatibilityResult_t)(ComputeNewPlayerCompatibilityResult_t) Marshal.PtrToStructure( p, typeof(ComputeNewPlayerCompatibilityResult_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(ComputeNewPlayerCompatibilityResult_t) ); + internal static ComputeNewPlayerCompatibilityResult_t Fill( IntPtr p ) => ((ComputeNewPlayerCompatibilityResult_t)(ComputeNewPlayerCompatibilityResult_t) Marshal.PtrToStructure( p, typeof(ComputeNewPlayerCompatibilityResult_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ComputeNewPlayerCompatibilityResult_t)default(ComputeNewPlayerCompatibilityResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ComputeNewPlayerCompatibilityResult_t)default(ComputeNewPlayerCompatibilityResult_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ComputeNewPlayerCompatibilityResult_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 11, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServer + 11, true ); actionServer = action; } else { - Event.Register( OnClient, default(ComputeNewPlayerCompatibilityResult_t).GetStructSize(), CallbackIdentifiers.SteamGameServer + 11, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServer + 11, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServer + 11, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSStatsReceived_t : Steamworks.ISteamCallback + internal struct GSStatsReceived_t { internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServerStats + 0; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsReceived_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSStatsReceived_t)(GSStatsReceived_t) Marshal.PtrToStructure( p, typeof(GSStatsReceived_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsReceived_t) ); + internal static GSStatsReceived_t Fill( IntPtr p ) => ((GSStatsReceived_t)(GSStatsReceived_t) Marshal.PtrToStructure( p, typeof(GSStatsReceived_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSStatsReceived_t)default(GSStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSStatsReceived_t)default(GSStatsReceived_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamGameServerStats + 0, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServerStats + 0, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSStatsReceived_t).GetStructSize(), CallbackIdentifiers.SteamGameServerStats + 0, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServerStats + 0, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServerStats + 0, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSStatsStored_t : Steamworks.ISteamCallback + internal struct GSStatsStored_t { internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameServerStats + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsStored_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSStatsStored_t)(GSStatsStored_t) Marshal.PtrToStructure( p, typeof(GSStatsStored_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsStored_t) ); + internal static GSStatsStored_t Fill( IntPtr p ) => ((GSStatsStored_t)(GSStatsStored_t) Marshal.PtrToStructure( p, typeof(GSStatsStored_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSStatsStored_t)default(GSStatsStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSStatsStored_t)default(GSStatsStored_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSStatsStored_t).GetStructSize(), CallbackIdentifiers.SteamGameServerStats + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameServerStats + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSStatsStored_t).GetStructSize(), CallbackIdentifiers.SteamGameServerStats + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameServerStats + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameServerStats + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GSStatsUnloaded_t : Steamworks.ISteamCallback + internal struct GSStatsUnloaded_t { internal ulong SteamIDUser; // m_steamIDUser class CSteamID - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 8; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsUnloaded_t) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => ((GSStatsUnloaded_t)(GSStatsUnloaded_t) Marshal.PtrToStructure( p, typeof(GSStatsUnloaded_t) ) ); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof(GSStatsUnloaded_t) ); + internal static GSStatsUnloaded_t Fill( IntPtr p ) => ((GSStatsUnloaded_t)(GSStatsUnloaded_t) Marshal.PtrToStructure( p, typeof(GSStatsUnloaded_t) ) ); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GSStatsUnloaded_t)default(GSStatsUnloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GSStatsUnloaded_t)default(GSStatsUnloaded_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GSStatsUnloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 8, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUserStats + 8, true ); actionServer = action; } else { - Event.Register( OnClient, default(GSStatsUnloaded_t).GetStructSize(), CallbackIdentifiers.SteamUserStats + 8, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUserStats + 8, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUserStats + 8, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct PlaybackStatusHasChanged_t : Steamworks.ISteamCallback + internal struct PlaybackStatusHasChanged_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(PlaybackStatusHasChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((PlaybackStatusHasChanged_t)(PlaybackStatusHasChanged_t) Marshal.PtrToStructure( p, typeof(PlaybackStatusHasChanged_t) )) : ((PlaybackStatusHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(PlaybackStatusHasChanged_t) : typeof(Pack8) ); + internal static PlaybackStatusHasChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((PlaybackStatusHasChanged_t)(PlaybackStatusHasChanged_t) Marshal.PtrToStructure( p, typeof(PlaybackStatusHasChanged_t) )) : ((PlaybackStatusHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (PlaybackStatusHasChanged_t)default(PlaybackStatusHasChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (PlaybackStatusHasChanged_t)default(PlaybackStatusHasChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(PlaybackStatusHasChanged_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamMusic + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(PlaybackStatusHasChanged_t).GetStructSize(), CallbackIdentifiers.SteamMusic + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamMusic + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamMusic + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7662,30 +11824,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct BroadcastUploadStart_t : Steamworks.ISteamCallback + internal struct BroadcastUploadStart_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(BroadcastUploadStart_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((BroadcastUploadStart_t)(BroadcastUploadStart_t) Marshal.PtrToStructure( p, typeof(BroadcastUploadStart_t) )) : ((BroadcastUploadStart_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(BroadcastUploadStart_t) : typeof(Pack8) ); + internal static BroadcastUploadStart_t Fill( IntPtr p ) => Config.PackSmall ? ((BroadcastUploadStart_t)(BroadcastUploadStart_t) Marshal.PtrToStructure( p, typeof(BroadcastUploadStart_t) )) : ((BroadcastUploadStart_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (BroadcastUploadStart_t)default(BroadcastUploadStart_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (BroadcastUploadStart_t)default(BroadcastUploadStart_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(BroadcastUploadStart_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientVideo + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(BroadcastUploadStart_t).GetStructSize(), CallbackIdentifiers.ClientVideo + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientVideo + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientVideo + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7699,30 +11885,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback + internal struct NewUrlLaunchParameters_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamApps + 14; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(NewUrlLaunchParameters_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((NewUrlLaunchParameters_t)(NewUrlLaunchParameters_t) Marshal.PtrToStructure( p, typeof(NewUrlLaunchParameters_t) )) : ((NewUrlLaunchParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(NewUrlLaunchParameters_t) : typeof(Pack8) ); + internal static NewUrlLaunchParameters_t Fill( IntPtr p ) => Config.PackSmall ? ((NewUrlLaunchParameters_t)(NewUrlLaunchParameters_t) Marshal.PtrToStructure( p, typeof(NewUrlLaunchParameters_t) )) : ((NewUrlLaunchParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (NewUrlLaunchParameters_t)default(NewUrlLaunchParameters_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (NewUrlLaunchParameters_t)default(NewUrlLaunchParameters_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(NewUrlLaunchParameters_t).GetStructSize(), CallbackIdentifiers.SteamApps + 14, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamApps + 14, true ); actionServer = action; } else { - Event.Register( OnClient, default(NewUrlLaunchParameters_t).GetStructSize(), CallbackIdentifiers.SteamApps + 14, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamApps + 14, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamApps + 14, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7736,32 +11946,56 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ItemInstalled_t : Steamworks.ISteamCallback + internal struct ItemInstalled_t { internal AppId AppID; // m_unAppID AppId_t internal PublishedFileId PublishedFileId; // m_nPublishedFileId PublishedFileId_t - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 5; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ItemInstalled_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((ItemInstalled_t)(ItemInstalled_t) Marshal.PtrToStructure( p, typeof(ItemInstalled_t) )) : ((ItemInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ItemInstalled_t) : typeof(Pack8) ); + internal static ItemInstalled_t Fill( IntPtr p ) => Config.PackSmall ? ((ItemInstalled_t)(ItemInstalled_t) Marshal.PtrToStructure( p, typeof(ItemInstalled_t) )) : ((ItemInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ItemInstalled_t)default(ItemInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ItemInstalled_t)default(ItemInstalled_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ItemInstalled_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 5, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientUGC + 5, true ); actionServer = action; } else { - Event.Register( OnClient, default(ItemInstalled_t).GetStructSize(), CallbackIdentifiers.ClientUGC + 5, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientUGC + 5, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientUGC + 5, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7786,8 +12020,7 @@ internal struct InputAnalogActionData_t internal bool BActive; // bActive bool #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(InputAnalogActionData_t) : typeof(Pack8) ); - public InputAnalogActionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputAnalogActionData_t)(InputAnalogActionData_t) Marshal.PtrToStructure( p, typeof(InputAnalogActionData_t) )) : ((InputAnalogActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static InputAnalogActionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputAnalogActionData_t)(InputAnalogActionData_t) Marshal.PtrToStructure( p, typeof(InputAnalogActionData_t) )) : ((InputAnalogActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -7820,8 +12053,7 @@ internal struct InputMotionData_t internal float RotVelZ; // rotVelZ float #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(InputMotionData_t) : typeof(Pack8) ); - public InputMotionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputMotionData_t)(InputMotionData_t) Marshal.PtrToStructure( p, typeof(InputMotionData_t) )) : ((InputMotionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static InputMotionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputMotionData_t)(InputMotionData_t) Marshal.PtrToStructure( p, typeof(InputMotionData_t) )) : ((InputMotionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -7853,8 +12085,7 @@ internal struct InputDigitalActionData_t internal bool BActive; // bActive bool #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(InputDigitalActionData_t) : typeof(Pack8) ); - public InputDigitalActionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputDigitalActionData_t)(InputDigitalActionData_t) Marshal.PtrToStructure( p, typeof(InputDigitalActionData_t) )) : ((InputDigitalActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static InputDigitalActionData_t Fill( IntPtr p ) => Config.PackSmall ? ((InputDigitalActionData_t)(InputDigitalActionData_t) Marshal.PtrToStructure( p, typeof(InputDigitalActionData_t) )) : ((InputDigitalActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -7872,30 +12103,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamInventoryDefinitionUpdate_t : Steamworks.ISteamCallback + internal struct SteamInventoryDefinitionUpdate_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryDefinitionUpdate_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryDefinitionUpdate_t)(SteamInventoryDefinitionUpdate_t) Marshal.PtrToStructure( p, typeof(SteamInventoryDefinitionUpdate_t) )) : ((SteamInventoryDefinitionUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamInventoryDefinitionUpdate_t) : typeof(Pack8) ); + internal static SteamInventoryDefinitionUpdate_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamInventoryDefinitionUpdate_t)(SteamInventoryDefinitionUpdate_t) Marshal.PtrToStructure( p, typeof(SteamInventoryDefinitionUpdate_t) )) : ((SteamInventoryDefinitionUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamInventoryDefinitionUpdate_t)default(SteamInventoryDefinitionUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamInventoryDefinitionUpdate_t)default(SteamInventoryDefinitionUpdate_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamInventoryDefinitionUpdate_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.ClientInventory + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamInventoryDefinitionUpdate_t).GetStructSize(), CallbackIdentifiers.ClientInventory + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.ClientInventory + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.ClientInventory + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7909,30 +12164,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamParentalSettingsChanged_t : Steamworks.ISteamCallback + internal struct SteamParentalSettingsChanged_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamParentalSettings + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamParentalSettingsChanged_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamParentalSettingsChanged_t)(SteamParentalSettingsChanged_t) Marshal.PtrToStructure( p, typeof(SteamParentalSettingsChanged_t) )) : ((SteamParentalSettingsChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamParentalSettingsChanged_t) : typeof(Pack8) ); + internal static SteamParentalSettingsChanged_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamParentalSettingsChanged_t)(SteamParentalSettingsChanged_t) Marshal.PtrToStructure( p, typeof(SteamParentalSettingsChanged_t) )) : ((SteamParentalSettingsChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamParentalSettingsChanged_t)default(SteamParentalSettingsChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamParentalSettingsChanged_t)default(SteamParentalSettingsChanged_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamParentalSettingsChanged_t).GetStructSize(), CallbackIdentifiers.SteamParentalSettings + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamParentalSettings + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamParentalSettingsChanged_t).GetStructSize(), CallbackIdentifiers.SteamParentalSettings + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamParentalSettings + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamParentalSettings + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7946,30 +12225,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamServersConnected_t : Steamworks.ISteamCallback + internal struct SteamServersConnected_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServersConnected_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamServersConnected_t)(SteamServersConnected_t) Marshal.PtrToStructure( p, typeof(SteamServersConnected_t) )) : ((SteamServersConnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamServersConnected_t) : typeof(Pack8) ); + internal static SteamServersConnected_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamServersConnected_t)(SteamServersConnected_t) Marshal.PtrToStructure( p, typeof(SteamServersConnected_t) )) : ((SteamServersConnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamServersConnected_t)default(SteamServersConnected_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamServersConnected_t)default(SteamServersConnected_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamServersConnected_t).GetStructSize(), CallbackIdentifiers.SteamUser + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamServersConnected_t).GetStructSize(), CallbackIdentifiers.SteamUser + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -7987,8 +12290,7 @@ internal struct NewLaunchQueryParameters_t { #region Marshalling - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(NewLaunchQueryParameters_t) : typeof(Pack8) ); - public NewLaunchQueryParameters_t Fill( IntPtr p ) => Config.PackSmall ? ((NewLaunchQueryParameters_t)(NewLaunchQueryParameters_t) Marshal.PtrToStructure( p, typeof(NewLaunchQueryParameters_t) )) : ((NewLaunchQueryParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + internal static NewLaunchQueryParameters_t Fill( IntPtr p ) => Config.PackSmall ? ((NewLaunchQueryParameters_t)(NewLaunchQueryParameters_t) Marshal.PtrToStructure( p, typeof(NewLaunchQueryParameters_t) )) : ((NewLaunchQueryParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); #endregion #region Packed Versions @@ -8002,31 +12304,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GCMessageAvailable_t : Steamworks.ISteamCallback + internal struct GCMessageAvailable_t { internal uint MessageSize; // m_nMessageSize uint32 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameCoordinator + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GCMessageAvailable_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GCMessageAvailable_t)(GCMessageAvailable_t) Marshal.PtrToStructure( p, typeof(GCMessageAvailable_t) )) : ((GCMessageAvailable_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GCMessageAvailable_t) : typeof(Pack8) ); + internal static GCMessageAvailable_t Fill( IntPtr p ) => Config.PackSmall ? ((GCMessageAvailable_t)(GCMessageAvailable_t) Marshal.PtrToStructure( p, typeof(GCMessageAvailable_t) )) : ((GCMessageAvailable_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GCMessageAvailable_t)default(GCMessageAvailable_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GCMessageAvailable_t)default(GCMessageAvailable_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GCMessageAvailable_t).GetStructSize(), CallbackIdentifiers.SteamGameCoordinator + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameCoordinator + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(GCMessageAvailable_t).GetStructSize(), CallbackIdentifiers.SteamGameCoordinator + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameCoordinator + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameCoordinator + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8041,30 +12367,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct GCMessageFailed_t : Steamworks.ISteamCallback + internal struct GCMessageFailed_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamGameCoordinator + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GCMessageFailed_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((GCMessageFailed_t)(GCMessageFailed_t) Marshal.PtrToStructure( p, typeof(GCMessageFailed_t) )) : ((GCMessageFailed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(GCMessageFailed_t) : typeof(Pack8) ); + internal static GCMessageFailed_t Fill( IntPtr p ) => Config.PackSmall ? ((GCMessageFailed_t)(GCMessageFailed_t) Marshal.PtrToStructure( p, typeof(GCMessageFailed_t) )) : ((GCMessageFailed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (GCMessageFailed_t)default(GCMessageFailed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (GCMessageFailed_t)default(GCMessageFailed_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(GCMessageFailed_t).GetStructSize(), CallbackIdentifiers.SteamGameCoordinator + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamGameCoordinator + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(GCMessageFailed_t).GetStructSize(), CallbackIdentifiers.SteamGameCoordinator + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamGameCoordinator + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamGameCoordinator + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8078,30 +12428,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct ScreenshotRequested_t : Steamworks.ISteamCallback + internal struct ScreenshotRequested_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamScreenshots + 2; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ScreenshotRequested_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((ScreenshotRequested_t)(ScreenshotRequested_t) Marshal.PtrToStructure( p, typeof(ScreenshotRequested_t) )) : ((ScreenshotRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(ScreenshotRequested_t) : typeof(Pack8) ); + internal static ScreenshotRequested_t Fill( IntPtr p ) => Config.PackSmall ? ((ScreenshotRequested_t)(ScreenshotRequested_t) Marshal.PtrToStructure( p, typeof(ScreenshotRequested_t) )) : ((ScreenshotRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (ScreenshotRequested_t)default(ScreenshotRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (ScreenshotRequested_t)default(ScreenshotRequested_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(ScreenshotRequested_t).GetStructSize(), CallbackIdentifiers.SteamScreenshots + 2, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamScreenshots + 2, true ); actionServer = action; } else { - Event.Register( OnClient, default(ScreenshotRequested_t).GetStructSize(), CallbackIdentifiers.SteamScreenshots + 2, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamScreenshots + 2, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamScreenshots + 2, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8115,30 +12489,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct LicensesUpdated_t : Steamworks.ISteamCallback + internal struct LicensesUpdated_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 25; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LicensesUpdated_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((LicensesUpdated_t)(LicensesUpdated_t) Marshal.PtrToStructure( p, typeof(LicensesUpdated_t) )) : ((LicensesUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(LicensesUpdated_t) : typeof(Pack8) ); + internal static LicensesUpdated_t Fill( IntPtr p ) => Config.PackSmall ? ((LicensesUpdated_t)(LicensesUpdated_t) Marshal.PtrToStructure( p, typeof(LicensesUpdated_t) )) : ((LicensesUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (LicensesUpdated_t)default(LicensesUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (LicensesUpdated_t)default(LicensesUpdated_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(LicensesUpdated_t).GetStructSize(), CallbackIdentifiers.SteamUser + 25, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 25, true ); actionServer = action; } else { - Event.Register( OnClient, default(LicensesUpdated_t).GetStructSize(), CallbackIdentifiers.SteamUser + 25, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 25, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 25, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8152,30 +12550,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct SteamShutdown_t : Steamworks.ISteamCallback + internal struct SteamShutdown_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 4; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamShutdown_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((SteamShutdown_t)(SteamShutdown_t) Marshal.PtrToStructure( p, typeof(SteamShutdown_t) )) : ((SteamShutdown_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(SteamShutdown_t) : typeof(Pack8) ); + internal static SteamShutdown_t Fill( IntPtr p ) => Config.PackSmall ? ((SteamShutdown_t)(SteamShutdown_t) Marshal.PtrToStructure( p, typeof(SteamShutdown_t) )) : ((SteamShutdown_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (SteamShutdown_t)default(SteamShutdown_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (SteamShutdown_t)default(SteamShutdown_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(SteamShutdown_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 4, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 4, true ); actionServer = action; } else { - Event.Register( OnClient, default(SteamShutdown_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 4, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 4, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 4, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8189,30 +12611,54 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct IPCountry_t : Steamworks.ISteamCallback + internal struct IPCountry_t { - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 1; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(IPCountry_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((IPCountry_t)(IPCountry_t) Marshal.PtrToStructure( p, typeof(IPCountry_t) )) : ((IPCountry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(IPCountry_t) : typeof(Pack8) ); + internal static IPCountry_t Fill( IntPtr p ) => Config.PackSmall ? ((IPCountry_t)(IPCountry_t) Marshal.PtrToStructure( p, typeof(IPCountry_t) )) : ((IPCountry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (IPCountry_t)default(IPCountry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (IPCountry_t)default(IPCountry_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(IPCountry_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 1, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUtils + 1, true ); actionServer = action; } else { - Event.Register( OnClient, default(IPCountry_t).GetStructSize(), CallbackIdentifiers.SteamUtils + 1, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUtils + 1, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUtils + 1, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions @@ -8226,31 +12672,55 @@ public struct Pack8 } [StructLayout( LayoutKind.Sequential, Pack = 4 )] - internal struct IPCFailure_t : Steamworks.ISteamCallback + internal struct IPCFailure_t { internal byte FailureType; // m_eFailureType uint8 - #region ISteamCallback - public int GetCallbackId() => CallbackIdentifiers.SteamUser + 17; - public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(IPCFailure_t) : typeof(Pack8) ); - public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? ((IPCFailure_t)(IPCFailure_t) Marshal.PtrToStructure( p, typeof(IPCFailure_t) )) : ((IPCFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #region SteamCallback + internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof(IPCFailure_t) : typeof(Pack8) ); + internal static IPCFailure_t Fill( IntPtr p ) => Config.PackSmall ? ((IPCFailure_t)(IPCFailure_t) Marshal.PtrToStructure( p, typeof(IPCFailure_t) )) : ((IPCFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + static Action actionClient; - [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( (IPCFailure_t)default(IPCFailure_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) ); static Action actionServer; - [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( (IPCFailure_t)default(IPCFailure_t).Fill( pvParam ) ); + [MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) ); public static void Install( Action action, bool server = false ) { if ( server ) { - Event.Register( OnServer, default(IPCFailure_t).GetStructSize(), CallbackIdentifiers.SteamUser + 17, true ); + Event.Register( OnServer, StructSize, CallbackIdentifiers.SteamUser + 17, true ); actionServer = action; } else { - Event.Register( OnClient, default(IPCFailure_t).GetStructSize(), CallbackIdentifiers.SteamUser + 17, false ); + Event.Register( OnClient, StructSize, CallbackIdentifiers.SteamUser + 17, false ); actionClient = action; } } + public static async Task GetResultAsync( SteamAPICall_t handle ) + { + bool failed = false; + + while ( !SteamUtils.IsCallComplete( handle, out failed ) ) + { + await Task.Delay( 1 ); + } + if ( failed ) return null; + + var ptr = Marshal.AllocHGlobal( StructSize ); + + try + { + if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, CallbackIdentifiers.SteamUser + 17, ref failed ) || failed ) + return null; + + return Fill( ptr ); + } + finally + { + Marshal.FreeHGlobal( ptr ); + } + } #endregion #region Packed Versions diff --git a/Facepunch.Steamworks/Generated/SteamTypes.cs b/Facepunch.Steamworks/Generated/SteamTypes.cs index cf31ccd..a17d4f0 100644 --- a/Facepunch.Steamworks/Generated/SteamTypes.cs +++ b/Facepunch.Steamworks/Generated/SteamTypes.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Linq; using Steamworks.Data; +using System.Threading.Tasks; namespace Steamworks.Data { diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs index 367e5a7..8d3f90a 100644 --- a/Facepunch.Steamworks/SteamUtils.cs +++ b/Facepunch.Steamworks/SteamUtils.cs @@ -250,38 +250,10 @@ public static bool VrHeadsetStreaming } } - internal static bool IsCallComplete( SteamAPICall_t call, out bool failed ) { failed = false; return Internal.IsAPICallCompleted( call, ref failed ); } - - internal static T? GetResult( SteamAPICall_t call ) where T : struct, ISteamCallback - { - var t = new T(); - - var size = t.GetStructSize(); - var ptr = Marshal.AllocHGlobal( size ); - - try - { - bool failed = false; - - if ( !Internal.GetAPICallResult( call, ptr, size, t.GetCallbackId(), ref failed ) ) - return null; - - if ( failed ) - return null; - - t = (T)t.Fill( ptr ); - - return t; - } - finally - { - Marshal.FreeHGlobal( ptr ); - } - } } } \ No newline at end of file diff --git a/Generator/CodeWriter/CodeWriter.cs b/Generator/CodeWriter/CodeWriter.cs index 40954b2..10a0635 100644 --- a/Generator/CodeWriter/CodeWriter.cs +++ b/Generator/CodeWriter/CodeWriter.cs @@ -110,6 +110,7 @@ private void Header( string NamespaceName = "Steamworks" ) WriteLine( "using System.Runtime.InteropServices;" ); WriteLine( "using System.Linq;" ); WriteLine( "using Steamworks.Data;" ); + WriteLine( "using System.Threading.Tasks;" ); WriteLine(); StartBlock( "namespace " + NamespaceName ); } diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index 6886901..61f6885 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -64,7 +64,7 @@ void Structs() // Main struct // WriteLine( "[StructLayout( LayoutKind.Sequential, Pack = 4 )]" ); - StartBlock( $"{Cleanup.Expose( name )} struct {name}{(isCallback?" : Steamworks.ISteamCallback":"")}" ); + StartBlock( $"{Cleanup.Expose( name )} struct {name}" ); { // // The fields @@ -74,43 +74,69 @@ void Structs() if ( isCallback ) { - WriteLine( "#region ISteamCallback" ); + WriteLine( "#region SteamCallback" ); { - WriteLine( $"public int GetCallbackId() => {c.CallbackId};" ); - if ( defaultPack == 4 ) { - WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof({name}) );" ); - WriteLine( $"public Steamworks.ISteamCallback Fill( IntPtr p ) => (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) ) );" ); + WriteLine( $"internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( typeof({name}) );" ); + WriteLine( $"internal static {name} Fill( IntPtr p ) => (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) ) );" ); } else { - WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof({name}) : typeof(Pack8) );" ); - WriteLine( $"public Steamworks.ISteamCallback Fill( IntPtr p ) => Config.PackSmall ? (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) )) : (({name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); + WriteLine( $"internal static readonly int StructSize = System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof({name}) : typeof(Pack8) );" ); + WriteLine( $"internal static {name} Fill( IntPtr p ) => Config.PackSmall ? (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) )) : (({name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); } - + WriteLine(); WriteLine( $"static Action<{name}> actionClient;" ); - WriteLine( $"[MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( ({name})default({name}).Fill( pvParam ) );" ); + WriteLine( $"[MonoPInvokeCallback] static void OnClient( IntPtr thisptr, IntPtr pvParam ) => actionClient?.Invoke( Fill( pvParam ) );" ); WriteLine( $"static Action<{name}> actionServer;" ); - WriteLine( $"[MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( ({name})default({name}).Fill( pvParam ) );" ); + WriteLine( $"[MonoPInvokeCallback] static void OnServer( IntPtr thisptr, IntPtr pvParam ) => actionServer?.Invoke( Fill( pvParam ) );" ); StartBlock( $"public static void Install( Action<{name}> action, bool server = false )" ); { StartBlock( "if ( server )" ); { - WriteLine( $"Event.Register( OnServer, default({name}).GetStructSize(), {c.CallbackId}, true );" ); + WriteLine( $"Event.Register( OnServer, StructSize, {c.CallbackId}, true );" ); WriteLine( $"actionServer = action;" ); } Else(); { - WriteLine( $"Event.Register( OnClient, default({name}).GetStructSize(), {c.CallbackId}, false );" ); + WriteLine( $"Event.Register( OnClient, StructSize, {c.CallbackId}, false );" ); WriteLine( $"actionClient = action;" ); } EndBlock(); } EndBlock(); + + StartBlock( $"public static async Task<{name}?> GetResultAsync( SteamAPICall_t handle )" ); + { + WriteLine( $"bool failed = false;" ); + WriteLine(); + StartBlock( $"while ( !SteamUtils.IsCallComplete( handle, out failed ) )" ); + { + WriteLine( $"await Task.Delay( 1 );" ); + } + EndBlock(); + + WriteLine( $"if ( failed ) return null;" ); + WriteLine( $"" ); + WriteLine( $"var ptr = Marshal.AllocHGlobal( StructSize );" ); + WriteLine( $"" ); + WriteLine( $"try" ); + WriteLine( $"{{" ); + WriteLine( $" if ( !SteamUtils.Internal.GetAPICallResult( handle, ptr, StructSize, {c.CallbackId}, ref failed ) || failed )" ); + WriteLine( $" return null;" ); + WriteLine( $"" ); + WriteLine( $" return Fill( ptr );" ); + WriteLine( $"}}" ); + WriteLine( $"finally" ); + WriteLine( $"{{" ); + WriteLine( $" Marshal.FreeHGlobal( ptr );" ); + WriteLine( $"}}" ); + } + EndBlock(); } WriteLine( "#endregion" ); } @@ -120,13 +146,13 @@ void Structs() { if ( defaultPack == 4 ) { - WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof({name}) );" ); - WriteLine( $"public {name} Fill( IntPtr p ) => (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) ) );" ); + //WriteLine( $"internal static int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( typeof({name}) );" ); + WriteLine( $"internal static {name} Fill( IntPtr p ) => (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) ) );" ); } else { - WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof({name}) : typeof(Pack8) );" ); - WriteLine( $"public {name} Fill( IntPtr p ) => Config.PackSmall ? (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) )) : (({name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); + //WriteLine( $"internal static int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Config.PackSmall ? typeof({name}) : typeof(Pack8) );" ); + WriteLine( $"internal static {name} Fill( IntPtr p ) => Config.PackSmall ? (({name})({name}) Marshal.PtrToStructure( p, typeof({name}) )) : (({name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); } } WriteLine( "#endregion" ); diff --git a/Generator/CodeWriter/Types/BaseType.cs b/Generator/CodeWriter/Types/BaseType.cs index 1080b75..6076e8c 100644 --- a/Generator/CodeWriter/Types/BaseType.cs +++ b/Generator/CodeWriter/Types/BaseType.cs @@ -114,7 +114,7 @@ public override string Return( string varname ) { if ( NativeType.EndsWith( "*" ) ) { - return $"return new {TypeName}().Fill( {varname} );"; + return $"return {TypeName}.Fill( {varname} );"; } return base.Return( varname ); @@ -125,7 +125,7 @@ internal class SteamApiCallType : BaseType { public string CallResult; public override string TypeName => "SteamAPICall_t"; - public override string Return( string varname ) => $"return await (new Result<{CallResult}>( {varname} )).GetResult();"; + public override string Return( string varname ) => $"return await {CallResult}.GetResultAsync( {varname} );"; public override string ReturnType => $"async Task<{CallResult}?>"; }