mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-22 12:16:15 +00:00
Fix up Play Now server selection logic, again 😁
This commit is contained in:
@@ -255,14 +255,18 @@ class W3DHub
|
||||
!server.status.password &&
|
||||
server.status.player_count < server.status.max_players
|
||||
end
|
||||
server_options.sort_by! { |s| [s.status.player_count, s.ping] }.reverse!
|
||||
# sort by player count HIGH to LOW
|
||||
# and by ping LOW to HIGH
|
||||
server_options.sort! do |a, b|
|
||||
[b.status.player_count, a.ping] <=> [a.status.player_count, b.ping]
|
||||
end
|
||||
|
||||
# try to find server with lowest ping and matching version
|
||||
found_server = server_options.find { |server| server.version == app_data[:installed_version] }
|
||||
# try to find server with lowest ping and undefined version
|
||||
found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION }
|
||||
|
||||
found_server || nil
|
||||
found_server
|
||||
end
|
||||
|
||||
def play_now(app_id, channel)
|
||||
|
||||
Reference in New Issue
Block a user