diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index 8a3e2ec..89798e8 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -12,6 +12,12 @@ namespace Steamworks /// public static class SteamMatchmaking { + /// + /// Maximum number of characters a lobby metadata key can be + /// + internal static int MaxLobbyKeyLength => 255; + + static ISteamMatchmaking _internal; internal static ISteamMatchmaking Internal @@ -37,7 +43,7 @@ internal static void InstallEvents() { LobbyInvite_t.Install( x => OnLobbyInvite?.Invoke( new Friend( x.SteamIDUser ), new Lobby( x.SteamIDLobby ) ) ); - LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby(x.SteamIDLobby ) ) ); + LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby( x.SteamIDLobby ) ) ); LobbyDataUpdate_t.Install( x => { diff --git a/Facepunch.Steamworks/Structs/LobbyQuery.cs b/Facepunch.Steamworks/Structs/LobbyQuery.cs index 36146d1..b52e5cf 100644 --- a/Facepunch.Steamworks/Structs/LobbyQuery.cs +++ b/Facepunch.Steamworks/Structs/LobbyQuery.cs @@ -43,6 +43,30 @@ public LobbyQuery FilterDistanceWorldwide() } #endregion + #region String key/value filter + internal MatchMakingKeyValuePair_t? stringFilter; + + /// + /// Filter by specified key/value pair; string parameters + /// + public LobbyQuery FilterStringKeyValue( string nKey, string nValue ) + { + if ( string.IsNullOrEmpty( nKey ) ) + throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) ); + + if ( nKey.Length > SteamMatchmaking.MaxLobbyKeyLength ) + throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) ); + + stringFilter = new MatchMakingKeyValuePair_t + { + Key = nKey, + Value = nValue + }; + + return this; + } + #endregion + #region Slots Filter internal int? slotsAvailable; @@ -88,6 +112,11 @@ void ApplyFilters() { SteamMatchmaking.Internal.AddRequestLobbyListResultCountFilter( maxResults.Value ); } + + if( stringFilter.HasValue ) + { + SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( stringFilter.Value.Key, stringFilter.Value.Value, LobbyComparison.Equal ); + } } ///