mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 23:25:55 +03:00
Sting Filter fixes
This commit is contained in:
parent
57f3b334b5
commit
0300b46ed3
@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Steamworks.Data
|
namespace Steamworks.Data
|
||||||
{
|
{
|
||||||
@ -44,24 +45,23 @@ public LobbyQuery FilterDistanceWorldwide()
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region String key/value filter
|
#region String key/value filter
|
||||||
internal MatchMakingKeyValuePair_t? stringFilter;
|
internal Dictionary<string, string> stringFilters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filter by specified key/value pair; string parameters
|
/// Filter by specified key/value pair; string parameters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LobbyQuery FilterStringKeyValue( string nKey, string nValue )
|
public LobbyQuery WithKeyValue( string key, string value )
|
||||||
{
|
{
|
||||||
if ( string.IsNullOrEmpty( nKey ) )
|
if ( string.IsNullOrEmpty( key ) )
|
||||||
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) );
|
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( key ) );
|
||||||
|
|
||||||
if ( nKey.Length > SteamMatchmaking.MaxLobbyKeyLength )
|
if ( key.Length > SteamMatchmaking.MaxLobbyKeyLength )
|
||||||
throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) );
|
throw new System.ArgumentException( $"Key length is longer than {SteamMatchmaking.MaxLobbyKeyLength}", nameof( key ) );
|
||||||
|
|
||||||
stringFilter = new MatchMakingKeyValuePair_t
|
if ( stringFilters == null )
|
||||||
{
|
stringFilters = new Dictionary<string, string>();
|
||||||
Key = nKey,
|
|
||||||
Value = nValue
|
stringFilters.Add( key, value );
|
||||||
};
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -113,9 +113,12 @@ void ApplyFilters()
|
|||||||
SteamMatchmaking.Internal.AddRequestLobbyListResultCountFilter( maxResults.Value );
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user