From 0300b46ed30d0281ae5f2a72f82aa1cea3d2e137 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Mon, 24 Jun 2019 15:09:29 +0100 Subject: [PATCH] Sting Filter fixes --- Facepunch.Steamworks/Structs/LobbyQuery.cs | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Facepunch.Steamworks/Structs/LobbyQuery.cs b/Facepunch.Steamworks/Structs/LobbyQuery.cs index b52e5cf..8a84b9e 100644 --- a/Facepunch.Steamworks/Structs/LobbyQuery.cs +++ b/Facepunch.Steamworks/Structs/LobbyQuery.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using System.Collections.Generic; namespace Steamworks.Data { @@ -44,24 +45,23 @@ public LobbyQuery FilterDistanceWorldwide() #endregion #region String key/value filter - internal MatchMakingKeyValuePair_t? stringFilter; + internal Dictionary stringFilters; /// /// Filter by specified key/value pair; string parameters /// - public LobbyQuery FilterStringKeyValue( string nKey, string nValue ) + public LobbyQuery WithKeyValue( string key, string value ) { - if ( string.IsNullOrEmpty( nKey ) ) - throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) ); + if ( string.IsNullOrEmpty( key ) ) + throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( key ) ); - if ( nKey.Length > SteamMatchmaking.MaxLobbyKeyLength ) - throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) ); + if ( key.Length > SteamMatchmaking.MaxLobbyKeyLength ) + throw new System.ArgumentException( $"Key length is longer than {SteamMatchmaking.MaxLobbyKeyLength}", nameof( key ) ); - stringFilter = new MatchMakingKeyValuePair_t - { - Key = nKey, - Value = nValue - }; + if ( stringFilters == null ) + stringFilters = new Dictionary(); + + stringFilters.Add( key, value ); return this; } @@ -113,9 +113,12 @@ void ApplyFilters() SteamMatchmaking.Internal.AddRequestLobbyListResultCountFilter( maxResults.Value ); } - if( stringFilter.HasValue ) + if ( stringFilters != null ) { - SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( stringFilter.Value.Key, stringFilter.Value.Value, LobbyComparison.Equal ); + foreach ( var k in stringFilters ) + { + SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( k.Key, k.Value, LobbyComparison.Equal ); + } } }