From 645e7bd91eaf437b515f7052d172e8cabc9d6736 Mon Sep 17 00:00:00 2001 From: thesupersoup <40295603+thesupersoup@users.noreply.github.com> Date: Sun, 23 Jun 2019 22:12:21 -0700 Subject: [PATCH] Removed second FilterStringKeyValue method and improved first Second method was non-functional due to access modifier inconsistency, added IsNullOrEmpty and MaxLobbyKeyLength check to first method, added MaxLobbyKeyLength (and backing field) to SteamMAtchmaking, taken from https://partner.steamgames.com/doc/api/ISteamMatchmaking#constants --- Facepunch.Steamworks/SteamMatchmaking.cs | 8 ++++++++ Facepunch.Steamworks/Structs/LobbyQuery.cs | 22 ++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index e93bc18..5e2b0ae 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -12,6 +12,14 @@ namespace Steamworks /// public static class SteamMatchmaking { + internal const int k_nMaxLobbyKeyLength = 255; + + /// + /// Maximum number of characters a lobby metadata key can be + /// + public static int MaxLobbyKeyLength { get { return k_nMaxLobbyKeyLength; } } + + static ISteamMatchmaking _internal; internal static ISteamMatchmaking Internal diff --git a/Facepunch.Steamworks/Structs/LobbyQuery.cs b/Facepunch.Steamworks/Structs/LobbyQuery.cs index adcf2d4..fec23cb 100644 --- a/Facepunch.Steamworks/Structs/LobbyQuery.cs +++ b/Facepunch.Steamworks/Structs/LobbyQuery.cs @@ -51,21 +51,14 @@ namespace Steamworks.Data /// public LobbyQuery FilterStringKeyValue( string nKey, string nValue ) { - stringFilter = new MatchMakingKeyValuePair_t + if ( !string.IsNullOrEmpty(nKey) && nKey.Length <= SteamMatchmaking.MaxLobbyKeyLength ) { - Key = nKey, - Value = nValue - }; - - return this; - } - - /// - /// Filter by specified key/value pair; MatchMakingKeyValuePair_t parameter - /// - public LobbyQuery FilterStringKeyValue( MatchMakingKeyValuePair_t kv ) - { - stringFilter = kv; + stringFilter = new MatchMakingKeyValuePair_t + { + Key = nKey, + Value = nValue + }; + } return this; } @@ -99,6 +92,7 @@ namespace Steamworks.Data #endregion + void ApplyFilters() { if ( distance.HasValue )