mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-10-16 23:37:02 +03:00
Don't release inventoryg result in InventoryUpdated callback
This commit is contained in:
parent
69ec868227
commit
7a30b76a26
@ -54,10 +54,13 @@ public async Task GetAllItems()
|
|||||||
var result = await SteamInventory.GetAllItemsAsync();
|
var result = await SteamInventory.GetAllItemsAsync();
|
||||||
|
|
||||||
Assert.IsTrue( result.HasValue );
|
Assert.IsTrue( result.HasValue );
|
||||||
|
Assert.IsTrue( result.Value.ItemCount > 0 );
|
||||||
|
|
||||||
using ( result )
|
using ( result )
|
||||||
{
|
{
|
||||||
var items = result?.GetItems( true );
|
var items = result.Value.GetItems( true );
|
||||||
|
|
||||||
|
Assert.IsNotNull( items );
|
||||||
|
|
||||||
foreach ( var item in items )
|
foreach ( var item in items )
|
||||||
{
|
{
|
||||||
@ -71,6 +74,33 @@ public async Task GetAllItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task GetAllItemsMultipleTimes()
|
||||||
|
{
|
||||||
|
await SteamInventory.WaitForDefinitions();
|
||||||
|
|
||||||
|
var fresult = await SteamInventory.GetAllItemsAsync();
|
||||||
|
|
||||||
|
Assert.IsTrue( fresult.HasValue );
|
||||||
|
Assert.IsTrue( fresult.Value.ItemCount > 0 );
|
||||||
|
|
||||||
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
|
var result = await SteamInventory.GetAllItemsAsync();
|
||||||
|
|
||||||
|
Assert.IsTrue( result.HasValue );
|
||||||
|
Assert.IsTrue( result.Value.GetItems().Length == fresult.Value.ItemCount );
|
||||||
|
|
||||||
|
|
||||||
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
|
result = await SteamInventory.GetAllItemsAsync();
|
||||||
|
|
||||||
|
Assert.IsTrue( result.HasValue );
|
||||||
|
Assert.IsTrue( result.Value.ItemCount == fresult.Value.ItemCount );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task Items()
|
public async Task Items()
|
||||||
{
|
{
|
||||||
|
@ -46,8 +46,6 @@ private static void InventoryUpdated( SteamInventoryFullUpdate_t x )
|
|||||||
Items = r.GetItems( false );
|
Items = r.GetItems( false );
|
||||||
|
|
||||||
OnInventoryUpdated?.Invoke( r );
|
OnInventoryUpdated?.Invoke( r );
|
||||||
|
|
||||||
r.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static event Action<InventoryResult> OnInventoryUpdated;
|
public static event Action<InventoryResult> OnInventoryUpdated;
|
||||||
|
@ -58,6 +58,8 @@ public InventoryItem[] GetItems( bool includeProperties = false )
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if ( _id.Value == -1 ) return;
|
||||||
|
|
||||||
SteamInventory.Internal.DestroyResult( _id );
|
SteamInventory.Internal.DestroyResult( _id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user