Added some config options for the unsafe fixes.

This commit is contained in:
Lucas Nicodemus 2011-12-11 10:58:55 -07:00
parent e1cd9f6bd4
commit a418ada6f5
3 changed files with 24 additions and 5 deletions

View file

@ -204,6 +204,12 @@ namespace TShockAPI
[Description("Displays a player's IP on join to everyone who has the log permission")]
public bool DisplayIPToAdmins = false;
[Description("Some tiles are 'fixed' by not letting TShock handle them. Disabling this may break certain asthetic tiles.")]
public bool EnableInsecureTileFixes = true;
[Description("Some weapons override the range checks, however malicious users can take advantage of this and send lots of packets of certain types. Disabling this will turn off weapons that affect this.")]
public bool EnableRangeCheckOverrides = true;
public static ConfigFile Read(string path)
{

View file

@ -257,9 +257,11 @@ namespace TShockAPI
var newtile = tiles[x, y];
if ((tile.type == 128 && newtile.Type == 128) || (tile.type == 105 && newtile.Type == 105))
{
Console.WriteLine("SendTileSquareCalled on a 128 or 105.");
changed = true;
return false;
//Console.WriteLine("SendTileSquareCalled on a 128 or 105.");
if (TShock.Config.EnableInsecureTileFixes)
{
return false;
}
}
if (tile.type == 0x17 && newtile.Type == 0x2)
@ -346,7 +348,14 @@ namespace TShockAPI
}
if (TShock.Config.RangeChecks && ((Math.Abs(plyX - tileX) > 32) || (Math.Abs(plyY - tileY) > 32)))
{
if (!(type == 1 && ((tiletype == 0 && args.Player.TPlayer.selectedItem == 114) || (tiletype == 127 && args.Player.TPlayer.selectedItem == 496)|| (tiletype == 53 && args.Player.TPlayer.selectedItem == 266))))
if ((type == 1 && ((tiletype == 0 && args.Player.TPlayer.selectedItem == 114) || (tiletype == 127 && args.Player.TPlayer.selectedItem == 496)|| (tiletype == 53 && args.Player.TPlayer.selectedItem == 266))))
{
if (!TShock.Config.EnableRangeCheckOverrides)
{
args.Player.SendMessage("This item has been disabled by the server owner.");
return true;
}
} else
{
Log.Debug(string.Format("TilePlaced(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Type:{6})",
plyX, plyY, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), tiletype));

View file

@ -32,6 +32,7 @@ using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using Community.CsharpSqlite.SQLiteClient;
using Hooks;
@ -47,7 +48,7 @@ namespace TShockAPI
[APIVersion(1, 9)]
public class TShock : TerrariaPlugin
{
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
public static readonly string VersionCodename = "1.1 broke our API";
public static string SavePath = "tshock";
@ -103,6 +104,8 @@ namespace TShockAPI
Order = 0;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public override void Initialize()
{
@ -216,6 +219,7 @@ namespace TShockAPI
Log.Error(ex.ToString());
Environment.Exit(1);
}
}
private void callHome()