diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp index 1af7a5b..934b154 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp @@ -247,28 +247,33 @@ void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerCont TArray< TSharedRef > FriendList; - FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList); - - for (int32 i = 0; i < FriendList.Num(); i++) + if (FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList)) { - TSharedRef Friend = FriendList[i]; - FBPFriendInfo BPF; - FOnlineUserPresence pres = Friend->GetPresence(); + for (int32 i = 0; i < FriendList.Num(); i++) + { + FBPFriendInfo BPF; + FOnlineUserPresence pres = FriendList[i]->GetPresence(); - BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); - BPF.DisplayName = Friend->GetDisplayName(); - BPF.RealName = Friend->GetRealName(); - BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); - BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; + BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); + BPF.DisplayName = FriendList[i]->GetDisplayName(); + BPF.RealName = FriendList[i]->GetRealName(); + BPF.UniqueNetId.SetUniqueNetId(FriendList[i]->GetUserId()); + BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; - BPF.PresenceInfo.bIsOnline = pres.bIsOnline; - BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; - BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; - BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); - BPF.PresenceInfo.StatusString = pres.Status.StatusStr; - BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; - BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; + BPF.PresenceInfo.bIsOnline = pres.bIsOnline; + BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; + BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; + BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); + BPF.PresenceInfo.StatusString = pres.Status.StatusStr; + BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; + BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; - FriendsList.Add(BPF); + FriendsList.Add(BPF); + } + + return; } + + UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get any friends!")); + return; } \ No newline at end of file diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/GetFriendsCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/GetFriendsCallbackProxy.cpp index 8886fef..ae789dc 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/GetFriendsCallbackProxy.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/GetFriendsCallbackProxy.cpp @@ -76,29 +76,29 @@ void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bo TArray FriendsListOut; TArray< TSharedRef > FriendList; - Friends->GetFriendsList(LocalUserNum, ListName, FriendList); - - for (int32 i = 0; i < FriendList.Num(); i++) + if (Friends->GetFriendsList(LocalUserNum, ListName, FriendList)) { - TSharedRef Friend = FriendList[i]; - FBPFriendInfo BPF; - FOnlineUserPresence pres = Friend->GetPresence(); - BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); - BPF.DisplayName = Friend->GetDisplayName(); - BPF.RealName = Friend->GetRealName(); - BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); - BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; + for (int32 i = 0; i < FriendList.Num(); i++) + { + FBPFriendInfo BPF; + FOnlineUserPresence pres = FriendList[i]->GetPresence(); + BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); + BPF.DisplayName = FriendList[i]->GetDisplayName(); + BPF.RealName = FriendList[i]->GetRealName(); + BPF.UniqueNetId.SetUniqueNetId(FriendList[i]->GetUserId()); + BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; - BPF.PresenceInfo.bIsOnline = pres.bIsOnline; - BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; - BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; - BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); - BPF.PresenceInfo.StatusString = pres.Status.StatusStr; - BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; - BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; + BPF.PresenceInfo.bIsOnline = pres.bIsOnline; + BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; + BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; + BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); + BPF.PresenceInfo.StatusString = pres.Status.StatusStr; + BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; + BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; - FriendsListOut.Add(BPF); + FriendsListOut.Add(BPF); + } } OnSuccess.Broadcast(FriendsListOut);