From ee6a98eb4efda7e0fc5bab90e8f7033255356dd3 Mon Sep 17 00:00:00 2001 From: ProfessorXZ Date: Mon, 1 Aug 2016 09:33:51 +0200 Subject: [PATCH] Fixes #1255 --- CHANGELOG.md | 8 ++++++++ TShockAPI/GetDataHandlers.cs | 34 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 440394fa..4c1253c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,15 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming Changes +* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ) * The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju) +* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ) +* Fixed clients being able to remove other players' portals (@ProfessorXZ) +* Fixed possible client crashes caused by invalid item netIDs (@ProfessorXZ) +* Fixed players being able to bypass permission checks when placing Tile Entities (@ProfessorXZ) +* Fixed players being able to bypass permission checks when placing items in Item Frames (@ProfessorXZ) +* Fixed a bug involving Item Frames which allowed players to duplicate items (@ProfessorXZ) +* Fixed an issue allowing clients to teleport NPCs to arbitrary locations (@ProfessorXZ) ## TShock 4.3.17 diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 74bff63b..1dc210de 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1255,6 +1255,7 @@ namespace TShockAPI { PacketTypes.MassWireOperation, HandleMassWireOperation }, { PacketTypes.GemLockToggle, HandleGemLockToggle }, { PacketTypes.CatchNPC, HandleCatchNpc }, + { PacketTypes.NpcTeleportPortal, HandleNpcTeleportPortal }, { PacketTypes.KillPortal, HandleKillPortal }, { PacketTypes.PlaceTileEntity, HandlePlaceTileEntity }, { PacketTypes.PlaceItemFrame, HandlePlaceItemFrame }, @@ -4089,7 +4090,30 @@ namespace TShockAPI if (Main.npc[npcID]?.catchItem == 0) { Main.npc[npcID].active = true; - NetMessage.SendData(23, -1, -1, "", npcID); + NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", npcID); + return true; + } + + return false; + } + + private static bool HandleNpcTeleportPortal(GetDataHandlerArgs args) + { + var npcIndex = args.Data.ReadByte(); + var portalColorIndex = args.Data.ReadInt16(); + var newPosition = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); + var velocity = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); + var projectile = Main.projectile.FirstOrDefault(p => p.position.X == newPosition.X && p.position.Y == newPosition.Y); // Check for projectiles at this location + + if (projectile == null || !projectile.active) + { + NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", npcIndex); + return true; + } + + if (projectile.type != ProjectileID.PortalGunGate) + { + NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", npcIndex); return true; } @@ -4154,25 +4178,25 @@ namespace TShockAPI if (TShock.CheckIgnores(args.Player)) { - NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, "", itemFrame.ID, 0, 1); return true; } if (TShock.CheckTilePermission(args.Player, x, y)) { - NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, "", itemFrame.ID, 0, 1); return true; } if (TShock.CheckRangePermission(args.Player, x, y)) { - NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, "", itemFrame.ID, 0, 1); return true; } if (itemFrame.item?.netID == args.TPlayer.inventory[args.TPlayer.selectedItem]?.netID) { - NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, "", itemFrame.ID, 0, 1); return true; }