diff --git a/Facepunch.Steamworks.Test/Client.cs b/Facepunch.Steamworks.Test/Client.cs index 91fb38b..c267219 100644 --- a/Facepunch.Steamworks.Test/Client.cs +++ b/Facepunch.Steamworks.Test/Client.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Facepunch.Steamworks.Test @@ -137,10 +138,14 @@ public void InventoryItemList() client.Inventory.Refresh(); // Wait for the items + var timeout = Stopwatch.StartNew(); while ( client.Inventory.Items == null ) { client.Update(); - System.Threading.Thread.Sleep( 10 ); + System.Threading.Thread.Sleep( 1000 ); + + if ( timeout.Elapsed.TotalSeconds > 5 ) + break; } // make sure callback was called diff --git a/Facepunch.Steamworks/Client/Inventory.cs b/Facepunch.Steamworks/Client/Inventory.cs index f919fd3..70a4498 100644 --- a/Facepunch.Steamworks/Client/Inventory.cs +++ b/Facepunch.Steamworks/Client/Inventory.cs @@ -29,7 +29,7 @@ public class Inventory public Action OnUpdate; internal Client client; - private int updateRequest = 0; + private int updateRequest = -1; internal Inventory( Client c ) { @@ -57,10 +57,13 @@ public void PlaytimeHeartbeat() public void Refresh() { // Pending - if ( updateRequest != 0 ) + if ( updateRequest != -1 ) return; - client.native.inventory.GetAllItems( ref updateRequest ); + if ( !client.native.inventory.GetAllItems( ref updateRequest ) ) + { + Console.WriteLine( "GetAllItems failed!?" ); + } } internal void LoadItemDefinitions() @@ -97,10 +100,10 @@ internal T DefinitionProperty( int i, string name ) internal void DestroyResult() { - if ( updateRequest != 0 ) + if ( updateRequest != -1 ) { client.native.inventory.DestroyResult( updateRequest ); - updateRequest = 0; + updateRequest = -1; } } @@ -112,7 +115,7 @@ internal void Update() private void UpdateRequest() { - if ( updateRequest == 0 ) + if ( updateRequest == -1 ) return; var status = (Valve.Steamworks.EResult) client.native.inventory.GetResultStatus( updateRequest );