From 630bdefd98db9f39b20fc38b6dbcc89e9bafd002 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 1 Apr 2019 21:28:03 -0700 Subject: [PATCH] Don't allow areas to cross outside mapgen world limits. Limit any area to within [-31000,31000]. --- pos.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pos.lua b/pos.lua index 8d3e6fe..59eae94 100644 --- a/pos.lua +++ b/pos.lua @@ -129,13 +129,17 @@ function areas:getPos(playerName) return areas:sortPos(pos1, pos2) end +local function posLimit(pos) + return math.max(math.min(p, 31000), -31000) +end + function areas:setPos1(playerName, pos) - areas.pos1[playerName] = pos + areas.pos1[playerName] = posLimit(pos) areas.markPos1(playerName) end function areas:setPos2(playerName, pos) - areas.pos2[playerName] = pos + areas.pos2[playerName] = posLimit(pos) areas.markPos2(playerName) end