diff options
author | Melanie | 2012-02-02 01:05:14 +0100 |
---|---|---|
committer | Melanie | 2012-02-02 01:05:14 +0100 |
commit | 45ad9e39a668fc283b392746572729659fb9539d (patch) | |
tree | 1a2e8fcddbc9fe7d73a3ba400aeec2c7a3533b9e /OpenSim/Region/Framework | |
parent | Re-Add the reading of attachment data hat was lost in the merge (diff) | |
download | opensim-SC-45ad9e39a668fc283b392746572729659fb9539d.zip opensim-SC-45ad9e39a668fc283b392746572729659fb9539d.tar.gz opensim-SC-45ad9e39a668fc283b392746572729659fb9539d.tar.bz2 opensim-SC-45ad9e39a668fc283b392746572729659fb9539d.tar.xz |
Improve reliability of script state saving by covering various saving
and loading scenarios which resulted in loss of continuity on item ids
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 5 |
2 files changed, 16 insertions, 13 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 2335ad5..dc64281 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -370,10 +370,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
370 | else | 370 | else |
371 | { | 371 | { |
372 | if (m_part.ParentGroup.m_savedScriptState != null) | 372 | if (m_part.ParentGroup.m_savedScriptState != null) |
373 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 373 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
374 | 374 | ||
375 | m_items.LockItemsForWrite(true); | 375 | m_items.LockItemsForWrite(true); |
376 | 376 | ||
377 | m_items[item.ItemID].OldItemID = item.OldItemID; | ||
377 | m_items[item.ItemID].PermsMask = 0; | 378 | m_items[item.ItemID].PermsMask = 0; |
378 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 379 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
379 | 380 | ||
@@ -392,17 +393,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
392 | } | 393 | } |
393 | } | 394 | } |
394 | 395 | ||
395 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 396 | private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) |
396 | { | 397 | { |
397 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 398 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
398 | if (engines.Length == 0) // No engine at all | 399 | if (engines.Length == 0) // No engine at all |
399 | return; | 400 | return oldID; |
400 | 401 | ||
401 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 402 | UUID stateID = oldID; |
403 | if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | ||
404 | stateID = loadedID; | ||
405 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID)) | ||
402 | { | 406 | { |
403 | XmlDocument doc = new XmlDocument(); | 407 | XmlDocument doc = new XmlDocument(); |
404 | 408 | ||
405 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); | 409 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); |
406 | 410 | ||
407 | ////////// CRUFT WARNING /////////////////////////////////// | 411 | ////////// CRUFT WARNING /////////////////////////////////// |
408 | // | 412 | // |
@@ -419,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
419 | 423 | ||
420 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | 424 | XmlElement rootN = newDoc.CreateElement("", "State", ""); |
421 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | 425 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); |
422 | uuidA.Value = oldID.ToString(); | 426 | uuidA.Value = stateID.ToString(); |
423 | rootN.Attributes.Append(uuidA); | 427 | rootN.Attributes.Append(uuidA); |
424 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | 428 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); |
425 | engineA.Value = "XEngine"; | 429 | engineA.Value = "XEngine"; |
@@ -433,20 +437,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
433 | // This created document has only the minimun data | 437 | // This created document has only the minimun data |
434 | // necessary for XEngine to parse it successfully | 438 | // necessary for XEngine to parse it successfully |
435 | 439 | ||
436 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | 440 | m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; |
437 | } | 441 | } |
438 | 442 | ||
439 | foreach (IScriptModule e in engines) | 443 | foreach (IScriptModule e in engines) |
440 | { | 444 | { |
441 | if (e != null) | 445 | if (e != null) |
442 | { | 446 | { |
443 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | 447 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID])) |
444 | break; | 448 | break; |
445 | } | 449 | } |
446 | } | 450 | } |
447 | 451 | ||
448 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 452 | m_part.ParentGroup.m_savedScriptState.Remove(stateID); |
449 | } | 453 | } |
454 | |||
455 | return stateID; | ||
450 | } | 456 | } |
451 | 457 | ||
452 | /// <summary> | 458 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2b0e115..6303cb1 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -807,10 +807,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
807 | 807 | ||
808 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) | 808 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) |
809 | { | 809 | { |
810 | Util.ReadUUID(reader, "OldItemID"); | 810 | item.OldItemID = Util.ReadUUID(reader, "OldItemID"); |
811 | // On deserialization, the old item id MUST BE UUID.Zero!!!!! | ||
812 | // Setting this to the saved value will BREAK script persistence! | ||
813 | // item.OldItemID = Util.ReadUUID(reader, "OldItemID"); | ||
814 | } | 811 | } |
815 | 812 | ||
816 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) | 813 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) |