From 57519b6dba97d7e7a2de71af9d58c93b4750bde8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 16 Jan 2008 18:35:34 +0000 Subject: * Store task inventory when an object is taken into agent inventory * This means that you can take an object from a region and rez it somewhere else, with its inventory intact. * As for earlier, at this stage only scripts can be placed in inventory * This isn't an efficient implementation, a better one will probably need to come along soonish --- OpenSim/Framework/TaskInventoryItem.cs | 115 +++++++++++++++++++++++++++------ 1 file changed, 96 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework/TaskInventoryItem.cs') diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 107993b..6e163a9 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -26,11 +26,78 @@ * */ +using System.Collections.Generic; +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; + using libsecondlife; using System; namespace OpenSim.Framework -{ +{ + public class TaskInventoryDictionary : Dictionary, IXmlSerializable + { + private static XmlSerializer tiiSerializer = new XmlSerializer(typeof(TaskInventoryItem)); + + // The alternative of simply serializing the list doesn't appear to work on mono, since + // we get a + // + // System.TypeInitializationException: An exception was thrown by the type initializer for OpenSim.Framework.TaskInventoryDictionary ---> System.ArgumentOutOfRangeException: < 0 + // Parameter name: length + // at System.String.Substring (Int32 startIndex, Int32 length) [0x00088] in /build/buildd/mono-1.2.4/mcs/class/corlib/System/String.cs:381 + // at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType) [0x001f6] in /build/buildd/mono-1.2.4/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:217 + // ... +// private static XmlSerializer tiiSerializer +// = new XmlSerializer(typeof(Dictionary.ValueCollection)); + + // see IXmlSerializable + public XmlSchema GetSchema() + { + return null; + } + + // see IXmlSerializable + public void ReadXml(XmlReader reader) + { + reader.Read(); + while (tiiSerializer.CanDeserialize(reader)) + { + TaskInventoryItem item = (TaskInventoryItem)tiiSerializer.Deserialize(reader); + Add(item.ItemID, item); + } + +// reader.Read(); +// while (reader.Name.Equals("TaskInventoryItem")) +// { +// TaskInventoryItem item = (TaskInventoryItem)tiiSerializer.Deserialize(reader); +// Add(item.ItemID, item); +// } + +// ICollection items +// = (ICollection)tiiSerializer.Deserialize(reader); +// +// foreach (TaskInventoryItem item in items) +// { +// Add(item.ItemID, item); +// } + } + + // see IXmlSerializable + public void WriteXml(XmlWriter writer) + { + foreach (TaskInventoryItem item in Values) + { + tiiSerializer.Serialize(writer, item); + } + + //tiiSerializer.Serialize(writer, Values); + } + } + + /// + /// Represents an item in a task inventory + /// public class TaskInventoryItem { /// @@ -75,27 +142,37 @@ namespace OpenSim.Framework "lsltext", String.Empty }; + + /// + /// Reset the LLUUIDs for this item. + /// + /// The new part ID to which this item belongs + public void ResetIDs(LLUUID partID) + { + ItemID = LLUUID.Random(); + ParentPartID = partID; + } - public LLUUID item_id = LLUUID.Zero; - public LLUUID parent_id = LLUUID.Zero; //parent folder id + public LLUUID ItemID = LLUUID.Zero; + public LLUUID ParentID = LLUUID.Zero; //parent folder id - public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint group_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint everyone_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint next_owner_mask = FULL_MASK_PERMISSIONS_GENERAL; - public LLUUID creator_id = LLUUID.Zero; - public LLUUID owner_id = LLUUID.Zero; - public LLUUID last_owner_id = LLUUID.Zero; - public LLUUID group_id = LLUUID.Zero; + public uint BaseMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint OwnerMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint GroupMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint EveryoneMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; + public LLUUID CreatorID = LLUUID.Zero; + public LLUUID OwnerID = LLUUID.Zero; + public LLUUID LastOwnerID = LLUUID.Zero; + public LLUUID GroupID = LLUUID.Zero; - public LLUUID asset_id = LLUUID.Zero; - public int type = 0; - public int inv_type = 0; - public uint flags = 0; - public string name = String.Empty; - public string desc = String.Empty; - public uint creation_date = 0; + public LLUUID AssetID = LLUUID.Zero; + public int Type = 0; + public int InvType = 0; + public uint Flags = 0; + public string Name = String.Empty; + public string Description = String.Empty; + public uint CreationDate = 0; public LLUUID ParentPartID = LLUUID.Zero; } -- cgit v1.1