diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 41b11c18..12b43c99 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -978,7 +978,7 @@ namespace TShockAPI var plr = players[0]; if (plr.Teleport(args.Player.TileX, args.Player.TileY + 3)) { - plr.SendMessage(string.Format("You were teleported to {0}.", plr.Name)); + plr.SendMessage(string.Format("You were teleported to {0}.", args.Player.Name)); args.Player.SendMessage(string.Format("You brought {0} here.", plr.Name)); } diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index f99a8cbd..d5d4d2b8 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -170,45 +170,21 @@ namespace TShockAPI.DB public bool InProtectedArea(int X, int Y, User user) //This whole thing is dumb { - try + Rectangle r = new Rectangle(X, Y, 0, 0); + for (int i = 0; i < RegionArray.Length; i++) { - using (var com = database.CreateCommand()) + if (RegionArray[i].RegionArea.Intersects(r)) { - com.CommandText = "SELECT * FROM Regions WHERE WorldID=@worldid"; - com.AddParameter("@worldid", Main.worldID.ToString()); - using (var reader = com.ExecuteReader()) + for (int j = 0; j < RegionArray[i].RegionAllowedIDs.Length; j++) { - while (reader.Read()) + if (RegionArray[i].RegionAllowedIDs[j] == user.Name) { - int X1 = reader.Get("X1"); - int Y1 = reader.Get("Y1"); - int height = reader.Get("height"); - int width = reader.Get("width"); - int Protected = reader.Get("Protected"); - string MergedIDs = DbExt.Get(reader, "UserIds"); - - string[] SplitIDs = MergedIDs.Split(','); - - if (X >= X1 && - X <= height && - Y >= Y1 && - Y <= width && - Protected == 1) - { - if (!SplitIDs.Contains(user.ID.ToString())) - return true; - } + return true; } - reader.Close(); } } - return false; - } - catch (Exception ex) - { - Log.Error(ex.ToString()); - return false; } + return false; } public static List ListIDs(string MergedIDs)