From f994b22cf2d621ea4b6314b71c23ed400433127f Mon Sep 17 00:00:00 2001 From: mordentral Date: Thu, 20 Apr 2017 14:32:46 -0400 Subject: [PATCH] Adding some missing safety checks to the voice library functions. Former-commit-id: 8cd15bd34f83bd2827c6672a24b5203bd2c2557b --- .../Private/AdvancedIdentityLibrary.cpp | 11 ++++-- .../Private/AdvancedVoiceLibrary.cpp | 36 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp index b2e4712..faad80a 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp @@ -31,7 +31,7 @@ void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerCont Result = EBlueprintResultSwitch::OnFailure; return; } - + AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId()); Result = EBlueprintResultSwitch::OnSuccess; } @@ -57,7 +57,7 @@ void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNe void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result) { - if(!UniqueNetID.IsValid()) + if (!UniqueNetID.IsValid()) { UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!")); Result = EBlueprintResultSwitch::OnFailure; @@ -103,6 +103,13 @@ void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId { IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); + if(!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!")); + Result = EBlueprintResultSwitch::OnFailure; + return; + } + if (!IdentityInterface.IsValid()) { UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!")); diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedVoiceLibrary.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedVoiceLibrary.cpp index 80cfe7f..8ca0d8b 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedVoiceLibrary.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedVoiceLibrary.cpp @@ -100,6 +100,12 @@ void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers() bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid()) @@ -113,6 +119,12 @@ bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNet bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid()) @@ -152,6 +164,12 @@ bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum) bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid()) @@ -165,6 +183,12 @@ bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNe bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid()) @@ -178,6 +202,12 @@ bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPU bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid()) @@ -191,6 +221,12 @@ bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUnique bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) { + if (!UniqueNetId.IsValid()) + { + UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker was passed an invalid unique net id!")); + return false; + } + IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid())