From e20f717269f71f26f41fdd10be87889b460483e9 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 19 May 2020 01:37:12 -0700 Subject: [PATCH] Remove reimplementation of Terraria player sync The reimplementation of Terraria player sync was first created by @Zidonuke when introducing better antihack and the item ban system. He added this because he was probably attempting to correct the client that sent that sent bad data. The primary purpose was to send data back to the client, not necessarily for the purpose of doing anything for the server. This is demonstrated by the fact that when we added player update handling, we started rejecting the packets outright and not sending the player any packets. This means that functionally we don't run this code hardly ever if someone is actually disabled. Some of those code was related to /confuse. That is also being removed. --- TShockAPI/GetDataHandlers.cs | 114 +---------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 20409603..199eb024 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2127,119 +2127,7 @@ namespace TShockAPI if (OnPlayerUpdate(args.Player, args.Data, playerID, controls, miscData1, miscData2, miscData3, selectedItem, position, velocity, originalPosition, homePosition)) return true; - if (controls.IsUsingItem) - { - // Reimplementation of normal Terraria stuff? - if (args.TPlayer.inventory[selectedItem].Name == "Mana Crystal" && args.Player.TPlayer.statManaMax <= 180) - { - args.Player.TPlayer.statMana += 20; - args.Player.TPlayer.statManaMax += 20; - args.Player.PlayerData.maxMana += 20; - } - else if (args.TPlayer.inventory[selectedItem].Name == "Life Crystal" && args.Player.TPlayer.statLifeMax <= 380) - { - args.TPlayer.statLife += 20; - args.TPlayer.statLifeMax += 20; - args.Player.PlayerData.maxHealth += 20; - } - else if (args.TPlayer.inventory[selectedItem].Name == "Life Fruit" && args.Player.TPlayer.statLifeMax >= 400 && args.Player.TPlayer.statLifeMax <= 495) - { - args.TPlayer.statLife += 5; - args.TPlayer.statLifeMax += 5; - args.Player.PlayerData.maxHealth += 5; - } - } - - // Where we rebuild sync data for Terraria? - args.TPlayer.selectedItem = selectedItem; - args.TPlayer.position = position; - args.TPlayer.oldVelocity = args.TPlayer.velocity; - args.TPlayer.velocity = velocity; - args.TPlayer.fallStart = (int)(position.Y / 16f); - args.TPlayer.controlUp = false; - args.TPlayer.controlDown = false; - args.TPlayer.controlLeft = false; - args.TPlayer.controlRight = false; - args.TPlayer.controlJump = false; - args.TPlayer.controlUseItem = false; - args.TPlayer.pulley = miscData1.IsUsingPulley; - - if (miscData1.IsUsingPulley) - args.TPlayer.pulleyDir = (byte)(miscData1.PulleyDirection ? 2 : 1); - - if (miscData1.IsVortexStealthActive) - args.TPlayer.vortexStealthActive = true; - else - args.TPlayer.vortexStealthActive = false; - - args.TPlayer.gravDir = miscData1.GravityDirection ? 1f : -1f; - - args.TPlayer.direction = -1; - - if (controls.MoveUp) - { - args.TPlayer.controlUp = true; - } - if (controls.MoveDown) - { - args.TPlayer.controlDown = true; - } - if (controls.MoveLeft) - { - args.TPlayer.controlLeft = true; - } - if (controls.MoveRight) - { - args.TPlayer.controlRight = true; - } - if (controls.Jump) - { - args.TPlayer.controlJump = true; - } - if (controls.IsUsingItem) - { - args.TPlayer.controlUseItem = true; - } - if (controls.FaceDirection) - { - args.TPlayer.direction = 1; - } - else - { - args.TPlayer.direction = -1; - } - - if (args.Player.Confused && Main.ServerSideCharacter && args.Player.IsLoggedIn) - { - if (args.TPlayer.controlUp) - { - args.TPlayer.controlDown = true; - args.TPlayer.controlUp = false; - } - else if (args.TPlayer.controlDown) - { - args.TPlayer.controlDown = false; - args.TPlayer.controlUp = true; - } - - if (args.TPlayer.controlLeft) - { - args.TPlayer.controlRight = true; - args.TPlayer.controlLeft = false; - } - else if (args.TPlayer.controlRight) - { - args.TPlayer.controlRight = false; - args.TPlayer.controlLeft = true; - } - - args.TPlayer.Update(args.TPlayer.whoAmI); - NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, -1, NetworkText.Empty, args.Player.Index); - return true; - } - - NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, args.Player.Index, NetworkText.Empty, args.Player.Index); - return true; + return false; } private static bool HandlePlayerHp(GetDataHandlerArgs args)