From 1e6c74ace017a8872bb5f5df16097dd71845920a Mon Sep 17 00:00:00 2001 From: Zidonuke Date: Thu, 29 Dec 2011 20:23:58 -0500 Subject: [PATCH] Fix stuff with teleporting. --- TShockAPI/GetDataHandlers.cs | 70 +++++++++++++++++++++--------------- TShockAPI/TSPlayer.cs | 3 -- TShockAPI/TShock.cs | 2 +- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 0516953c..6555daff 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -738,39 +738,51 @@ namespace TShockAPI if (!pos.Equals(args.Player.LastNetPosition)) { float distance = Vector2.Distance(new Vector2(pos.X / 16f, pos.Y / 16f), new Vector2(args.Player.LastNetPosition.X / 16f, args.Player.LastNetPosition.Y / 16f)); - if (TShock.CheckIgnores(args.Player) && distance > TShock.Config.MaxRangeForDisabled) + if (TShock.CheckIgnores(args.Player)) { - if(args.Player.IgnoreActionsForCheating != "none") + if (distance > TShock.Config.MaxRangeForDisabled) { - args.Player.SendMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating, Color.Red); + if (args.Player.IgnoreActionsForCheating != "none") + { + args.Player.SendMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating, + Color.Red); + } + else if (args.Player.IgnoreActionsForDisabledArmor != "none") + { + args.Player.SendMessage( + "Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor, Color.Red); + } + else if (args.Player.IgnoreActionsForInventory != "none") + { + args.Player.SendMessage( + "Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory, + Color.Red); + } + else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) + { + args.Player.SendMessage("Please /register or /login to play!", Color.Red); + } + else if (args.Player.IgnoreActionsForClearingTrashCan) + { + args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red); + } + else if (TShock.Config.PvPMode == "always" && !args.TPlayer.hostile) + { + args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", + Color.Red); + } + int lastTileX = (int) (args.Player.LastNetPosition.X/16f); + int lastTileY = (int) (args.Player.LastNetPosition.Y/16f); + if (!args.Player.Teleport(lastTileX, lastTileY + 3)) + { + args.Player.Spawn(); + } + return true; } - else if (args.Player.IgnoreActionsForDisabledArmor != "none") + else { - args.Player.SendMessage("Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor, Color.Red); + return true; } - else if (args.Player.IgnoreActionsForInventory != "none") - { - args.Player.SendMessage("Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory, Color.Red); - } - else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) - { - args.Player.SendMessage("Please /register or /login to play!", Color.Red); - } - else if (args.Player.IgnoreActionsForClearingTrashCan) - { - args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red); - } - else if (TShock.Config.PvPMode == "always" && !args.TPlayer.hostile) - { - args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red); - } - int lastTileX = (int)(args.Player.LastNetPosition.X / 16f); - int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f); - if (!args.Player.Teleport(lastTileX, lastTileY + 3)) - { - args.Player.Spawn(); - } - return true; } if (args.Player.Dead) @@ -789,8 +801,8 @@ namespace TShockAPI } return true; } + args.Player.LastNetPosition = pos; } - args.Player.LastNetPosition = pos; if ((control & 32) == 32) { diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 9e008af6..2fa914b8 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -234,7 +234,6 @@ namespace TShockAPI { InitSpawn = false; - LastNetPosition = new Vector2(tilex * 16f, tiley * 16f); SendWorldInfo(tilex, tiley, true); //150 Should avoid all client crash errors @@ -245,7 +244,6 @@ namespace TShockAPI { InitSpawn = true; SendWorldInfo(Main.spawnTileX, Main.spawnTileY, false); - SendMessage("Warning, teleport failed due to being too close to the edge of the map.", Color.Red); return false; } @@ -261,7 +259,6 @@ namespace TShockAPI public void Spawn() { - LastNetPosition = new Vector2(TPlayer.SpawnX*16f, TPlayer.SpawnX*16f); Spawn(TPlayer.SpawnX, TPlayer.SpawnY); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 1dce2606..8c70e98f 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -842,7 +842,7 @@ namespace TShockAPI if (Config.RememberLeavePos) { var pos = RememberedPos.GetLeavePos(player.Name, player.IP); - player.Teleport((int) pos.X, (int) pos.Y); + player.Teleport((int) pos.X, (int) pos.Y + 3); } e.Handled = true;