diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5b430155..4e7f6d39 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -18,14 +18,15 @@ 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; using System.Text; using System.Threading; -using Microsoft.Xna.Framework; using Terraria; using TShockAPI.DB; +using Region = TShockAPI.DB.Region; namespace TShockAPI { @@ -916,7 +917,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; - Vector2 vector = new Vector2(penis57, penis58); + PointF vector = new PointF(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))); @@ -1325,7 +1326,7 @@ namespace TShockAPI { string warpName = String.Join(" ", args.Parameters); var warp = TShock.Warps.FindWarp(warpName); - if (warp.WarpPos != Vector2.Zero) + if (warp.WarpPos != PointF.Empty) { if (args.Player.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3)) args.Player.SendMessage("Warped to " + warpName, Color.Yellow); @@ -1716,7 +1717,7 @@ namespace TShockAPI { if (args.Parameters.Count > 1) { - if (!args.Player.TempPoints.Any(p => p == Point.Zero)) + if (!args.Player.TempPoints.Any(p => p == PointF.Empty)) { 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); @@ -1726,8 +1727,8 @@ namespace TShockAPI if (TShock.Regions.AddRegion(x, y, width, height, regionName, Main.worldID.ToString())) { - args.Player.TempPoints[0] = Point.Zero; - args.Player.TempPoints[1] = Point.Zero; + args.Player.TempPoints[0] = Point.Empty; + args.Player.TempPoints[1] = Point.Empty; args.Player.SendMessage("Set region " + regionName, Color.Yellow); } else @@ -1786,8 +1787,8 @@ namespace TShockAPI } case "clear": { - args.Player.TempPoints[0] = Point.Zero; - args.Player.TempPoints[1] = Point.Zero; + args.Player.TempPoints[0] = Point.Empty; + args.Player.TempPoints[1] = Point.Empty; 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 1a1a4761..8e2166c4 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -20,10 +20,10 @@ 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; -using Microsoft.Xna.Framework; using MySql.Data.MySqlClient; using Terraria; @@ -88,22 +88,28 @@ namespace TShockAPI.DB while (reader.Read() && reader.NodeType != XmlNodeType.Text) ; + int t = 0; + switch (name) { case "RegionName": region.Name = reader.Value; break; case "Point1X": - int.TryParse(reader.Value, out rect.X); + int.TryParse(reader.Value, out t); + rect.X = t; break; case "Point1Y": - int.TryParse(reader.Value, out rect.Y); + int.TryParse(reader.Value, out t); + rect.Y = t; break; case "Point2X": - int.TryParse(reader.Value, out rect.Width); + int.TryParse(reader.Value, out t); + rect.Width = t; break; case "Point2Y": - int.TryParse(reader.Value, out rect.Height); + int.TryParse(reader.Value, out t); + rect.Height = t; break; case "Protected": region.DisableBuild = reader.Value.ToLower().Equals("true"); @@ -175,7 +181,7 @@ namespace TShockAPI.DB string mergedids = reader.Get("UserIds"); string name = reader.Get("RegionName"); - string[] splitids = mergedids.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); + string[] splitids = mergedids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected != 0, Main.worldID.ToString()); @@ -370,13 +376,13 @@ namespace TShockAPI.DB public static List ListIDs(string MergedIDs) { - return MergedIDs.Split(new []{','}, StringSplitOptions.RemoveEmptyEntries).ToList(); + return MergedIDs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } - public bool RemoveUser(string regionName, string userName ) + public bool RemoveUser(string regionName, string userName) { Region r = GetRegionByName(regionName); - if( r != null ) + if (r != null) { r.RemoveID(TShock.Users.GetUserID(userName)); string ids = string.Join(",", r.AllowedIDs); @@ -408,7 +414,7 @@ namespace TShockAPI.DB foreach (var r in Regions) { if (r.Name == regionName && r.WorldID == Main.worldID.ToString()) - r.setAllowedIDs( MergedIDs ); + r.setAllowedIDs(MergedIDs); } return q != 0; } @@ -509,16 +515,16 @@ namespace TShockAPI.DB return false; } - public void setAllowedIDs( String ids ) + public void setAllowedIDs(String ids) { String[] id_arr = ids.Split(','); List id_list = new List(); - foreach( String id in id_arr ) + foreach (String id in id_arr) { int i = 0; int.TryParse(id, out i); - if( i != 0 ) - id_list.Add( i ); + if (i != 0) + id_list.Add(i); } AllowedIDs = id_list; } @@ -526,7 +532,7 @@ namespace TShockAPI.DB public void RemoveID(int id) { var index = -1; - for (int i = 0; i < AllowedIDs.Count; i++ ) + for (int i = 0; i < AllowedIDs.Count; i++) { if (AllowedIDs[i] == id) { @@ -534,7 +540,7 @@ namespace TShockAPI.DB break; } } - AllowedIDs.RemoveAt( index ); + AllowedIDs.RemoveAt(index); } } } diff --git a/TShockAPI/DB/RememberPosManager.cs b/TShockAPI/DB/RememberPosManager.cs index e1d89ed9..4bb546dc 100644 --- a/TShockAPI/DB/RememberPosManager.cs +++ b/TShockAPI/DB/RememberPosManager.cs @@ -17,10 +17,8 @@ along with this program. If not, see . */ using System; -using System.Collections.Generic; -using System.Xml; using System.Data; -using Microsoft.Xna.Framework; +using System.Drawing; using MySql.Data.MySqlClient; using Terraria; @@ -45,7 +43,7 @@ namespace TShockAPI.DB creator.EnsureExists(table); } - public Vector2 GetLeavePos(string name, string IP) + public PointF GetLeavePos(string name, string IP) { try { @@ -53,7 +51,7 @@ namespace TShockAPI.DB { if (reader.Read()) { - return new Vector2(reader.Get("X"), reader.Get("Y")); + return new PointF(reader.Get("X"), reader.Get("Y")); } } } @@ -62,12 +60,12 @@ namespace TShockAPI.DB Log.Error(ex.ToString()); } - return new Vector2(); + return new PointF(); } public void InsertLeavePos(string name, string IP, int X, int Y) { - if (GetLeavePos(name, IP) == Vector2.Zero) + if (GetLeavePos(name, IP) == PointF.Empty) { try { diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs index a6f6c615..d265caa9 100644 --- a/TShockAPI/DB/WarpsManager.cs +++ b/TShockAPI/DB/WarpsManager.cs @@ -19,9 +19,9 @@ 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 Microsoft.Xna.Framework; using MySql.Data.MySqlClient; using Terraria; @@ -173,11 +173,11 @@ namespace TShockAPI.DB { try { - return new Warp(new Vector2(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), reader.Get("Private")); + return new Warp(new PointF(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), reader.Get("Private")); } catch { - return new Warp(new Vector2(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), "0"); + return new Warp(new PointF(reader.Get("X"), reader.Get("Y")), reader.Get("WarpName"), reader.Get("WorldID"), "0"); } } } @@ -247,12 +247,12 @@ namespace TShockAPI.DB public class Warp { - public Vector2 WarpPos { get; set; } + public PointF WarpPos { get; set; } public string WarpName { get; set; } public string WorldWarpID { get; set; } public string Private { get; set; } - public Warp(Vector2 warppos, string name, string worldid, string hidden) + public Warp(PointF warppos, string name, string worldid, string hidden) { WarpPos = warppos; WarpName = name; @@ -262,7 +262,7 @@ namespace TShockAPI.DB public Warp() { - WarpPos = Vector2.Zero; + WarpPos = PointF.Empty; WarpName = null; WorldWarpID = string.Empty; Private = "0"; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index acf4faeb..98d52670 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -18,9 +18,9 @@ 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 Microsoft.Xna.Framework; using Terraria; using TerrariaAPI; using TShockAPI.Net; @@ -393,7 +393,7 @@ namespace TShockAPI if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && args.Player.Active) { args.Player.TileThreshold++; - var coords = new Vector2(x, y); + var coords = new PointF(x, y); if (!args.Player.TilesDestroyed.ContainsKey(coords)) args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]); } diff --git a/TShockAPI/Net/DisconnectMsg.cs b/TShockAPI/Net/DisconnectMsg.cs index e838280e..ad1ebf57 100644 --- a/TShockAPI/Net/DisconnectMsg.cs +++ b/TShockAPI/Net/DisconnectMsg.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using Microsoft.Xna.Framework; using TerrariaAPI; using XNAHelpers; diff --git a/TShockAPI/PacketBufferer.cs b/TShockAPI/PacketBufferer.cs index cd19f6ed..3b698a60 100644 --- a/TShockAPI/PacketBufferer.cs +++ b/TShockAPI/PacketBufferer.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.IO; using System.Net.Sockets; using System.Text; -using Microsoft.Xna.Framework; using Terraria; using TerrariaAPI; using TerrariaAPI.Hooks; @@ -90,7 +89,7 @@ namespace TShockAPI Compressed = new int[52]; } - void GameHooks_Update(GameTime obj) + void GameHooks_Update() { FlushAll(); } diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 9f074a56..23288060 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.2.8.0824")] -[assembly: AssemblyFileVersion("3.2.8.0824")] +[assembly: AssemblyVersion("3.2.8.0830")] +[assembly: AssemblyFileVersion("3.2.8.0830")] diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index ce01f940..65cbada2 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -17,9 +17,9 @@ along with this program. If not, see . */ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Threading; -using Microsoft.Xna.Framework; using Terraria; using TerrariaAPI; using TShockAPI.Net; @@ -32,7 +32,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 +46,10 @@ namespace TShockAPI public DateTime LastTileChangeNotify { get; set; } public bool InitSpawn; public bool DisplayLogs = true; - public Vector2 oldSpawn = Vector2.Zero; + public PointF oldSpawn = PointF.Empty; public TSPlayer LastWhisper; public int LoginAttempts { get; set; } - public Vector2 TeleportCoords = new Vector2(-1, -1); + public PointF TeleportCoords = new PointF(-1, -1); public string UserAccountName { get; set; } public bool HasBeenSpammedWithBuildMessage; public bool IsLoggedIn; @@ -143,14 +143,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"); @@ -404,17 +404,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] = 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 (Vector2 coords in destroyedTiles.Keys) + foreach (PointF coords in destroyedTiles.Keys) { All.SendTileSquare((int)coords.X, (int)coords.Y, 3); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 7d0a034c..49db3888 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -28,13 +28,13 @@ 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.Threading; using Community.CsharpSqlite.SQLiteClient; -using Microsoft.Xna.Framework; using MySql.Data.MySqlClient; using Terraria; using TerrariaAPI; @@ -353,7 +353,7 @@ namespace TShockAPI private DateTime LastCheck = DateTime.UtcNow; - private void OnUpdate(GameTime time) + private void OnUpdate() { UpdateManager.UpdateProcedureCheck(); @@ -801,9 +801,16 @@ namespace TShockAPI public static bool CheckSpawn(int x, int y) { - Vector2 tile = new Vector2(x, y); - Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY); - return Vector2.Distance(spawn, tile) <= Config.SpawnProtectionRadius; + PointF tile = new PointF(x, y); + PointF spawn = new PointF(Main.spawnTileX, Main.spawnTileY); + return Distance(spawn, tile) <= Config.SpawnProtectionRadius; + } + public static float Distance(PointF value1, PointF value2) + { + float num2 = value1.X - value2.X; + float num = value1.Y - value2.Y; + float num3 = (num2 * num2) + (num * num); + return (float)Math.Sqrt((double)num3); } public static bool HackedHealth(TSPlayer player) diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 16c5480d..8cded74b 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -52,9 +52,6 @@ False ..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll - - - False ..\SqlBins\MySql.Data.dll @@ -70,6 +67,7 @@ + @@ -85,10 +83,6 @@ False ..\TerrariaServerBins\TerrariaServerAPI.dll - - False - ..\TerrariaServerBins\XNAHelpers.dll - @@ -182,7 +176,7 @@ - +