Resharper code cleanup, including:

- Optimized using statements
 - Removal of redundant code
This commit is contained in:
Lucas Nicodemus 2011-07-26 23:37:06 -06:00
parent 3dd7af1a30
commit 37146adb4c
23 changed files with 141 additions and 185 deletions

View file

@ -18,10 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using Terraria; using Terraria;

View file

@ -17,12 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Text;
using System.Threading; using System.Threading;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria; using Terraria;
@ -370,7 +369,7 @@ namespace TShockAPI
catch (UserManagerException ex) catch (UserManagerException ex)
{ {
args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green); args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green);
Log.ConsoleError("RegisterUser returned an error: " + ex.ToString()); Log.ConsoleError("RegisterUser returned an error: " + ex);
} }
} }
@ -406,7 +405,7 @@ namespace TShockAPI
catch (UserManagerException ex) catch (UserManagerException ex)
{ {
args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green); args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green);
Log.ConsoleError("RegisterUser returned an error: " + ex.ToString()); Log.ConsoleError("RegisterUser returned an error: " + ex);
} }
} }
@ -936,7 +935,7 @@ namespace TShockAPI
return; return;
} }
NPC eater = Tools.GetNPCById(13); NPC eater = Tools.GetNPCById(13);
TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned eater of worlds {1} times!", args.Player.Name, amount)); Tools.Broadcast(string.Format("{0} has spawned eater of worlds {1} times!", args.Player.Name, amount));
} }
@ -955,7 +954,7 @@ namespace TShockAPI
} }
NPC eye = Tools.GetNPCById(4); NPC eye = Tools.GetNPCById(4);
TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned eye {1} times!", args.Player.Name, amount)); Tools.Broadcast(string.Format("{0} has spawned eye {1} times!", args.Player.Name, amount));
} }
@ -973,7 +972,7 @@ namespace TShockAPI
return; return;
} }
NPC king = Tools.GetNPCById(50); NPC king = Tools.GetNPCById(50);
TSPlayer.Server.SpawnNPC(king.type, king.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(king.type, king.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned king slime {1} times!", args.Player.Name, amount)); Tools.Broadcast(string.Format("{0} has spawned king slime {1} times!", args.Player.Name, amount));
} }
@ -992,7 +991,7 @@ namespace TShockAPI
} }
NPC skeletron = Tools.GetNPCById(35); NPC skeletron = Tools.GetNPCById(35);
TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned skeletron {1} times!", args.Player.Name, amount)); Tools.Broadcast(string.Format("{0} has spawned skeletron {1} times!", args.Player.Name, amount));
} }
@ -1014,10 +1013,10 @@ namespace TShockAPI
NPC king = Tools.GetNPCById(50); NPC king = Tools.GetNPCById(50);
NPC skeletron = Tools.GetNPCById(35); NPC skeletron = Tools.GetNPCById(35);
TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.Server.SpawnNPC(king.type, king.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(king.type, king.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, (int)args.Player.TileX, (int)args.Player.TileY); TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned all bosses {1} times!", args.Player.Name, amount)); Tools.Broadcast(string.Format("{0} has spawned all bosses {1} times!", args.Player.Name, amount));
} }
@ -1054,7 +1053,7 @@ namespace TShockAPI
var npc = npcs[0]; var npc = npcs[0];
if (npc.type >= 1 && npc.type < Main.maxNPCTypes) if (npc.type >= 1 && npc.type < Main.maxNPCTypes)
{ {
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, (int)args.Player.TileX, (int)args.Player.TileY, 50, 20); TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY, 50, 20);
Tools.Broadcast(string.Format("{0} was spawned {1} time(s).", npc.name, amount)); Tools.Broadcast(string.Format("{0} was spawned {1} time(s).", npc.name, amount));
} }
else else
@ -1988,8 +1987,8 @@ namespace TShockAPI
else else
{ {
var ply = players[0]; var ply = players[0];
args.Player.SendMessage("Annoying " + ply.Name + " for " + annoy.ToString() + " seconds."); args.Player.SendMessage("Annoying " + ply.Name + " for " + annoy + " seconds.");
(new Thread(new ParameterizedThreadStart(ply.Whoopie))).Start(annoy); (new Thread(ply.Whoopie)).Start(annoy);
} }
} }
#endregion General Commands #endregion General Commands
@ -2080,7 +2079,7 @@ namespace TShockAPI
if (itemAmount == 0 || itemAmount > item.maxStack) if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack; itemAmount = item.maxStack;
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount); args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount.ToString(), item.name)); args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
} }
else else
{ {
@ -2150,8 +2149,8 @@ namespace TShockAPI
if (itemAmount == 0 || itemAmount > item.maxStack) if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack; itemAmount = item.maxStack;
plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount); plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount.ToString(), item.name)); args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name));
plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount.ToString(), item.name)); plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
} }
else else
{ {

View file

@ -27,9 +27,9 @@ namespace TShockAPI
public int DefaultMaximumSpawns = 4; public int DefaultMaximumSpawns = 4;
public int DefaultSpawnRate = 700; public int DefaultSpawnRate = 700;
public int ServerPort = 7777; public int ServerPort = 7777;
public bool EnableWhitelist = false; public bool EnableWhitelist;
public bool InfiniteInvasion = false; public bool InfiniteInvasion;
public bool AlwaysPvP = false; public bool AlwaysPvP;
public bool KickCheaters = true; public bool KickCheaters = true;
public bool BanCheaters = true; public bool BanCheaters = true;
public bool KickGriefers = true; public bool KickGriefers = true;
@ -44,24 +44,24 @@ namespace TShockAPI
public string DistributationAgent = "facepunch"; public string DistributationAgent = "facepunch";
public int MaxSlots = 8; public int MaxSlots = 8;
public bool RangeChecks = true; public bool RangeChecks = true;
public bool SpamChecks = false; public bool SpamChecks;
public bool DisableBuild = false; public bool DisableBuild;
public int TileThreshold = 60; public int TileThreshold = 60;
public float[] AdminChatRGB = { 255, 0, 0 }; public float[] AdminChatRGB = { 255, 0, 0 };
public string AdminChatPrefix = "(Admin) "; public string AdminChatPrefix = "(Admin) ";
public bool AdminChatEnabled = true; public bool AdminChatEnabled = true;
public int PvpThrottle = 0; public int PvpThrottle;
public int BackupInterval = 0; public int BackupInterval;
public int BackupKeepFor = 60; public int BackupKeepFor = 60;
public bool RememberLeavePos = false; public bool RememberLeavePos;
public bool HardcoreOnly = false; public bool HardcoreOnly;
public bool KickOnHardcoreDeath = false; public bool KickOnHardcoreDeath;
public bool BanOnHardcoreDeath = false; public bool BanOnHardcoreDeath;
public bool AutoSave = true; public bool AutoSave = true;
@ -94,9 +94,9 @@ namespace TShockAPI
public string HardcoreBanReason = "Death results in a ban"; public string HardcoreBanReason = "Death results in a ban";
public string HardcoreKickReason = "Death results in a kick"; public string HardcoreKickReason = "Death results in a kick";
public bool EnableDNSHostResolution = false; public bool EnableDNSHostResolution;
public bool EnableBanOnUsernames = false; public bool EnableBanOnUsernames;
public bool EnableAntiLag = true; public bool EnableAntiLag = true;

View file

@ -17,12 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Text;
using Community.CsharpSqlite.SQLiteClient;
using TShockAPI.DB;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {
@ -63,7 +59,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs"); String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "bans.txt"); String file2 = Path.Combine(path, "bans.txt");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path); Directory.CreateDirectory(path);
if (File.Exists(file2)) if (File.Exists(file2))
File.Delete(file2); File.Delete(file2);
File.Move(file, file2); File.Move(file, file2);

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq;
using System.Text;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {
@ -55,8 +53,8 @@ namespace TShockAPI.DB
return parm; return parm;
} }
static Dictionary<Type, Func<IDataReader, int, object>> ReadFuncs = new Dictionary<Type, Func<IDataReader, int, object>>() static Dictionary<Type, Func<IDataReader, int, object>> ReadFuncs = new Dictionary<Type, Func<IDataReader, int, object>>
{ {
{typeof(bool), (s, i) => s.GetBoolean(i)}, {typeof(bool), (s, i) => s.GetBoolean(i)},
{typeof(byte), (s, i) => s.GetByte(i)}, {typeof(byte), (s, i) => s.GetByte(i)},
{typeof(Int16), (s, i) => s.GetInt16(i)}, {typeof(Int16), (s, i) => s.GetInt16(i)},

View file

@ -1,10 +1,8 @@
using System; using System;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; using System.Data;
using Community.CsharpSqlite.SQLiteClient; using System.IO;
using System.Linq;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {
@ -72,7 +70,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs"); String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "groups.txt"); String file2 = Path.Combine(path, "groups.txt");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path); Directory.CreateDirectory(path);
if (File.Exists(file2)) if (File.Exists(file2))
File.Delete(file2); File.Delete(file2);
File.Move(file, file2); File.Move(file, file2);

View file

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; using System.Data;
using Community.CsharpSqlite.SQLiteClient;
using TShockAPI.DB;
using System.IO; using System.IO;
namespace TShockAPI.DB namespace TShockAPI.DB
@ -50,7 +46,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs"); String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "itembans.txt"); String file2 = Path.Combine(path, "itembans.txt");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path); Directory.CreateDirectory(path);
if (File.Exists(file2)) if (File.Exists(file2))
File.Delete(file2); File.Delete(file2);
File.Move(file, file2); File.Move(file, file2);

View file

@ -18,17 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Data; using System.Data;
using TShockAPI.DB; using System.IO;
using Community.CsharpSqlite.SQLiteClient; using System.Xml;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria; using Terraria;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {
public class RegionManager public class RegionManager
@ -171,8 +166,8 @@ namespace TShockAPI.DB
int height = reader.Get<int>("height"); int height = reader.Get<int>("height");
int width = reader.Get<int>("width"); int width = reader.Get<int>("width");
int Protected = reader.Get<int>("Protected"); int Protected = reader.Get<int>("Protected");
string MergedIDs = DbExt.Get<string>(reader, "UserIds"); string MergedIDs = reader.Get<string>("UserIds");
string name = DbExt.Get<string>(reader, "RegionName"); string name = reader.Get<string>("RegionName");
string[] SplitIDs = MergedIDs.Split(','); string[] SplitIDs = MergedIDs.Split(',');
@ -215,8 +210,8 @@ namespace TShockAPI.DB
int height = reader.Get<int>("height"); int height = reader.Get<int>("height");
int width = reader.Get<int>("width"); int width = reader.Get<int>("width");
int Protected = reader.Get<int>("Protected"); int Protected = reader.Get<int>("Protected");
string MergedIDs = DbExt.Get<string>(reader, "UserIds"); string MergedIDs = reader.Get<string>("UserIds");
string name = DbExt.Get<string>(reader, "RegionName"); string name = reader.Get<string>("RegionName");
string[] SplitIDs = MergedIDs.Split(','); string[] SplitIDs = MergedIDs.Split(',');
Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected != 0, Main.worldID.ToString()); Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected != 0, Main.worldID.ToString());

View file

@ -1,9 +1,4 @@
using System; namespace TShockAPI.DB
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TShockAPI.DB
{ {
class SqlTable class SqlTable
{ {

View file

@ -18,12 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.IO;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.IO;
using System.Text;
using Community.CsharpSqlite.SQLiteClient;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {
public class UserManager public class UserManager
@ -82,7 +79,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs"); String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "users.txt"); String file2 = Path.Combine(path, "users.txt");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path); Directory.CreateDirectory(path);
if (File.Exists(file2)) if (File.Exists(file2))
File.Delete(file2); File.Delete(file2);
File.Move(file, file2); File.Move(file, file2);
@ -201,7 +198,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex.ToString()); Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex);
} }
return returndata; return returndata;
} }
@ -220,7 +217,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex.ToString()); Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex);
} }
return -1; return -1;
} }
@ -244,7 +241,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex.ToString()); Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex);
} }
return Tools.GetGroup("default"); return Tools.GetGroup("default");
} }
@ -266,7 +263,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex.ToString()); Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex);
} }
return Tools.GetGroup("default"); return Tools.GetGroup("default");
} }

