Updated to new binary (with the api merged).

Removed System.Drawing dependency
This commit is contained in:
high 2011-09-24 18:29:27 -04:00
parent b95caf67c2
commit b2f47f57ac
20 changed files with 82 additions and 96 deletions

View file

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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;

View file

@ -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;

View file

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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<int>("X"), reader.Get<int>("Y"));
return new Vector2(reader.Get<int>("X"), reader.Get<int>("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
{

View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"), reader.Get<string>("Private"));
return new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"), reader.Get<string>("Private"));
}
catch
{
return new Warp(new PointF(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"), "0");
return new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("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";

View file

@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
}

View file

@ -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
{

View file

@ -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
{

View file

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

View file

@ -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
{

View file

@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.IO;
using System.Text;
using TerrariaAPI;
using XNAHelpers;
using System.IO.Streams;
namespace TShockAPI.Net
{

View file

@ -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
{

View file

@ -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")]

View file

@ -24,7 +24,7 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Terraria;
using XNAHelpers;
using System.IO.Streams;
namespace TShockAPI
{

View file

@ -17,13 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PointF, TileData> TilesDestroyed { get; protected set; }
public Dictionary<Vector2, TileData> 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<PointF, TileData>();
TilesDestroyed = new Dictionary<Vector2, TileData>();
Index = index;
Group = new Group("null");
}
protected TSPlayer(String playerName)
{
TilesDestroyed = new Dictionary<PointF, TileData>();
TilesDestroyed = new Dictionary<Vector2, TileData>();
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<PointF, TileData> destroyedTiles)
public void RevertKillTile(Dictionary<Vector2, TileData> destroyedTiles)
{
// Update Main.Tile first so that when tile sqaure is sent it is correct
foreach (KeyValuePair<PointF, TileData> entry in destroyedTiles)
foreach (KeyValuePair<Vector2, TileData> 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);
}

View file

@ -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);
}
/// <summary>
@ -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;

View file

@ -70,7 +70,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -82,10 +81,6 @@
<HintPath>..\TerrariaServerBins\TerrariaServer.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="TerrariaServerAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BackupManager.cs" />
@ -186,7 +181,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
@ -25,7 +25,7 @@ using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using Terraria;
using TerrariaAPI;
namespace TShockAPI
{

View file

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Net;
using System.Threading;
using Newtonsoft.Json;

View file

@ -1,5 +1,4 @@
using System;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System.Linq;

View file

@ -67,10 +67,10 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="TerrariaServerAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="TerrariaServer, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
<ExecutableExtension>.exe</ExecutableExtension>
<HintPath>..\TerrariaServerBins\TerrariaServer.exe</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>