diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h index 0a35350..02c176d 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h @@ -30,16 +30,16 @@ #pragma push_macro("ARRAY_COUNT") #undef ARRAY_COUNT -#if USING_CODE_ANALYSIS -MSVC_PRAGMA(warning(push)) -MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) +#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 +#if USING_CODE_ANALYSIS +MSVC_PRAGMA(warning(pop)) +#endif // USING_CODE_ANALYSIS #include #include @@ -52,183 +52,183 @@ MSVC_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 GetTypeHash(A.UniqueNetId); - //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; - } +/** +* 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 GetTypeHash(A.UniqueNetId); + //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 @@ -297,11 +297,11 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") FString GroupTag; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numOnline; + int32 numOnline = 0; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numInGame; + int32 numInGame = 0; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") - int32 numChatting; + int32 numChatting = 0; };