mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Inventory fix
This commit is contained in:
parent
f72e3432ae
commit
a9d6ea6cef
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
namespace Facepunch.Steamworks.Test
|
||||||
@ -137,10 +138,14 @@ public void InventoryItemList()
|
|||||||
client.Inventory.Refresh();
|
client.Inventory.Refresh();
|
||||||
|
|
||||||
// Wait for the items
|
// Wait for the items
|
||||||
|
var timeout = Stopwatch.StartNew();
|
||||||
while ( client.Inventory.Items == null )
|
while ( client.Inventory.Items == null )
|
||||||
{
|
{
|
||||||
client.Update();
|
client.Update();
|
||||||
System.Threading.Thread.Sleep( 10 );
|
System.Threading.Thread.Sleep( 1000 );
|
||||||
|
|
||||||
|
if ( timeout.Elapsed.TotalSeconds > 5 )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure callback was called
|
// make sure callback was called
|
||||||
|
@ -29,7 +29,7 @@ public class Inventory
|
|||||||
public Action OnUpdate;
|
public Action OnUpdate;
|
||||||
|
|
||||||
internal Client client;
|
internal Client client;
|
||||||
private int updateRequest = 0;
|
private int updateRequest = -1;
|
||||||
|
|
||||||
internal Inventory( Client c )
|
internal Inventory( Client c )
|
||||||
{
|
{
|
||||||
@ -57,10 +57,13 @@ public void PlaytimeHeartbeat()
|
|||||||
public void Refresh()
|
public void Refresh()
|
||||||
{
|
{
|
||||||
// Pending
|
// Pending
|
||||||
if ( updateRequest != 0 )
|
if ( updateRequest != -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.native.inventory.GetAllItems( ref updateRequest );
|
if ( !client.native.inventory.GetAllItems( ref updateRequest ) )
|
||||||
|
{
|
||||||
|
Console.WriteLine( "GetAllItems failed!?" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void LoadItemDefinitions()
|
internal void LoadItemDefinitions()
|
||||||
@ -97,10 +100,10 @@ internal T DefinitionProperty<T>( int i, string name )
|
|||||||
|
|
||||||
internal void DestroyResult()
|
internal void DestroyResult()
|
||||||
{
|
{
|
||||||
if ( updateRequest != 0 )
|
if ( updateRequest != -1 )
|
||||||
{
|
{
|
||||||
client.native.inventory.DestroyResult( updateRequest );
|
client.native.inventory.DestroyResult( updateRequest );
|
||||||
updateRequest = 0;
|
updateRequest = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +115,7 @@ internal void Update()
|
|||||||
|
|
||||||
private void UpdateRequest()
|
private void UpdateRequest()
|
||||||
{
|
{
|
||||||
if ( updateRequest == 0 )
|
if ( updateRequest == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var status = (Valve.Steamworks.EResult) client.native.inventory.GetResultStatus( updateRequest );
|
var status = (Valve.Steamworks.EResult) client.native.inventory.GetResultStatus( updateRequest );
|
||||||
|
Loading…
Reference in New Issue
Block a user