mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 05:35:35 +03:00
Fix GetAvatar sometimes failing instead of waiting for the avatar to load
This commit is contained in:
parent
438127288a
commit
13280cd57c
@ -271,9 +271,19 @@ public void GetAvatar( AvatarSize size, ulong steamid, Action<Image> callback )
|
||||
// Lets request it from Steam
|
||||
if (!client.native.friends.RequestUserInformation(steamid, false))
|
||||
{
|
||||
// Steam told us to get fucked
|
||||
callback(null);
|
||||
return;
|
||||
// from docs: false means that we already have all the details about that user, and functions that require this information can be used immediately
|
||||
// but that's probably not true because we just checked the cache
|
||||
|
||||
// check again in case it was just a race
|
||||
image = GetCachedAvatar(size, steamid);
|
||||
if ( image != null )
|
||||
{
|
||||
callback(image);
|
||||
return;
|
||||
}
|
||||
|
||||
// maybe Steam returns false if it was already requested? just add another callback and hope it comes
|
||||
// if not it'll time out anyway
|
||||
}
|
||||
|
||||
PersonaCallbacks.Add( new PersonaCallback
|
||||
@ -326,7 +336,10 @@ internal void Cycle()
|
||||
{
|
||||
if ( cb.Callback != null )
|
||||
{
|
||||
cb.Callback( null );
|
||||
// final attempt, will be null unless the callback was missed somehow
|
||||
var image = GetCachedAvatar( cb.Size, cb.SteamId );
|
||||
|
||||
cb.Callback( image );
|
||||
}
|
||||
|
||||
PersonaCallbacks.Remove( cb );
|
||||
|
Loading…
Reference in New Issue
Block a user