diff --git a/CHANGELOG.md b/CHANGELOG.md index 893519d5..a69b28a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Attempted to fix the problem with the magic mirror spawn problems. You should be able to remove your spawn point in SSC by right clicking on a bed now. (@hakusaro, @AxeelAnder) * Added HandleFoodPlatterTryPlacing event, which is called whenever a player places a food in a plate. Add antihack to bouncer, to prevent removing food from plates if the region is protected; To prevent placement if they are not in range; To prevent placement if the item is not placed from player hand. (@Patrikkk) * Fixed an offset error in NetTile that impacted `SendTileSquare`. It was being read as a `byte` and not a `ushort`. (@QuiCM) +* Fixed coins not dropping after being picked up by npcs. The ExtraValue packet was not being read correctly. (@Olink) * Removed packet monitoring from debug logs. To achieve the same results, install @QuiCM's packet monitor plugin (it does better things). (@hakusaro) * Updated packet monitoring in send tile square handler for Bouncer debugging. (@hakusaro) * Added `/sync`, activated with `tshock.synclocalarea`. This is a default guest permission. When the command is issued, the server will resync area around the player in the event of a desync issue. (@hakusaro) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index b6d35d62..a81ff597 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -151,7 +151,8 @@ namespace TShockAPI { PacketTypes.CrystalInvasionStart, HandleOldOnesArmy }, { PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 }, { PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 }, - { PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing } + { PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }, + { PacketTypes.SyncRevengeMarker, HandleSyncRevengeMarker } }; } @@ -3383,24 +3384,38 @@ namespace TShockAPI private static bool HandleSyncExtraValue(GetDataHandlerArgs args) { var npcIndex = args.Data.ReadInt16(); - var extraValue = args.Data.ReadSingle(); + var extraValue = args.Data.ReadInt32(); var position = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); - if (position.X < 0 || position.X >= Main.maxTilesX || position.Y < 0 || position.Y >= Main.maxTilesY) + if (position.X < 0 || position.X >= (Main.maxTilesX * 16.0f) || position.Y < 0 || position.Y >= (Main.maxTilesY * 16.0f)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name); return true; } - if (!Main.expertMode) + if (!Main.expertMode && !Main.masterMode) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert mode check {0}", args.Player.Name); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert/master mode check {0}", args.Player.Name); return true; } - if (!args.Player.IsInRange((int)position.X, (int)position.Y)) + if (npcIndex < 0 || npcIndex >= Main.npc.Length) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0}", args.Player.Name); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc id out of bounds check - NPC ID: {0}", npcIndex); + return true; + } + + var npc = Main.npc[npcIndex]; + if (npc == null) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc is null - NPC ID: {0}", npcIndex); + return true; + } + + var distanceFromCoinPacketToNpc = Utils.Distance(position, npc.position); + if (distanceFromCoinPacketToNpc >= (5*16f)) //5 tile range + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0},{1} vs {2},{3} which is {4}", npc.position.X, npc.position.Y, position.X, position.Y, distanceFromCoinPacketToNpc); return true; } @@ -3628,6 +3643,21 @@ namespace TShockAPI return false; } + private static bool HandleSyncRevengeMarker(GetDataHandlerArgs args) + { + int uniqueID = args.Data.ReadInt32(); + Vector2 location = args.Data.ReadVector2(); + int netId = args.Data.ReadInt32(); + float npcHpPercent = args.Data.ReadSingle(); + int npcTypeAgainstDiscouragement = args.Data.ReadInt32(); //tfw the argument is Type Against Discouragement + int npcAiStyleAgainstDiscouragement = args.Data.ReadInt32(); //see ^ + int coinsValue = args.Data.ReadInt32(); + float baseValue = args.Data.ReadSingle(); + bool spawnedFromStatus = args.Data.ReadBoolean(); + + return false; + } + public enum EditAction { KillTile = 0, diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 3839a5ec..a0bc4e64 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1633,7 +1633,8 @@ namespace TShockAPI e.Handled = true; return; } - } else if (e.MsgId == PacketTypes.ProjectileNew) + } + else if (e.MsgId == PacketTypes.ProjectileNew) { if (e.number >= 0 && e.number < Main.projectile.Length) { @@ -1658,7 +1659,6 @@ namespace TShockAPI } } } - } }