mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Main menu server list: Select first compatible search result (#15755)
Fixes a bug where an incompatible server would be selected instead due to being the "first" result before grouping.
This commit is contained in:
parent
ec83312540
commit
36c9742c0a
1 changed files with 11 additions and 6 deletions
|
@ -423,8 +423,17 @@ local function search_server_list(input)
|
||||||
return a.points > b.points
|
return a.points > b.points
|
||||||
end)
|
end)
|
||||||
menudata.search_result = search_result
|
menudata.search_result = search_result
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Find first compatible server (favorite or public)
|
||||||
|
for _, server in ipairs(search_result) do
|
||||||
|
if is_server_protocol_compat(server.proto_min, server.proto_max) then
|
||||||
|
set_selected_server(server)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- If no compatible server found, clear selection
|
||||||
|
set_selected_server(nil)
|
||||||
|
end
|
||||||
local function main_button_handler(tabview, fields, name, tabdata)
|
local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
if fields.te_name then
|
if fields.te_name then
|
||||||
gamedata.playername = fields.te_name
|
gamedata.playername = fields.te_name
|
||||||
|
@ -507,17 +516,13 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
if fields.btn_mp_clear then
|
if fields.btn_mp_clear then
|
||||||
tabdata.search_for = ""
|
tabdata.search_for = ""
|
||||||
menudata.search_result = nil
|
menudata.search_result = nil
|
||||||
|
set_selected_server(nil)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.btn_mp_search or fields.key_enter_field == "te_search" then
|
if fields.btn_mp_search or fields.key_enter_field == "te_search" then
|
||||||
tabdata.search_for = fields.te_search
|
tabdata.search_for = fields.te_search
|
||||||
search_server_list(fields.te_search)
|
search_server_list(fields.te_search)
|
||||||
if menudata.search_result then
|
|
||||||
-- Note: This clears the selection if there are no results
|
|
||||||
set_selected_server(menudata.search_result[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue