aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-06-28 08:00:00 +0800
committerRunxi Yu <me@runxiyu.org>2024-06-28 08:00:00 +0800
commit11c7849bdf53557bc327fee06bddbbf1e23c4512 (patch)
treea90dba953d7cc9584c979ad3b6772f55c58f42ed /builtin/common
parent53dd648c96b899b706f30de656896713d7e8ff08 (diff)
downloadhax-minetest-server-11c7849bdf53557bc327fee06bddbbf1e23c4512.tar.gz
hax-minetest-server-11c7849bdf53557bc327fee06bddbbf1e23c4512.zip
Hax's version of Minetest Server 5.6.0
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]builtin/common/information_formspecs.lua4
-rw-r--r--builtin/common/misc_helpers.lua1
-rw-r--r--builtin/common/vector.lua8
3 files changed, 11 insertions, 2 deletions
diff --git a/builtin/common/information_formspecs.lua b/builtin/common/information_formspecs.lua
index 1445a017c..d4426aff4 100644..100755
--- a/builtin/common/information_formspecs.lua
+++ b/builtin/common/information_formspecs.lua
@@ -57,11 +57,11 @@ local function build_chatcommands_formspec(name, sel, copy)
.. "any entry in the list.").. "\n" ..
S("Double-click to copy the entry to the chat history.")
- local privs = core.get_player_privs(name)
+ local check_player_privs = core.check_player_privs
for i, data in ipairs(mod_cmds) do
rows[#rows + 1] = COLOR_BLUE .. ",0," .. F(data[1]) .. ","
for j, cmds in ipairs(data[2]) do
- local has_priv = privs[cmds[2].privs]
+ local has_priv = check_player_privs(name, cmds[2].privs)
rows[#rows + 1] = ("%s,1,%s,%s"):format(
has_priv and COLOR_GREEN or COLOR_GRAY,
cmds[1], F(cmds[2].params))
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 467f18804..a8ec5817a 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -5,6 +5,7 @@
local string_sub, string_find = string.sub, string.find
--------------------------------------------------------------------------------
+
local function basic_dump(o)
local tp = type(o)
if tp == "number" then
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua
index a08472e32..b662f73fc 100644
--- a/builtin/common/vector.lua
+++ b/builtin/common/vector.lua
@@ -125,6 +125,14 @@ function vector.distance(a, b)
return math.sqrt(x * x + y * y + z * z)
end
+-- square roots are expensive
+function vector.distance_sq(a, b)
+ local x = a.x - b.x
+ local y = a.y - b.y
+ local z = a.z - b.z
+ return x * x + y * y + z * z
+end
+
function vector.direction(pos1, pos2)
return vector.subtract(pos2, pos1):normalize()
end