Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lobby list request filtering #141

Merged
merged 10 commits into from
Nov 28, 2023
Merged

Add lobby list request filtering #141

merged 10 commits into from
Nov 28, 2023

Conversation

wyvernbw
Copy link
Contributor

@wyvernbw wyvernbw commented Aug 19, 2023

closes #140

Summary

added 7 functions for filtering out lobby requests:

  • set_lobby_list_filter: adds filters defined in a LobbyListFilter struct.
  • set_request_lobby_list_string_filter: adds filters for key value pairs of strings.
  • set_request_lobby_list_numerical_filter: adds filters for key value pairs of string number types.
  • set_request_lobby_list_near_value_filter: adds sorting based on which value is closer to the filter
  • set_request_lobby_list_distance_filter: adds filtering based on geographical distance
  • set_request_lobby_list_slots_available_filter: adds filtering based on how many open slots a lobby has
  • set_request_lobby_list_result_count_filter: adds the maximum number of results a request can resolve to.

added 1 struct:

  • LobbyListFilter: struct that holds every option possible for filtering

added 1 enum:

  • DistanceFilter: thin wrapper over ELobbyDistanceFilter
    I included documentation for everything I added and one code example.

@wyvernbw
Copy link
Contributor Author

I omitted comparison types for the filters as they don't seem very useful imho. I'm open to changing this, ofc

@TrustNoOneElse
Copy link
Contributor

First pretty cool that you are working on this!

I just wanted to note that you can have a List/Array of String-, Numeric- and NearValueFilters, that why i would update the LobbyListFilter struct to actually support it.

Another point on which im not certain about but the keyof those filters cannot exceed 255 chars. For setting the metadata of a lobby the function itself already returns a bool, if thats the case. In this case of the filter functions, we could maybe implement a safety check for the user, because he may be not aware of this or to add this to the docs.

@wyvernbw
Copy link
Contributor Author

Thanks for the kind words!

I didnt know you can pass in multiple key value pairs, i assumed you have to call the function multiple times. Is this done by passing a pointer to the array to the underlying steamworks-sys call?

I just checked and you are correct, you can only pass in keys shorter than 256 characters

@TrustNoOneElse
Copy link
Contributor

TrustNoOneElse commented Aug 20, 2023

That is correct, you have to call the function multiple times. What i meant was your helper type LobbyListFilter, which currently only suppports one times of String, Numeric and Nearfilters. Thats why i would suggest the change to take in a Array of key/value pairs for this 3 types of filter.

And to the comparison types:
For String i can't see the use too, besides Equal and NotEqual. Also i don't know anyone which used besides this two comparision types any other comparision. But for numeric you can do quite a lot with this things.
Some examples:
NotEqual: Could be a metadata with a playerid matched against last time, so you could filter out that they don't play again, to have variation.
For the other cases (Greater then, Less Then, Equal Less, Equal Greater), the best example is level matchmaking or elo/skill matchmaking.

@wyvernbw
Copy link
Contributor Author

ok so ive added a few things as you suggested and some qol changes

  • multiple key-value pair filters
    • LobbyListFilter now takes a slices of key-value pairs
  • newtype pattern for filters
    • filters take a LobbyKey struct instead of a simple str slice. This is done to restrict how a key is constructed so it can be validated.
    • new StringFilter, NumberFilter and NearFilter structs. Useful for giving a name to tuples
  • comparison types
    • new ComparisonFilter enum that can be used with NumberFilter and NearFilter. Includes all options from steamworks
    • new StringFilterKind enum. Allows users to pass in whether they want to exclude or include a string value.
  • lobby key validation (as mentioned)

@wyvernbw
Copy link
Contributor Author

wyvernbw commented Aug 23, 2023

Ok so turns out &[T] cannot be deserialized in serde. At least i can't figure out how. So i just went ahead and changed it to use Vec. A more performant (i think) option would be Arc<[T]> but that would require the rc feature in serde

@Noxime Noxime merged commit ea0af23 into Noxime:master Nov 28, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrappers for lobby list request filtering
3 participants