Updated Regions.InAreaRegion.Name to allow overlapping regions - For plugins that use this it will require updating the code

This commit is contained in:
darkunderdog 2012-01-04 20:11:22 -06:00
parent 62bc28332a
commit 6079d84c9e
2 changed files with 19 additions and 16 deletions

View file

@ -258,18 +258,19 @@ namespace TShockAPI.DB
return false; return false;
} }
public string InAreaRegionName(int x, int y) public List<string> InAreaRegionName(int x, int y)
{ {
List<string> regions = new List<string>() { };
foreach (Region region in Regions) foreach (Region region in Regions)
{ {
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 &&
region.DisableBuild) region.DisableBuild)
{ {
return region.Name; regions.Add(region.Name);
} }
} }
return null; return regions;
} }
public static List<string> ListIDs(string MergedIDs) public static List<string> ListIDs(string MergedIDs)

View file

@ -1197,13 +1197,15 @@ namespace TShockAPI
if (args.Player.AwaitingName) if (args.Player.AwaitingName)
{ {
if (TShock.Regions.InAreaRegionName(tileX, tileY) == null) var protectedregions = TShock.Regions.InAreaRegionName(tileX, tileY);
if (protectedregions.Count == 0)
{ {
args.Player.SendMessage("Region is not protected", Color.Yellow); args.Player.SendMessage("Region is not protected", Color.Yellow);
} }
else else
{ {
args.Player.SendMessage("Region Name: " + TShock.Regions.InAreaRegionName(tileX, tileY), Color.Yellow); string regionlist = string.Join(",", protectedregions.ToArray());
args.Player.SendMessage("Region Name(s): " + regionlist, Color.Yellow);
} }
args.Player.SendTileSquare(tileX, tileY); args.Player.SendTileSquare(tileX, tileY);
args.Player.AwaitingName = false; args.Player.AwaitingName = false;