mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01: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
|
||||
end)
|
||||
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)
|
||||
if fields.te_name then
|
||||
gamedata.playername = fields.te_name
|
||||
|
@ -507,17 +516,13 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
if fields.btn_mp_clear then
|
||||
tabdata.search_for = ""
|
||||
menudata.search_result = nil
|
||||
set_selected_server(nil)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_search or fields.key_enter_field == "te_search" then
|
||||
tabdata.search_for = 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
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue