protected MarketplaceItem(IReadOnlyPacket packet) { Id = packet.ReadLegacyLong(); UnknownInt2 = packet.ReadInt(); int itemType = packet.ReadInt(); switch (itemType) { case 1: Type = ItemType.Floor; Kind = packet.ReadInt(); Data = StuffData.Parse(packet); break; case 2: Type = ItemType.Wall; Kind = packet.ReadInt(); Data = new LegacyData() { Value = packet.ReadString() }; break; case 3: Type = ItemType.Floor; Kind = packet.ReadInt(); Data = new LegacyData() { Flags = ItemDataFlags.IsLimitedRare, LimitedNumber = packet.ReadInt(), LimitedTotal = packet.ReadInt() }; break; default: throw new Exception($"Unknown MarketplaceItem type: {itemType}"); } Price = packet.ReadInt(); TimeRemaining = packet.ReadInt(); Average = packet.ReadInt(); Offers = packet.ReadInt(); }
public static StuffData Parse(IReadOnlyPacket packet) { int value = packet.ReadInt(); var type = (StuffDataType)(value & 0xFF); StuffData data = type switch { StuffDataType.Legacy => new LegacyData(), StuffDataType.Map => new MapData(), StuffDataType.StringArray => new StringArrayData(), StuffDataType.VoteResult => new VoteResultData(), StuffDataType.ItemData4 => new ItemData4(), StuffDataType.IntArray => new IntArrayData(), StuffDataType.HighScore => new HighScoreData(), StuffDataType.CrackableFurni => new CrackableFurniData(), _ => throw new Exception($"Unknown ItemData type: {type}"), }; data.Flags = (ItemDataFlags)(value >> 8); data.Initialize(packet); return(data); }
protected InventoryItem(IReadOnlyPacket packet) : this() { ItemId = packet.ReadLegacyLong(); if (packet.Protocol == ClientType.Flash) { Type = H.ToItemType(packet.ReadString()); } else { Type = H.ToItemType(packet.ReadShort()); } Id = packet.ReadLegacyLong(); Kind = packet.ReadInt(); Category = (FurniCategory)packet.ReadInt(); Data = StuffData.Parse(packet); _Bool1 = packet.ReadBool(); IsTradeable = packet.ReadBool(); IsGroupable = packet.ReadBool(); IsSellable = packet.ReadBool(); SecondsToExpiration = packet.ReadInt(); HasRentPeriodStarted = packet.ReadBool(); RoomId = packet.ReadLegacyLong(); if (packet.Protocol == ClientType.Unity) { // - Seems to be consistent _String1 = packet.ReadString(); // string "" _String2 = packet.ReadString(); // string "r" / "s" _Int3 = packet.ReadInt(); // int 1187551480 } if (Type == ItemType.Floor) { if (packet.Protocol == ClientType.Flash) { _String2 = packet.ReadString(); Extra = packet.ReadInt(); } else { // 10 bytes ? _String3 = packet.ReadString(); Extra = packet.ReadInt(); _Int5 = packet.ReadInt(); } } else { _String3 = string.Empty; } /*if (clientType == ClientType.Flash) * { * ItemId = packet.ReadInt(); * Type = H.ToItemType(packet.ReadString()); * Id = packet.ReadInt(); * Kind = packet.ReadInt(); * Category = (FurniCategory)packet.ReadInt(); * Data = StuffData.Parse(packet, clientType); * _Bool1 = packet.ReadBool(); * IsTradeable = packet.ReadBool(); * IsGroupable = packet.ReadBool(); * IsSellable = packet.ReadBool(); * SecondsToExpiration = packet.ReadInt(); * HasRentPeriodStarted = packet.ReadBool(); * RoomId = packet.ReadInt(); * * if (Type == ItemType.Floor) * { * _String2 = packet.ReadString(); * Extra = packet.ReadInt(); * } * } * else * { * ItemId = packet.ReadLong(); * Type = H.ToItemType(packet.ReadShort()); * Id = packet.ReadLong(); * Kind = packet.ReadInt(); * Category = (FurniCategory)packet.ReadInt(); * Data = StuffData.Parse(packet, clientType); * _Bool1 = packet.ReadBool(); * IsTradeable = packet.ReadBool(); * IsGroupable = packet.ReadBool(); * IsSellable = packet.ReadBool(); * SecondsToExpiration = packet.ReadInt(); * HasRentPeriodStarted = packet.ReadBool(); * RoomId = packet.ReadLong(); * * // - Seems to be consistent * _String1 = packet.ReadString(); // string "" * _String2 = packet.ReadString(); // string "r" / "s" * _Int3 = packet.ReadInt(); // int 1187551480 * * if (Type == ItemType.Floor) * { * // 10 bytes ? * _String3 = packet.ReadString(); * Extra = packet.ReadInt(); * _Int5 = packet.ReadInt(); * } * else * { * _String3 = string.Empty; * } * }*/ }