summaryrefslogtreecommitdiff
path: root/src/content_cso.h
diff options
context:
space:
mode:
authoryou <ovvv@web.de>2018-06-23 09:16:01 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-06-23 09:16:01 +0200
commit968ce9af598024ec71e9ffb2d15c3997a13ad754 (patch)
tree0ad28040f1deb3ca1885d5147b23931d237a76f5 /src/content_cso.h
parent07b1743d3db086f0f984968252d9e3ac71336a7e (diff)
downloadminetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.tar.gz
minetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.tar.bz2
minetest-968ce9af598024ec71e9ffb2d15c3997a13ad754.zip
RTT fixes (#7428)
* Few code updates * Do not show average RTT before timing out * Fix unwanted integer division in RTTStatistics * Fix float format, prettier jitter calculation * Use +=, 0.1f -> 100.0f for stronger average updates
Diffstat (limited to 'src/content_cso.h')
0 files changed, 0 insertions, 0 deletions
10000) local backstring = filetocheck:reverse() return filetocheck:sub(0, filetocheck:len() - backstring:find(DIR_DELIM) + 1) .. randname end -------------------------------------------------------------------------------- function menu_render_worldlist() local retval = "" local current_worldlist = menudata.worldlist:get_list() for i, v in ipairs(current_worldlist) do if retval ~= "" then retval = retval .. "," end retval = retval .. core.formspec_escape(v.name) .. " \\[" .. core.formspec_escape(v.gameid) .. "\\]" end return retval end -------------------------------------------------------------------------------- function menu_handle_key_up_down(fields, textlist, settingname) 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 elseif fields.key_down and oldidx and oldidx < menudata.worldlist:size() then newidx = oldidx + 1 end core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx)) configure_selected_world_params(newidx) return true end return false end -------------------------------------------------------------------------------- function asyncOnlineFavourites() if not menudata.public_known then menudata.public_known = {{ name = fgettext("Loading..."), description = fgettext_ne("Try reenabling public serverlist and check your internet connection.") }} 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 menudata.favorites = menudata.public_known menudata.favorites_is_public = true end core.event_handler("Refresh") end ) end -------------------------------------------------------------------------------- function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency) local textlines = core.wrap_text(text, textlen, true) local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width .. "," .. height .. ";" .. tl_name .. ";" for i = 1, #textlines do textlines[i] = textlines[i]:gsub("\r", "") retval = retval .. core.formspec_escape(textlines[i]) .. "," end retval = retval .. ";0;" if transparency then retval = retval .. "true" end retval = retval .. "]" return retval end -------------------------------------------------------------------------------- function is_server_protocol_compat(server_proto_min, server_proto_max) 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 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. ", s_p_min, s_p_max) else server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ", s_p_min) end if min_supp_proto ~= max_supp_proto then client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.", min_supp_proto, max_supp_proto) else client_prot_ver_info = fgettext_ne("We only support protocol version $1.", min_supp_proto) end gamedata.errormessage = fgettext_ne("Protocol version mismatch. ") .. server_prot_ver_info .. client_prot_ver_info return false end return true end -------------------------------------------------------------------------------- function menu_worldmt(selected, setting, value) local world = menudata.worldlist:get_list()[selected] if world then local filename = world.path .. DIR_DELIM .. "world.mt" local world_conf = Settings(filename) if value then if not world_conf:write() then core.log("error", "Failed to write world config file") end world_conf:set(setting, value) world_conf:write() else return world_conf:get(setting) end else return nil end end function menu_worldmt_legacy(selected) local modes_names = {"creative_mode", "enable_damage", "server_announce"} for _, mode_name in pairs(modes_names) do local mode_val = menu_worldmt(selected, mode_name) if mode_val then core.settings:set(mode_name, mode_val) else menu_worldmt(selected, mode_name, core.settings:get(mode_name)) end end end