From 6079d84c9ea54906c230b21277595812874eabe3 Mon Sep 17 00:00:00 2001 From: darkunderdog Date: Wed, 4 Jan 2012 20:11:22 -0600 Subject: [PATCH] Updated Regions.InAreaRegion.Name to allow overlapping regions - For plugins that use this it will require updating the code --- TShockAPI/DB/RegionManager.cs | 27 ++++++++++++++------------- TShockAPI/GetDataHandlers.cs | 8 +++++--- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 53c99a10..ccd96c63 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -258,19 +258,20 @@ namespace TShockAPI.DB return false; } - public string InAreaRegionName(int x, int y) - { - foreach (Region region in Regions) - { - if (x >= region.Area.Left && x <= region.Area.Right && - y >= region.Area.Top && y <= region.Area.Bottom && - region.DisableBuild) - { - return region.Name; - } - } - return null; - } + public List InAreaRegionName(int x, int y) + { + List regions = new List() { }; + foreach (Region region in Regions) + { + if (x >= region.Area.Left && x <= region.Area.Right && + y >= region.Area.Top && y <= region.Area.Bottom && + region.DisableBuild) + { + regions.Add(region.Name); + } + } + return regions; + } public static List ListIDs(string MergedIDs) { diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 558604ca..783ad398 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1197,13 +1197,15 @@ namespace TShockAPI 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); } 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.AwaitingName = false;