Fixes some potential issues with concurrency, as well as cleaning up my z index check.
This commit is contained in:
parent
88a9c05220
commit
410f6cf872
1 changed files with 12 additions and 16 deletions
|
|
@ -238,17 +238,13 @@ namespace TShockAPI.DB
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Region top = null;
|
Region top = null;
|
||||||
for (int i = 0; i < Regions.Count; i++)
|
|
||||||
|
foreach (Region region in Regions.ToList())
|
||||||
{
|
{
|
||||||
if (Regions[i].InArea(x,y) )
|
if (region.InArea(x, y))
|
||||||
{
|
{
|
||||||
if (top == null)
|
if (top == null || region.Z > top.Z)
|
||||||
top = Regions[i];
|
top = region;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Regions[i].Z > top.Z)
|
|
||||||
top = Regions[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return top == null || top.HasPermissionToBuildInRegion(ply);
|
return top == null || top.HasPermissionToBuildInRegion(ply);
|
||||||
|
|
@ -256,7 +252,7 @@ namespace TShockAPI.DB
|
||||||
|
|
||||||
public bool InArea(int x, int y)
|
public bool InArea(int x, int y)
|
||||||
{
|
{
|
||||||
foreach (Region region in Regions)
|
foreach (Region region in Regions.ToList())
|
||||||
{
|
{
|
||||||
if (x >= region.Area.Left && x <= region.Area.Right &&
|
if (x >= region.Area.Left && x <= region.Area.Right &&
|
||||||
y >= region.Area.Top && y <= region.Area.Bottom &&
|
y >= region.Area.Top && y <= region.Area.Bottom &&
|
||||||
|
|
@ -271,7 +267,7 @@ namespace TShockAPI.DB
|
||||||
public List<string> InAreaRegionName(int x, int y)
|
public List<string> InAreaRegionName(int x, int y)
|
||||||
{
|
{
|
||||||
List<string> regions = new List<string>() { };
|
List<string> regions = new List<string>() { };
|
||||||
foreach (Region region in Regions)
|
foreach (Region region in Regions.ToList())
|
||||||
{
|
{
|
||||||
if (x >= region.Area.Left && x <= region.Area.Right &&
|
if (x >= region.Area.Left && x <= region.Area.Right &&
|
||||||
y >= region.Area.Top && y <= region.Area.Bottom &&
|
y >= region.Area.Top && y <= region.Area.Bottom &&
|
||||||
|
|
@ -286,7 +282,7 @@ namespace TShockAPI.DB
|
||||||
public List<Region> InAreaRegion(int x, int y)
|
public List<Region> InAreaRegion(int x, int y)
|
||||||
{
|
{
|
||||||
List<Region> regions = new List<Region>() { };
|
List<Region> regions = new List<Region>() { };
|
||||||
foreach (Region region in Regions)
|
foreach (Region region in Regions.ToList())
|
||||||
{
|
{
|
||||||
if (x >= region.Area.Left && x <= region.Area.Right &&
|
if (x >= region.Area.Left && x <= region.Area.Right &&
|
||||||
y >= region.Area.Top && y <= region.Area.Bottom &&
|
y >= region.Area.Top && y <= region.Area.Bottom &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue