From 45e5773c233fe2bc0b03b79030421150ba1831e7 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Fri, 29 May 2020 17:12:46 +0930 Subject: [PATCH] Fix a read bug on NetTiles that causes tiles to have junk data --- TShockAPI/GetDataHandlers.cs | 8 ++++++++ TShockAPI/Net/NetTile.cs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 74dbff85..181ce190 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2316,6 +2316,14 @@ namespace TShockAPI { var player = args.Player; var size = args.Data.ReadInt16(); + var changeType = TileChangeType.None; + + bool hasChangeType = ((size & 0x7FFF) & 0x8000) != 0; + if (hasChangeType) + { + changeType = (TileChangeType)args.Data.ReadInt8(); + } + var tileX = args.Data.ReadInt16(); var tileY = args.Data.ReadInt16(); var data = args.Data; diff --git a/TShockAPI/Net/NetTile.cs b/TShockAPI/Net/NetTile.cs index c49aadea..62b362f9 100644 --- a/TShockAPI/Net/NetTile.cs +++ b/TShockAPI/Net/NetTile.cs @@ -30,7 +30,7 @@ namespace TShockAPI.Net public short FrameX { get; set; } public short FrameY { get; set; } public bool Lighted { get; set; } - public byte Wall { get; set; } + public ushort Wall { get; set; } public byte Liquid { get; set; } public byte LiquidType { get; set; } public bool Wire { get; set; } @@ -179,7 +179,7 @@ namespace TShockAPI.Net } if (HasWall) - stream.WriteInt8(Wall); + stream.WriteInt16((short)Wall); if (HasLiquid) { @@ -223,7 +223,7 @@ namespace TShockAPI.Net if (flags[2]) { - Wall = stream.ReadInt8(); + Wall = stream.ReadUInt16(); } if (flags[3])