aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Serialiser
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs25
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs64
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs14
3 files changed, 91 insertions, 12 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
index 8a13f2b..e76d40d 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
@@ -64,7 +64,8 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
64 /// </summary> 64 /// </summary>
65 /// <param name="scene"></param> 65 /// <param name="scene"></param>
66 /// <param name="reader"></param> 66 /// <param name="reader"></param>
67 void LoadPrimsFromXml2(Scene scene, TextReader reader); 67 /// <param name="startScripts"></param>
68 void LoadPrimsFromXml2(Scene scene, TextReader reader, bool startScripts);
68 69
69 /// <summary> 70 /// <summary>
70 /// Save prims in the xml2 format 71 /// Save prims in the xml2 format
@@ -74,6 +75,17 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
74 void SavePrimsToXml2(Scene scene, string fileName); 75 void SavePrimsToXml2(Scene scene, string fileName);
75 76
76 /// <summary> 77 /// <summary>
78 /// Save prims in the xml2 format, optionally specifying a bounding box for which
79 /// prims should be saved. If both min and max vectors are LLVector3.Zero, then all prims
80 /// are exported.
81 /// </summary>
82 /// <param name="scene"></param>
83 /// <param name="stream"></param>
84 /// <param name="min"></param>
85 /// <param name="max"></param>
86 void SavePrimsToXml2(Scene scene, TextWriter stream, LLVector3 min, LLVector3 max);
87
88 /// <summary>
77 /// Save a set of prims in the xml2 format 89 /// Save a set of prims in the xml2 format
78 /// </summary> 90 /// </summary>
79 /// <param name="entityList"></param> 91 /// <param name="entityList"></param>
@@ -81,6 +93,17 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
81 void SavePrimListToXml2(List<EntityBase> entityList, string fileName); 93 void SavePrimListToXml2(List<EntityBase> entityList, string fileName);
82 94
83 /// <summary> 95 /// <summary>
96 /// Save a set of prims in the xml2 format, optionally specifying a bounding box for which
97 /// prims should be saved. If both min and max vectors are LLVector3.Zero, then all prims
98 /// are exported.
99 /// </summary>
100 /// <param name="entityList"></param>
101 /// <param name="stream"></param>
102 /// <param name="min"></param>
103 /// <param name="max"></param>
104 void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, LLVector3 min, LLVector3 max);
105
106 /// <summary>
84 /// Deserializes a scene object from its xml2 representation. This does not load the object into the scene. 107 /// Deserializes a scene object from its xml2 representation. This does not load the object into the scene.
85 /// </summary> 108 /// </summary>
86 /// <param name="xmlString"></param> 109 /// <param name="xmlString"></param>
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
index cd1fecb..0df19d9 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
@@ -143,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes
143 /// <param name="fileName"></param> 143 /// <param name="fileName"></param>
144 public static void LoadPrimsFromXml2(Scene scene, string fileName) 144 public static void LoadPrimsFromXml2(Scene scene, string fileName)
145 { 145 {
146 LoadPrimsFromXml2(scene, new XmlTextReader(fileName)); 146 LoadPrimsFromXml2(scene, new XmlTextReader(fileName), false);
147 } 147 }
148 148
149 /// <summary> 149 /// <summary>
@@ -151,9 +151,10 @@ namespace OpenSim.Region.Environment.Scenes
151 /// </summary> 151 /// </summary>
152 /// <param name="scene"></param> 152 /// <param name="scene"></param>
153 /// <param name="reader"></param> 153 /// <param name="reader"></param>
154 public static void LoadPrimsFromXml2(Scene scene, TextReader reader) 154 /// <param name="startScripts"></param>
155 public static void LoadPrimsFromXml2(Scene scene, TextReader reader, bool startScripts)
155 { 156 {
156 LoadPrimsFromXml2(scene, new XmlTextReader(reader)); 157 LoadPrimsFromXml2(scene, new XmlTextReader(reader), startScripts);
157 } 158 }
158 159
159 /// <summary> 160 /// <summary>
@@ -161,7 +162,8 @@ namespace OpenSim.Region.Environment.Scenes
161 /// </summary> 162 /// </summary>
162 /// <param name="scene"></param> 163 /// <param name="scene"></param>
163 /// <param name="reader"></param> 164 /// <param name="reader"></param>
164 protected static void LoadPrimsFromXml2(Scene scene, XmlTextReader reader) 165 /// <param name="startScripts"></param>
166 protected static void LoadPrimsFromXml2(Scene scene, XmlTextReader reader, bool startScripts)
165 { 167 {
166 XmlDocument doc = new XmlDocument(); 168 XmlDocument doc = new XmlDocument();
167 reader.WhitespaceHandling = WhitespaceHandling.None; 169 reader.WhitespaceHandling = WhitespaceHandling.None;
@@ -169,9 +171,17 @@ namespace OpenSim.Region.Environment.Scenes
169 reader.Close(); 171 reader.Close();
170 XmlNode rootNode = doc.FirstChild; 172 XmlNode rootNode = doc.FirstChild;
171 173
174 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
172 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 175 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
173 { 176 {
174 CreatePrimFromXml2(scene, aPrimNode.OuterXml); 177 SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml);
178 if (obj != null && startScripts)
179 sceneObjects.Add(obj);
180 }
181
182 foreach (SceneObjectGroup sceneObject in sceneObjects)
183 {
184 sceneObject.CreateScriptInstances(0, true);
175 } 185 }
176 } 186 }
177 187
@@ -198,10 +208,36 @@ namespace OpenSim.Region.Environment.Scenes
198 SavePrimListToXml2(EntityList, fileName); 208 SavePrimListToXml2(EntityList, fileName);
199 } 209 }
200 210
211 public static void SavePrimsToXml2(Scene scene, TextWriter stream, LLVector3 min, LLVector3 max)
212 {
213 List<EntityBase> EntityList = scene.GetEntities();
214
215 SavePrimListToXml2(EntityList, stream, min, max);
216 }
217
201 public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName) 218 public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
202 { 219 {
203 FileStream file = new FileStream(fileName, FileMode.Create); 220 FileStream file = new FileStream(fileName, FileMode.Create);
204 StreamWriter stream = new StreamWriter(file); 221 try
222 {
223 StreamWriter stream = new StreamWriter(file);
224 try
225 {
226 SavePrimListToXml2(entityList, stream, LLVector3.Zero, LLVector3.Zero);
227 }
228 finally
229 {
230 stream.Close();
231 }
232 }
233 finally
234 {
235 file.Close();
236 }
237 }
238
239 public static void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, LLVector3 min, LLVector3 max)
240 {
205 int primCount = 0; 241 int primCount = 0;
206 stream.WriteLine("<scene>\n"); 242 stream.WriteLine("<scene>\n");
207 243
@@ -209,13 +245,23 @@ namespace OpenSim.Region.Environment.Scenes
209 { 245 {
210 if (ent is SceneObjectGroup) 246 if (ent is SceneObjectGroup)
211 { 247 {
212 stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); 248 SceneObjectGroup g = (SceneObjectGroup)ent;
249 if (!min.Equals(LLVector3.Zero) || !max.Equals(LLVector3.Zero))
250 {
251 LLVector3 pos = g.RootPart.GetWorldPosition();
252 if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
253 continue;
254 if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
255 continue;
256 }
257
258 stream.WriteLine(g.ToXmlString2());
213 primCount++; 259 primCount++;
214 } 260 }
215 } 261 }
216 stream.WriteLine("</scene>\n"); 262 stream.WriteLine("</scene>\n");
217 stream.Close(); 263 stream.Flush();
218 file.Close();
219 } 264 }
265
220 } 266 }
221} 267}
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index ce59ecc..d722d68 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
102 SceneXmlLoader.LoadPrimsFromXml2(scene, fileName); 102 SceneXmlLoader.LoadPrimsFromXml2(scene, fileName);
103 } 103 }
104 104
105 public void LoadPrimsFromXml2(Scene scene, TextReader reader) 105 public void LoadPrimsFromXml2(Scene scene, TextReader reader, bool startScripts)
106 { 106 {
107 SceneXmlLoader.LoadPrimsFromXml2(scene, reader); 107 SceneXmlLoader.LoadPrimsFromXml2(scene, reader, startScripts);
108 } 108 }
109 109
110 public void SavePrimsToXml2(Scene scene, string fileName) 110 public void SavePrimsToXml2(Scene scene, string fileName)
@@ -112,6 +112,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
112 SceneXmlLoader.SavePrimsToXml2(scene, fileName); 112 SceneXmlLoader.SavePrimsToXml2(scene, fileName);
113 } 113 }
114 114
115 public void SavePrimsToXml2(Scene scene, TextWriter stream, LLVector3 min, LLVector3 max)
116 {
117 SceneXmlLoader.SavePrimsToXml2(scene, stream, min, max);
118 }
119
115 public SceneObjectGroup DeserializeGroupFromXml2(string xmlString) 120 public SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
116 { 121 {
117 return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); 122 return SceneXmlLoader.DeserializeGroupFromXml2(xmlString);
@@ -127,6 +132,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
127 SceneXmlLoader.SavePrimListToXml2(entityList, fileName); 132 SceneXmlLoader.SavePrimListToXml2(entityList, fileName);
128 } 133 }
129 134
135 public void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, LLVector3 min, LLVector3 max)
136 {
137 SceneXmlLoader.SavePrimListToXml2(entityList, stream, min, max);
138 }
139
130 public List<string> SerialiseRegion(Scene scene, string saveDir) 140 public List<string> SerialiseRegion(Scene scene, string saveDir)
131 { 141 {
132 List<string> results = new List<string>(); 142 List<string> results = new List<string>();