Mainmenu: Still support favorites if send_pre_v25_init is disabled
@SmallJoker has noted a bug that servers from the (local) main menu
favorites list can't be opened.
This commit fixes the bug by disabling any main menu based protocol
checks for servers from the favorite list.
Also, it fixes a second bug that happens when a server from the
public serverlist doesn't send its supported protocol versions,
most likely because its running a minetest older than commit [1].
Then we have shown an error msg that the server has enforced
one specific protocol version. This was most likely not the case.
Of course, we can't do anything better than do an assumption on
the protocol versions if they are not known. That assumption
should however be closest to the most often occuring case as
possible.
Also, some little cleanups.
[1]: 5a0ed780f5
"Server: announce MIN/MAX protocol version supported to serverlist. Client: check serverlist"
stable-0.4
parent
d82c5da0dc
commit
bc4dc80c01
|
@ -246,6 +246,7 @@ function asyncOnlineFavourites()
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
menudata.favorites = menudata.public_known
|
menudata.favorites = menudata.public_known
|
||||||
|
menudata.favorites_is_public = true
|
||||||
core.handle_async(
|
core.handle_async(
|
||||||
function(param)
|
function(param)
|
||||||
return core.get_favorites("online")
|
return core.get_favorites("online")
|
||||||
|
@ -257,6 +258,7 @@ function asyncOnlineFavourites()
|
||||||
if favs[1] then
|
if favs[1] then
|
||||||
menudata.public_known = favs
|
menudata.public_known = favs
|
||||||
menudata.favorites = menudata.public_known
|
menudata.favorites = menudata.public_known
|
||||||
|
menudata.favorites_is_public = true
|
||||||
end
|
end
|
||||||
core.event_handler("Refresh")
|
core.event_handler("Refresh")
|
||||||
end
|
end
|
||||||
|
@ -297,12 +299,14 @@ function is_server_protocol_compat_or_error(server_proto_min, server_proto_max)
|
||||||
if not is_server_protocol_compat(server_proto_min, server_proto_max) then
|
if not is_server_protocol_compat(server_proto_min, server_proto_max) then
|
||||||
local server_prot_ver_info
|
local server_prot_ver_info
|
||||||
local client_prot_ver_info
|
local client_prot_ver_info
|
||||||
if server_proto_min ~= server_proto_max then
|
local s_p_min = server_proto_min or 13
|
||||||
|
local s_p_max = server_proto_max or 24
|
||||||
|
if s_p_min ~= s_p_max then
|
||||||
server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
|
server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
|
||||||
server_proto_min or 13, server_proto_max or 24)
|
s_p_min, s_p_max)
|
||||||
else
|
else
|
||||||
server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ",
|
server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ",
|
||||||
server_proto_min or 13)
|
s_p_min)
|
||||||
end
|
end
|
||||||
if min_supp_proto ~= max_supp_proto then
|
if min_supp_proto ~= max_supp_proto then
|
||||||
client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.",
|
client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.",
|
||||||
|
|
|
@ -102,22 +102,22 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
local event = core.explode_table_event(fields["favourites"])
|
local event = core.explode_table_event(fields["favourites"])
|
||||||
if event.type == "DCL" then
|
if event.type == "DCL" then
|
||||||
if event.row <= #menudata.favorites then
|
if event.row <= #menudata.favorites then
|
||||||
if not is_server_protocol_compat_or_error(menudata.favorites[event.row].proto_min,
|
local fav = menudata.favorites[event.row]
|
||||||
menudata.favorites[event.row].proto_max) then
|
if menudata.favorites_is_public and
|
||||||
|
not is_server_protocol_compat_or_error(
|
||||||
|
fav.proto_min, fav.proto_max) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
gamedata.address = menudata.favorites[event.row].address
|
gamedata.address = fav.address
|
||||||
gamedata.port = menudata.favorites[event.row].port
|
gamedata.port = fav.port
|
||||||
gamedata.playername = fields["te_name"]
|
gamedata.playername = fields["te_name"]
|
||||||
if fields["te_pwd"] ~= nil then
|
if fields["te_pwd"] ~= nil then
|
||||||
gamedata.password = fields["te_pwd"]
|
gamedata.password = fields["te_pwd"]
|
||||||
end
|
end
|
||||||
gamedata.selected_world = 0
|
gamedata.selected_world = 0
|
||||||
|
|
||||||
if menudata.favorites ~= nil then
|
gamedata.servername = fav.name
|
||||||
gamedata.servername = menudata.favorites[event.row].name
|
gamedata.serverdescription = fav.description
|
||||||
gamedata.serverdescription = menudata.favorites[event.row].description
|
|
||||||
end
|
|
||||||
|
|
||||||
if gamedata.address ~= nil and
|
if gamedata.address ~= nil and
|
||||||
gamedata.port ~= nil then
|
gamedata.port ~= nil then
|
||||||
|
@ -188,6 +188,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
else
|
else
|
||||||
menudata.favorites = core.get_favorites("local")
|
menudata.favorites = core.get_favorites("local")
|
||||||
|
menudata.favorites_is_public = false
|
||||||
end
|
end
|
||||||
tabdata.fav_selected = nil
|
tabdata.fav_selected = nil
|
||||||
return true
|
return true
|
||||||
|
@ -197,7 +198,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
local current_favourite = core.get_table_index("favourites")
|
local current_favourite = core.get_table_index("favourites")
|
||||||
if current_favourite == nil then return end
|
if current_favourite == nil then return end
|
||||||
core.delete_favorite(current_favourite)
|
core.delete_favorite(current_favourite)
|
||||||
menudata.favorites = order_favorite_list(core.get_favorites())
|
menudata.favorites = core.get_favorites("local")
|
||||||
tabdata.fav_selected = nil
|
tabdata.fav_selected = nil
|
||||||
|
|
||||||
core.setting_set("address","")
|
core.setting_set("address","")
|
||||||
|
@ -221,11 +222,13 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
menudata.favorites[fav_idx].address == fields["te_address"] and
|
menudata.favorites[fav_idx].address == fields["te_address"] and
|
||||||
menudata.favorites[fav_idx].port == fields["te_port"] then
|
menudata.favorites[fav_idx].port == fields["te_port"] then
|
||||||
|
|
||||||
gamedata.servername = menudata.favorites[fav_idx].name
|
local fav = menudata.favorites[fav_idx]
|
||||||
gamedata.serverdescription = menudata.favorites[fav_idx].description
|
gamedata.servername = fav.name
|
||||||
|
gamedata.serverdescription = fav.description
|
||||||
|
|
||||||
if not is_server_protocol_compat_or_error(menudata.favorites[fav_idx].proto_min,
|
if menudata.favorites_is_public and
|
||||||
menudata.favorites[fav_idx].proto_max)then
|
not is_server_protocol_compat_or_error(
|
||||||
|
fav.proto_min, fav.proto_max) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -252,6 +255,7 @@ local function on_change(type,old_tab,new_tab)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
else
|
else
|
||||||
menudata.favorites = core.get_favorites("local")
|
menudata.favorites = core.get_favorites("local")
|
||||||
|
menudata.favorites_is_public = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
else
|
else
|
||||||
menudata.favorites = core.get_favorites("local")
|
menudata.favorites = core.get_favorites("local")
|
||||||
|
menudata.favorites_is_public = false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -149,12 +150,14 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
if fav_idx ~= nil and fav_idx <= #menudata.favorites and
|
if fav_idx ~= nil and fav_idx <= #menudata.favorites and
|
||||||
menudata.favorites[fav_idx].address == fields["te_address"] and
|
menudata.favorites[fav_idx].address == fields["te_address"] and
|
||||||
menudata.favorites[fav_idx].port == fields["te_port"] then
|
menudata.favorites[fav_idx].port == fields["te_port"] then
|
||||||
|
local fav = menudata.favorites[fav_idx]
|
||||||
|
|
||||||
gamedata.servername = menudata.favorites[fav_idx].name
|
gamedata.servername = fav.name
|
||||||
gamedata.serverdescription = menudata.favorites[fav_idx].description
|
gamedata.serverdescription = fav.description
|
||||||
|
|
||||||
if not is_server_protocol_compat_or_error(menudata.favorites[fav_idx].proto_min,
|
if menudata.favorites_is_public and
|
||||||
menudata.favorites[fav_idx].proto_max) then
|
not is_server_protocol_compat_or_error(
|
||||||
|
fav.proto_min, fav.proto_max) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -192,6 +195,7 @@ local function on_activate(type,old_tab,new_tab)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
else
|
else
|
||||||
menudata.favorites = core.get_favorites("local")
|
menudata.favorites = core.get_favorites("local")
|
||||||
|
menudata.favorites_is_public = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue