From dcf67248f7da7478f1d404816b9010fb8bbc4c88 Mon Sep 17 00:00:00 2001 From: high Date: Tue, 28 Jun 2011 10:56:47 -0400 Subject: [PATCH] Moved unhandled exception logging to before saving the world. In case the world saving crashes. Tidied some code. New day, new version --- TShockAPI/GetDataHandlers.cs | 25 ++++++++++++------------- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- TShockAPI/RegionManager.cs | 6 ++++-- TShockAPI/TShock.cs | 8 ++------ 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 94bd517f..4932a15d 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -165,12 +165,11 @@ namespace TShockAPI { return Tools.HandleGriefer(args.Player, "Sent client info more than once"); } - if (ConfigurationManager.HardcoreOnly) - if (!hardcore) - { - Tools.ForceKick(args.Player, "Server is set to hardcore characters only!"); - return true; - } + if (ConfigurationManager.HardcoreOnly && !hardcore) + { + Tools.ForceKick(args.Player, "Server is set to hardcore characters only!"); + return true; + } args.Player.ReceivedInfo = true; return false; @@ -295,13 +294,13 @@ namespace TShockAPI if (!args.Player.TilesDestroyed.ContainsKey(coords)) args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]); } - if (args.Player.LastExplosive != null) - if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000) - { - args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds).ToString() + " milliseconds before placing/destroying tiles", Color.Red); - args.Player.SendTileSquare(x, y); - return true; - } + + if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000) + { + args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds).ToString() + " milliseconds before placing/destroying tiles", Color.Red); + args.Player.SendTileSquare(x, y); + return true; + } return false; } diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 9bbabf72..8d310394 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.0.0627")] -[assembly: AssemblyFileVersion("2.3.0.0627")] \ No newline at end of file +[assembly: AssemblyVersion("2.3.0.0628")] +[assembly: AssemblyFileVersion("2.3.0.0628")] \ No newline at end of file diff --git a/TShockAPI/RegionManager.cs b/TShockAPI/RegionManager.cs index 1a7ccf5e..4d48fb8c 100644 --- a/TShockAPI/RegionManager.cs +++ b/TShockAPI/RegionManager.cs @@ -71,9 +71,11 @@ namespace TShockAPI { foreach(Region region in Regions) { - if (X >= region.RegionArea.Left && X <= region.RegionArea.Right && Y >= region.RegionArea.Top && Y <= region.RegionArea.Bottom && region.DisableBuild && Main.worldName == region.WorldRegionName && (!AllowedUser(region.RegionName, IP.ToLower()) || region.RegionAllowedIPs.Count == 0)) + if (X >= region.RegionArea.Left && X <= region.RegionArea.Right && + Y >= region.RegionArea.Top && Y <= region.RegionArea.Bottom && + region.DisableBuild && Main.worldName == region.WorldRegionName && + (!AllowedUser(region.RegionName, IP.ToLower()) || region.RegionAllowedIPs.Count == 0)) { - Console.WriteLine(region.RegionName); return true; } } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 99d0f6f7..19e71a65 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -138,6 +138,7 @@ namespace TShockAPI /// private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { + Log.Error(e.ExceptionObject.ToString()); if (e.IsTerminating) { if (Main.worldPathName != null) @@ -147,7 +148,6 @@ namespace TShockAPI } DeInitialize(); } - Log.Error(e.ExceptionObject.ToString()); } private void HandleCommandLine(string[] parms) @@ -537,11 +537,7 @@ namespace TShockAPI { Vector2 tile = new Vector2(x, y); Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY); - var distance = Vector2.Distance(spawn, tile); - if (distance > ConfigurationManager.SpawnProtectRadius) - return false; - else - return true; + return Vector2.Distance(spawn, tile) <= ConfigurationManager.SpawnProtectRadius; } public static bool HackedHealth(TSPlayer player)