From 47775e70bff80b80e64048ec957084c29f04a064 Mon Sep 17 00:00:00 2001 From: mordentral Date: Thu, 21 Jun 2018 14:06:02 -0400 Subject: [PATCH] 4.20 update, working Former-commit-id: b4d3b7358c168e4e34576b001d18c0cc3b5d8c59 --- AdvancedSessions/AdvancedSessions.uplugin | 4 +- .../AdvancedSessions.Build.cs | 4 +- .../AdvancedSteamSessions.uplugin | 4 +- .../Classes/AdvancedSteamFriendsLibrary.h | 234 +++++++++++++++++- .../Private/AdvancedSteamFriendsLibrary.cpp | 47 +--- ...SteamRequestGroupOfficersCallbackProxy.cpp | 9 +- 6 files changed, 240 insertions(+), 62 deletions(-) diff --git a/AdvancedSessions/AdvancedSessions.uplugin b/AdvancedSessions/AdvancedSessions.uplugin index a1de391..51e7b0c 100644 --- a/AdvancedSessions/AdvancedSessions.uplugin +++ b/AdvancedSessions/AdvancedSessions.uplugin @@ -2,8 +2,8 @@ "FileVersion" : 3, "FriendlyName" : "Advanced Sessions", - "Version" : 4.17, - "VersionName": "4.17", + "Version" : 4.20, + "VersionName": "4.20", "Description" : "Adds new blueprint functions to handle more advanced session operations.", "Category" : "Advanced Sessions Plugin", "CreatedBy" : "Joshua Statzer", diff --git a/AdvancedSessions/Source/AdvancedSessions/AdvancedSessions.Build.cs b/AdvancedSessions/Source/AdvancedSessions/AdvancedSessions.Build.cs index 0da5a42..c1ec2ee 100644 --- a/AdvancedSessions/Source/AdvancedSessions/AdvancedSessions.Build.cs +++ b/AdvancedSessions/Source/AdvancedSessions/AdvancedSessions.Build.cs @@ -10,8 +10,8 @@ public class AdvancedSessions : ModuleRules PublicDefinitions.Add("WITH_ADVANCED_SESSIONS=1"); - PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ }); - PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" }); + // PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ }); + // PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ }); PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/}); } diff --git a/AdvancedSteamSessions/AdvancedSteamSessions.uplugin b/AdvancedSteamSessions/AdvancedSteamSessions.uplugin index f476b1c..d971796 100644 --- a/AdvancedSteamSessions/AdvancedSteamSessions.uplugin +++ b/AdvancedSteamSessions/AdvancedSteamSessions.uplugin @@ -2,8 +2,8 @@ "FileVersion" : 3, "FriendlyName" : "Advanced Steam Sessions", - "Version" : 4.17, - "VersionName": "4.17", + "Version" : 4.20, + "VersionName": "4.20", "Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS", "Category" : "Advanced Sessions Plugin", "CreatedBy" : "Joshua Statzer", diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h index 8cb332e..38f5dfb 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h @@ -12,9 +12,225 @@ #include "OnlinePresenceInterface.h" #include "Engine/GameInstance.h" #include "OnlineSessionInterface.h" - #include "UObjectIterator.h" +// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro +// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just +// disable the warnings locally. Remove when this is fixed in the SDK +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4996) +// #TODO check back on this at some point +#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... +#endif + +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + +#pragma push_macro("ARRAY_COUNT") +#undef ARRAY_COUNT + +#if USING_CODE_ANALYSIS +MSVC_PRAGMA(warning(push)) +MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) +#endif // USING_CODE_ANALYSIS + +#include + +#if USING_CODE_ANALYSIS +MSVC_PRAGMA(warning(pop)) +#endif // USING_CODE_ANALYSIS + +#include +#include +//#include +#pragma pop_macro("ARRAY_COUNT") + +// @todo Steam: See above +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// Making a copy of this here since the original is still in a private folder and is screwing with things +/** +* Steam specific implementation of the unique net id +*/ +class FUniqueNetIdSteam2 : + public FUniqueNetId +{ +PACKAGE_SCOPE: + /** Holds the net id for a player */ + uint64 UniqueNetId; + + /** Hidden on purpose */ + FUniqueNetIdSteam2() : + UniqueNetId(0) + { + } + + /** + * Copy Constructor + * + * @param Src the id to copy + */ + explicit FUniqueNetIdSteam2(const FUniqueNetIdSteam2& Src) : + UniqueNetId(Src.UniqueNetId) + { + } + +public: + /** + * Constructs this object with the specified net id + * + * @param InUniqueNetId the id to set ours to + */ + explicit FUniqueNetIdSteam2(uint64 InUniqueNetId) : + UniqueNetId(InUniqueNetId) + { + } + + /** + * Constructs this object with the steam id + * + * @param InUniqueNetId the id to set ours to + */ + explicit FUniqueNetIdSteam2(CSteamID InSteamId) : + UniqueNetId(InSteamId.ConvertToUint64()) + { + } + + /** + * Constructs this object with the specified net id + * + * @param String textual representation of an id + */ + explicit FUniqueNetIdSteam2(const FString& Str) : + UniqueNetId(FCString::Atoi64(*Str)) + { + } + + + /** + * Constructs this object with the specified net id + * + * @param InUniqueNetId the id to set ours to (assumed to be FUniqueNetIdSteam in fact) + */ + explicit FUniqueNetIdSteam2(const FUniqueNetId& InUniqueNetId) : + UniqueNetId(*(uint64*)InUniqueNetId.GetBytes()) + { + } + + virtual FName GetType() const override + { + return STEAM_SUBSYSTEM; + } + + /** + * Get the raw byte representation of this net id + * This data is platform dependent and shouldn't be manipulated directly + * + * @return byte array of size GetSize() + */ + virtual const uint8* GetBytes() const override + { + return (uint8*)&UniqueNetId; + } + + /** + * Get the size of the id + * + * @return size in bytes of the id representation + */ + virtual int32 GetSize() const override + { + return sizeof(uint64); + } + + /** + * Check the validity of the id + * + * @return true if this is a well formed ID, false otherwise + */ + virtual bool IsValid() const override + { + return UniqueNetId != 0 && CSteamID(UniqueNetId).IsValid(); + } + + /** + * Platform specific conversion to string representation of data + * + * @return data in string form + */ + virtual FString ToString() const override + { + return FString::Printf(TEXT("%llu"), UniqueNetId); + } + + /** + * Get a human readable representation of the net id + * Shouldn't be used for anything other than logging/debugging + * + * @return id in string form + */ + virtual FString ToDebugString() const override + { + CSteamID SteamID(UniqueNetId); + if (SteamID.IsLobby()) + { + return FString::Printf(TEXT("Lobby [0x%llX]"), UniqueNetId); + } + else if (SteamID.BAnonGameServerAccount()) + { + return FString::Printf(TEXT("Server [0x%llX]"), UniqueNetId); + } + else if (SteamID.IsValid()) + { + const FString NickName(SteamFriends() ? UTF8_TO_TCHAR(SteamFriends()->GetFriendPersonaName(UniqueNetId)) : TEXT("UNKNOWN")); + return FString::Printf(TEXT("%s [0x%llX]"), *NickName, UniqueNetId); + } + else + { + return FString::Printf(TEXT("INVALID [0x%llX]"), UniqueNetId); + } + } + + /** Needed for TMap::GetTypeHash() */ + friend uint32 GetTypeHash(const FUniqueNetIdSteam2& A) + { + return (uint32)(A.UniqueNetId) + ((uint32)((A.UniqueNetId) >> 32) * 23); + } + + /** Convenience cast to CSteamID */ + operator CSteamID() + { + return UniqueNetId; + } + + /** Convenience cast to CSteamID */ + operator const CSteamID() const + { + return UniqueNetId; + } + + /** Convenience cast to CSteamID pointer */ + operator CSteamID*() + { + return (CSteamID*)&UniqueNetId; + } + + /** Convenience cast to CSteamID pointer */ + operator const CSteamID*() const + { + return (const CSteamID*)&UniqueNetId; + } + + friend FArchive& operator<<(FArchive& Ar, FUniqueNetIdSteam2& UserId) + { + return Ar << UserId.UniqueNetId; + } +}; + +#endif + #include "AdvancedSteamFriendsLibrary.generated.h" @@ -35,24 +251,22 @@ struct FBPSteamGroupInfo GENERATED_USTRUCT_BODY() public: - + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - FBPUniqueNetId GroupID; // Uint64 representation + FBPUniqueNetId GroupID; // Uint64 representation UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - FString GroupName; + FString GroupName; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - FString GroupTag; + FString GroupTag; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numOnline; + int32 numOnline; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numInGame; + int32 numInGame; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numChatting; + int32 numChatting; }; - - UCLASS() class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary { diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp index f4064ff..6e3ad1f 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp @@ -2,45 +2,6 @@ #include "AdvancedSteamFriendsLibrary.h" #include "OnlineSubSystemHeader.h" -// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro - -// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just -// disable the warnings locally. Remove when this is fixed in the SDK -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4996) -// #TODO check back on this at some point -#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... -#endif - -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX - -#pragma push_macro("ARRAY_COUNT") -#undef ARRAY_COUNT - -#if USING_CODE_ANALYSIS -MSVC_PRAGMA(warning(push)) -MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) -#endif // USING_CODE_ANALYSIS - -#include - -#if USING_CODE_ANALYSIS -MSVC_PRAGMA(warning(pop)) -#endif // USING_CODE_ANALYSIS - -#include -#include -#include -#pragma pop_macro("ARRAY_COUNT") - -#endif - -// @todo Steam: See above -#ifdef _MSC_VER -#pragma warning(pop) -#endif - //General Log DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog); @@ -97,6 +58,7 @@ DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog); void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray & SteamGroups) { + #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (SteamAPI_Init()) @@ -112,7 +74,7 @@ void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray & St FBPSteamGroupInfo GroupInfo; - TSharedPtr ValueID(new const FUniqueNetIdSteam(SteamGroupID)); + TSharedPtr ValueID(new const FUniqueNetIdSteam2(SteamGroupID)); GroupInfo.GroupID.SetUniqueNetId(ValueID); SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting); GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID))); @@ -122,6 +84,7 @@ void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray & St } } #endif + } void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result, FString & GameName, int32 & AppID) @@ -209,7 +172,7 @@ FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId U FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64) { FBPUniqueNetId netId; - + #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (!(SteamID64.Len() > 0)) { @@ -220,7 +183,7 @@ FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FStri if (SteamAPI_Init()) { // Already does the conversion - TSharedPtr ValueID(new const FUniqueNetIdSteam(SteamID64)); + TSharedPtr ValueID(new const FUniqueNetIdSteam2(SteamID64)); //FCString::Atoi64(*SteamID64)); netId.SetUniqueNetId(ValueID); diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/SteamRequestGroupOfficersCallbackProxy.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/SteamRequestGroupOfficersCallbackProxy.cpp index c5d3dc8..647c20d 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/SteamRequestGroupOfficersCallbackProxy.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/SteamRequestGroupOfficersCallbackProxy.cpp @@ -2,8 +2,9 @@ #include "SteamRequestGroupOfficersCallbackProxy.h" #include "CoreOnline.h" +#include "AdvancedSteamFriendsLibrary.h" #include "OnlineSubSystemHeader.h" -#include "OnlineSubsystemSteamTypes.h" +//#include "OnlineSubsystemSteamTypes.h" ////////////////////////////////////////////////////////////////////////// // UEndSessionCallbackProxy @@ -44,7 +45,7 @@ void USteamRequestGroupOfficersCallbackProxy::Activate() void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure) { TArray OfficerArray; - + #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (bIOFailure || !pResult || !pResult->m_bSuccess) @@ -62,7 +63,7 @@ void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanO Officer.bIsOwner = true; - TSharedPtr ValueID(new const FUniqueNetIdSteam(ClanOwner)); + TSharedPtr ValueID(new const FUniqueNetIdSteam2(ClanOwner)); Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID); OfficerArray.Add(Officer); @@ -72,7 +73,7 @@ void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanO Officer.bIsOwner = false; - TSharedPtr newValueID(new const FUniqueNetIdSteam(OfficerSteamID)); + TSharedPtr newValueID(new const FUniqueNetIdSteam2(OfficerSteamID)); Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID); OfficerArray.Add(Officer);