Removed XNA dependencies

This commit is contained in:
high 2011-08-30 08:36:34 -04:00
parent 8bb8114223
commit 21ac8a4a0e
16 changed files with 72 additions and 68 deletions

View file

@ -18,14 +18,15 @@ 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;
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;

View file

@ -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<string>("UserIds");
string name = reader.Get<string>("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<string> 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<int> id_list = new List<int>();
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);
}
}
}

View file

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

View file

@ -19,9 +19,9 @@ 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 Microsoft.Xna.Framework;
using MySql.Data.MySqlClient;
using Terraria;
@ -173,11 +173,11 @@ namespace TShockAPI.DB
{
try
{
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"));
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"));
}
catch
{
return new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"), "0");
return new Warp(new PointF(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 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";

View file

@ -18,9 +18,9 @@ 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 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]);
}

View file

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

View file

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

View file

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

View file

@ -17,9 +17,9 @@ 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 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<Vector2, Tile> TilesDestroyed { get; protected set; }
public Dictionary<PointF, Tile> 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<Vector2, Tile>();
TilesDestroyed = new Dictionary<PointF, Tile>();
Index = index;
Group = new Group("null");
}
protected TSPlayer(String playerName)
{
TilesDestroyed = new Dictionary<Vector2, Tile>();
TilesDestroyed = new Dictionary<PointF, Tile>();
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<Vector2, Tile> destroyedTiles)
public void RevertKillTile(Dictionary<PointF, Tile> destroyedTiles)
{
// Update Main.Tile first so that when tile sqaure is sent it is correct
foreach (KeyValuePair<Vector2, Tile> entry in destroyedTiles)
foreach (KeyValuePair<PointF, Tile> 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);
}

View file

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

View file

@ -52,9 +52,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SqlBins\MySql.Data.dll</HintPath>
@ -70,6 +67,7 @@
</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" />
@ -85,10 +83,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
</Reference>
<Reference Include="XNAHelpers, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\XNAHelpers.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BackupManager.cs" />
@ -182,7 +176,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -17,13 +17,13 @@ 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;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Xna.Framework;
using Terraria;
using TerrariaAPI;

View file

@ -17,9 +17,9 @@ 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 Microsoft.Xna.Framework;
using Newtonsoft.Json;
namespace TShockAPI

Binary file not shown.