mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 16:34:07 +00:00
Fixed duplicating lobby results (forgot to use second array second time around).
Changed HasOnlineSubsystem to use a better function Not running second search for AllServers enum when the subsystem isn't steam Steam is the only subsystem that actually uses the flags that deal with that. Former-commit-id: b07eadc87eaf82584ec63b6b4e91ace69fd5023f
This commit is contained in:
@@ -99,9 +99,9 @@ enum class EBlueprintAsyncResultSwitch : uint8
|
|||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class EBPServerPresenceSearchType : uint8
|
enum class EBPServerPresenceSearchType : uint8
|
||||||
{
|
{
|
||||||
|
AllServers,
|
||||||
ClientServersOnly,
|
ClientServersOnly,
|
||||||
DedicatedServersOnly,
|
DedicatedServersOnly
|
||||||
AllServers
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wanted this to be switchable in the editor
|
// Wanted this to be switchable in the editor
|
||||||
|
@@ -52,6 +52,7 @@ private:
|
|||||||
void OnCompleted(bool bSuccess);
|
void OnCompleted(bool bSuccess);
|
||||||
|
|
||||||
bool bRunSecondSearch;
|
bool bRunSecondSearch;
|
||||||
|
bool bIsOnSecondSearch;
|
||||||
|
|
||||||
TArray<FBlueprintSessionResult> SessionSearchResults;
|
TArray<FBlueprintSessionResult> SessionSearchResults;
|
||||||
|
|
||||||
|
@@ -296,7 +296,7 @@ void UAdvancedSessionsLibrary::GetSessionPropertyFloat(const TArray<FSessionProp
|
|||||||
|
|
||||||
bool UAdvancedSessionsLibrary::HasOnlineSubsystem(FName SubSystemName)
|
bool UAdvancedSessionsLibrary::HasOnlineSubsystem(FName SubSystemName)
|
||||||
{
|
{
|
||||||
return((IOnlineSubsystem::Get(SubSystemName) != NULL));
|
return IOnlineSubsystem::DoesInstanceExist(SubSystemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAdvancedSessionsLibrary::GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex)
|
void UAdvancedSessionsLibrary::GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex)
|
||||||
|
@@ -13,6 +13,7 @@ UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FOb
|
|||||||
, bUseLAN(false)
|
, bUseLAN(false)
|
||||||
{
|
{
|
||||||
bRunSecondSearch = false;
|
bRunSecondSearch = false;
|
||||||
|
bIsOnSecondSearch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable)
|
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable)
|
||||||
@@ -43,6 +44,7 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
{
|
{
|
||||||
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
|
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
|
||||||
bRunSecondSearch = false;
|
bRunSecondSearch = false;
|
||||||
|
bIsOnSecondSearch = false;
|
||||||
|
|
||||||
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
|
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
|
||||||
|
|
||||||
@@ -108,12 +110,15 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
|
|
||||||
case EBPServerPresenceSearchType::DedicatedServersOnly:
|
case EBPServerPresenceSearchType::DedicatedServersOnly:
|
||||||
{
|
{
|
||||||
tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
//tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EBPServerPresenceSearchType::AllServers:
|
case EBPServerPresenceSearchType::AllServers:
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
// Only steam uses the separate searching flags currently
|
||||||
|
if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||||
{
|
{
|
||||||
bRunSecondSearch = true;
|
bRunSecondSearch = true;
|
||||||
|
|
||||||
@@ -124,9 +129,10 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||||
|
|
||||||
DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +168,30 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSuccess && SearchObject.IsValid())
|
if (bSuccess)
|
||||||
|
{
|
||||||
|
if (bIsOnSecondSearch)
|
||||||
|
{
|
||||||
|
if (SearchObjectDedicated.IsValid())
|
||||||
|
{
|
||||||
|
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
||||||
|
for (auto& Result : SearchObjectDedicated->SearchResults)
|
||||||
|
{
|
||||||
|
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
|
||||||
|
|
||||||
|
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
|
||||||
|
|
||||||
|
FBlueprintSessionResult BPResult;
|
||||||
|
BPResult.OnlineResult = Result;
|
||||||
|
SessionSearchResults.Add(BPResult);
|
||||||
|
}
|
||||||
|
OnSuccess.Broadcast(SessionSearchResults);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SearchObject.IsValid())
|
||||||
{
|
{
|
||||||
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
||||||
for (auto& Result : SearchObject->SearchResults)
|
for (auto& Result : SearchObject->SearchResults)
|
||||||
@@ -181,6 +210,8 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!bRunSecondSearch)
|
if (!bRunSecondSearch)
|
||||||
@@ -197,6 +228,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
if (bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
|
if (bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
|
||||||
{
|
{
|
||||||
bRunSecondSearch = false;
|
bRunSecondSearch = false;
|
||||||
|
bIsOnSecondSearch = true;
|
||||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
|
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user