Moved unhandled exception logging to before saving the world. In case the world saving crashes.

Tidied some code.
New day, new version
This commit is contained in:
high 2011-06-28 10:56:47 -04:00
parent 923aa66694
commit dcf67248f7
4 changed files with 20 additions and 23 deletions

View file

@ -165,12 +165,11 @@ namespace TShockAPI
{ {
return Tools.HandleGriefer(args.Player, "Sent client info more than once"); return Tools.HandleGriefer(args.Player, "Sent client info more than once");
} }
if (ConfigurationManager.HardcoreOnly) if (ConfigurationManager.HardcoreOnly && !hardcore)
if (!hardcore) {
{ Tools.ForceKick(args.Player, "Server is set to hardcore characters only!");
Tools.ForceKick(args.Player, "Server is set to hardcore characters only!"); return true;
return true; }
}
args.Player.ReceivedInfo = true; args.Player.ReceivedInfo = true;
return false; return false;
@ -295,13 +294,13 @@ namespace TShockAPI
if (!args.Player.TilesDestroyed.ContainsKey(coords)) if (!args.Player.TilesDestroyed.ContainsKey(coords))
args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]); args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]);
} }
if (args.Player.LastExplosive != null)
if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000) 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.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds).ToString() + " milliseconds before placing/destroying tiles", Color.Red);
args.Player.SendTileSquare(x, y); args.Player.SendTileSquare(x, y);
return true; return true;
} }
return false; return false;
} }

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.0.0627")] [assembly: AssemblyVersion("2.3.0.0628")]
[assembly: AssemblyFileVersion("2.3.0.0627")] [assembly: AssemblyFileVersion("2.3.0.0628")]

View file

@ -71,9 +71,11 @@ namespace TShockAPI
{ {
foreach(Region region in Regions) 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; return true;
} }
} }

View file

@ -138,6 +138,7 @@ namespace TShockAPI
/// <param name="e"></param> /// <param name="e"></param>
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
Log.Error(e.ExceptionObject.ToString());
if (e.IsTerminating) if (e.IsTerminating)
{ {
if (Main.worldPathName != null) if (Main.worldPathName != null)
@ -147,7 +148,6 @@ namespace TShockAPI
} }
DeInitialize(); DeInitialize();
} }
Log.Error(e.ExceptionObject.ToString());
} }
private void HandleCommandLine(string[] parms) private void HandleCommandLine(string[] parms)
@ -537,11 +537,7 @@ namespace TShockAPI
{ {
Vector2 tile = new Vector2(x, y); Vector2 tile = new Vector2(x, y);
Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY); Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY);
var distance = Vector2.Distance(spawn, tile); return Vector2.Distance(spawn, tile) <= ConfigurationManager.SpawnProtectRadius;
if (distance > ConfigurationManager.SpawnProtectRadius)
return false;
else
return true;
} }
public static bool HackedHealth(TSPlayer player) public static bool HackedHealth(TSPlayer player)