diff options
Diffstat (limited to '')
8 files changed, 136 insertions, 23 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 2fe36a8..11024d6 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
192 | 192 | ||
193 | foreach (SceneObjectGroup sceneObject in sceneObjects) | 193 | foreach (SceneObjectGroup sceneObject in sceneObjects) |
194 | { | 194 | { |
195 | sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine); | 195 | sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index a069ac3..c856b5b 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs | |||
@@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
180 | 180 | ||
181 | foreach (SceneObjectGroup sceneObject in sceneObjects) | 181 | foreach (SceneObjectGroup sceneObject in sceneObjects) |
182 | { | 182 | { |
183 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine); | 183 | sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index 244b76f8..5d21dc5 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs | |||
@@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
104 | 104 | ||
105 | public event OnPermissionErrorDelegate OnPermissionError; | 105 | public event OnPermissionErrorDelegate OnPermissionError; |
106 | 106 | ||
107 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine); | 107 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); |
108 | 108 | ||
109 | public event NewRezScript OnRezScript; | 109 | public event NewRezScript OnRezScript; |
110 | 110 | ||
@@ -548,13 +548,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
548 | } | 548 | } |
549 | } | 549 | } |
550 | 550 | ||
551 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) | 551 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) |
552 | { | 552 | { |
553 | handlerRezScript = OnRezScript; | 553 | handlerRezScript = OnRezScript; |
554 | if (handlerRezScript != null) | 554 | if (handlerRezScript != null) |
555 | { | 555 | { |
556 | handlerRezScript(localID, itemID, script, startParam, | 556 | handlerRezScript(localID, itemID, script, startParam, |
557 | postOnRez, engine); | 557 | postOnRez, engine, stateSource); |
558 | } | 558 | } |
559 | } | 559 | } |
560 | 560 | ||
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 0b24ce9..aca82c3 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -1667,7 +1667,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1667 | copy.UpdateGroupRotation(rot); | 1667 | copy.UpdateGroupRotation(rot); |
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine); | 1670 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); |
1671 | copy.HasGroupChanged = true; | 1671 | copy.HasGroupChanged = true; |
1672 | copy.ScheduleGroupForFullUpdate(); | 1672 | copy.ScheduleGroupForFullUpdate(); |
1673 | return copy; | 1673 | return copy; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 4e93551..b0bac42 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
61 | { | 61 | { |
62 | if (group is SceneObjectGroup) | 62 | if (group is SceneObjectGroup) |
63 | { | 63 | { |
64 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine); | 64 | ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
@@ -292,7 +292,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
292 | { | 292 | { |
293 | // Needs to determine which engine was running it and use that | 293 | // Needs to determine which engine was running it and use that |
294 | // | 294 | // |
295 | part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine); | 295 | part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | { | 298 | { |
@@ -1343,7 +1343,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1343 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); | 1343 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); |
1344 | // TODO: switch to posting on_rez here when scripts | 1344 | // TODO: switch to posting on_rez here when scripts |
1345 | // have state in inventory | 1345 | // have state in inventory |
1346 | part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine); | 1346 | part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); |
1347 | 1347 | ||
1348 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1348 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
1349 | // "Rezzed script {0} into prim local ID {1} for user {2}", | 1349 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
@@ -1407,7 +1407,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1407 | part.AddInventoryItem(taskItem); | 1407 | part.AddInventoryItem(taskItem); |
1408 | part.GetProperties(remoteClient); | 1408 | part.GetProperties(remoteClient); |
1409 | 1409 | ||
1410 | part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine); | 1410 | part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); |
1411 | } | 1411 | } |
1412 | } | 1412 | } |
1413 | 1413 | ||
@@ -1503,7 +1503,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1503 | 1503 | ||
1504 | if (running > 0) | 1504 | if (running > 0) |
1505 | { | 1505 | { |
1506 | destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine); | 1506 | destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine, 0); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | ScenePresence avatar; | 1509 | ScenePresence avatar; |
@@ -2050,7 +2050,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
2050 | } | 2050 | } |
2051 | 2051 | ||
2052 | // Fire on_rez | 2052 | // Fire on_rez |
2053 | group.CreateScriptInstances(0, true, DefaultScriptEngine); | 2053 | group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); |
2054 | 2054 | ||
2055 | if (!attachment) | 2055 | if (!attachment) |
2056 | rootPart.ScheduleFullUpdate(); | 2056 | rootPart.ScheduleFullUpdate(); |
@@ -2154,7 +2154,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
2154 | group.UpdateGroupRotation(rot); | 2154 | group.UpdateGroupRotation(rot); |
2155 | //group.ApplyPhysics(m_physicalPrim); | 2155 | //group.ApplyPhysics(m_physicalPrim); |
2156 | group.Velocity = vel; | 2156 | group.Velocity = vel; |
2157 | group.CreateScriptInstances(param, true, DefaultScriptEngine); | 2157 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 0); |
2158 | rootPart.ScheduleFullUpdate(); | 2158 | rootPart.ScheduleFullUpdate(); |
2159 | 2159 | ||
2160 | if (!ExternalChecks.ExternalChecksBypassPermissions()) | 2160 | if (!ExternalChecks.ExternalChecksBypassPermissions()) |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 70ea709..62e6691 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.Drawing.Imaging; | 31 | using System.Drawing.Imaging; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Xml; | ||
33 | using System.Threading; | 34 | using System.Threading; |
34 | using System.Timers; | 35 | using System.Timers; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -591,7 +592,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
591 | { | 592 | { |
592 | if (ent is SceneObjectGroup) | 593 | if (ent is SceneObjectGroup) |
593 | { | 594 | { |
594 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine); | 595 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
595 | } | 596 | } |
596 | } | 597 | } |
597 | } | 598 | } |
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 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using log4net; | 32 | using log4net; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
33 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using System.Collections.Generic; | ||
36 | using System.Xml; | ||
34 | 37 | ||
35 | namespace OpenSim.Region.Environment.Scenes | 38 | namespace 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 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 2f08322..501f199 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -126,7 +126,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
126 | /// <summary> | 126 | /// <summary> |
127 | /// Start all the scripts contained in this prim's inventory | 127 | /// Start all the scripts contained in this prim's inventory |
128 | /// </summary> | 128 | /// </summary> |
129 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine) | 129 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
130 | { | 130 | { |
131 | lock (m_taskInventory) | 131 | lock (m_taskInventory) |
132 | { | 132 | { |
@@ -134,7 +134,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
134 | { | 134 | { |
135 | if ((int)InventoryType.LSL == item.InvType) | 135 | if ((int)InventoryType.LSL == item.InvType) |
136 | { | 136 | { |
137 | CreateScriptInstance(item, startParam, postOnRez, engine); | 137 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
@@ -163,7 +163,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
163 | /// </summary> | 163 | /// </summary> |
164 | /// <param name="item"></param> | 164 | /// <param name="item"></param> |
165 | /// <returns></returns> | 165 | /// <returns></returns> |
166 | public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine) | 166 | public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) |
167 | { | 167 | { |
168 | // m_log.InfoFormat( | 168 | // m_log.InfoFormat( |
169 | // "[PRIM INVENTORY]: " + | 169 | // "[PRIM INVENTORY]: " + |
@@ -194,7 +194,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
194 | m_taskInventory[item.ItemID].PermsGranter = UUID.Zero; | 194 | m_taskInventory[item.ItemID].PermsGranter = UUID.Zero; |
195 | string script = Utils.BytesToString(asset.Data); | 195 | string script = Utils.BytesToString(asset.Data); |
196 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script, | 196 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script, |
197 | startParam, postOnRez, engine); | 197 | startParam, postOnRez, engine, stateSource); |
198 | m_parentGroup.AddActiveScriptCount(1); | 198 | m_parentGroup.AddActiveScriptCount(1); |
199 | ScheduleFullUpdate(); | 199 | ScheduleFullUpdate(); |
200 | } | 200 | } |
@@ -208,13 +208,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
208 | /// <param name="itemId"> | 208 | /// <param name="itemId"> |
209 | /// A <see cref="UUID"/> | 209 | /// A <see cref="UUID"/> |
210 | /// </param> | 210 | /// </param> |
211 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine) | 211 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
212 | { | 212 | { |
213 | lock (m_taskInventory) | 213 | lock (m_taskInventory) |
214 | { | 214 | { |
215 | if (m_taskInventory.ContainsKey(itemId)) | 215 | if (m_taskInventory.ContainsKey(itemId)) |
216 | { | 216 | { |
217 | CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine); | 217 | CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine, stateSource); |
218 | } | 218 | } |
219 | else | 219 | else |
220 | { | 220 | { |
@@ -765,7 +765,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
765 | return ret; | 765 | return ret; |
766 | } | 766 | } |
767 | 767 | ||
768 | string[] GetScriptAssemblies() | 768 | public string[] GetScriptAssemblies() |
769 | { | 769 | { |
770 | IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 770 | IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
771 | 771 | ||
@@ -789,5 +789,29 @@ namespace OpenSim.Region.Environment.Scenes | |||
789 | } | 789 | } |
790 | return ret.ToArray(); | 790 | return ret.ToArray(); |
791 | } | 791 | } |
792 | |||
793 | public Dictionary<UUID, string> GetScriptStates() | ||
794 | { | ||
795 | IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
796 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | ||
797 | |||
798 | foreach (TaskInventoryItem item in m_taskInventory.Values) | ||
799 | { | ||
800 | if (item.InvType == 10) | ||
801 | { | ||
802 | foreach (IScriptModule e in engines) | ||
803 | { | ||
804 | string n = e.GetXMLState(item.ItemID); | ||
805 | if (n != "") | ||
806 | { | ||
807 | if (!ret.ContainsKey(item.ItemID)) | ||
808 | ret[item.ItemID] = n; | ||
809 | break; | ||
810 | } | ||
811 | } | ||
812 | } | ||
813 | } | ||
814 | return ret; | ||
815 | } | ||
792 | } | 816 | } |
793 | } | 817 | } |