aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-11-09 19:30:40 +0000
committerMelanie Thielker2008-11-09 19:30:40 +0000
commit664e8a464e4608afeb590a3330ccc69e7988138b (patch)
tree099c17a1769a7e7ac16232c5a20f5d9515a1d480 /OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
parentCause llGetInventoryType to return the asset type, which corresponds with (diff)
downloadopensim-SC_OLD-664e8a464e4608afeb590a3330ccc69e7988138b.zip
opensim-SC_OLD-664e8a464e4608afeb590a3330ccc69e7988138b.tar.gz
opensim-SC_OLD-664e8a464e4608afeb590a3330ccc69e7988138b.tar.bz2
opensim-SC_OLD-664e8a464e4608afeb590a3330ccc69e7988138b.tar.xz
Script region crossing. This has not user functionality, but lays all the
groundwork.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs92
1 files changed, 90 insertions, 2 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 24ebc48..a4801ad 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -26,11 +26,14 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Reflection; 30using System.Reflection;
30using OpenMetaverse; 31using OpenMetaverse;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using System.Collections.Generic;
36using System.Xml;
34 37
35namespace OpenSim.Region.Environment.Scenes 38namespace OpenSim.Region.Environment.Scenes
36{ 39{
@@ -56,14 +59,15 @@ namespace OpenSim.Region.Environment.Scenes
56 /// Start the scripts contained in all the prims in this group. 59 /// Start the scripts contained in all the prims in this group.
57 /// </summary> 60 /// </summary>
58 public void CreateScriptInstances(int startParam, bool postOnRez, 61 public void CreateScriptInstances(int startParam, bool postOnRez,
59 string engine) 62 string engine, int stateSource)
60 { 63 {
61 // Don't start scripts if they're turned off in the region! 64 // Don't start scripts if they're turned off in the region!
62 if (!m_scene.RegionInfo.RegionSettings.DisableScripts) 65 if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
63 { 66 {
64 foreach (SceneObjectPart part in m_parts.Values) 67 foreach (SceneObjectPart part in m_parts.Values)
65 { 68 {
66 part.CreateScriptInstances(startParam, postOnRez, engine); 69 part.CreateScriptInstances(startParam, postOnRez, engine,
70 stateSource);
67 } 71 }
68 } 72 }
69 } 73 }
@@ -277,5 +281,89 @@ namespace OpenSim.Region.Environment.Scenes
277 foreach (SceneObjectPart part in m_parts.Values) 281 foreach (SceneObjectPart part in m_parts.Values)
278 part.ApplyNextOwnerPermissions(); 282 part.ApplyNextOwnerPermissions();
279 } 283 }
284
285 public string GetStateSnapshot()
286 {
287 List<string> assemblies = new List<string>();
288 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
289
290 foreach (SceneObjectPart part in m_parts.Values)
291 {
292 foreach (string a in part.GetScriptAssemblies())
293 {
294 if (a != "" && !assemblies.Contains(a))
295 assemblies.Add(a);
296 }
297
298 foreach (KeyValuePair<UUID, string> s in part.GetScriptStates())
299 {
300 states[s.Key] = s.Value;
301 }
302 }
303
304 if (states.Count < 1 || assemblies.Count < 1)
305 return "";
306
307 XmlDocument xmldoc = new XmlDocument();
308
309 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
310 "", "");
311
312 xmldoc.AppendChild(xmlnode);
313 XmlElement rootElement = xmldoc.CreateElement("", "ScriptData",
314 "");
315
316 xmldoc.AppendChild(rootElement);
317
318 XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
319 "");
320
321 rootElement.AppendChild(wrapper);
322
323 foreach (string assembly in assemblies)
324 {
325 string fn = Path.GetFileName(assembly);
326 FileInfo fi = new FileInfo(assembly);
327 Byte[] data = new Byte[fi.Length];
328
329 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
330 fs.Read(data, 0, data.Length);
331 fs.Close();
332
333 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
334 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
335 assemblyName.Value = fn;
336 assemblyData.Attributes.Append(assemblyName);
337
338 assemblyData.InnerText = System.Convert.ToBase64String(data);
339
340 wrapper.AppendChild(assemblyData);
341 }
342
343 wrapper = xmldoc.CreateElement("", "ScriptStates",
344 "");
345
346 rootElement.AppendChild(wrapper);
347
348 foreach (KeyValuePair<UUID, string> state in states)
349 {
350 XmlElement stateData = xmldoc.CreateElement("", "State", "");
351
352 XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
353 stateID.Value = state.Key.ToString();
354 stateData.Attributes.Append(stateID);
355
356 XmlDocument sdoc = new XmlDocument();
357 sdoc.LoadXml(state.Value);
358 XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
359 XmlNode rootNode = rootL[0];
360
361 XmlNode newNode = xmldoc.ImportNode(rootNode, true);
362 stateData.AppendChild(newNode);
363 wrapper.AppendChild(stateData);
364 }
365
366 return xmldoc.InnerXml;
367 }
280 } 368 }
281} 369}