diff --git a/LibreMetaverse.Types/Color4.cs b/LibreMetaverse.Types/Color4.cs index 0fd21fc0..0b7dd8e0 100644 --- a/LibreMetaverse.Types/Color4.cs +++ b/LibreMetaverse.Types/Color4.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -27,7 +26,6 @@ using System; using System.Runtime.InteropServices; -using ProtoBuf; namespace OpenMetaverse { @@ -36,20 +34,15 @@ namespace OpenMetaverse /// [Serializable] [StructLayout(LayoutKind.Sequential)] - [ProtoContract] public struct Color4 : IComparable, IEquatable { /// Red - [ProtoMember(1)] public float R; /// Green - [ProtoMember(2)] public float G; /// Blue - [ProtoMember(3)] public float B; /// Alpha - [ProtoMember(4)] public float A; #region Constructors diff --git a/LibreMetaverse.Types/LibreMetaverse.Types.csproj b/LibreMetaverse.Types/LibreMetaverse.Types.csproj index 247cd4af..f34673ff 100644 --- a/LibreMetaverse.Types/LibreMetaverse.Types.csproj +++ b/LibreMetaverse.Types/LibreMetaverse.Types.csproj @@ -130,9 +130,6 @@ - - - diff --git a/LibreMetaverse.Types/Quaternion.cs b/LibreMetaverse.Types/Quaternion.cs index f5e92eff..34ff2b4f 100644 --- a/LibreMetaverse.Types/Quaternion.cs +++ b/LibreMetaverse.Types/Quaternion.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -28,29 +27,23 @@ using System; using System.Runtime.InteropServices; using System.Globalization; -using ProtoBuf; namespace OpenMetaverse { [Serializable] - [ProtoContract] [StructLayout(LayoutKind.Sequential)] public struct Quaternion : IEquatable { /// X value - [ProtoMember(1)] public float X; /// Y value - [ProtoMember(2)] public float Y; /// Z value - [ProtoMember(3)] public float Z; /// W value - [ProtoMember(4)] public float W; #region Constructors diff --git a/LibreMetaverse.Types/UUID.cs b/LibreMetaverse.Types/UUID.cs index eaf13353..98e516d5 100644 --- a/LibreMetaverse.Types/UUID.cs +++ b/LibreMetaverse.Types/UUID.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -27,7 +26,6 @@ using System; using System.Security.Cryptography; -using ProtoBuf; namespace OpenMetaverse { @@ -36,11 +34,9 @@ namespace OpenMetaverse /// Life networking protocol /// [Serializable] - [ProtoContract] public struct UUID : IComparable, IEquatable { /// The System.Guid object this struct wraps around - [ProtoMember(1)] public Guid Guid { get; set; } #region Constructors diff --git a/LibreMetaverse.Types/Vector2.cs b/LibreMetaverse.Types/Vector2.cs index f01fc2a2..e3138516 100644 --- a/LibreMetaverse.Types/Vector2.cs +++ b/LibreMetaverse.Types/Vector2.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -28,7 +27,6 @@ using System; using System.Runtime.InteropServices; using System.Globalization; -using ProtoBuf; namespace OpenMetaverse { @@ -37,14 +35,11 @@ namespace OpenMetaverse /// [Serializable] [StructLayout(LayoutKind.Sequential)] - [ProtoContract] public struct Vector2 : IComparable, IEquatable { /// X value - [ProtoMember(1)] public float X; /// Y value - [ProtoMember(2)] public float Y; #region Constructors diff --git a/LibreMetaverse.Types/Vector3.cs b/LibreMetaverse.Types/Vector3.cs index b0e89ac5..b4655170 100644 --- a/LibreMetaverse.Types/Vector3.cs +++ b/LibreMetaverse.Types/Vector3.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -28,7 +27,6 @@ using System; using System.Runtime.InteropServices; using System.Globalization; -using ProtoBuf; namespace OpenMetaverse { @@ -37,19 +35,15 @@ namespace OpenMetaverse /// [Serializable] [StructLayout(LayoutKind.Sequential)] - [ProtoContract] public struct Vector3 : IComparable, IEquatable { /// X value - [ProtoMember(1)] public float X; /// Y value - [ProtoMember(2)] public float Y; /// Z value - [ProtoMember(3)] public float Z; #region Constructors diff --git a/LibreMetaverse.Types/Vector3d.cs b/LibreMetaverse.Types/Vector3d.cs index 383c8ed1..0f71dabe 100644 --- a/LibreMetaverse.Types/Vector3d.cs +++ b/LibreMetaverse.Types/Vector3d.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -28,7 +27,6 @@ using System; using System.Runtime.InteropServices; using System.Globalization; -using ProtoBuf; namespace OpenMetaverse { @@ -37,17 +35,13 @@ namespace OpenMetaverse /// [Serializable] [StructLayout(LayoutKind.Sequential)] - [ProtoContract] public struct Vector3d : IComparable, IEquatable { /// X value - [ProtoMember(1)] public double X; /// Y value - [ProtoMember(2)] public double Y; /// Z value - [ProtoMember(3)] public double Z; #region Constructors diff --git a/LibreMetaverse.Types/Vector4.cs b/LibreMetaverse.Types/Vector4.cs index 91f9b38a..3ed77218 100644 --- a/LibreMetaverse.Types/Vector4.cs +++ b/LibreMetaverse.Types/Vector4.cs @@ -1,6 +1,5 @@ /* * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. * All rights reserved. * * - Redistribution and use in source and binary forms, with or without @@ -28,26 +27,20 @@ using System; using System.Runtime.InteropServices; using System.Globalization; -using ProtoBuf; namespace OpenMetaverse { [Serializable] [StructLayout(LayoutKind.Sequential)] - [ProtoContract] public struct Vector4 : IComparable, IEquatable { /// X value - [ProtoMember(1)] public float X; /// Y value - [ProtoMember(2)] public float Y; /// Z value - [ProtoMember(3)] public float Z; /// W value - [ProtoMember(4)] public float W; #region Constructors diff --git a/LibreMetaverse/Inventory.cs b/LibreMetaverse/Inventory.cs index e9800962..6a2cb8b1 100644 --- a/LibreMetaverse/Inventory.cs +++ b/LibreMetaverse/Inventory.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.Serialization.Formatters.Binary; -using ProtoBuf; namespace OpenMetaverse { @@ -352,7 +351,7 @@ namespace OpenMetaverse Logger.Log("Caching " + Items.Count.ToString() + " inventory items to " + filename, Helpers.LogLevel.Info); foreach (KeyValuePair kvp in Items) { - Serializer.Serialize(stream, kvp.Value); + ZeroFormatter.ZeroFormatterSerializer.Serialize(stream, kvp.Value); } } } @@ -382,7 +381,7 @@ namespace OpenMetaverse { while (stream.Position < stream.Length) { - var node = Serializer.Deserialize(stream); + var node = ZeroFormatter.ZeroFormatterSerializer.Deserialize(stream); nodes.Add(node); item_count++; } diff --git a/LibreMetaverse/InventoryBase.cs b/LibreMetaverse/InventoryBase.cs index e1ed982a..a7c8c529 100644 --- a/LibreMetaverse/InventoryBase.cs +++ b/LibreMetaverse/InventoryBase.cs @@ -1,57 +1,24 @@ -/* - * Copyright (c) 2006-2016, openmetaverse.co - * Copyright (c) 2021, Sjofn LLC. - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the openmetaverse.co nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; +using System; +using System.Collections.Generic; using System.Runtime.Serialization; +using System.Text; using OpenMetaverse.StructuredData; -using ProtoBuf; namespace OpenMetaverse { /// /// Base Class for Inventory Items /// - [Serializable] - [ProtoContract] - [ProtoInclude(5, typeof(InventoryItem))] - [ProtoInclude(6, typeof(InventoryFolder))] + [Serializable()] public abstract class InventoryBase : ISerializable { /// of item/folder - [ProtoMember(1)] public UUID UUID; /// of parent folder - [ProtoMember(2)] public UUID ParentUUID; /// Name of item/folder - [ProtoMember(3)] public string Name; /// Item/Folder Owners - [ProtoMember(4)] public UUID OwnerID; /// @@ -135,20 +102,6 @@ namespace OpenMetaverse /// An Item in Inventory /// [Serializable] - [ProtoContract(SkipConstructor=true)] - [ProtoInclude(15, typeof(InventoryTexture))] - [ProtoInclude(16, typeof(InventorySound))] - [ProtoInclude(17, typeof(InventoryCallingCard))] - [ProtoInclude(18, typeof(InventoryLandmark))] - [ProtoInclude(19, typeof(InventoryObject))] - [ProtoInclude(20, typeof(InventoryNotecard))] - [ProtoInclude(21, typeof(InventoryCategory))] - [ProtoInclude(22, typeof(InventoryLSL))] - [ProtoInclude(23, typeof(InventorySnapshot))] - [ProtoInclude(24, typeof(InventoryAttachment))] - [ProtoInclude(25, typeof(InventoryWearable))] - [ProtoInclude(26, typeof(InventoryAnimation))] - [ProtoInclude(27, typeof(InventoryGesture))] public class InventoryItem : InventoryBase { public override string ToString() @@ -157,47 +110,33 @@ namespace OpenMetaverse Description + "' " + Permissions; } /// The of this item - [ProtoMember(1)] public UUID AssetUUID; /// The combined of this item - [ProtoMember(2)] public Permissions Permissions; /// The type of item from - [ProtoMember(3)] public AssetType AssetType; /// The type of item from the enum - [ProtoMember(4)] public InventoryType InventoryType; /// The of the creator of this item - [ProtoMember(5)] public UUID CreatorID; /// A Description of this item - [ProtoMember(6)] public string Description; /// The s this item is set to or owned by - [ProtoMember(7)] public UUID GroupID; /// If true, item is owned by a group - [ProtoMember(8)] public bool GroupOwned; /// The price this item can be purchased for - [ProtoMember(9)] public int SalePrice; /// The type of sale from the enum - [ProtoMember(10)] public SaleType SaleType; /// Combined flags from - [ProtoMember(11)] public uint Flags; /// Time and date this inventory item was created, stored as /// UTC (Coordinated Universal Time) - [ProtoMember(12)] public DateTime CreationDate; /// Used to update the AssetID in requests sent to the server - [ProtoMember(13)] public UUID TransactionID; /// The of the previous owner of the item - [ProtoMember(14)] public UUID LastOwnerID; /// @@ -409,8 +348,7 @@ namespace OpenMetaverse /// InventoryTexture Class representing a graphical image /// /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryTexture : InventoryItem { /// @@ -438,8 +376,7 @@ namespace OpenMetaverse /// /// InventorySound Class representing a playable sound /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventorySound : InventoryItem { /// @@ -467,8 +404,7 @@ namespace OpenMetaverse /// /// InventoryCallingCard Class, contains information on another avatar /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryCallingCard : InventoryItem { /// @@ -496,8 +432,7 @@ namespace OpenMetaverse /// /// InventoryLandmark Class, contains details on a specific location /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryLandmark : InventoryItem { /// @@ -539,8 +474,7 @@ namespace OpenMetaverse /// /// InventoryObject Class contains details on a primitive or coalesced set of primitives /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryObject : InventoryItem { /// @@ -586,8 +520,7 @@ namespace OpenMetaverse /// /// InventoryNotecard Class, contains details on an encoded text document /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryNotecard : InventoryItem { /// @@ -616,8 +549,7 @@ namespace OpenMetaverse /// InventoryCategory Class /// /// TODO: Is this even used for anything? - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryCategory : InventoryItem { /// @@ -645,8 +577,7 @@ namespace OpenMetaverse /// /// InventoryLSL Class, represents a Linden Scripting Language object /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryLSL : InventoryItem { /// @@ -674,8 +605,7 @@ namespace OpenMetaverse /// /// InventorySnapshot Class, an image taken with the viewer /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventorySnapshot : InventoryItem { /// @@ -703,8 +633,7 @@ namespace OpenMetaverse /// /// InventoryAttachment Class, contains details on an attachable object /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryAttachment : InventoryItem { /// @@ -741,8 +670,7 @@ namespace OpenMetaverse /// /// InventoryWearable Class, details on a clothing item or body part /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryWearable : InventoryItem { /// @@ -775,8 +703,7 @@ namespace OpenMetaverse /// /// InventoryAnimation Class, A bvh encoded object which animates an avatar /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryAnimation : InventoryItem { /// @@ -804,8 +731,7 @@ namespace OpenMetaverse /// /// InventoryGesture Class, details on a series of animations, sounds, and actions /// - [Serializable] - [ProtoContract(SkipConstructor = true)] + [Serializable()] public class InventoryGesture : InventoryItem { /// @@ -834,9 +760,7 @@ namespace OpenMetaverse /// A folder contains s and has certain attributes specific /// to itself /// - [Serializable] - [ProtoContract(SkipConstructor = true)] - + [Serializable()] public class InventoryFolder : InventoryBase { /// The Preferred for a folder. diff --git a/LibreMetaverse/InventoryNode.cs b/LibreMetaverse/InventoryNode.cs index b8481b6a..3298974e 100644 --- a/LibreMetaverse/InventoryNode.cs +++ b/LibreMetaverse/InventoryNode.cs @@ -27,26 +27,58 @@ using System; using System.Runtime.Serialization; -using ProtoBuf; +using ZeroFormatter; namespace OpenMetaverse { - [Serializable] - [ProtoContract(SkipConstructor=true)] - public class InventoryNode : ISerializable + [ZeroFormattable] + public class InventoryNode { + [Index(0)] + private InventoryBase data; + [Index(1)] + private InventoryNode parent; + [Index(3)] + private UUID parentID; //used for de-seralization + [Index(4)] private InventoryNodeDictionary nodes; + [Index(5)] + private bool needsUpdate = true; + [IgnoreFormat] + private object tag; - [ProtoMember(1)] - public InventoryBase Data { get; set; } + /// + public InventoryBase Data + { + get => data; + set => data = value; + } - [ProtoMember(2)] - public InventoryNode Parent { get; set; } + /// User data + public object Tag + { + get => tag; + set => tag = value; + } - [ProtoMember(3)] - public UUID ParentID { get; private set; } - - public DateTime ModifyTime + /// + public InventoryNode Parent + { + get => parent; + set => parent = value; + } + + /// + public UUID ParentID => parentID; + + /// + public InventoryNodeDictionary Nodes + { + get { return nodes ?? (nodes = new InventoryNodeDictionary(this)); } + set => nodes = value; + } + + public System.DateTime ModifyTime { get { @@ -54,7 +86,7 @@ namespace OpenMetaverse { return item.CreationDate; } - DateTime newest = default; //.MinValue; + DateTime newest = default(DateTime); //.MinValue; if (Data is InventoryFolder) { foreach (var node in Nodes.Values) @@ -67,26 +99,29 @@ namespace OpenMetaverse } } + public void Sort() + { + Nodes.Sort(); + } + /// /// For inventory folder nodes specifies weather the folder needs to be /// refreshed from the server /// - [ProtoMember(4)] - public bool NeedsUpdate { get; set; } - - public InventoryNodeDictionary Nodes + public bool NeedsUpdate { - get => nodes ?? (nodes = new InventoryNodeDictionary(this)); - set => nodes = value; + get { return needsUpdate; } + set { needsUpdate = value; } } - /// - /// InventoryNode Ctor - /// - /// data + public InventoryNode() + { + } + + /// public InventoryNode(InventoryBase data) { - this.Data = data; + this.data = data; } /// @@ -94,8 +129,8 @@ namespace OpenMetaverse /// public InventoryNode(InventoryBase data, InventoryNode parent) { - this.Data = data; - this.Parent = parent; + this.data = data; + this.parent = parent; if (parent != null) { @@ -103,20 +138,15 @@ namespace OpenMetaverse lock (parent.Nodes.SyncRoot) parent.Nodes.Add(data.UUID, this); } } - - public void Sort() - { - Nodes.Sort(); - } /// /// Serialization handler for the InventoryNode Class /// public void GetObjectData(SerializationInfo info, StreamingContext ctxt) { - info.AddValue("Parent", Parent?.Data.UUID ?? UUID.Zero, typeof(UUID)); - info.AddValue("Type", Data.GetType(), typeof(Type)); - Data.GetObjectData(info, ctxt); + info.AddValue("Parent", parent?.Data.UUID ?? UUID.Zero, typeof(UUID)); + info.AddValue("Type", data.GetType(), typeof(Type)); + data.GetObjectData(info, ctxt); } /// @@ -124,12 +154,12 @@ namespace OpenMetaverse /// public InventoryNode(SerializationInfo info, StreamingContext ctxt) { - ParentID = (UUID)info.GetValue("Parent", typeof(UUID)); + parentID = (UUID)info.GetValue("Parent", typeof(UUID)); Type type = (Type)info.GetValue("Type", typeof(Type)); // Construct a new inventory object based on the Type stored in Type - System.Reflection.ConstructorInfo ctr = type.GetConstructor(new[] {typeof(SerializationInfo),typeof(StreamingContext)}); - Data = (InventoryBase) ctr?.Invoke(new object[] { info, ctxt }); + System.Reflection.ConstructorInfo ctr = type.GetConstructor(new Type[] {typeof(SerializationInfo),typeof(StreamingContext)}); + data = (InventoryBase) ctr.Invoke(new Object[] { info, ctxt }); } public override string ToString() diff --git a/LibreMetaverse/LibreMetaverse.csproj b/LibreMetaverse/LibreMetaverse.csproj index c87ade29..5cef4f8c 100644 --- a/LibreMetaverse/LibreMetaverse.csproj +++ b/LibreMetaverse/LibreMetaverse.csproj @@ -126,12 +126,12 @@ - + diff --git a/LibreMetaverse/Permissions.cs b/LibreMetaverse/Permissions.cs index fa561d3d..ab2cf652 100644 --- a/LibreMetaverse/Permissions.cs +++ b/LibreMetaverse/Permissions.cs @@ -26,7 +26,6 @@ using System; using OpenMetaverse.StructuredData; -using ProtoBuf; namespace OpenMetaverse { @@ -71,19 +70,13 @@ namespace OpenMetaverse /// /// /// - [Serializable] - [ProtoContract] + [Serializable()] public struct Permissions { - [ProtoMember(1)] public PermissionMask BaseMask; - [ProtoMember(2)] public PermissionMask EveryoneMask; - [ProtoMember(3)] public PermissionMask GroupMask; - [ProtoMember(4)] public PermissionMask NextOwnerMask; - [ProtoMember(5)] public PermissionMask OwnerMask; public Permissions(uint baseMask, uint everyoneMask, uint groupMask, uint nextOwnerMask, uint ownerMask)