Skip to content

Commit 7baddd1

Browse files
tenplus1Zeno-
authored andcommittedApr 28, 2016
Avoid teleporting player if /teleport coords are out-of-range
1 parent dc35091 commit 7baddd1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎builtin/game/chatcommands.lua

+10-4
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,16 @@ core.register_chatcommand("teleport", {
352352
p.x = tonumber(p.x)
353353
p.y = tonumber(p.y)
354354
p.z = tonumber(p.z)
355-
teleportee = core.get_player_by_name(name)
356-
if teleportee and p.x and p.y and p.z then
357-
teleportee:setpos(p)
358-
return true, "Teleporting to "..core.pos_to_string(p)
355+
if p.x and p.y and p.z then
356+
local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000)
357+
if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then
358+
return false, "Cannot teleport out of map bounds!"
359+
end
360+
teleportee = core.get_player_by_name(name)
361+
if teleportee then
362+
teleportee:setpos(p)
363+
return true, "Teleporting to "..core.pos_to_string(p)
364+
end
359365
end
360366

361367
local teleportee = nil

0 commit comments

Comments
 (0)
Please sign in to comment.