Handle inventory timeouts

This commit is contained in:
Garry Newman 2016-10-12 20:43:19 +01:00
parent 14ebfbf0da
commit cccc426d0f
2 changed files with 19 additions and 6 deletions

View File

@ -21,9 +21,9 @@ namespace Facepunch.Steamworks
{ {
if ( Items != null ) return false; if ( Items != null ) return false;
if ( Handle == -1 ) return false; if ( Handle == -1 ) return false;
if ( inventory.inventory.GetResultStatus( Handle ) == 22 ) return true; if ( Status() == Callbacks.Result.Pending ) return true;
Fill(); TryFill();
return false; return false;
} }
} }
@ -34,10 +34,17 @@ namespace Facepunch.Steamworks
{ {
if ( Items != null ) return true; if ( Items != null ) return true;
if ( Handle == -1 ) return false; if ( Handle == -1 ) return false;
return inventory.inventory.GetResultStatus( Handle ) == 1; return Status() == Callbacks.Result.OK;
} }
} }
internal Callbacks.Result Status()
{
if ( Handle == -1 ) return Callbacks.Result.InvalidParam;
return (Callbacks.Result)inventory.inventory.GetResultStatus( Handle );
}
internal Result( Inventory inventory, int Handle ) internal Result( Inventory inventory, int Handle )
{ {
this.Handle = Handle; this.Handle = Handle;
@ -54,12 +61,17 @@ namespace Facepunch.Steamworks
return IsSuccess; return IsSuccess;
} }
internal void Fill() internal void TryFill()
{ {
if ( Items != null ) return; if ( Items != null )
return;
if ( !IsSuccess )
return;
Valve.Steamworks.SteamItemDetails_t[] steamItems = null; Valve.Steamworks.SteamItemDetails_t[] steamItems = null;
inventory.inventory.GetResultItems( Handle, out steamItems ); if ( !inventory.inventory.GetResultItems( Handle, out steamItems ) )
return;
if ( steamItems == null ) if ( steamItems == null )
{ {

View File

@ -149,6 +149,7 @@ namespace Facepunch.Steamworks
if ( LocalPlayerRequest.IsSuccess ) if ( LocalPlayerRequest.IsSuccess )
{ {
// Try again.
RetrieveInventory(); RetrieveInventory();
return; return;
} }