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 @@ public bool IsPending
{
if ( Items != null ) 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;
}
}
@ -34,10 +34,17 @@ internal bool IsSuccess
{
if ( Items != null ) return true;
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 )
{
this.Handle = Handle;
@ -54,12 +61,17 @@ public bool Block( float maxWait = 5.0f )
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;
inventory.inventory.GetResultItems( Handle, out steamItems );
if ( !inventory.inventory.GetResultItems( Handle, out steamItems ) )
return;
if ( steamItems == null )
{

View File

@ -149,6 +149,7 @@ private void UpdateLocalRequest()
if ( LocalPlayerRequest.IsSuccess )
{
// Try again.
RetrieveInventory();
return;
}