aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs64
1 files changed, 55 insertions, 9 deletions
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}