Keep friend status up to date via PersonaStateChange_t

This commit is contained in:
Garry Newman 2018-03-27 10:21:11 +01:00
parent 80bf89c9e6
commit 476321c026

View File

@ -338,13 +338,24 @@ internal void Cycle()
private void OnPersonaStateChange( PersonaStateChange_t data ) private void OnPersonaStateChange( PersonaStateChange_t data )
{ {
if ( (data.ChangeFlags & 0x0040) != 0x0040 ) return; // wait for k_EPersonaChangeAvatar // k_EPersonaChangeAvatar
if ( (data.ChangeFlags & 0x0040) == 0x0040 )
LoadForSteamid( data.SteamID ); {
LoadAvatarForSteamId( data.SteamID );
} }
void LoadForSteamid( ulong Steamid ) //
// Find and refresh this friend's status
//
foreach ( var friend in All )
{
if ( friend.Id != data.SteamID ) continue;
friend.Refresh();
}
}
void LoadAvatarForSteamId( ulong Steamid )
{ {
for ( int i = PersonaCallbacks.Count - 1; i >= 0; i-- ) for ( int i = PersonaCallbacks.Count - 1; i >= 0; i-- )
{ {
@ -365,7 +376,7 @@ void LoadForSteamid( ulong Steamid )
private void OnAvatarImageLoaded( AvatarImageLoaded_t data ) private void OnAvatarImageLoaded( AvatarImageLoaded_t data )
{ {
LoadForSteamid( data.SteamID ); LoadAvatarForSteamId( data.SteamID );
} }
} }