View file

@ -20,8 +20,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
using Microsoft.Xna.Framework;
using System.Xml; using System.Xml;
using Microsoft.Xna.Framework;
using Terraria; using Terraria;
namespace TShockAPI.DB namespace TShockAPI.DB
@ -111,7 +111,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs"); String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "warps.xml"); String file2 = Path.Combine(path, "warps.xml");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path); Directory.CreateDirectory(path);
if (File.Exists(file2)) if (File.Exists(file2))
File.Delete(file2); File.Delete(file2);
//File.Move(file, file2); //File.Move(file, file2);

View file

@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.IO; using System.IO;
using Terraria;
namespace TShockAPI namespace TShockAPI
{ {

View file

@ -340,7 +340,7 @@ namespace TShockAPI
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) + " milliseconds before placing/destroying tiles", Color.Red);
args.Player.SendTileSquare(x, y); args.Player.SendTileSquare(x, y);
return true; return true;
} }

View file

@ -16,11 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
namespace TShockAPI namespace TShockAPI
{ {

View file

@ -17,10 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using Terraria; using Terraria;
using XNAHelpers; using XNAHelpers;

View file

@ -17,11 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using Terraria;
using TerrariaAPI; using TerrariaAPI;
using XNAHelpers; using XNAHelpers;

View file

@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.4.0724")] [assembly: AssemblyVersion("3.1.4.0726")]
[assembly: AssemblyFileVersion("3.1.4.0724")] [assembly: AssemblyFileVersion("3.1.4.0726")]

View file

@ -18,12 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text;
using System.Threading;
using Terraria; using Terraria;
namespace TShockAPI namespace TShockAPI
@ -36,7 +35,7 @@ namespace TShockAPI
public static int ListenPort; public static int ListenPort;
public static bool ContinueServer = true; public static bool ContinueServer = true;
public static string Response = ""; public static string Response = "";
private static bool Started = false; private static bool Started;
private static UdpClient listener; private static UdpClient listener;
public static void StartThread() public static void StartThread()
@ -55,9 +54,9 @@ namespace TShockAPI
try try
{ {
Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}", Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}",
ListenPort.ToString(), ListenPort,
Password)); Password));
Thread listen = new Thread(new ThreadStart(Listener)); Thread listen = new Thread(Listener);
listen.Start(); listen.Start();
while (true) while (true)
{ {
@ -87,7 +86,7 @@ namespace TShockAPI
catch (SocketException e) catch (SocketException e)
{ {
if (e.SocketErrorCode == SocketError.AddressAlreadyInUse) if (e.SocketErrorCode == SocketError.AddressAlreadyInUse)
Log.ConsoleError("Could not bind to " + ListenPort.ToString() + ". Are you sure you don't have another instance running?"); Log.ConsoleError("Could not bind to " + ListenPort + ". Are you sure you don't have another instance running?");
} }
catch (Exception e) catch (Exception e)
{ {
@ -150,7 +149,7 @@ namespace TShockAPI
args[1] = args[0] = ""; args[1] = args[0] = "";
string command = string.Join(" ", args.ToArray()); string command = string.Join(" ", args.ToArray());
command = command.TrimEnd(' ').TrimEnd('\0').TrimStart(' '); command = command.TrimEnd(' ').TrimEnd('\0').TrimStart(' ');
Log.ConsoleInfo("Rcon from " + EP.ToString() + ":" + command); Log.ConsoleInfo("Rcon from " + EP + ":" + command);
Response = ""; Response = "";
response = ExecuteCommand(command); response = ExecuteCommand(command);
response += "\n" + Response; response += "\n" + Response;
@ -160,7 +159,7 @@ namespace TShockAPI
else else
{ {
response = "Bad rconpassword.\n"; response = "Bad rconpassword.\n";
Log.ConsoleInfo("Bad rconpassword from " + EP.ToString()); Log.ConsoleInfo("Bad rconpassword from " + EP);
} }
} }
else else
@ -186,7 +185,7 @@ namespace TShockAPI
var infostring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}", var infostring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}",
TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers, TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers,
Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots, Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots,
TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum.ToString(), TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum,
Netplay.password != "" ? 1 : 0); Netplay.password != "" ? 1 : 0);
if (challenge != "") if (challenge != "")
infostring += @"\challenge\" + challenge; infostring += @"\challenge\" + challenge;
@ -205,7 +204,7 @@ namespace TShockAPI
var statusstring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}", var statusstring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}",
TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers, TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers,
Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots, Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots,
TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum.ToString(), TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum,
Netplay.password != "" ? 1 : 0) + "\n"; Netplay.password != "" ? 1 : 0) + "\n";
if (challenge != "") if (challenge != "")
statusstring += @"\challenge\" + challenge; statusstring += @"\challenge\" + challenge;
@ -260,7 +259,7 @@ namespace TShockAPI
if (player != null && player.Active) if (player != null && player.Active)
{ {
count++; count++;
Response += (string.Format("{0} 0 0 {1}({2}) {3} {4} 0 0", count, player.Name, player.Group.Name, Netplay.serverSock[player.Index].tcpClient.Client.RemoteEndPoint.ToString())) + "\n"; Response += (string.Format("{0} 0 0 {1}({2}) {3} {4} 0 0", count, player.Name, player.Group.Name, Netplay.serverSock[player.Index].tcpClient.Client.RemoteEndPoint)) + "\n";
} }
} }
} }
@ -334,7 +333,7 @@ namespace TShockAPI
catch (SocketException e) catch (SocketException e)
{ {
if (e.SocketErrorCode == SocketError.AddressAlreadyInUse) if (e.SocketErrorCode == SocketError.AddressAlreadyInUse)
Log.ConsoleError("Could not bind to " + ListenPort.ToString() + ". Are you sure you don't have another instance running?"); Log.ConsoleError("Could not bind to " + ListenPort + ". Are you sure you don't have another instance running?");
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -18,12 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Terraria;
using Microsoft.Xna.Framework;
using System.Xml; using System.Xml;
using Microsoft.Xna.Framework;
namespace TShockAPI namespace TShockAPI
{ {

View file

@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria; using Terraria;
using TerrariaAPI; using TerrariaAPI;
using TShockAPI.DB;
using TShockAPI.Net; using TShockAPI.Net;
namespace TShockAPI namespace TShockAPI
@ -38,21 +38,21 @@ namespace TShockAPI
public bool ReceivedInfo { get; set; } public bool ReceivedInfo { get; set; }
public int Index { get; protected set; } public int Index { get; protected set; }
public DateTime LastPvpChange { get; protected set; } public DateTime LastPvpChange { get; protected set; }
public Rectangle TempArea = new Rectangle(); public Rectangle TempArea;
public DateTime LastExplosive { get; set; } public DateTime LastExplosive { get; set; }
public DateTime LastTileChangeNotify { get; set; } public DateTime LastTileChangeNotify { get; set; }
public bool InitSpawn = false; public bool InitSpawn;
public bool DisplayLogs = true; public bool DisplayLogs = true;
public Vector2 oldSpawn = Vector2.Zero; public Vector2 oldSpawn = Vector2.Zero;
public TSPlayer LastWhisper; public TSPlayer LastWhisper;
public int LoginAttempts { get; set; } public int LoginAttempts { get; set; }
public Vector2 TeleportCoords = new Vector2(-1, -1); public Vector2 TeleportCoords = new Vector2(-1, -1);
public string UserAccountName { get; set; } public string UserAccountName { get; set; }
public bool HasBeenSpammedWithBuildMessage = false; public bool HasBeenSpammedWithBuildMessage;
public bool IsLoggedIn = false; public bool IsLoggedIn;
public int UserID = -1; public int UserID = -1;
public bool HasBeenNaggedAboutLoggingIn = false; public bool HasBeenNaggedAboutLoggingIn;
Player FakePlayer = null; Player FakePlayer;
public bool RealPlayer public bool RealPlayer
{ {
@ -241,7 +241,7 @@ namespace TShockAPI
{ {
try try
{ {
SendData(PacketTypes.TileSendSquare, "", size, (float)(x - (size / 2)), (float)(y - (size / 2))); SendData(PacketTypes.TileSendSquare, "", size, (x - (size / 2)), (y - (size / 2)));
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
@ -253,7 +253,7 @@ namespace TShockAPI
public virtual void GiveItem(int type, string name, int width, int height, int stack) public virtual void GiveItem(int type, string name, int width, int height, int stack)
{ {
int itemid = Terraria.Item.NewItem((int)X, (int)Y, width, height, type, stack, true); int itemid = Item.NewItem((int)X, (int)Y, width, height, type, stack, true);
// This is for special pickaxe/hammers/swords etc // This is for special pickaxe/hammers/swords etc
Main.item[itemid].SetDefaults(name); Main.item[itemid].SetDefaults(name);
// The set default overrides the wet and stack set by NewItem // The set default overrides the wet and stack set by NewItem
@ -310,18 +310,18 @@ namespace TShockAPI
{ {
Main.player[0].inventory[player].SetDefaults("Whoopie Cushion"); Main.player[0].inventory[player].SetDefaults("Whoopie Cushion");
Main.player[0].inventory[player].stack = 1; Main.player[0].inventory[player].stack = 1;
SendData(TerrariaAPI.PacketTypes.PlayerSlot, "Whoopie Cushion", player, 0f); SendData(PacketTypes.PlayerSlot, "Whoopie Cushion", player, 0f);
Main.player[player].position = TPlayer.position; Main.player[player].position = TPlayer.position;
Main.player[player].selectedItem = 0; Main.player[player].selectedItem = 0;
Main.player[player].controlUseItem = true; Main.player[player].controlUseItem = true;
SendData(TerrariaAPI.PacketTypes.PlayerUpdate, number: player); SendData(PacketTypes.PlayerUpdate, number: player);
System.Threading.Thread.Sleep(500); Thread.Sleep(500);
Main.player[player].controlUseItem = false; Main.player[player].controlUseItem = false;
SendData(TerrariaAPI.PacketTypes.PlayerUpdate, number: player); SendData(PacketTypes.PlayerUpdate, number: player);
System.Threading.Thread.Sleep(50); Thread.Sleep(50);
} }
Main.player[0].inventory[0] = oriinv; Main.player[0].inventory[0] = oriinv;
SendData(TerrariaAPI.PacketTypes.PlayerSlot, oriinv.name, player, 0f); SendData(PacketTypes.PlayerSlot, oriinv.name, player, 0f);
} }
//Todo: Separate this into a few functions. SendTo, SendToAll, etc //Todo: Separate this into a few functions. SendTo, SendToAll, etc
@ -423,7 +423,7 @@ namespace TShockAPI
// Send all players updated tile sqaures // Send all players updated tile sqaures
foreach (Vector2 coords in destroyedTiles.Keys) foreach (Vector2 coords in destroyedTiles.Keys)
{ {
TSPlayer.All.SendTileSquare((int)coords.X, (int)coords.Y, 3); All.SendTileSquare((int)coords.X, (int)coords.Y, 3);
} }
} }
} }

View file

@ -32,16 +32,14 @@ using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
using System.Threading; using System.Threading;
using MySql.Data.MySqlClient;
using Community.CsharpSqlite.SQLiteClient; using Community.CsharpSqlite.SQLiteClient;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using MySql.Data.MySqlClient;
using Microsoft.Xna.Framework.Graphics;
using Terraria; using Terraria;
using TerrariaAPI; using TerrariaAPI;
using TerrariaAPI.Hooks; using TerrariaAPI.Hooks;
using System.Text;
using TShockAPI.DB; using TShockAPI.DB;
namespace TShockAPI namespace TShockAPI
@ -68,7 +66,7 @@ namespace TShockAPI
public static IDbConnection DB; public static IDbConnection DB;
public static Process TShockProcess; public static Process TShockProcess;
public static bool OverridePort = false; public static bool OverridePort;
public static double ElapsedTime; public static double ElapsedTime;
@ -136,13 +134,14 @@ namespace TShockAPI
{ {
var hostport = Config.MySqlHost.Split(':'); var hostport = Config.MySqlHost.Split(':');
DB = new MySqlConnection(); DB = new MySqlConnection();
DB.ConnectionString = String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';", DB.ConnectionString =
hostport[0], String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';",
hostport.Length > 1 ? hostport[1] : "3306", hostport[0],
Config.MySqlDbName, hostport.Length > 1 ? hostport[1] : "3306",
Config.MySqlUsername, Config.MySqlDbName,
Config.MySqlPassword Config.MySqlUsername,
); Config.MySqlPassword
);
DB.Open(); DB.Open();
} }
catch (MySqlException ex) catch (MySqlException ex)
@ -178,17 +177,17 @@ namespace TShockAPI
NetHooks.GetData += GetData; NetHooks.GetData += GetData;
NetHooks.GreetPlayer += OnGreetPlayer; NetHooks.GreetPlayer += OnGreetPlayer;
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc; NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
NetHooks.SendData += new NetHooks.SendDataD(NetHooks_SendData); NetHooks.SendData += NetHooks_SendData;
GetDataHandlers.InitGetDataHandler(); GetDataHandlers.InitGetDataHandler();
Commands.InitCommands(); Commands.InitCommands();
//RconHandler.StartThread(); //RconHandler.StartThread();
Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled")); Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled")); Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
} }
void NetHooks_SendData(SendDataEventArgs e) private void NetHooks_SendData(SendDataEventArgs e)
{ {
if (e.MsgID == PacketTypes.PlayerActive) if (e.MsgID == PacketTypes.PlayerActive)
{ {
@ -305,11 +304,12 @@ namespace TShockAPI
*/ */
public static int AuthToken = -1; public static int AuthToken = -1;
private void OnPostInit() private void OnPostInit()
{ {
if (!File.Exists(Path.Combine(SavePath, "auth.lck")) && !File.Exists(Path.Combine(SavePath, "authcode.txt"))) if (!File.Exists(Path.Combine(SavePath, "auth.lck")) && !File.Exists(Path.Combine(SavePath, "authcode.txt")))
{ {
var r = new Random((int)DateTime.Now.ToBinary()); var r = new Random((int) DateTime.Now.ToBinary());
AuthToken = r.Next(100000, 10000000); AuthToken = r.Next(100000, 10000000);
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken); Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken);
@ -326,7 +326,8 @@ namespace TShockAPI
AuthToken = Convert.ToInt32(tr.ReadLine()); AuthToken = Convert.ToInt32(tr.ReadLine());
tr.Close(); tr.Close();
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("TShock Notice: authcode.txt is still present, and the AuthToken located in that file will be used."); Console.WriteLine(
"TShock Notice: authcode.txt is still present, and the AuthToken located in that file will be used.");
Console.WriteLine("To become superadmin, join the game and type /auth " + AuthToken); Console.WriteLine("To become superadmin, join the game and type /auth " + AuthToken);
Console.WriteLine("This token will display until disabled by verification. (/auth-verify)"); Console.WriteLine("This token will display until disabled by verification. (/auth-verify)");
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
@ -340,6 +341,7 @@ namespace TShockAPI
private DateTime LastCheck = DateTime.UtcNow; private DateTime LastCheck = DateTime.UtcNow;
private void OnUpdate(GameTime time) private void OnUpdate(GameTime time)
{ {
UpdateManager.UpdateProcedureCheck(); UpdateManager.UpdateProcedureCheck();
@ -351,13 +353,13 @@ namespace TShockAPI
if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1) if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1)
{ {
LastCheck = DateTime.UtcNow; LastCheck = DateTime.UtcNow;
foreach (TSPlayer player in TShock.Players) foreach (TSPlayer player in Players)
{ {
if (player != null && player.Active) if (player != null && player.Active)
{ {
if (player.TilesDestroyed != null) if (player.TilesDestroyed != null)
{ {
if (player.TileThreshold >= TShock.Config.TileThreshold) if (player.TileThreshold >= Config.TileThreshold)
{ {
if (Tools.HandleTntUser(player, "Kill tile abuse detected.")) if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
{ {
@ -377,7 +379,7 @@ namespace TShockAPI
for (int i = 0; i < inv.Length; i++) for (int i = 0; i < inv.Length; i++)
{ {
if (inv[i] != null && TShock.Itembans.ItemIsBanned(inv[i].name)) if (inv[i] != null && Itembans.ItemIsBanned(inv[i].name))
{ {
player.Disconnect("Using banned item: " + inv[i].name + ", remove it and rejoin"); player.Disconnect("Using banned item: " + inv[i].name + ", remove it and rejoin");
break; break;
@ -394,14 +396,14 @@ namespace TShockAPI
var player = new TSPlayer(ply); var player = new TSPlayer(ply);
if (Config.EnableDNSHostResolution) if (Config.EnableDNSHostResolution)
{ {
player.Group = TShock.Users.GetGroupForIPExpensive(player.IP); player.Group = Users.GetGroupForIPExpensive(player.IP);
} }
else else
{ {
player.Group = TShock.Users.GetGroupForIP(player.IP); player.Group = Users.GetGroupForIP(player.IP);
} }
if (Tools.ActivePlayers() + 1 > TShock.Config.MaxSlots && !player.Group.HasPermission("reservedslot")) if (Tools.ActivePlayers() + 1 > Config.MaxSlots && !player.Group.HasPermission("reservedslot"))
{ {
Tools.ForceKick(player, "Server is full"); Tools.ForceKick(player, "Server is full");
handler.Handled = true; handler.Handled = true;
@ -435,11 +437,11 @@ namespace TShockAPI
{ {
Log.Info(string.Format("{0} left.", tsplr.Name)); Log.Info(string.Format("{0} left.", tsplr.Name));
if (TShock.Config.RememberLeavePos) if (Config.RememberLeavePos)
{ {
RemeberedPosManager.RemeberedPosistions.Add(new RemeberedPos(tsplr.IP, RemeberedPosManager.RemeberedPosistions.Add(new RemeberedPos(tsplr.IP,
new Vector2(tsplr.X / 16, new Vector2(tsplr.X/16,
(tsplr.Y / 16) + 3))); (tsplr.Y/16) + 3)));
RemeberedPosManager.WriteSettings(); RemeberedPosManager.WriteSettings();
} }
} }
@ -469,8 +471,9 @@ namespace TShockAPI
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && Config.AdminChatEnabled) if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && Config.AdminChatEnabled)
{ {
Tools.Broadcast(TShock.Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text, Tools.Broadcast(Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
(byte)TShock.Config.AdminChatRGB[0], (byte)TShock.Config.AdminChatRGB[1], (byte)TShock.Config.AdminChatRGB[2]); (byte) Config.AdminChatRGB[0], (byte) Config.AdminChatRGB[1],
(byte) Config.AdminChatRGB[2]);
e.Handled = true; e.Handled = true;
return; return;
} }
@ -534,7 +537,8 @@ namespace TShockAPI
if (player != null && player.Active) if (player != null && player.Active)
{ {
count++; count++;
TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}]", player.Name, player.IP, player.Group.Name)); TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}]", player.Name, player.IP,
player.Group.Name));
} }
} }
TSPlayer.Server.SendMessage(string.Format("{0} players connected.", count)); TSPlayer.Server.SendMessage(string.Format("{0} players connected.", count));
@ -546,8 +550,8 @@ namespace TShockAPI
} }
else if (text == "autosave") else if (text == "autosave")
{ {
Main.autoSave = TShock.Config.AutoSave = !TShock.Config.AutoSave; Main.autoSave = Config.AutoSave = !Config.AutoSave;
Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled")); Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
e.Handled = true; e.Handled = true;
} }
else if (text.StartsWith("/")) else if (text.StartsWith("/"))
@ -577,7 +581,8 @@ namespace TShockAPI
//Debug.WriteLine("Recv: {0:X} ({2}): {3} ({1:XX})", player.Index, (byte)type, player.TPlayer.dead ? "dead " : "alive", type.ToString()); //Debug.WriteLine("Recv: {0:X} ({2}): {3} ({1:XX})", player.Index, (byte)type, player.TPlayer.dead ? "dead " : "alive", type.ToString());
// Stop accepting updates from player as this player is going to be kicked/banned during OnUpdate (different thread so can produce race conditions) // Stop accepting updates from player as this player is going to be kicked/banned during OnUpdate (different thread so can produce race conditions)
if ((TShock.Config.BanKillTileAbusers || TShock.Config.KickKillTileAbusers) && player.TileThreshold >= TShock.Config.TileThreshold && !player.Group.HasPermission("ignoregriefdetection")) if ((Config.BanKillTileAbusers || Config.KickKillTileAbusers) &&
player.TileThreshold >= Config.TileThreshold && !player.Group.HasPermission("ignoregriefdetection"))
{ {
Log.Debug("Rejecting " + type + " from " + player.Name + " as this player is about to be kicked"); Log.Debug("Rejecting " + type + " from " + player.Name + " as this player is about to be kicked");
e.Handled = true; e.Handled = true;
@ -618,7 +623,9 @@ namespace TShockAPI
if (Config.AlwaysPvP) if (Config.AlwaysPvP)
{ {
player.SetPvP(true); player.SetPvP(true);
player.SendMessage("PvP is forced! Enable PvP else you can't deal damage to other people. (People can kill you)", Color.Red); player.SendMessage(
"PvP is forced! Enable PvP else you can't deal damage to other people. (People can kill you)",
Color.Red);
} }
if (player.Group.HasPermission("causeevents") && Config.InfiniteInvasion) if (player.Group.HasPermission("causeevents") && Config.InfiniteInvasion)
{ {
@ -630,7 +637,7 @@ namespace TShockAPI
{ {
if (playerIP.IP == player.IP) if (playerIP.IP == player.IP)
{ {
player.Teleport((int)playerIP.Pos.X, (int)playerIP.Pos.Y); player.Teleport((int) playerIP.Pos.X, (int) playerIP.Pos.Y);
RemeberedPosManager.RemeberedPosistions.Remove(playerIP); RemeberedPosManager.RemeberedPosistions.Remove(playerIP);
RemeberedPosManager.WriteSettings(); RemeberedPosManager.WriteSettings();
break; break;
@ -667,13 +674,13 @@ namespace TShockAPI
public static void StartInvasion() public static void StartInvasion()
{ {
Main.invasionType = 1; Main.invasionType = 1;
if (TShock.Config.InfiniteInvasion) if (Config.InfiniteInvasion)
{ {
Main.invasionSize = 20000000; Main.invasionSize = 20000000;
} }
else else
{ {
Main.invasionSize = 100 + (TShock.Config.InvasionMultiplier * Tools.ActivePlayers()); Main.invasionSize = 100 + (Config.InvasionMultiplier*Tools.ActivePlayers());
} }
Main.invasionWarn = 0; Main.invasionWarn = 0;
@ -687,13 +694,14 @@ namespace TShockAPI
} }
} }
static int KillCount = 0; private static int KillCount;
public static void IncrementKills() public static void IncrementKills()
{ {
KillCount++; KillCount++;
Random r = new Random(); Random r = new Random();
int random = r.Next(5); int random = r.Next(5);
if (KillCount % 100 == 0) if (KillCount%100 == 0)
{ {
switch (random) switch (random)
{ {
@ -723,15 +731,15 @@ 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);
return Vector2.Distance(spawn, tile) <= TShock.Config.SpawnProtectionRadius; return Vector2.Distance(spawn, tile) <= Config.SpawnProtectionRadius;
} }
public static bool HackedHealth(TSPlayer player) public static bool HackedHealth(TSPlayer player)
{ {
return (player.TPlayer.statManaMax > 200) || return (player.TPlayer.statManaMax > 200) ||
(player.TPlayer.statMana > 200) || (player.TPlayer.statMana > 200) ||
(player.TPlayer.statLifeMax > 400) || (player.TPlayer.statLifeMax > 400) ||
(player.TPlayer.statLife > 400); (player.TPlayer.statLife > 400);
} }
public void OnConfigRead(ConfigFile file) public void OnConfigRead(ConfigFile file)
@ -772,7 +780,5 @@ namespace TShockAPI
Log.ConsoleError("Invalid or not supported hashing algorithm: " + file.HashAlgorithm); Log.ConsoleError("Invalid or not supported hashing algorithm: " + file.HashAlgorithm);
} }
} }
} }
} }

View file

@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Net;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria; using Terraria;
using System.Linq;
namespace TShockAPI namespace TShockAPI
{ {
@ -488,8 +488,8 @@ namespace TShockAPI
public static HashAlgorithm HashAlgo = new MD5Cng(); public static HashAlgorithm HashAlgo = new MD5Cng();
public static readonly Dictionary<string, Type> HashTypes = new Dictionary<string, Type>() public static readonly Dictionary<string, Type> HashTypes = new Dictionary<string, Type>
{ {
{"sha512", typeof(SHA512Managed)}, {"sha512", typeof(SHA512Managed)},
{"sha256", typeof(SHA256Managed)}, {"sha256", typeof(SHA256Managed)},
{"md5", typeof(MD5Cng)}, {"md5", typeof(MD5Cng)},

View file

@ -16,14 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Net; using System.Net;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria;
namespace TShockAPI namespace TShockAPI
{ {