From ad21e90e90def2b8d7d12ae18e06921e857ca95d Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 8 May 2019 09:49:32 +0100 Subject: [PATCH] Added IsPack4OnWindows to codegen struct --- Facepunch.Steamworks/Generated/SteamStructs.cs | 16 +--------------- Generator/CodeWriter/Struct.cs | 5 +---- Generator/SteamApiDefinition.cs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Facepunch.Steamworks/Generated/SteamStructs.cs b/Facepunch.Steamworks/Generated/SteamStructs.cs index 0d7f8b1..3c2173a 100644 --- a/Facepunch.Steamworks/Generated/SteamStructs.cs +++ b/Facepunch.Steamworks/Generated/SteamStructs.cs @@ -5620,21 +5620,7 @@ namespace Steamworks.Data internal ulong UGC; // m_hUGC UGCHandle_t #region Marshalling - 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 - - [StructLayout( LayoutKind.Sequential, Pack = 8 )] - public struct Pack8 - { - internal ulong SteamIDUser; // m_steamIDUser class CSteamID - internal int GlobalRank; // m_nGlobalRank int32 - internal int Score; // m_nScore int32 - internal int CDetails; // m_cDetails int32 - internal ulong UGC; // m_hUGC UGCHandle_t - - public static implicit operator LeaderboardEntry_t ( LeaderboardEntry_t.Pack8 d ) => new LeaderboardEntry_t{ SteamIDUser = d.SteamIDUser,GlobalRank = d.GlobalRank,Score = d.Score,CDetails = d.CDetails,UGC = d.UGC, }; - } + internal static LeaderboardEntry_t Fill( IntPtr p ) => ((LeaderboardEntry_t)(LeaderboardEntry_t) Marshal.PtrToStructure( p, typeof(LeaderboardEntry_t) ) ); #endregion } diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index 61f6885..48f966e 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -53,10 +53,7 @@ namespace Generator if ( name.Contains( "::" ) ) continue; - int defaultPack = 8; - - if ( c.Fields.Any( x => x.Type.Contains( "CSteamID" ) ) && !ForceLargePackStructs.Contains( c.Name ) ) - defaultPack = 4; + int defaultPack = c.IsPack4OnWindows ? 4 : 8; var isCallback = !string.IsNullOrEmpty( c.CallbackId ); diff --git a/Generator/SteamApiDefinition.cs b/Generator/SteamApiDefinition.cs index f0b7b02..833ddcd 100644 --- a/Generator/SteamApiDefinition.cs +++ b/Generator/SteamApiDefinition.cs @@ -54,6 +54,22 @@ namespace Generator public string CallbackId { get; set; } public bool IsCallResult { get; set; } + + + public bool IsPack4OnWindows + { + get + { + // if ( Name.Contains( "LeaderboardEntry_t" ) ) + // return false; + + if ( Fields.Any( x => x.Type.Contains( "CSteamID" ) ) ) + return true; + + return false; + } + } + } public List structs { get; set; }