diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 42fc8b0d..f2d45403 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -514,6 +514,9 @@ function core.item_drop(itemstack, dropper, pos) local dropper_is_player = dropper and dropper:is_player() local p = table.copy(pos) local cnt = itemstack:get_count() + if not core.is_valid_pos(p) then + return + end if dropper_is_player then p.y = p.y + 1.2 if dropper:get_player_control().sneak then diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index b68bb4c0..ea142aa1 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -162,7 +162,7 @@ end -- Checks if specified volume intersects a protected volume -- Backport from Minetest 5.0 -function core.intersects_protection(minp, maxp, player_name, interval) +function core.is_area_protected(minp, maxp, player_name, interval) -- 'interval' is the largest allowed interval for the 3D lattice of checks. -- Compute the optimal float step 'd' for each axis so that all corners and @@ -175,14 +175,18 @@ function core.intersects_protection(minp, maxp, player_name, interval) local d = {} for _, c in pairs({"x", "y", "z"}) do + if minp[c] > maxp[c] then + -- Repair positions: 'minp' > 'maxp' + local tmp = maxp[c] + maxp[c] = minp[c] + minp[c] = tmp + end + if maxp[c] > minp[c] then d[c] = (maxp[c] - minp[c]) / math.ceil((maxp[c] - minp[c]) / interval) - 1e-4 - elseif maxp[c] == minp[c] then + else d[c] = 1 -- Any value larger than 0 to avoid division by zero - else -- maxp[c] < minp[c], print error and treat as protection intersected - core.log("error", "maxp < minp in 'minetest.intersects_protection()'") - return true end end @@ -192,13 +196,13 @@ function core.intersects_protection(minp, maxp, player_name, interval) local y = math.floor(yf + 0.5) for xf = minp.x, maxp.x, d.x do local x = math.floor(xf + 0.5) - if core.is_protected({x = x, y = y, z = z}, player_name) then - return true + local pos = {x = x, y = y, z = z} + if core.is_protected(pos, player_name) then + return pos end end end end - return false end diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index aa97361b..136abe91 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -21,7 +21,7 @@ local breath_bar_definition = hud_elem_type = "statbar", position = {x = 0.5, y = 1}, alignment = {x = -1, y = -1}, - offset = {x = 10, y = -134}, + offset = {x = 8, y = -134}, size = {x = 24, y = 24}, text = "bubble.png", number = 20, diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 072ac5b6..6fadb95c 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -35,7 +35,7 @@ common_update_cached_supp_proto() -------------------------------------------------------------------------------- local function render_client_count(n) - if n > 99 then return '99+' + if n > 999 then return '999' elseif n >= 0 then return tostring(n) else return '?' end end @@ -54,14 +54,16 @@ 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 .. - (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") .. "," .. - "6=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mc.png") .. "," .. - "7=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mt.png") + "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_favorite.png") .. "," .. + "2=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mc.png") .. "," .. + "3=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mt.png") .. "," .. + "4=" .. core.formspec_escape(defaulttexturedir .. "server_flags_damage.png") .. "," .. + "5=" .. core.formspec_escape(defaulttexturedir .. "server_flags_creative.png") .. "," .. + "6=" .. core.formspec_escape(defaulttexturedir .. "server_flags_pvp.png") .. "," .. + "14=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," .. + "13=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," .. + "12=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," .. + "11=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png") end -------------------------------------------------------------------------------- @@ -102,22 +104,22 @@ function render_serverlist_row(spec, is_favorite, is_approved) details = "1," else if is_approved then - details = "6," + details = "2," else - details = "7," + details = "3," end end if spec.ping then local ping = spec.ping * 1000 if ping <= 50 then - details = details .. "2," + details = details .. "14," elseif ping <= 100 then - details = details .. "3," + details = details .. "13," elseif ping <= 250 then - details = details .. "4," + details = details .. "12," else - details = details .. "5," + details = details .. "11," end else details = details .. "0," @@ -134,7 +136,7 @@ function render_serverlist_row(spec, is_favorite, is_approved) elseif clients_percent <= 60 then clients_color = '#a1e587' -- 0-60%: green elseif clients_percent <= 90 then clients_color = '#ffdc97' -- 60-90%: yellow elseif clients_percent == 100 then clients_color = '#dd5b5b' -- full server: red (darker) - else clients_color = '#ffba97' -- 90-100%: orange + else clients_color = '#ffba97' -- 90-100%: orange end details = details .. clients_color .. ',' .. @@ -147,20 +149,14 @@ function render_serverlist_row(spec, is_favorite, is_approved) details = details .. ',?,/,?,' end - if spec.creative then - details = details .. "1," - else - details = details .. "0," - end - if spec.damage then - details = details .. "1," + details = details .. "4," else - details = details .. "0," + details = details .. "5," end if spec.pvp then - details = details .. "1," + details = details .. "6," else details = details .. "0," end diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index d8059936..af3470eb 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -56,13 +56,13 @@ local function create_world_formspec(dialogdata) "size[11.5,3.75,false]" .. "background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir .. "bg_dialog.png") .. ";true]" .. - "label[2,0;" .. fgettext("World name") .. "]".. + "label[1.5,0;" .. fgettext("World name:") .. "]".. "field[4.5,0.4;6,0.5;te_world_name;;]" .. - "label[2,1;" .. fgettext("Seed") .. "]".. + "label[1.5,1;" .. fgettext("Seed:") .. "]".. "field[4.5,1.4;6,0.5;te_seed;;".. current_seed .. "]" .. - "label[2,2;" .. fgettext("Mapgen") .. "]".. + "label[1.5,2;" .. fgettext("Mapgen:") .. "]".. "dropdown[4.2,2;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" .. "dropdown[600.2,6;6.3;games;" .. gamemgr.gamelist() .. ";1]" .. diff --git a/builtin/mainmenu/dlg_delete_world.lua b/builtin/mainmenu/dlg_delete_world.lua index 8ab68912..06751b90 100644 --- a/builtin/mainmenu/dlg_delete_world.lua +++ b/builtin/mainmenu/dlg_delete_world.lua @@ -21,8 +21,7 @@ local function delete_world_formspec(dialogdata) "size[11.5,3.75,false]" .. "background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir .. "bg_dialog.png") .. ";true]" .. - "label[5,1.4;" .. - fgettext("Delete World") .. "]" .. + "label[5,1.4;" .. fgettext("Delete World") .. "]" .. "label[5,1.8;" .. fgettext("\"$1\"?", dialogdata.delete_name) .. "]" .. "button[3.25,3.4;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" .. "button[5.75,3.4;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]" diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 6981416d..3eb9afba 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -36,11 +36,13 @@ dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua") dofile(menupath .. DIR_DELIM .. "common.lua") dofile(menupath .. DIR_DELIM .. "gamemgr.lua") dofile(menupath .. DIR_DELIM .. "textures.lua") + dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua") --dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua") dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua") --dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua") dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua") + if not use_simple_menu then dofile(menupath .. DIR_DELIM .. "modmgr.lua") -- dofile(menupath .. DIR_DELIM .. "store.lua") @@ -88,14 +90,11 @@ local function init_globals() menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic) menudata.worldlist:set_sortmode("alphabetic") - local default_game = "default" - mm_texture.init() -- Create main tabview local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0}) - tv_main:set_autosave_tab(true) tv_main:add(tabs.local_game) tv_main:add(tabs.play_online) @@ -107,15 +106,19 @@ local function init_globals() --tv_main:add(tabs.mods) tv_main:add(tabs.credits) + tv_main:set_autosave_tab(true) tv_main:set_global_event_handler(main_event_handler) tv_main:set_fixed_size(false) - tv_main:set_tab(core.settings:get("maintab_LAST")) + local last_tab = core.settings:get("maintab_LAST") + if last_tab and tv_main.current_tab ~= last_tab then + tv_main:set_tab(last_tab) + end ui.set_default("maintab") tv_main:show() -- Create modstore ui - --if PLATFORM == "Android" then + --if use_simple_menu then -- modstore.init({x = 12, y = 6}, 3, 2) --else -- modstore.init({x = 12, y = 8}, 4, 3) diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index 27d0a7cd..1424c9b9 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -81,8 +81,7 @@ local function get_formspec(tabview, name, tabdata) "text,align=right;" .. -- clients "text,align=center,padding=0.25;" .. -- "/" "text,align=right,padding=0.25;" .. -- clients_max - image_column(fgettext("Creative mode"), "creative") .. ",padding=0.25;" .. - image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" .. + image_column(fgettext("Server mode"), "damage") .. ",padding=0.25;" .. image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" .. "color,span=1;" .. "text,padding=0.25]" .. diff --git a/builtin/profiler/reporter.lua b/builtin/profiler/reporter.lua index 95b969d7..f06e7f11 100644 --- a/builtin/profiler/reporter.lua +++ b/builtin/profiler/reporter.lua @@ -73,7 +73,7 @@ local Formatter = { end } -local widths = { 55, 9, 9, 9, 5, 5, 5 } +local widths = { 50, 8, 8, 8, 5, 5, 5 } local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths)) local HR = {}