This commit is contained in:
Lucas Nicodemus 2011-09-02 23:21:01 -06:00
parent b0f5a49ec2
commit 442a5b4202
15 changed files with 74 additions and 255 deletions

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;
@ -145,14 +145,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");
@ -406,17 +406,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);
}