From e50386084c5e2b98a9a36bd9a9b429e90b85b432 Mon Sep 17 00:00:00 2001 From: MarioE Date: Tue, 19 Nov 2013 18:01:47 -0500 Subject: [PATCH] Fix invis glitch --- TShockAPI/GetDataHandlers.cs | 3 +- TShockAPI/TShock.cs | 162 +++++++++++++++++++---------------- 2 files changed, 87 insertions(+), 78 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 785ff390..73fc6df0 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2447,7 +2447,7 @@ namespace TShockAPI bool hasPermission = !TShock.CheckProjectilePermission(args.Player, index, type); if (!TShock.Config.IgnoreProjUpdate && !hasPermission) { - if ((type == 100) || (type > 289 && type < 298) || (type >= 325 && type <= 328)) + if ((type == 100) || type == 261 || (type > 289 && type < 298) || (type >= 325 && type <= 328)) { Log.Debug("Certain projectiles have been ignored for cheat detection."); } @@ -3189,7 +3189,6 @@ namespace TShockAPI private static bool HandlePlayerAnimation(GetDataHandlerArgs args) { - if (OnPlayerAnimation()) return true; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index e529d5e1..65501420 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1291,7 +1291,7 @@ namespace TShockAPI sock.kill = true; using (var ms = new MemoryStream()) { - new DisconnectMsg {Reason = str}.PackFull(ms); + new DisconnectMsg { Reason = str }.PackFull(ms); SendBytesBufferless(sock, ms.ToArray()); } }; @@ -1311,82 +1311,92 @@ namespace TShockAPI } } e.Handled = true; + return; + } + else if (e.MsgId == PacketTypes.WorldInfo) + { + if (e.remoteClient == -1) return; + var player = Players[e.remoteClient]; + if (player == null) return; + if (Config.UseServerName) + { + using (var ms = new MemoryStream()) + { + var msg = new WorldInfoMsg + { + Time = (int)Main.time, + DayTime = Main.dayTime, + MoonPhase = (byte)Main.moonPhase, + BloodMoon = Main.bloodMoon, + MaxTilesX = Main.maxTilesX, + MaxTilesY = Main.maxTilesY, + SpawnX = Main.spawnTileX, + SpawnY = Main.spawnTileY, + WorldSurface = (int)Main.worldSurface, + RockLayer = (int)Main.rockLayer, + //Sending a fake world id causes the client to not be able to find a stored spawnx/y. + //This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn. + WorldID = Main.worldID, + MoonType = (byte)Main.moonType, + TreeX0 = Main.treeX[0], + TreeX1 = Main.treeX[1], + TreeX2 = Main.treeX[2], + TreeStyle0 = (byte)Main.treeStyle[0], + TreeStyle1 = (byte)Main.treeStyle[1], + TreeStyle2 = (byte)Main.treeStyle[2], + TreeStyle3 = (byte)Main.treeStyle[3], + CaveBackX0 = Main.caveBackX[0], + CaveBackX1 = Main.caveBackX[1], + CaveBackX2 = Main.caveBackX[2], + CaveBackStyle0 = (byte)Main.caveBackStyle[0], + CaveBackStyle1 = (byte)Main.caveBackStyle[1], + CaveBackStyle2 = (byte)Main.caveBackStyle[2], + CaveBackStyle3 = (byte)Main.caveBackStyle[3], + SetBG0 = (byte)WorldGen.treeBG, + SetBG1 = (byte)WorldGen.corruptBG, + SetBG2 = (byte)WorldGen.jungleBG, + SetBG3 = (byte)WorldGen.snowBG, + SetBG4 = (byte)WorldGen.hallowBG, + SetBG5 = (byte)WorldGen.crimsonBG, + SetBG6 = (byte)WorldGen.desertBG, + SetBG7 = (byte)WorldGen.oceanBG, + IceBackStyle = (byte)Main.iceBackStyle, + JungleBackStyle = (byte)Main.jungleBackStyle, + HellBackStyle = (byte)Main.hellBackStyle, + WindSpeed = Main.windSpeed, + NumberOfClouds = (byte)Main.numClouds, + BossFlags = (WorldGen.shadowOrbSmashed ? BossFlags.OrbSmashed : BossFlags.None) | + (NPC.downedBoss1 ? BossFlags.DownedBoss1 : BossFlags.None) | + (NPC.downedBoss2 ? BossFlags.DownedBoss2 : BossFlags.None) | + (NPC.downedBoss3 ? BossFlags.DownedBoss3 : BossFlags.None) | + (Main.hardMode ? BossFlags.HardMode : BossFlags.None) | + (NPC.downedClown ? BossFlags.DownedClown : BossFlags.None) | + (Main.ServerSideCharacter ? BossFlags.ServerSideCharacter : BossFlags.None), + BossFlags2 = (NPC.downedMechBoss1 ? BossFlags2.DownedMechBoss1 : BossFlags2.None) | + (NPC.downedMechBoss2 ? BossFlags2.DownedMechBoss2 : BossFlags2.None) | + (NPC.downedMechBoss3 ? BossFlags2.DownedMechBoss3 : BossFlags2.None) | + (NPC.downedMechBossAny ? BossFlags2.DownedMechBossAny : BossFlags2.None) | + (Main.cloudBGActive == 1f ? BossFlags2.CloudBg : BossFlags2.None) | + (WorldGen.crimson ? BossFlags2.Crimson : BossFlags2.None) | + (Main.pumpkinMoon ? BossFlags2.Pumpkin : BossFlags2.None), + Rain = Main.maxRaining, + WorldName = TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName + }; + msg.PackFull(ms); + player.SendRawData(ms.ToArray()); + } + e.Handled = true; + return; + } + } + else if (e.MsgId == PacketTypes.PlayerHp) + { + if (Main.player[(byte)e.number].statLife <= 0) + { + e.Handled = true; + return; + } } - if (e.MsgId == PacketTypes.WorldInfo) - { - if (e.remoteClient == -1) return; - var player = Players[e.remoteClient]; - if (player == null) return; - if (Config.UseServerName) - { - using (var ms = new MemoryStream()) - { - var msg = new WorldInfoMsg - { - Time = (int) Main.time, - DayTime = Main.dayTime, - MoonPhase = (byte) Main.moonPhase, - BloodMoon = Main.bloodMoon, - MaxTilesX = Main.maxTilesX, - MaxTilesY = Main.maxTilesY, - SpawnX = Main.spawnTileX, - SpawnY = Main.spawnTileY, - WorldSurface = (int) Main.worldSurface, - RockLayer = (int) Main.rockLayer, - //Sending a fake world id causes the client to not be able to find a stored spawnx/y. - //This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn. - WorldID = Main.worldID, - MoonType = (byte)Main.moonType, - TreeX0 = Main.treeX[0], - TreeX1 = Main.treeX[1], - TreeX2 = Main.treeX[2], - TreeStyle0 = (byte)Main.treeStyle[0], - TreeStyle1 = (byte)Main.treeStyle[1], - TreeStyle2 = (byte)Main.treeStyle[2], - TreeStyle3 = (byte)Main.treeStyle[3], - CaveBackX0 = Main.caveBackX[0], - CaveBackX1 = Main.caveBackX[1], - CaveBackX2 = Main.caveBackX[2], - CaveBackStyle0 = (byte)Main.caveBackStyle[0], - CaveBackStyle1 = (byte)Main.caveBackStyle[1], - CaveBackStyle2 = (byte)Main.caveBackStyle[2], - CaveBackStyle3 = (byte)Main.caveBackStyle[3], - SetBG0 = (byte)WorldGen.treeBG, - SetBG1 = (byte)WorldGen.corruptBG, - SetBG2 = (byte)WorldGen.jungleBG, - SetBG3 = (byte)WorldGen.snowBG, - SetBG4 = (byte)WorldGen.hallowBG, - SetBG5 = (byte)WorldGen.crimsonBG, - SetBG6 = (byte)WorldGen.desertBG, - SetBG7 = (byte)WorldGen.oceanBG, - IceBackStyle = (byte)Main.iceBackStyle, - JungleBackStyle = (byte)Main.jungleBackStyle, - HellBackStyle = (byte)Main.hellBackStyle, - WindSpeed = Main.windSpeed, - NumberOfClouds = (byte)Main.numClouds, - BossFlags = (WorldGen.shadowOrbSmashed ? BossFlags.OrbSmashed : BossFlags.None) | - (NPC.downedBoss1 ? BossFlags.DownedBoss1 : BossFlags.None) | - (NPC.downedBoss2 ? BossFlags.DownedBoss2 : BossFlags.None) | - (NPC.downedBoss3 ? BossFlags.DownedBoss3 : BossFlags.None) | - (Main.hardMode ? BossFlags.HardMode : BossFlags.None) | - (NPC.downedClown ? BossFlags.DownedClown : BossFlags.None) | - (Main.ServerSideCharacter ? BossFlags.ServerSideCharacter : BossFlags.None), - BossFlags2 = (NPC.downedMechBoss1 ? BossFlags2.DownedMechBoss1 : BossFlags2.None) | - (NPC.downedMechBoss2 ? BossFlags2.DownedMechBoss2 : BossFlags2.None) | - (NPC.downedMechBoss3 ? BossFlags2.DownedMechBoss3 : BossFlags2.None) | - (NPC.downedMechBossAny ? BossFlags2.DownedMechBossAny : BossFlags2.None) | - (Main.cloudBGActive == 1f ? BossFlags2.CloudBg : BossFlags2.None) | - (WorldGen.crimson ? BossFlags2.Crimson : BossFlags2.None) | - (Main.pumpkinMoon ? BossFlags2.Pumpkin : BossFlags2.None), - Rain = Main.maxRaining, - WorldName = TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName - }; - msg.PackFull(ms); - player.SendRawData(ms.ToArray()); - } - e.Handled = true; - } - } } private void OnStartHardMode(HandledEventArgs e)