diff options
author | tenplus1 <tenplus1@users.noreply.github.com> | 2016-04-28 23:59:54 +1000 |
---|---|---|
committer | Craig Robbins <kde.psych@gmail.com> | 2016-04-29 00:00:35 +1000 |
commit | 7baddd173591cc9394d57cdb265f978495314f7a (patch) | |
tree | 68bac3c30c8085a451a23c40154f2335a3098eb0 /builtin | |
parent | dc35091affef70e8af8caa2b0fbbd328f1844550 (diff) | |
download | minetest-7baddd173591cc9394d57cdb265f978495314f7a.tar.gz minetest-7baddd173591cc9394d57cdb265f978495314f7a.tar.bz2 minetest-7baddd173591cc9394d57cdb265f978495314f7a.zip |
Avoid teleporting player if /teleport coords are out-of-range
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/chatcommands.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 7480446f2..3350140ee 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -352,10 +352,16 @@ core.register_chatcommand("teleport", { p.x = tonumber(p.x) p.y = tonumber(p.y) p.z = tonumber(p.z) - teleportee = core.get_player_by_name(name) - if teleportee and p.x and p.y and p.z then - teleportee:setpos(p) - return true, "Teleporting to "..core.pos_to_string(p) + if p.x and p.y and p.z then + local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000) + 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 + return false, "Cannot teleport out of map bounds!" + end + teleportee = core.get_player_by_name(name) + if teleportee then + teleportee:setpos(p) + return true, "Teleporting to "..core.pos_to_string(p) + end end local teleportee = nil |