From 866cb5b87e149f0c5f9b764a724717e6c5a5cf2d Mon Sep 17 00:00:00 2001 From: teascade Date: Sun, 14 May 2017 23:47:45 +0300 Subject: [PATCH] Fix Inventory syncing --- Assets/Scripts/Entities/SyncBases/Inventory.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Assets/Scripts/Entities/SyncBases/Inventory.cs b/Assets/Scripts/Entities/SyncBases/Inventory.cs index 369fb7d..34e0dc7 100644 --- a/Assets/Scripts/Entities/SyncBases/Inventory.cs +++ b/Assets/Scripts/Entities/SyncBases/Inventory.cs @@ -80,8 +80,16 @@ namespace Cyber.Entities.SyncBases { Drive.AddItem(ItemDB.Singleton.Get(id)); } + bool ReceivedSlots = reader.ReadBoolean(); + if (!ReceivedSlots) { + Equipped.ClearAllEquipped(); + return; + } + byte[] Slots = reader.ReadBytesAndSize(); + Debug.Log(Slots); + byte[][] EquippedIdsBytes = new byte[4][]; EquippedIdsBytes[0] = reader.ReadBytesAndSize(); EquippedIdsBytes[1] = reader.ReadBytesAndSize(); @@ -106,12 +114,20 @@ namespace Cyber.Entities.SyncBases { IDs[i] = Items[i].ID; } byte[][] ByteArray = NetworkHelper.SerializeIntArray(IDs); + writer.WriteBytesFull(ByteArray[0]); writer.WriteBytesFull(ByteArray[1]); writer.WriteBytesFull(ByteArray[2]); writer.WriteBytesFull(ByteArray[3]); var slotList = new List(Equipped.GetEquippedDict().Keys).ConvertAll(x => (byte) x); + + if (slotList.Count > 0) { + writer.Write(true); + } else { + writer.Write(false); + } + slotList.Sort((a, b) => { return b - a; });