diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index 2624c085..4cb34216 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -18,7 +18,7 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
+
using System.IO;
using System.Linq;
using System.Net;
@@ -919,7 +919,7 @@ namespace TShockAPI
int penis57 = Main.rand.Next(Main.maxTilesX - 50) + 100;
penis57 *= 0x10;
int penis58 = Main.rand.Next((int)(Main.maxTilesY * 0.05)) * 0x10;
- PointF vector = new PointF(penis57, penis58);
+ Vector2 vector = new Vector2(penis57, penis58);
float speedX = Main.rand.Next(-100, 0x65);
float speedY = Main.rand.Next(200) + 100;
float penis61 = (float)Math.Sqrt(((speedX * speedX) + (speedY * speedY)));
@@ -1225,7 +1225,7 @@ namespace TShockAPI
string warpName = String.Join(" ", args.Parameters[1]);
var warp = TShock.Warps.FindWarp(warpName);
var plr = foundplr[0];
- if (warp.WarpPos != PointF.Empty)
+ if (warp.WarpPos != Vector2.Zero)
{
if (plr.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3))
{
@@ -1364,7 +1364,7 @@ namespace TShockAPI
{
string warpName = String.Join(" ", args.Parameters);
var warp = TShock.Warps.FindWarp(warpName);
- if (warp.WarpPos != PointF.Empty)
+ if (warp.WarpPos != Vector2.Zero)
{
if (args.Player.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3))
args.Player.SendMessage("Warped to " + warpName, Color.Yellow);
@@ -1755,7 +1755,7 @@ namespace TShockAPI
{
if (args.Parameters.Count > 1)
{
- if (!args.Player.TempPoints.Any(p => p == PointF.Empty))
+ if (!args.Player.TempPoints.Any(p => p == Point.Zero))
{
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
var x = Math.Min(args.Player.TempPoints[0].X, args.Player.TempPoints[1].X);
@@ -1765,8 +1765,8 @@ namespace TShockAPI
if (TShock.Regions.AddRegion(x, y, width, height, regionName, Main.worldID.ToString()))
{
- args.Player.TempPoints[0] = Point.Empty;
- args.Player.TempPoints[1] = Point.Empty;
+ args.Player.TempPoints[0] = Point.Zero;
+ args.Player.TempPoints[1] = Point.Zero;
args.Player.SendMessage("Set region " + regionName, Color.Yellow);
}
else
@@ -1825,8 +1825,8 @@ namespace TShockAPI
}
case "clear":
{
- args.Player.TempPoints[0] = Point.Empty;
- args.Player.TempPoints[1] = Point.Empty;
+ args.Player.TempPoints[0] = Point.Zero;
+ args.Player.TempPoints[1] = Point.Zero;
args.Player.SendMessage("Cleared temp area", Color.Yellow);
args.Player.AwaitingTempPoint = 0;
break;
diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs
index cd4c2faf..2f49388d 100644
--- a/TShockAPI/DB/RegionManager.cs
+++ b/TShockAPI/DB/RegionManager.cs
@@ -20,7 +20,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
-using System.Drawing;
+
using System.IO;
using System.Linq;
using System.Xml;
diff --git a/TShockAPI/DB/RememberPosManager.cs b/TShockAPI/DB/RememberPosManager.cs
index 4bb546dc..71a9bc5e 100644
--- a/TShockAPI/DB/RememberPosManager.cs
+++ b/TShockAPI/DB/RememberPosManager.cs
@@ -18,7 +18,7 @@ along with this program. If not, see .
using System;
using System.Data;
-using System.Drawing;
+
using MySql.Data.MySqlClient;
using Terraria;
@@ -43,7 +43,7 @@ namespace TShockAPI.DB
creator.EnsureExists(table);
}
- public PointF GetLeavePos(string name, string IP)
+ public Vector2 GetLeavePos(string name, string IP)
{
try
{
@@ -51,7 +51,7 @@ namespace TShockAPI.DB
{
if (reader.Read())
{
- return new PointF(reader.Get("X"), reader.Get("Y"));
+ return new Vector2(reader.Get("X"), reader.Get("Y"));
}
}
}
@@ -60,12 +60,12 @@ namespace TShockAPI.DB
Log.Error(ex.ToString());
}
- return new PointF();
+ return new Vector2();
}
public void InsertLeavePos(string name, string IP, int X, int Y)
{
- if (GetLeavePos(name, IP) == PointF.Empty)
+ if (GetLeavePos(name, IP) == Vector2.Zero)
{
try
{
diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs
index d265caa9..c1599e0b 100644
--- a/TShockAPI/DB/WarpsManager.cs
+++ b/TShockAPI/DB/WarpsManager.cs
@@ -19,7 +19,7 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.Data;
-using System.Drawing;
+
using System.IO;
using System.Xml;
using MySql.Data.MySqlClient;
@@ -173,11 +173,11 @@ namespace TShockAPI.DB
{
try
{
- return new Warp(new PointF(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), reader.Get("Private"));
+ return new Warp(new Vector2(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), reader.Get("Private"));
}
catch
{
- return new Warp(new PointF(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), "0");
+ return new Warp(new Vector2(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), "0");
}
}
}
@@ -247,12 +247,12 @@ namespace TShockAPI.DB
public class Warp
{
- public PointF WarpPos { get; set; }
+ public Vector2 WarpPos { get; set; }
public string WarpName { get; set; }
public string WorldWarpID { get; set; }
public string Private { get; set; }
- public Warp(PointF warppos, string name, string worldid, string hidden)
+ public Warp(Vector2 warppos, string name, string worldid, string hidden)
{
WarpPos = warppos;
WarpName = name;
@@ -262,7 +262,7 @@ namespace TShockAPI.DB
public Warp()
{
- WarpPos = PointF.Empty;
+ WarpPos = Vector2.Zero;
WarpName = null;
WorldWarpID = string.Empty;
Private = "0";
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index b426264c..d17247e8 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -18,13 +18,13 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
+
using System.IO;
using System.Text;
using Terraria;
-using TerrariaAPI;
+
using TShockAPI.Net;
-using XNAHelpers;
+using System.IO.Streams;
namespace TShockAPI
{
@@ -393,7 +393,7 @@ namespace TShockAPI
if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && args.Player.Active)
{
args.Player.TileThreshold++;
- var coords = new PointF(x, y);
+ var coords = new Vector2(x, y);
if (!args.Player.TilesDestroyed.ContainsKey(coords))
args.Player.TilesDestroyed.Add(coords, Main.tile[x, y].Data);
}
diff --git a/TShockAPI/Net/BaseMsg.cs b/TShockAPI/Net/BaseMsg.cs
index ed41cf71..77fa041c 100644
--- a/TShockAPI/Net/BaseMsg.cs
+++ b/TShockAPI/Net/BaseMsg.cs
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
+using System.IO.Streams;
using System.Linq;
using System.Text;
-using TerrariaAPI;
-using XNAHelpers;
+
+using System.IO.Streams;
namespace TShockAPI.Net
{
diff --git a/TShockAPI/Net/DisconnectMsg.cs b/TShockAPI/Net/DisconnectMsg.cs
index ad1ebf57..a8318e6b 100644
--- a/TShockAPI/Net/DisconnectMsg.cs
+++ b/TShockAPI/Net/DisconnectMsg.cs
@@ -1,10 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.IO;
+using System.IO.Streams;
using System.Text;
-using TerrariaAPI;
-using XNAHelpers;
namespace TShockAPI.Net
{
diff --git a/TShockAPI/Net/NetTile.cs b/TShockAPI/Net/NetTile.cs
index be269a61..8871065f 100644
--- a/TShockAPI/Net/NetTile.cs
+++ b/TShockAPI/Net/NetTile.cs
@@ -19,7 +19,7 @@ along with this program. If not, see .
using System;
using System.IO;
using Terraria;
-using XNAHelpers;
+using System.IO.Streams;
namespace TShockAPI.Net
{
diff --git a/TShockAPI/Net/SpawnMsg.cs b/TShockAPI/Net/SpawnMsg.cs
index 29e9e4c9..dc851379 100644
--- a/TShockAPI/Net/SpawnMsg.cs
+++ b/TShockAPI/Net/SpawnMsg.cs
@@ -1,8 +1,5 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using TerrariaAPI;
-using XNAHelpers;
+using System.IO;
+using System.IO.Streams;
namespace TShockAPI.Net
{
diff --git a/TShockAPI/Net/WorldInfoMsg.cs b/TShockAPI/Net/WorldInfoMsg.cs
index 1ba56691..8726ced4 100644
--- a/TShockAPI/Net/WorldInfoMsg.cs
+++ b/TShockAPI/Net/WorldInfoMsg.cs
@@ -19,8 +19,8 @@ along with this program. If not, see .
using System;
using System.IO;
using System.Text;
-using TerrariaAPI;
-using XNAHelpers;
+
+using System.IO.Streams;
namespace TShockAPI.Net
{
diff --git a/TShockAPI/PacketBufferer.cs b/TShockAPI/PacketBufferer.cs
index 3b698a60..0257c78f 100644
--- a/TShockAPI/PacketBufferer.cs
+++ b/TShockAPI/PacketBufferer.cs
@@ -5,8 +5,8 @@ using System.IO;
using System.Net.Sockets;
using System.Text;
using Terraria;
-using TerrariaAPI;
-using TerrariaAPI.Hooks;
+
+using Hooks;
namespace TShockAPI
{
diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs
index 480d2285..39be7979 100644
--- a/TShockAPI/Properties/AssemblyInfo.cs
+++ b/TShockAPI/Properties/AssemblyInfo.cs
@@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.3.3.0906")]
-[assembly: AssemblyFileVersion("3.3.3.0906")]
+[assembly: AssemblyVersion("3.3.3.0924")]
+[assembly: AssemblyFileVersion("3.3.3.0924")]
diff --git a/TShockAPI/RconHandler.cs b/TShockAPI/RconHandler.cs
index d693e266..d407a144 100644
--- a/TShockAPI/RconHandler.cs
+++ b/TShockAPI/RconHandler.cs
@@ -24,7 +24,7 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Terraria;
-using XNAHelpers;
+using System.IO.Streams;
namespace TShockAPI
{
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index 8060dc03..5b7f4a13 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -17,13 +17,12 @@ along with this program. If not, see .
*/
using System;
using System.Collections.Generic;
-using System.Drawing;
+
using System.IO;
using System.Threading;
using Terraria;
-using TerrariaAPI;
+
using TShockAPI.Net;
-using XNAHelpers;
namespace TShockAPI
{
@@ -32,7 +31,7 @@ namespace TShockAPI
public static readonly TSServerPlayer Server = new TSServerPlayer();
public static readonly TSPlayer All = new TSPlayer("All");
public int TileThreshold { get; set; }
- public Dictionary TilesDestroyed { get; protected set; }
+ public Dictionary TilesDestroyed { get; protected set; }
public bool SyncHP { get; set; }
public bool SyncMP { get; set; }
public Group Group { get; set; }
@@ -46,10 +45,10 @@ namespace TShockAPI
public DateTime LastTileChangeNotify { get; set; }
public bool InitSpawn;
public bool DisplayLogs = true;
- public PointF oldSpawn = PointF.Empty;
+ public Vector2 oldSpawn = Vector2.Zero;
public TSPlayer LastWhisper;
public int LoginAttempts { get; set; }
- public PointF TeleportCoords = new PointF(-1, -1);
+ public Vector2 TeleportCoords = new Vector2(-1, -1);
public string UserAccountName { get; set; }
public bool HasBeenSpammedWithBuildMessage;
public bool IsLoggedIn;
@@ -69,7 +68,7 @@ namespace TShockAPI
}
public bool ConnectionAlive
{
- get { return RealPlayer ? Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill : false; }
+ get { return RealPlayer && (Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill); }
}
public string IP
{
@@ -145,14 +144,14 @@ namespace TShockAPI
public TSPlayer(int index)
{
- TilesDestroyed = new Dictionary();
+ TilesDestroyed = new Dictionary();
Index = index;
Group = new Group("null");
}
protected TSPlayer(String playerName)
{
- TilesDestroyed = new Dictionary();
+ TilesDestroyed = new Dictionary();
Index = -1;
FakePlayer = new Player { name = playerName, whoAmi = -1 };
Group = new Group("null");
@@ -406,17 +405,17 @@ namespace TShockAPI
NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
}
- public void RevertKillTile(Dictionary destroyedTiles)
+ public void RevertKillTile(Dictionary destroyedTiles)
{
// Update Main.Tile first so that when tile sqaure is sent it is correct
- foreach (KeyValuePair entry in destroyedTiles)
+ foreach (KeyValuePair entry in destroyedTiles)
{
Main.tile[(int)entry.Key.X, (int)entry.Key.Y].Data = entry.Value;
Log.Debug(string.Format("Reverted DestroyedTile(TileXY:{0}_{1}, Type:{2})",
entry.Key.X, entry.Key.Y, Main.tile[(int)entry.Key.X, (int)entry.Key.Y].type));
}
// Send all players updated tile sqaures
- foreach (PointF coords in destroyedTiles.Keys)
+ foreach (Vector2 coords in destroyedTiles.Keys)
{
All.SendTileSquare((int)coords.X, (int)coords.Y, 3);
}
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 61565bb9..276715ed 100644
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -29,20 +29,15 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
-using System.Drawing;
using System.IO;
using System.Net;
using System.Reflection;
-using System.Linq;
-using System.Text.RegularExpressions;
using System.Threading;
using Community.CsharpSqlite.SQLiteClient;
-using HttpServer;
+using Hooks;
using MySql.Data.MySqlClient;
using Rests;
using Terraria;
-using TerrariaAPI;
-using TerrariaAPI.Hooks;
using TShockAPI.DB;
using TShockAPI.Net;
@@ -242,25 +237,29 @@ namespace TShockAPI
return new RestObject("200") { Response = "Successful login" }; //Maybe return some user info too?
}
- public override void DeInitialize()
+ protected override void Dispose(bool disposing)
{
- GameHooks.PostInitialize -= OnPostInit;
- GameHooks.Update -= OnUpdate;
- ServerHooks.Join -= OnJoin;
- ServerHooks.Leave -= OnLeave;
- ServerHooks.Chat -= OnChat;
- ServerHooks.Command -= ServerHooks_OnCommand;
- NetHooks.GetData -= OnGetData;
- NetHooks.SendData -= NetHooks_SendData;
- NetHooks.GreetPlayer -= OnGreetPlayer;
- NpcHooks.StrikeNpc -= NpcHooks_OnStrikeNpc;
- if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
+ if (disposing)
{
- Console.WriteLine("Thanks for using TShock! Process ID file is now being destroyed.");
- File.Delete(Path.Combine(SavePath, "tshock.pid"));
+ GameHooks.PostInitialize -= OnPostInit;
+ GameHooks.Update -= OnUpdate;
+ ServerHooks.Join -= OnJoin;
+ ServerHooks.Leave -= OnLeave;
+ ServerHooks.Chat -= OnChat;
+ ServerHooks.Command -= ServerHooks_OnCommand;
+ NetHooks.GetData -= OnGetData;
+ NetHooks.SendData -= NetHooks_SendData;
+ NetHooks.GreetPlayer -= OnGreetPlayer;
+ NpcHooks.StrikeNpc -= NpcHooks_OnStrikeNpc;
+ if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
+ {
+ Console.WriteLine("Thanks for using TShock! Process ID file is now being destroyed.");
+ File.Delete(Path.Combine(SavePath, "tshock.pid"));
+ }
+ RestApi.Dispose();
}
- RestApi.Dispose();
- //RconHandler.ShutdownAllThreads();
+
+ base.Dispose(disposing);
}
///
@@ -850,11 +849,11 @@ namespace TShockAPI
public static bool CheckSpawn(int x, int y)
{
- PointF tile = new PointF(x, y);
- PointF spawn = new PointF(Main.spawnTileX, Main.spawnTileY);
+ Vector2 tile = new Vector2(x, y);
+ Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY);
return Distance(spawn, tile) <= Config.SpawnProtectionRadius;
}
- public static float Distance(PointF value1, PointF value2)
+ public static float Distance(Vector2 value1, Vector2 value2)
{
float num2 = value1.X - value2.X;
float num = value1.Y - value2.Y;
diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj
index 5a4d895b..dbe4a050 100644
--- a/TShockAPI/TShockAPI.csproj
+++ b/TShockAPI/TShockAPI.csproj
@@ -70,7 +70,6 @@
-
@@ -82,10 +81,6 @@
..\TerrariaServerBins\TerrariaServer.exe
False
-
- False
- ..\TerrariaServerBins\TerrariaServerAPI.dll
-
@@ -186,7 +181,7 @@
-
+