InventoryResult.Serialize

This commit is contained in:
Garry Newman 2019-04-29 11:13:17 +01:00
parent 0d509bf126
commit 1625268f5d
3 changed files with 31 additions and 2 deletions

View File

@ -152,11 +152,11 @@ namespace Steamworks
#region FunctionMeta #region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] [UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )] [return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FSerializeResult( IntPtr self, SteamInventoryResult_t resultHandle, [In,Out] IntPtr[] pOutBuffer, ref uint punOutBufferSize ); private delegate bool FSerializeResult( IntPtr self, SteamInventoryResult_t resultHandle, IntPtr pOutBuffer, ref uint punOutBufferSize );
private FSerializeResult _SerializeResult; private FSerializeResult _SerializeResult;
#endregion #endregion
internal bool SerializeResult( SteamInventoryResult_t resultHandle, [In,Out] IntPtr[] pOutBuffer, ref uint punOutBufferSize ) internal bool SerializeResult( SteamInventoryResult_t resultHandle, IntPtr pOutBuffer, ref uint punOutBufferSize )
{ {
return _SerializeResult( Self, resultHandle, pOutBuffer, ref punOutBufferSize ); return _SerializeResult( Self, resultHandle, pOutBuffer, ref punOutBufferSize );
} }

View File

@ -70,5 +70,33 @@ namespace Steamworks
{ {
SteamInventory.Internal.DestroyResult( _id ); SteamInventory.Internal.DestroyResult( _id );
} }
/// <summary>
/// Serialized result sets contain a short signature which can't be forged or replayed across different game sessions.
/// A result set can be serialized on the local client, transmitted to other players via your game networking, and
/// deserialized by the remote players.This is a secure way of preventing hackers from lying about posessing
/// rare/high-value items. Serializes a result set with signature bytes to an output buffer.The size of a serialized
/// result depends on the number items which are being serialized.When securely transmitting items to other players,
/// it is recommended to use GetItemsByID first to create a minimal result set.
/// Results have a built-in timestamp which will be considered "expired" after an hour has elapsed.See DeserializeResult
/// for expiration handling.
/// </summary>
public unsafe byte[] Serialize()
{
uint size = 0;
if ( !SteamInventory.Internal.SerializeResult( _id, IntPtr.Zero, ref size ) )
return null;
var data = new byte[size];
fixed ( byte* ptr = data )
{
if ( !SteamInventory.Internal.SerializeResult( _id, (IntPtr)ptr, ref size ) )
return null;
}
return data;
}
} }
} }

View File

@ -61,6 +61,7 @@ internal class BaseType
get get
{ {
if ( VarName == "pOut" ) return false; if ( VarName == "pOut" ) return false;
if ( VarName == "pOutBuffer" ) return false;
if ( VarName == "pubRGB" ) return false; if ( VarName == "pubRGB" ) return false;
if ( VarName == "psteamIDClans" ) return true; if ( VarName == "psteamIDClans" ) return true;