aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Serialization/External/LandDataSerializer.cs')
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs179
1 files changed, 117 insertions, 62 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
index 3ae9a8e..a12877a 100644
--- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -28,8 +28,10 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection;
31using System.Text; 32using System.Text;
32using System.Xml; 33using System.Xml;
34using log4net;
33using OpenMetaverse; 35using OpenMetaverse;
34using OpenSim.Framework; 36using OpenSim.Framework;
35 37
@@ -40,8 +42,119 @@ namespace OpenSim.Framework.Serialization.External
40 /// </summary> 42 /// </summary>
41 public class LandDataSerializer 43 public class LandDataSerializer
42 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
43 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 47 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
44 48
49 private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors
50 = new Dictionary<string, Action<LandData, XmlTextReader>>();
51
52 private static Dictionary<string, Action<LandAccessEntry, XmlTextReader>> m_laeProcessors
53 = new Dictionary<string, Action<LandAccessEntry, XmlTextReader>>();
54
55 static LandDataSerializer()
56 {
57 // LandData processors
58 m_ldProcessors.Add(
59 "Area", (ld, xtr) => ld.Area = Convert.ToInt32(xtr.ReadElementString("Area")));
60 m_ldProcessors.Add(
61 "AuctionID", (ld, xtr) => ld.AuctionID = Convert.ToUInt32(xtr.ReadElementString("AuctionID")));
62 m_ldProcessors.Add(
63 "AuthBuyerID", (ld, xtr) => ld.AuthBuyerID = UUID.Parse(xtr.ReadElementString("AuthBuyerID")));
64 m_ldProcessors.Add(
65 "Category", (ld, xtr) => ld.Category = (ParcelCategory)Convert.ToSByte(xtr.ReadElementString("Category")));
66 m_ldProcessors.Add(
67 "ClaimDate", (ld, xtr) => ld.ClaimDate = Convert.ToInt32(xtr.ReadElementString("ClaimDate")));
68 m_ldProcessors.Add(
69 "ClaimPrice", (ld, xtr) => ld.ClaimPrice = Convert.ToInt32(xtr.ReadElementString("ClaimPrice")));
70 m_ldProcessors.Add(
71 "GlobalID", (ld, xtr) => ld.GlobalID = UUID.Parse(xtr.ReadElementString("GlobalID")));
72 m_ldProcessors.Add(
73 "GroupID", (ld, xtr) => ld.GroupID = UUID.Parse(xtr.ReadElementString("GroupID")));
74 m_ldProcessors.Add(
75 "IsGroupOwned", (ld, xtr) => ld.IsGroupOwned = Convert.ToBoolean(xtr.ReadElementString("IsGroupOwned")));
76 m_ldProcessors.Add(
77 "Bitmap", (ld, xtr) => ld.Bitmap = Convert.FromBase64String(xtr.ReadElementString("Bitmap")));
78 m_ldProcessors.Add(
79 "Description", (ld, xtr) => ld.Description = xtr.ReadElementString("Description"));
80 m_ldProcessors.Add(
81 "Flags", (ld, xtr) => ld.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags")));
82 m_ldProcessors.Add(
83 "LandingType", (ld, xtr) => ld.LandingType = Convert.ToByte(xtr.ReadElementString("LandingType")));
84 m_ldProcessors.Add(
85 "Name", (ld, xtr) => ld.Name = xtr.ReadElementString("Name"));
86 m_ldProcessors.Add(
87 "Status", (ld, xtr) => ld.Status = (ParcelStatus)Convert.ToSByte(xtr.ReadElementString("Status")));
88 m_ldProcessors.Add(
89 "LocalID", (ld, xtr) => ld.LocalID = Convert.ToInt32(xtr.ReadElementString("LocalID")));
90 m_ldProcessors.Add(
91 "MediaAutoScale", (ld, xtr) => ld.MediaAutoScale = Convert.ToByte(xtr.ReadElementString("MediaAutoScale")));
92 m_ldProcessors.Add(
93 "MediaID", (ld, xtr) => ld.MediaID = UUID.Parse(xtr.ReadElementString("MediaID")));
94 m_ldProcessors.Add(
95 "MediaURL", (ld, xtr) => ld.MediaURL = xtr.ReadElementString("MediaURL"));
96 m_ldProcessors.Add(
97 "MusicURL", (ld, xtr) => ld.MusicURL = xtr.ReadElementString("MusicURL"));
98
99 m_ldProcessors.Add(
100 "ParcelAccessList", ProcessParcelAccessList);
101
102 m_ldProcessors.Add(
103 "PassHours", (ld, xtr) => ld.PassHours = Convert.ToSingle(xtr.ReadElementString("PassHours")));
104 m_ldProcessors.Add(
105 "PassPrice", (ld, xtr) => ld.PassPrice = Convert.ToInt32(xtr.ReadElementString("PassPrice")));
106 m_ldProcessors.Add(
107 "SalePrice", (ld, xtr) => ld.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice")));
108 m_ldProcessors.Add(
109 "SnapshotID", (ld, xtr) => ld.SnapshotID = UUID.Parse(xtr.ReadElementString("SnapshotID")));
110 m_ldProcessors.Add(
111 "UserLocation", (ld, xtr) => ld.UserLocation = Vector3.Parse(xtr.ReadElementString("UserLocation")));
112 m_ldProcessors.Add(
113 "UserLookAt", (ld, xtr) => ld.UserLookAt = Vector3.Parse(xtr.ReadElementString("UserLookAt")));
114
115 // No longer used here //
116 // m_ldProcessors.Add("Dwell", (landData, xtr) => return);
117
118 m_ldProcessors.Add(
119 "OtherCleanTime", (ld, xtr) => ld.OtherCleanTime = Convert.ToInt32(xtr.ReadElementString("OtherCleanTime")));
120
121 // LandAccessEntryProcessors
122 m_laeProcessors.Add(
123 "AgentID", (lae, xtr) => lae.AgentID = UUID.Parse(xtr.ReadElementString("AgentID")));
124 m_laeProcessors.Add(
125 "Time", (lae, xtr) =>
126 {
127 // We really don't care about temp vs perm here and this
128 // would break on old oars. Assume all bans are perm
129 xtr.ReadElementString("Time");
130 lae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time"));
131 }
132 );
133 m_laeProcessors.Add(
134 "AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString("AccessList")));
135 }
136
137 public static void ProcessParcelAccessList(LandData ld, XmlTextReader xtr)
138 {
139 if (!xtr.IsEmptyElement)
140 {
141 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
142 {
143 LandAccessEntry lae = new LandAccessEntry();
144
145 xtr.ReadStartElement("ParcelAccessEntry");
146
147 ExternalRepresentationUtils.ExecuteReadProcessors<LandAccessEntry>(lae, m_laeProcessors, xtr);
148
149 xtr.ReadEndElement();
150
151 ld.ParcelAccessList.Add(lae);
152 }
153 }
154
155 xtr.Read();
156 }
157
45 /// <summary> 158 /// <summary>
46 /// Reify/deserialize landData 159 /// Reify/deserialize landData
47 /// </summary> 160 /// </summary>
@@ -63,72 +176,14 @@ namespace OpenSim.Framework.Serialization.External
63 { 176 {
64 LandData landData = new LandData(); 177 LandData landData = new LandData();
65 178
66 StringReader sr = new StringReader(serializedLandData); 179 using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData)))
67 XmlTextReader xtr = new XmlTextReader(sr);
68
69 xtr.ReadStartElement("LandData");
70
71 landData.Area = Convert.ToInt32( xtr.ReadElementString("Area"));
72 landData.AuctionID = Convert.ToUInt32( xtr.ReadElementString("AuctionID"));
73 landData.AuthBuyerID = UUID.Parse( xtr.ReadElementString("AuthBuyerID"));
74 landData.Category = (ParcelCategory)Convert.ToSByte( xtr.ReadElementString("Category"));
75 landData.ClaimDate = Convert.ToInt32( xtr.ReadElementString("ClaimDate"));
76 landData.ClaimPrice = Convert.ToInt32( xtr.ReadElementString("ClaimPrice"));
77 landData.GlobalID = UUID.Parse( xtr.ReadElementString("GlobalID"));
78 landData.GroupID = UUID.Parse( xtr.ReadElementString("GroupID"));
79 landData.IsGroupOwned = Convert.ToBoolean( xtr.ReadElementString("IsGroupOwned"));
80 landData.Bitmap = Convert.FromBase64String( xtr.ReadElementString("Bitmap"));
81 landData.Description = xtr.ReadElementString("Description");
82 landData.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags"));
83 landData.LandingType = Convert.ToByte( xtr.ReadElementString("LandingType"));
84 landData.Name = xtr.ReadElementString("Name");
85 landData.Status = (ParcelStatus)Convert.ToSByte( xtr.ReadElementString("Status"));
86 landData.LocalID = Convert.ToInt32( xtr.ReadElementString("LocalID"));
87 landData.MediaAutoScale = Convert.ToByte( xtr.ReadElementString("MediaAutoScale"));
88 landData.MediaID = UUID.Parse( xtr.ReadElementString("MediaID"));
89 landData.MediaURL = xtr.ReadElementString("MediaURL");
90 landData.MusicURL = xtr.ReadElementString("MusicURL");
91 landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID"));
92
93 landData.ParcelAccessList = new List<LandAccessEntry>();
94 xtr.Read();
95 if (xtr.Name != "ParcelAccessList")
96 throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name));
97
98 if (!xtr.IsEmptyElement)
99 { 180 {
100 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 181 reader.ReadStartElement("LandData");
101 {
102 LandAccessEntry pae = new LandAccessEntry();
103 182
104 xtr.ReadStartElement("ParcelAccessEntry"); 183 ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader);
105 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
106 // We really don't care about temp vs perm here and this
107 // would break on old oars. Assume all bans are perm
108 xtr.ReadElementString("Time");
109 pae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time"));
110 pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
111 xtr.ReadEndElement();
112 184
113 landData.ParcelAccessList.Add(pae); 185 reader.ReadEndElement();
114 }
115 } 186 }
116 xtr.Read();
117
118 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
119 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
120 landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
121 landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
122 landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
123 landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
124 // No longer used here
125 xtr.ReadElementString("Dwell");
126 landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
127
128 xtr.ReadEndElement();
129
130 xtr.Close();
131 sr.Close();
132 187
133 return landData; 188 return landData;
134 } 189 }