diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/IScriptModule.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 55 |
2 files changed, 49 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index f11e571..98efcbe 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | string ScriptEngineName { get; } | 35 | string ScriptEngineName { get; } |
36 | 36 | ||
37 | string GetXMLState(UUID itemID); | 37 | string GetXMLState(UUID itemID); |
38 | void SetXMLState(UUID itemID, string xml); | 38 | bool SetXMLState(UUID itemID, string xml); |
39 | 39 | ||
40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); | 40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); |
41 | bool PostObjectEvent(UUID itemID, string name, Object[] args); | 41 | bool PostObjectEvent(UUID itemID, string name, Object[] args); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index b57d912..0321c41 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -295,15 +296,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
295 | 296 | ||
296 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 297 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
297 | { | 298 | { |
299 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
300 | if (engines == null) // No engine at all | ||
301 | return; | ||
302 | |||
298 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 303 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) |
299 | { | 304 | { |
300 | string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(), | 305 | XmlDocument doc = new XmlDocument(); |
301 | newID.ToString()+".state"); | 306 | |
302 | FileStream fs = File.Create(fpath); | 307 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); |
303 | Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]); | 308 | |
304 | fs.Write(buffer,0,buffer.Length); | 309 | ////////// CRUFT WARNING /////////////////////////////////// |
305 | fs.Close(); | 310 | // |
306 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 311 | // Old objects will have <ScriptState><State> ... |
312 | // This format is XEngine ONLY | ||
313 | // | ||
314 | // New objects have <State Engine="...." ...><ScriptState>... | ||
315 | // This can be passed to any engine | ||
316 | // | ||
317 | XmlNode n = doc.SelectSingleNode("ScriptState"); | ||
318 | if (n != null) // Old format data | ||
319 | { | ||
320 | XmlDocument newDoc = new XmlDocument(); | ||
321 | |||
322 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | ||
323 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | ||
324 | uuidA.Value = oldID.ToString(); | ||
325 | rootN.Attributes.Append(uuidA); | ||
326 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | ||
327 | engineA.Value = "XEngine"; | ||
328 | rootN.Attributes.Append(engineA); | ||
329 | |||
330 | newDoc.AppendChild(rootN); | ||
331 | |||
332 | XmlNode stateN = newDoc.ImportNode(n, true); | ||
333 | rootN.AppendChild(stateN); | ||
334 | |||
335 | // This created document has only the minimun data | ||
336 | // necessary for XEngine to parse it successfully | ||
337 | |||
338 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | ||
339 | } | ||
340 | foreach (IScriptModule e in engines) | ||
341 | { | ||
342 | if (e != null) | ||
343 | { | ||
344 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | ||
345 | break; | ||
346 | } | ||
347 | } | ||
307 | } | 348 | } |
308 | } | 349 | } |
309 | 350 | ||