Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit f5d37e8

Browse files
committed
fix bug in reselectland.
1 parent faaed6a commit f5d37e8

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

iland-core.lua

+22-27
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,7 @@ Map = {
197197
table.insert(Map.Chunk.data[dimid][Tx][Tz],#Map.Chunk.data[dimid][Tx][Tz]+1,landId)
198198
end
199199
elseif mode=='del' then
200-
local p = Array.Fetch(Map.Chunk.data[dimid][Tx][Tz],landId)
201-
if p~=-1 then
202-
table.remove(Map.Chunk.data[dimid][Tx][Tz],p)
203-
end
200+
Array.Remove(Map.Chunk.data[dimid][Tx][Tz],landId)
204201
end
205202
end
206203
end
@@ -268,16 +265,13 @@ Map = {
268265
end
269266
elseif mode == 'del' then
270267
for x = spos.x,epos.x do
271-
local tar = Map.Land.AXIS.data[dimid]['x'][x]
272-
table.remove(tar,Array.Fetch(tar,landId))
268+
Array.Remove(Map.Land.AXIS.data[dimid]['x'][x],landId)
273269
end
274270
for y = spos.y,epos.y do
275-
local tar = Map.Land.AXIS.data[dimid]['y'][y]
276-
table.remove(tar,Array.Fetch(tar,landId))
271+
Array.Remove(Map.Land.AXIS.data[dimid]['y'][y],landId)
277272
end
278273
for z = spos.z,epos.z do
279-
local tar = Map.Land.AXIS.data[dimid]['z'][z]
280-
table.remove(tar,Array.Fetch(tar,landId))
274+
Array.Remove(Map.Land.AXIS.data[dimid]['z'][z],landId)
281275
end
282276
end
283277
end
@@ -446,15 +440,9 @@ Map = {
446440
end
447441
local landId = record.landId
448442
if landId~=-1 then
449-
local pos = Array.Fetch(map.land_recorded_pos[landId],strpos)
450-
if pos ~= -1 then
451-
table.remove(map.land_recorded_pos[landId],pos)
452-
end
443+
Array.Remove(map.land_recorded_pos[landId],strpos)
453444
else
454-
local pos = Array.Fetch(map.non_land_pos,strpos)
455-
if pos ~= -1 then
456-
table.remove(map.non_land_pos,pos)
457-
end
445+
Array.Remove(map.non_land_pos,strpos)
458446
end
459447
map.data[strpos] = nil
460448
end,
@@ -509,10 +497,7 @@ Map = {
509497
clear_range = function(cubestr) -- clear single range's cache.
510498
local map = Map.CachedQuery.RangeArea
511499
for n,landId in pairs(map.data[cubestr].landlist) do
512-
local pos = Array.Fetch(map.recorded_landId[landId],"this."..cubestr..".landlist.(*)"..n)
513-
if pos~=-1 then
514-
table.remove(map.recorded_landId[landId],pos)
515-
end
500+
Array.Remove(map.recorded_landId[landId],"this."..cubestr..".landlist.(*)"..n)
516501
end
517502
map.data[cubestr] = nil
518503
end,
@@ -1985,6 +1970,9 @@ RangeSelector = {
19851970
if checkColl.status then
19861971
local sp = cfg.land.min_space
19871972
local nearbyLands = ILAPI.GetLandInRange(Pos.Add(posA,sp),Pos.Reduce(pos,sp),dimid)
1973+
if MEM[xuid].reselectLand~=nil then
1974+
Array.Remove(nearbyLands,MEM[xuid].reselectLand.id)
1975+
end
19881976
if #nearbyLands ~= 0 then
19891977
SendText(player,_Tr('title.rangeselector.fail.space','<a>',MakeShortILD(nearbyLands[1])))
19901978
else
@@ -2303,7 +2291,7 @@ end
23032291
function ILAPI.DeleteLand(landId)
23042292
local owner=ILAPI.GetOwner(landId)
23052293
if owner~='?' then
2306-
table.remove(land_owners[owner],Array.Fetch(land_owners[owner],landId))
2294+
Array.Remove(land_owners[owner],landId)
23072295
end
23082296
Map.CachedQuery.RangeArea.refresh(landId)
23092297
Map.CachedQuery.SinglePos.refresh(landId)
@@ -2546,15 +2534,15 @@ function ILAPI.AddTrust(landId,xuid)
25462534
end
25472535
function ILAPI.RemoveTrust(landId,xuid)
25482536
local shareList = land_data[landId].settings.share
2549-
table.remove(shareList,Array.Fetch(shareList,xuid))
2537+
Array.Remove(shareList,xuid)
25502538
Map.Land.Trusted.update(landId)
25512539
ILAPI.save({0,1,0})
25522540
return true
25532541
end
25542542
function ILAPI.SetOwner(landId,xuid)
25552543
local ownerXuid = ILAPI.GetOwner(landId)
25562544
if ownerXuid ~= '?' then
2557-
table.remove(land_owners[ownerXuid],Array.Fetch(land_owners[ownerXuid],landId))
2545+
Array.Remove(land_owners[ownerXuid],landId)
25582546
end
25592547
table.insert(land_owners[xuid],#land_owners[xuid]+1,landId)
25602548
Map.Land.Owner.update(landId)
@@ -2671,9 +2659,9 @@ function ILAPI.SetRange(landId,newposA,newposB,newDimid)
26712659
land_data[landId].range.end_position = {posB.x,posB.y,posB.z}
26722660
land_data[landId].range.dimid = newDimid
26732661
land_data[landId].settings.tpoint = {posA.x,posA.y+1,posA.z}
2662+
Map.Land.Position.update(landId,'add')
26742663
Map.Land.Edge.update(landId,'add')
26752664
Map.Chunk.update(landId,'add')
2676-
Map.Land.Position.update(landId,'add')
26772665
Map.Land.AXIS.update(landId,'add')
26782666
Map.CachedQuery.RangeArea.refresh(landId)
26792667
Map.CachedQuery.SinglePos.refresh(landId)
@@ -2893,6 +2881,13 @@ Array = {
28932881
end
28942882
return origin
28952883
end,
2884+
Remove = function(array,value)
2885+
local pos = Array.Fetch(array,value)
2886+
if pos~=-1 then
2887+
table.remove(array,pos)
2888+
end
2889+
return array
2890+
end,
28962891
Reverse = function(tab)
28972892
local tmp_tab = table.clone(tab)
28982893
local rtn = {}
@@ -3669,7 +3664,7 @@ function RegisterCommands()
36693664
ERROR(_Tr('console.landop.del.failbynull','<a>',name))
36703665
return
36713666
end
3672-
table.remove(cfg.land.operator,Array.Fetch(cfg.land.operator,xuid))
3667+
Array.Remove(cfg.land.operator,xuid)
36733668
Map.Land.Operator.update()
36743669
ILAPI.save({1,0,0})
36753670
INFO('System',_Tr('console.landop.del.success','<a>',name,'<b>',xuid))

0 commit comments

Comments
 (0)