end
local function configure_selected_world_params(idx)
- local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
+ local worldconfig = pkgmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
- core.setting_set("creative_mode", worldconfig.creative_mode)
+ core.settings:set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage then
- core.setting_set("enable_damage", worldconfig.enable_damage)
+ core.settings:set("enable_damage", worldconfig.enable_damage)
end
end
function image_column(tooltip, flagname)
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
- "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png")
+ "1=" .. core.formspec_escape(defaulttexturedir ..
+ (flagname and "server_flags_" .. flagname .. ".png" or "blank.png")) .. "," ..
+ "2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," ..
+ "3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," ..
+ "4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," ..
+ "5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png")
end
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------
-function render_favorite(spec, is_favorite)
+function render_serverlist_row(spec, is_favorite)
local text = ""
if spec.name then
text = text .. core.formspec_escape(spec.name:trim())
details = "0,"
end
+ if spec.ping then
+ local ping = spec.ping * 1000
+ if ping <= 50 then
+ details = details .. "2,"
+ elseif ping <= 100 then
+ details = details .. "3,"
+ elseif ping <= 250 then
+ details = details .. "4,"
+ else
+ details = details .. "5,"
+ end
+ else
+ details = details .. "0,"
+ end
+
if spec.clients and spec.clients_max then
local clients_color = ''
local clients_percent = 100 * spec.clients / spec.clients_max
--------------------------------------------------------------------------------
os.tempfolder = function()
- if core.setting_get("TMPFolder") then
- return core.setting_get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
+ if core.settings:get("TMPFolder") then
+ return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
end
local filetocheck = os.tmpname()
os.remove(filetocheck)
- local randname = "MTTempModFolder_" .. math.random(0,10000)
- if DIR_DELIM == "\\" then
+ -- https://blogs.msdn.microsoft.com/vcblog/2014/06/18/c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
+ -- The C runtime (CRT) function called by os.tmpname is tmpnam.
+ -- Microsofts tmpnam implementation in older CRT / MSVC releases is defective.
+ -- tmpnam return values starting with a backslash characterize this behavior.
+ -- https://sourceforge.net/p/mingw-w64/bugs/555/
+ -- MinGW tmpnam implementation is forwarded to the CRT directly.
+ -- https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/
+ -- MinGW links to an older CRT release (msvcrt.dll).
+ -- Due to legal concerns MinGW will never use a newer CRT.
+ --
+ -- Make use of TEMP to compose the temporary filename if an old
+ -- style tmpnam return value is detected.
+ if filetocheck:sub(1, 1) == "\\" then
local tempfolder = os.getenv("TEMP")
return tempfolder .. filetocheck
- else
- local backstring = filetocheck:reverse()
- return filetocheck:sub(0,filetocheck:len()-backstring:find(DIR_DELIM)+1) ..randname
end
+ local randname = "MTTempModFolder_" .. math.random(0,10000)
+ local backstring = filetocheck:reverse()
+ return filetocheck:sub(0, filetocheck:len() - backstring:find(DIR_DELIM) + 1) ..
+ randname
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function menu_handle_key_up_down(fields, textlist, settingname)
- local oldidx, newidx = core.get_textlist_index(textlist)
+ local oldidx, newidx = core.get_textlist_index(textlist), 1
if fields.key_up or fields.key_down then
if fields.key_up and oldidx and oldidx > 1 then
newidx = oldidx - 1
oldidx < menudata.worldlist:size() then
newidx = oldidx + 1
end
- core.setting_set(settingname, menudata.worldlist:get_raw_index(newidx))
+ core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx))
configure_selected_world_params(newidx)
return true
end
end
menudata.favorites = menudata.public_known
menudata.favorites_is_public = true
+
+ if not menudata.public_downloading then
+ menudata.public_downloading = true
+ else
+ return
+ end
+
core.handle_async(
function(param)
return core.get_favorites("online")
end,
nil,
function(result)
+ menudata.public_downloading = nil
local favs = order_favorite_list(result)
if favs[1] then
menudata.public_known = favs
--------------------------------------------------------------------------------
function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency)
- local textlines = core.splittext(text, textlen)
+ local textlines = core.wrap_text(text, textlen, true)
local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width ..
"," .. height .. ";" .. tl_name .. ";"
--------------------------------------------------------------------------------
function is_server_protocol_compat(server_proto_min, server_proto_max)
- return min_supp_proto <= (server_proto_max or 24) and max_supp_proto >= (server_proto_min or 13)
+ if (not server_proto_min) or (not server_proto_max) then
+ -- There is no info. Assume the best and act as if we would be compatible.
+ return true
+ end
+ return min_supp_proto <= server_proto_max and max_supp_proto >= server_proto_min
end
--------------------------------------------------------------------------------
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
local server_prot_ver_info, client_prot_ver_info
- local s_p_min = server_proto_min or 13
- local s_p_max = server_proto_max or 24
+ local s_p_min = server_proto_min
+ local s_p_max = server_proto_max
if s_p_min ~= s_p_max then
server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
for _, mode_name in pairs(modes_names) do
local mode_val = menu_worldmt(selected, mode_name)
if mode_val then
- core.setting_set(mode_name, mode_val)
+ core.settings:set(mode_name, mode_val)
else
- menu_worldmt(selected, mode_name, core.setting_get(mode_name))
+ menu_worldmt(selected, mode_name, core.settings:get(mode_name))
end
end
end