-
Notifications
You must be signed in to change notification settings - Fork 250
Expose player ratings and divisions to the session #6569
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
Changes from all commits
c397db6
d11609e
1c6384b
28734ca
8e2b159
89e8e7f
b280465
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - (#6569) Fix the matchmaker lobby not passing ratings, divisions and clan tags to the session |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| --****************************************************************************************************** | ||
| --** Copyright (c) 2024 Willem 'Jip' Wijnia | ||
| --** | ||
| --** Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| --** of this software and associated documentation files (the "Software"), to deal | ||
| --** in the Software without restriction, including without limitation the rights | ||
| --** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| --** copies of the Software, and to permit persons to whom the Software is | ||
| --** furnished to do so, subject to the following conditions: | ||
| --** | ||
| --** The above copyright notice and this permission notice shall be included in all | ||
| --** copies or substantial portions of the Software. | ||
| --** | ||
| --** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| --** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| --** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| --** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| --** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| --** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| --** SOFTWARE. | ||
| --****************************************************************************************************** | ||
|
|
||
| --- A component that represent all the supported lobby <-> server communications. | ||
| ---@class UIAutolobbyArgumentsComponent | ||
| AutolobbyArgumentsComponent = ClassSimple { | ||
|
|
||
| --- Represent all valid command line arguments for the lobby | ||
| ArgumentKeys = { | ||
| ["/init"] = true, | ||
| ["/joincustom"] = true, | ||
| ["/gpgnet"] = true, | ||
|
|
||
| -- related to player info | ||
| ["/clan"] = true, | ||
| ["/country"] = true, | ||
| ["/numgames"] = true, | ||
|
|
||
| -- related to player settings | ||
| ["/team"] = true, | ||
| ["/uef"] = true, | ||
| ["/cybran"] = true, | ||
| ["/aeon"] = true, | ||
| ["/seraphim"] = true, | ||
| ["/startspot"] = true, | ||
|
|
||
| -- related to rating | ||
| ["/deviation"] = true, | ||
| ["/mean"] = true, | ||
|
|
||
| -- related to divisions | ||
| ["division"] = true, | ||
| ["/subdivision"] = true, | ||
|
|
||
| -- related to game settings | ||
| ["/gameoptions"] = true, | ||
| ["/players"] = true, | ||
| }, | ||
|
|
||
| --- Verifies that it is an expected command line argument | ||
| ---@param self UIAutolobbyArgumentsComponent | UIAutolobbyCommunications | ||
| ---@param option string | ||
| ---@return boolean | ||
| ValidCommandLineKey = function(self, option) | ||
| if not self.ArgumentKeys[option] then | ||
| self:DebugWarn("Unknown command line argument: ", option) | ||
| return false | ||
| end | ||
|
|
||
| return true | ||
| end, | ||
|
|
||
| --- Attempts to retrieve a string-like command line argument | ||
| ---@param self UIAutolobbyArgumentsComponent | UIAutolobbyCommunications | ||
| ---@param option string | ||
| ---@param default string | ||
| ---@return string | ||
| GetCommandLineArgumentString = function(self, option, default) | ||
| if not self:ValidCommandLineKey(option) then | ||
| return default | ||
| end | ||
|
|
||
| -- try to get the first argument | ||
| local arguments = GetCommandLineArg(option, 1) | ||
| if arguments and (not option[ arguments[1] ]) then | ||
| return arguments[1] | ||
| end | ||
|
|
||
| return default | ||
| end, | ||
|
|
||
| --- Attempts to retrieve a number-like command line argument | ||
| ---@param self UIAutolobbyArgumentsComponent | UIAutolobbyCommunications | ||
| ---@param option string | ||
| ---@param default number | ||
| ---@return number | ||
| GetCommandLineArgumentNumber = function(self, option, default) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if verifying as thoroughly as checking types is necessary, it just adds to the load of thinking which function is best to use without improving the solution to the original issue: The guards in |
||
| if not self:ValidCommandLineKey(option) then | ||
| return default | ||
| end | ||
|
|
||
| -- try to get the first argument and parse it as a number | ||
| local arguments = GetCommandLineArg(option, 1) | ||
| if arguments and (not option[ arguments[1] ]) then | ||
| local parsed = tonumber(arguments[1]) | ||
| if parsed then | ||
| return parsed | ||
| else | ||
| self:DebugWarn("Failed to parse as a number: ", arguments[1], " for key ", option) | ||
| return default | ||
| end | ||
| end | ||
|
|
||
| return default | ||
| end, | ||
|
|
||
| --- Attempts to retrieve a table-like command line argument | ||
| ---@param self UIAutolobbyArgumentsComponent | UIAutolobbyCommunications | ||
| ---@param option string | ||
| ---@return table<string, string> | ||
| GetCommandLineArgumentArray = function(self, option) | ||
| if not self:ValidCommandLineKey(option) then | ||
| return {} | ||
| end | ||
|
Comment on lines
+120
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the utils function will return an empty table for a non-existent key, so if we don't want to verify if a requested command line key is valid, then this function is not necessary as the default empty table return value is already implemented. |
||
|
|
||
| return import("/lua/system/utils.lua").GetCommandLineArgTable(option) | ||
| end, | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.