diff --git a/iland-core.lua b/iland-core.lua index b8b6f25..85dc1a6 100644 --- a/iland-core.lua +++ b/iland-core.lua @@ -1601,6 +1601,9 @@ function ILAPI.CreateLand(xuid,startpos,endpos,dimid) end local posA,posB = SortPos(startpos,endpos) + if not ILAPI.IsLandCollision(posA,posB,dimid).status then + return -1 + end -- LandData Templete land_data[landId]={ @@ -1754,7 +1757,7 @@ function ILAPI.GetDistence(landId,vec4) depos = { pos,euc } end end - if ILAPI.GetLandDimension(landId)=='2D' then + if ILAPI.GetDimension(landId)=='2D' then return depos[2] end return math.sqrt(pow(depos[2])+pow(math.min(math.abs(vec4.y-VecMap[landId].a.y),math.abs(vec4.y-VecMap[landId].b.y)))) @@ -2085,6 +2088,31 @@ end function ILAPI.GetMemoryCount() return tonumber(string.format("%.2f",collectgarbage('count')/1024)) end +function ILAPI.SetRange(landId,newposA,newposB,newDimid) + + if ILAPI.GetDimension(landId) == '2D' then + newposA.y = minY + newposB.y = maxY + end + if not ILAPI.IsLandCollision(newposA,newposB,newDimid,{landId}).status then + return false + end + local posA,posB = SortPos(newposA,newposB) + + UpdateLandEdgeMap(landId,'del') + UpdateChunk(landId,'del') + UpdateLandPosMap(landId,'del') + land_data[landId].range.start_position = {posA.x,posA.y,posA.z} + land_data[landId].range.end_position = {posB.x,posB.y,posB.z} + land_data[landId].range.dimid = newDimid + land_data[landId].settings.tpoint = {posA.x,posA.y+1,posA.z} + UpdateLandEdgeMap(landId,'add') + UpdateChunk(landId,'add') + UpdateLandPosMap(landId,'add') + + ILAPI.save({0,1,0}) + return true +end -- +-+ +-+ +-+ +-+ +-+ +-+ -- |T| |H| |E| |E| |N| |D| @@ -2094,6 +2122,7 @@ end function _Tr(a,...) if DEV_MODE and LangPack[a]==nil then WARN('Translation not found: '..a) + return end local result = CloneTable(LangPack[a]) local args = {...} @@ -2557,27 +2586,33 @@ mc.regPlayerCmd(MainCmd..' buy',_Tr('command.land_buy'),function (player,args) local xuid = player.xuid local range = MEM[xuid].newLand.range local player_credits = Money_Get(player) + local landId if price > player_credits then - SendText(player,_Tr('title.buyland.moneynotenough').._Tr('title.buyland.ordersaved','',cfg.features.selection.tool_name));return + SendText(player,_Tr('title.buyland.moneynotenough').._Tr('title.buyland.ordersaved','',cfg.features.selection.tool_name)) + return else - Money_Del(player,price) - end - SendText(player,_Tr('title.buyland.succeed')) - local landId = ILAPI.CreateLand(xuid,range.posA,range.posB,range.dimid) - RangeSelector.Clear(player) - MEM[xuid].newLand = nil - player:sendModalForm( - 'Complete.', - _Tr('gui.buyland.succeed'), - _Tr('gui.general.looklook'), - _Tr('gui.general.cancel'), - function(player,res) - if res then - MEM[xuid].landId = landId - GUI_FastMgr(player) - end + landId = ILAPI.CreateLand(xuid,range.posA,range.posB,range.dimid) + if landId~=-1 then + Money_Del(player,price) + SendText(player,_Tr('title.buyland.succeed')) + player:sendModalForm( + 'Complete.', + _Tr('gui.buyland.succeed'), + _Tr('gui.general.looklook'), + _Tr('gui.general.cancel'), + function(player,res) + if res then + MEM[xuid].landId = landId + GUI_FastMgr(player) + end + end + ) + else + SendText(player,_Tr('title.buyland.fail.apirefuse')) end - ) + RangeSelector.Clear(player) + MEM[xuid].newLand = nil + end end) end) mc.regPlayerCmd(MainCmd..' ok',_Tr('command.land_ok'),function (player,args) @@ -2619,37 +2654,22 @@ mc.regPlayerCmd(MainCmd..' ok',_Tr('command.land_ok'),function (player,args) _Tr('gui.general.cancel'), function(player,result) if result==nil or not(result) then return end - if payT==0 then - if Money_Get(player) 再次单击地面呼出订单\n放弃此次购买请使用\"/land giveup\"", "title.buyland.succeed": "购买成功!\n正在为您注册领地...", "title.land.deleted": " 已删除", @@ -228,6 +229,7 @@ "title.giveup.succeed": "许可已被放弃", "title.giveup.failed": "没有可以放弃的圈地许可", "title.reselectland.giveup.succeed": "已取消重新圈地", + "title.reselectland.fail.apirefuse": "付款过程中止,因为API拒绝修改此领地。", "title.reselectland.succeed": "选定成功!新的领地范围已生效。", "title.landlimit.noperm": "这里是领地,你无权操作", "title.landlimit.nearby": "距离他人领地太近,操作被撤销",