diff options
author | Melanie | 2009-12-21 10:26:52 +0000 |
---|---|---|
committer | Melanie | 2009-12-21 10:26:52 +0000 |
commit | 27453890d5a5d09e47c638ccef92f45b1ce360b2 (patch) | |
tree | 31d240c542ff545ecf4d7a853bf6ea1e0f1a4c18 /OpenSim/Region/Framework/Scenes | |
parent | Remove extra checking on the itemID of saved state, since it changes during (diff) | |
download | opensim-SC_OLD-27453890d5a5d09e47c638ccef92f45b1ce360b2.zip opensim-SC_OLD-27453890d5a5d09e47c638ccef92f45b1ce360b2.tar.gz opensim-SC_OLD-27453890d5a5d09e47c638ccef92f45b1ce360b2.tar.bz2 opensim-SC_OLD-27453890d5a5d09e47c638ccef92f45b1ce360b2.tar.xz |
Script State Fix: Part 2
Change the reader to wrap old-style definitions in new style wrappers.
Change importer to not check irrelevant data that can't be reconstructed
This removes the last bit of knowledge of XEngine's .state files from core.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 22eedba..47e4ad0 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; |
@@ -283,15 +284,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
283 | 284 | ||
284 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 285 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
285 | { | 286 | { |
287 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
288 | if (engines == null) // No engine at all | ||
289 | return; | ||
290 | |||
286 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 291 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) |
287 | { | 292 | { |
288 | string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(), | 293 | XmlDocument doc = new XmlDocument(); |
289 | newID.ToString()+".state"); | 294 | |
290 | FileStream fs = File.Create(fpath); | 295 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); |
291 | Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]); | 296 | |
292 | fs.Write(buffer,0,buffer.Length); | 297 | ////////// CRUFT WARNING /////////////////////////////////// |
293 | fs.Close(); | 298 | // |
294 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 299 | // Old objects will have <ScriptState><State> ... |
300 | // This format is XEngine ONLY | ||
301 | // | ||
302 | // New objects have <State Engine="...." ...><ScriptState>... | ||
303 | // This can be passed to any engine | ||
304 | // | ||
305 | XmlNode n = doc.SelectSingleNode("ScriptState"); | ||
306 | if (n != null) // Old format data | ||
307 | { | ||
308 | XmlDocument newDoc = new XmlDocument(); | ||
309 | |||
310 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | ||
311 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | ||
312 | uuidA.Value = oldID.ToString(); | ||
313 | rootN.Attributes.Append(uuidA); | ||
314 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | ||
315 | engineA.Value = "XEngine"; | ||
316 | rootN.Attributes.Append(engineA); | ||
317 | |||
318 | newDoc.AppendChild(rootN); | ||
319 | |||
320 | XmlNode stateN = newDoc.ImportNode(n, true); | ||
321 | rootN.AppendChild(stateN); | ||
322 | |||
323 | // This created document has only the minimun data | ||
324 | // necessary for XEngine to parse it successfully | ||
325 | |||
326 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | ||
327 | } | ||
328 | foreach (IScriptModule e in engines) | ||
329 | { | ||
330 | if (e != null) | ||
331 | { | ||
332 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | ||
333 | break; | ||
334 | } | ||
335 | } | ||
295 | } | 336 | } |
296 | } | 337 | } |
297 | 338 | ||