From d5abb32aebb6dc85668b1151f5d40980df91d0f3 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 25 Jun 2019 12:04:43 +0100 Subject: [PATCH] Neater generated vtable code --- .../Interfaces/ISteamGameServerStats.cs | 32 ++-- .../Generated/Interfaces/ISteamUGC.cs | 162 +++++++++--------- .../Generated/Interfaces/ISteamUserStats.cs | 104 +++++------ Generator/CodeWriter/ClassVTable.cs | 50 +++--- 4 files changed, 182 insertions(+), 166 deletions(-) diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs index dfe46e0..eb08f85 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs @@ -13,22 +13,24 @@ namespace Steamworks public override void InitInternals() { - #if PLATFORM_WIN64 - int[] loc = new[] { 0, 16, 8, 24, 40, 32, 48, 56, 64, 72 }; - #else - int[] loc = new[] { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72 }; - #endif + _RequestUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 0 ) ); + _GetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24 ) ); + _UpdateUserAvgRateStat = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 48 ) ); + _SetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 56 ) ); + _ClearUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 64 ) ); + _StoreUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 72 ) ); - _RequestUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[0] ) ); - _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[1] ) ); - _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[2] ) ); - _GetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[3] ) ); - _SetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[4] ) ); - _SetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[5] ) ); - _UpdateUserAvgRateStat = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[6] ) ); - _SetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[7] ) ); - _ClearUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[8] ) ); - _StoreUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[9] ) ); + #if PLATFORM_WIN64 + _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + _SetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40 ) ); + _SetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32 ) ); + #else + _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + _SetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32 ) ); + _SetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40 ) ); + #endif } internal override void Shutdown() { diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs index 107b710..9097eba 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs @@ -13,88 +13,88 @@ namespace Steamworks public override void InitInternals() { - #if PLATFORM_WIN64 - int[] loc = new[] { 0, 16, 8, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 464, 472, 480, 488, 496, 504, 512, 520, 528, 536, 544, 552, 560, 568, 576, 584, 592, 600 }; - #else - int[] loc = new[] { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 464, 472, 480, 488, 496, 504, 512, 520, 528, 536, 544, 552, 560, 568, 576, 584, 592, 600 }; - #endif + _CreateQueryUserUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 0 ) ); + _CreateQueryUGCDetailsRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24 ) ); + _SendQueryUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32 ) ); + _GetQueryUGCResult = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40 ) ); + _GetQueryUGCPreviewURL = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 48 ) ); + _GetQueryUGCMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 56 ) ); + _GetQueryUGCChildren = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 64 ) ); + _GetQueryUGCStatistic = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 72 ) ); + _GetQueryUGCNumAdditionalPreviews = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 80 ) ); + _GetQueryUGCAdditionalPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 88 ) ); + _GetQueryUGCNumKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 96 ) ); + _GetQueryUGCKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 104 ) ); + _ReleaseQueryUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 112 ) ); + _AddRequiredTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 120 ) ); + _AddExcludedTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 128 ) ); + _SetReturnOnlyIDs = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 136 ) ); + _SetReturnKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 144 ) ); + _SetReturnLongDescription = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 152 ) ); + _SetReturnMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 160 ) ); + _SetReturnChildren = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 168 ) ); + _SetReturnAdditionalPreviews = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 176 ) ); + _SetReturnTotalOnly = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 184 ) ); + _SetReturnPlaytimeStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 192 ) ); + _SetLanguage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200 ) ); + _SetAllowCachedResponse = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 208 ) ); + _SetCloudFileNameFilter = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 216 ) ); + _SetMatchAnyTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 224 ) ); + _SetSearchText = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 232 ) ); + _SetRankedByTrendDays = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 240 ) ); + _AddRequiredKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 248 ) ); + _RequestUGCDetails = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 256 ) ); + _CreateItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 264 ) ); + _StartItemUpdate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 272 ) ); + _SetItemTitle = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 280 ) ); + _SetItemDescription = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 288 ) ); + _SetItemUpdateLanguage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 296 ) ); + _SetItemMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 304 ) ); + _SetItemVisibility = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 312 ) ); + _SetItemTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 320 ) ); + _SetItemContent = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 328 ) ); + _SetItemPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 336 ) ); + _SetAllowLegacyUpload = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 344 ) ); + _RemoveItemKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 352 ) ); + _AddItemKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 360 ) ); + _AddItemPreviewFile = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 368 ) ); + _AddItemPreviewVideo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 376 ) ); + _UpdateItemPreviewFile = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 384 ) ); + _UpdateItemPreviewVideo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 392 ) ); + _RemoveItemPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 400 ) ); + _SubmitItemUpdate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 408 ) ); + _GetItemUpdateProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 416 ) ); + _SetUserItemVote = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 424 ) ); + _GetUserItemVote = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 432 ) ); + _AddItemToFavorites = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 440 ) ); + _RemoveItemFromFavorites = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 448 ) ); + _SubscribeItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 456 ) ); + _UnsubscribeItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 464 ) ); + _GetNumSubscribedItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 472 ) ); + _GetSubscribedItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 480 ) ); + _GetItemState = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 488 ) ); + _GetItemInstallInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 496 ) ); + _GetItemDownloadInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 504 ) ); + _DownloadItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 512 ) ); + _BInitWorkshopForGameServer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 520 ) ); + _SuspendDownloads = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 528 ) ); + _StartPlaytimeTracking = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 536 ) ); + _StopPlaytimeTracking = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 544 ) ); + _StopPlaytimeTrackingForAllItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 552 ) ); + _AddDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 560 ) ); + _RemoveDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 568 ) ); + _AddAppDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 576 ) ); + _RemoveAppDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 584 ) ); + _GetAppDependencies = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 592 ) ); + _DeleteItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 600 ) ); - _CreateQueryUserUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[0] ) ); - _CreateQueryAllUGCRequest1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[1] ) ); - _CreateQueryAllUGCRequest2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[2] ) ); - _CreateQueryUGCDetailsRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[3] ) ); - _SendQueryUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[4] ) ); - _GetQueryUGCResult = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[5] ) ); - _GetQueryUGCPreviewURL = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[6] ) ); - _GetQueryUGCMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[7] ) ); - _GetQueryUGCChildren = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[8] ) ); - _GetQueryUGCStatistic = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[9] ) ); - _GetQueryUGCNumAdditionalPreviews = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[10] ) ); - _GetQueryUGCAdditionalPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[11] ) ); - _GetQueryUGCNumKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[12] ) ); - _GetQueryUGCKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[13] ) ); - _ReleaseQueryUGCRequest = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[14] ) ); - _AddRequiredTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[15] ) ); - _AddExcludedTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[16] ) ); - _SetReturnOnlyIDs = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[17] ) ); - _SetReturnKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[18] ) ); - _SetReturnLongDescription = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[19] ) ); - _SetReturnMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[20] ) ); - _SetReturnChildren = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[21] ) ); - _SetReturnAdditionalPreviews = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[22] ) ); - _SetReturnTotalOnly = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[23] ) ); - _SetReturnPlaytimeStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[24] ) ); - _SetLanguage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[25] ) ); - _SetAllowCachedResponse = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[26] ) ); - _SetCloudFileNameFilter = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[27] ) ); - _SetMatchAnyTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[28] ) ); - _SetSearchText = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[29] ) ); - _SetRankedByTrendDays = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[30] ) ); - _AddRequiredKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[31] ) ); - _RequestUGCDetails = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[32] ) ); - _CreateItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[33] ) ); - _StartItemUpdate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[34] ) ); - _SetItemTitle = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[35] ) ); - _SetItemDescription = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[36] ) ); - _SetItemUpdateLanguage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[37] ) ); - _SetItemMetadata = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[38] ) ); - _SetItemVisibility = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[39] ) ); - _SetItemTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[40] ) ); - _SetItemContent = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[41] ) ); - _SetItemPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[42] ) ); - _SetAllowLegacyUpload = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[43] ) ); - _RemoveItemKeyValueTags = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[44] ) ); - _AddItemKeyValueTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[45] ) ); - _AddItemPreviewFile = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[46] ) ); - _AddItemPreviewVideo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[47] ) ); - _UpdateItemPreviewFile = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[48] ) ); - _UpdateItemPreviewVideo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[49] ) ); - _RemoveItemPreview = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[50] ) ); - _SubmitItemUpdate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[51] ) ); - _GetItemUpdateProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[52] ) ); - _SetUserItemVote = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[53] ) ); - _GetUserItemVote = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[54] ) ); - _AddItemToFavorites = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[55] ) ); - _RemoveItemFromFavorites = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[56] ) ); - _SubscribeItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[57] ) ); - _UnsubscribeItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[58] ) ); - _GetNumSubscribedItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[59] ) ); - _GetSubscribedItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[60] ) ); - _GetItemState = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[61] ) ); - _GetItemInstallInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[62] ) ); - _GetItemDownloadInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[63] ) ); - _DownloadItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[64] ) ); - _BInitWorkshopForGameServer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[65] ) ); - _SuspendDownloads = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[66] ) ); - _StartPlaytimeTracking = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[67] ) ); - _StopPlaytimeTracking = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[68] ) ); - _StopPlaytimeTrackingForAllItems = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[69] ) ); - _AddDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[70] ) ); - _RemoveDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[71] ) ); - _AddAppDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[72] ) ); - _RemoveAppDependency = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[73] ) ); - _GetAppDependencies = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[74] ) ); - _DeleteItem = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[75] ) ); + #if PLATFORM_WIN64 + _CreateQueryAllUGCRequest1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + _CreateQueryAllUGCRequest2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + #else + _CreateQueryAllUGCRequest1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + _CreateQueryAllUGCRequest2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + #endif } internal override void Shutdown() { diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs index 9e9fb3c..1f6aef2 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs @@ -13,55 +13,63 @@ namespace Steamworks public override void InitInternals() { - #if PLATFORM_WIN64 - int[] loc = new[] { 0, 16, 8, 32, 24, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 144, 136, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 320, 312, 336, 328 }; - #else - int[] loc = new[] { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336 }; - #endif + _RequestCurrentStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 0 ) ); + _UpdateAvgRateStat = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40 ) ); + _GetAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 48 ) ); + _SetAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 56 ) ); + _ClearAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 64 ) ); + _GetAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 72 ) ); + _StoreStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 80 ) ); + _GetAchievementIcon = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 88 ) ); + _GetAchievementDisplayAttribute = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 96 ) ); + _IndicateAchievementProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 104 ) ); + _GetNumAchievements = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 112 ) ); + _GetAchievementName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 120 ) ); + _RequestUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 128 ) ); + _GetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 152 ) ); + _GetUserAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 160 ) ); + _ResetAllStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 168 ) ); + _FindOrCreateLeaderboard = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 176 ) ); + _FindLeaderboard = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 184 ) ); + _GetLeaderboardName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 192 ) ); + _GetLeaderboardEntryCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200 ) ); + _GetLeaderboardSortMethod = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 208 ) ); + _GetLeaderboardDisplayType = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 216 ) ); + _DownloadLeaderboardEntries = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 224 ) ); + _DownloadLeaderboardEntriesForUsers = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 232 ) ); + _GetDownloadedLeaderboardEntry = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 240 ) ); + _UploadLeaderboardScore = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 248 ) ); + _AttachLeaderboardUGC = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 256 ) ); + _GetNumberOfCurrentPlayers = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 264 ) ); + _RequestGlobalAchievementPercentages = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 272 ) ); + _GetMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 280 ) ); + _GetNextMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 288 ) ); + _GetAchievementAchievedPercent = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 296 ) ); + _RequestGlobalStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 304 ) ); - _RequestCurrentStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[0] ) ); - _GetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[1] ) ); - _GetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[2] ) ); - _SetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[3] ) ); - _SetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[4] ) ); - _UpdateAvgRateStat = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[5] ) ); - _GetAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[6] ) ); - _SetAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[7] ) ); - _ClearAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[8] ) ); - _GetAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[9] ) ); - _StoreStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[10] ) ); - _GetAchievementIcon = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[11] ) ); - _GetAchievementDisplayAttribute = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[12] ) ); - _IndicateAchievementProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[13] ) ); - _GetNumAchievements = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[14] ) ); - _GetAchievementName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[15] ) ); - _RequestUserStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[16] ) ); - _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[17] ) ); - _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[18] ) ); - _GetUserAchievement = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[19] ) ); - _GetUserAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[20] ) ); - _ResetAllStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[21] ) ); - _FindOrCreateLeaderboard = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[22] ) ); - _FindLeaderboard = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[23] ) ); - _GetLeaderboardName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[24] ) ); - _GetLeaderboardEntryCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[25] ) ); - _GetLeaderboardSortMethod = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[26] ) ); - _GetLeaderboardDisplayType = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[27] ) ); - _DownloadLeaderboardEntries = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[28] ) ); - _DownloadLeaderboardEntriesForUsers = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[29] ) ); - _GetDownloadedLeaderboardEntry = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[30] ) ); - _UploadLeaderboardScore = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[31] ) ); - _AttachLeaderboardUGC = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[32] ) ); - _GetNumberOfCurrentPlayers = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[33] ) ); - _RequestGlobalAchievementPercentages = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[34] ) ); - _GetMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[35] ) ); - _GetNextMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[36] ) ); - _GetAchievementAchievedPercent = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[37] ) ); - _RequestGlobalStats = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[38] ) ); - _GetGlobalStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[39] ) ); - _GetGlobalStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[40] ) ); - _GetGlobalStatHistory1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[41] ) ); - _GetGlobalStatHistory2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[42] ) ); + #if PLATFORM_WIN64 + _GetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + _GetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + _SetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32 ) ); + _SetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24 ) ); + _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 144 ) ); + _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 136 ) ); + _GetGlobalStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 320 ) ); + _GetGlobalStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 312 ) ); + _GetGlobalStatHistory1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 336 ) ); + _GetGlobalStatHistory2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 328 ) ); + #else + _GetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8 ) ); + _GetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16 ) ); + _SetStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24 ) ); + _SetStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32 ) ); + _GetUserStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 136 ) ); + _GetUserStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 144 ) ); + _GetGlobalStat1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 312 ) ); + _GetGlobalStat2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 320 ) ); + _GetGlobalStatHistory1 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 328 ) ); + _GetGlobalStatHistory2 = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 336 ) ); + #endif } internal override void Shutdown() { diff --git a/Generator/CodeWriter/ClassVTable.cs b/Generator/CodeWriter/ClassVTable.cs index 6cb6a3d..a6ceb0f 100644 --- a/Generator/CodeWriter/ClassVTable.cs +++ b/Generator/CodeWriter/ClassVTable.cs @@ -93,40 +93,46 @@ namespace Generator StartBlock( $"public override void InitInternals()" ); { + var different = new List(); - if ( standardLocations.SequenceEqual( windowsLocations ) ) + for ( int i = 0; i < clss.Functions.Count; i++ ) { - for ( int i = 0; i < clss.Functions.Count; i++ ) - { - var func = clss.Functions[i]; + var func = clss.Functions[i]; - if ( Cleanup.IsDeprecated( $"{clss.Name}.{func.Name}" ) ) - WriteLine( $" // {func.Name} is deprecated" ); - else - WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {standardLocations[i]} ) );" ); + if ( Cleanup.IsDeprecated( $"{clss.Name}.{func.Name}" ) ) + { + WriteLine( $" // {func.Name} is deprecated" ); + } + else + { + if ( standardLocations[i] != windowsLocations[i] ) + { + different.Add( i ); + continue; + } + + WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {standardLocations[i]} ) );" ); } } - else + + if ( different.Count > 0 ) { + WriteLine( "" ); WriteLine( "#if PLATFORM_WIN64" ); - WriteLine( $"int[] loc = new[] {{ {string.Join( ", ", windowsLocations )} }};" ); - WriteLine( "#else" ); - WriteLine( $"int[] loc = new[] {{ {string.Join( ", ", standardLocations )} }};" ); - WriteLine( "#endif" ); - WriteLine(); - - for ( int i = 0; i < clss.Functions.Count; i++ ) + foreach ( var i in different ) { var func = clss.Functions[i]; - - if ( Cleanup.IsDeprecated( $"{clss.Name}.{func.Name}" ) ) - WriteLine( $" // {func.Name} is deprecated" ); - else - WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, loc[{i}] ) );" ); + WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {windowsLocations[i]} ) );" ); } + WriteLine( "#else" ); + foreach ( var i in different ) + { + var func = clss.Functions[i]; + WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {standardLocations[i]} ) );" ); + } + WriteLine( "#endif" ); } - } EndBlock();