mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-26 13:31:17 +03:00
SteamItemDetails_t should read flags properly on windows
This commit is contained in:
parent
778b1081cb
commit
a5bd78a597
@ -15,6 +15,7 @@ namespace Steamworks
|
||||
{
|
||||
_GetResultStatus = Marshal.GetDelegateForFunctionPointer<FGetResultStatus>( Marshal.ReadIntPtr( VTable, 0) );
|
||||
_GetResultItems = Marshal.GetDelegateForFunctionPointer<FGetResultItems>( Marshal.ReadIntPtr( VTable, 8) );
|
||||
_GetResultItems_Windows = Marshal.GetDelegateForFunctionPointer<FGetResultItems_Windows>( Marshal.ReadIntPtr( VTable, 8) );
|
||||
_GetResultItemProperty = Marshal.GetDelegateForFunctionPointer<FGetResultItemProperty>( Marshal.ReadIntPtr( VTable, 16) );
|
||||
_GetResultTimestamp = Marshal.GetDelegateForFunctionPointer<FGetResultTimestamp>( Marshal.ReadIntPtr( VTable, 24) );
|
||||
_CheckResultSteamID = Marshal.GetDelegateForFunctionPointer<FCheckResultSteamID>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
@ -57,6 +58,7 @@ namespace Steamworks
|
||||
|
||||
_GetResultStatus = null;
|
||||
_GetResultItems = null;
|
||||
_GetResultItems_Windows = null;
|
||||
_GetResultItemProperty = null;
|
||||
_GetResultTimestamp = null;
|
||||
_CheckResultSteamID = null;
|
||||
@ -110,10 +112,35 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetResultItems( IntPtr self, SteamInventoryResult_t resultHandle, [In,Out] SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize );
|
||||
private FGetResultItems _GetResultItems;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetResultItems_Windows( IntPtr self, SteamInventoryResult_t resultHandle, [In,Out] SteamItemDetails_t.Pack8[] pOutItemsArray, ref uint punOutItemsArraySize );
|
||||
private FGetResultItems_Windows _GetResultItems_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetResultItems( SteamInventoryResult_t resultHandle, [In,Out] SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamItemDetails_t.Pack8[] pOutItemsArray_windows = pOutItemsArray == null ? null : new SteamItemDetails_t.Pack8[ pOutItemsArray.Length ];
|
||||
if ( pOutItemsArray_windows != null )
|
||||
{
|
||||
for ( int i=0; i<pOutItemsArray.Length; i++ )
|
||||
{
|
||||
pOutItemsArray_windows[i] = pOutItemsArray[i];
|
||||
}
|
||||
}
|
||||
var retVal = _GetResultItems_Windows( Self, resultHandle, pOutItemsArray_windows, ref punOutItemsArraySize );
|
||||
if ( pOutItemsArray_windows != null )
|
||||
{
|
||||
for ( int i=0; i<pOutItemsArray.Length; i++ )
|
||||
{
|
||||
pOutItemsArray[i] = pOutItemsArray_windows[i];
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetResultItems( Self, resultHandle, pOutItemsArray, ref punOutItemsArraySize );
|
||||
}
|
||||
|
||||
|
@ -10707,7 +10707,21 @@ namespace Steamworks.Data
|
||||
internal ushort Flags; // m_unFlags uint16
|
||||
|
||||
#region Marshalling
|
||||
internal static SteamItemDetails_t Fill( IntPtr p ) => ((SteamItemDetails_t)(SteamItemDetails_t) Marshal.PtrToStructure( p, typeof(SteamItemDetails_t) ) );
|
||||
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
|
||||
|
||||
[StructLayout( LayoutKind.Sequential, Pack = 8 )]
|
||||
public struct Pack8
|
||||
{
|
||||
internal InventoryItemId ItemId; // m_itemId SteamItemInstanceID_t
|
||||
internal InventoryDefId Definition; // m_iDefinition SteamItemDef_t
|
||||
internal ushort Quantity; // m_unQuantity uint16
|
||||
internal ushort Flags; // m_unFlags uint16
|
||||
|
||||
public static implicit operator SteamItemDetails_t ( SteamItemDetails_t.Pack8 d ) => new SteamItemDetails_t{ ItemId = d.ItemId,Definition = d.Definition,Quantity = d.Quantity,Flags = d.Flags, };
|
||||
public static implicit operator SteamItemDetails_t.Pack8 ( SteamItemDetails_t d ) => new SteamItemDetails_t.Pack8{ ItemId = d.ItemId,Definition = d.Definition,Quantity = d.Quantity,Flags = d.Flags, };
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,16 @@ namespace Generator
|
||||
|
||||
if ( arg.IsVector )
|
||||
{
|
||||
WriteLine( $"{arg.TypeName}.Pack8[] {arg.VarName}_windows = {arg.VarName};" );
|
||||
WriteLine( $"{arg.TypeName}.Pack8[] {arg.VarName}_windows = {arg.VarName} == null ? null : new {arg.TypeName}.Pack8[ {arg.VarName}.Length ];" );
|
||||
StartBlock( $"if ( {arg.VarName}_windows != null )" );
|
||||
{
|
||||
StartBlock( $"for ( int i=0; i<{arg.VarName}.Length; i++ )" );
|
||||
{
|
||||
WriteLine( $"{arg.VarName}_windows[i] = {arg.VarName}[i];" );
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -274,7 +283,22 @@ namespace Generator
|
||||
{
|
||||
if ( !arg.WindowsSpecific ) continue;
|
||||
|
||||
WriteLine( $"{arg.VarName} = {arg.VarName}_windows;" );
|
||||
if ( arg.IsVector )
|
||||
{
|
||||
StartBlock( $"if ( {arg.VarName}_windows != null )" );
|
||||
{
|
||||
StartBlock( $"for ( int i=0; i<{arg.VarName}.Length; i++ )" );
|
||||
{
|
||||
WriteLine( $"{arg.VarName}[i] = {arg.VarName}_windows[i];" );
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine( $"{arg.VarName} = {arg.VarName}_windows;" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !returnType.IsVoid )
|
||||
|
@ -60,7 +60,6 @@ namespace Generator
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Name.Contains( "SteamItemDetails_t" ) ) return true;
|
||||
if ( Name.Contains( "MatchMakingKeyValuePair_t" ) ) return true;
|
||||
|
||||
if ( Fields.Any( x => x.Type.Contains( "CSteamID" ) ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user