diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ffd5e246..9fc50466 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 { @@ -917,7 +918,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))); @@ -1326,7 +1327,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); @@ -1717,7 +1718,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); @@ -1727,8 +1728,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 @@ -1787,8 +1788,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 82d87df9..d6341b86 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 29d67f40..27adefd1 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -36,5 +36,10 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("3.2.8.0903")] [assembly: AssemblyFileVersion("3.2.8.0903")] +======= +[assembly: AssemblyVersion("3.2.8.0830")] +[assembly: AssemblyFileVersion("3.2.8.0830")] +>>>>>>> remotes/origin/general-devel-mono diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 251f5650..30abe815 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; @@ -145,14 +145,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 +406,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 cb5b20e1..d586cbe7 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; @@ -44,7 +44,7 @@ using TShockAPI.Net; namespace TShockAPI { - [APIVersion(1, 7)] + [APIVersion(1, 8)] public class TShock : TerrariaPlugin { public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; @@ -356,7 +356,7 @@ namespace TShockAPI private DateTime LastCheck = DateTime.UtcNow; - private void OnUpdate(GameTime time) + private void OnUpdate() { UpdateManager.UpdateProcedureCheck(); @@ -812,9 +812,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 deleted file mode 100644 index 86c48adf..00000000 --- a/TShockAPI/TShockAPI.csproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {49606449-072B-4CF5-8088-AA49DA586694} - Library - Properties - TShockAPI - TShockAPI - v4.0 - 512 - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - ..\..\serverplugins\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - - - - False - ..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll - - - - - - False - ..\SqlBins\MySql.Data.dll - True - - - False - ..\SqlBins\MySql.Web.dll - True - - - .\Newtonsoft.Json.dll - - - - - - - - - - False - .exe - ..\TerrariaServerBins\TerrariaServer.exe - False - - - False - ..\TerrariaServerBins\TerrariaServerAPI.dll - - - False - ..\TerrariaServerBins\XNAHelpers.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - - - - - - - - - - - "$(ProjectDir)postbuild.bat" - - - - - - - - \ No newline at end of file diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index b9c29351..94c98f1b 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -17,13 +17,13 @@ along with this program. If not, see . */ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Security.Cryptography; using System.Text; -using Microsoft.Xna.Framework; using Terraria; using TerrariaAPI; diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index e6fb7072..fb97fa37 100644 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -17,9 +17,9 @@ along with this program. If not, see . */ using System; using System.Collections.Generic; +using System.Drawing; using System.Net; using System.Threading; -using Microsoft.Xna.Framework; using Newtonsoft.Json; namespace TShockAPI diff --git a/TerrariaServerBins/TerrariaServer.exe b/TerrariaServerBins/TerrariaServer.exe index d0445039..4f24f811 100644 Binary files a/TerrariaServerBins/TerrariaServer.exe and b/TerrariaServerBins/TerrariaServer.exe differ diff --git a/TerrariaServerBins/TerrariaServerAPI.dll b/TerrariaServerBins/TerrariaServerAPI.dll index 98f98188..13596f23 100644 Binary files a/TerrariaServerBins/TerrariaServerAPI.dll and b/TerrariaServerBins/TerrariaServerAPI.dll differ