diff options
3 files changed, 28 insertions, 15 deletions
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index fa514f0..5d8b8be 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs | |||
@@ -65,6 +65,7 @@ namespace OpenSim.Framework | |||
65 | private int _permsMask; | 65 | private int _permsMask; |
66 | private int _type = 0; | 66 | private int _type = 0; |
67 | private UUID _oldID = UUID.Zero; | 67 | private UUID _oldID = UUID.Zero; |
68 | private UUID _loadedID = UUID.Zero; | ||
68 | 69 | ||
69 | private bool _ownerChanged = false; | 70 | private bool _ownerChanged = false; |
70 | 71 | ||
@@ -234,6 +235,15 @@ namespace OpenSim.Framework | |||
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
238 | public UUID LoadedItemID { | ||
239 | get { | ||
240 | return _loadedID; | ||
241 | } | ||
242 | set { | ||
243 | _loadedID = value; | ||
244 | } | ||
245 | } | ||
246 | |||
237 | public UUID LastOwnerID { | 247 | public UUID LastOwnerID { |
238 | get { | 248 | get { |
239 | return _lastOwnerID; | 249 | return _lastOwnerID; |
@@ -359,8 +369,8 @@ namespace OpenSim.Framework | |||
359 | /// <param name="partID">The new part ID to which this item belongs</param> | 369 | /// <param name="partID">The new part ID to which this item belongs</param> |
360 | public void ResetIDs(UUID partID) | 370 | public void ResetIDs(UUID partID) |
361 | { | 371 | { |
362 | if (_oldID == UUID.Zero) | 372 | _loadedID = _oldID; |
363 | _oldID = ItemID; | 373 | _oldID = ItemID; |
364 | ItemID = UUID.Random(); | 374 | ItemID = UUID.Random(); |
365 | ParentPartID = partID; | 375 | ParentPartID = partID; |
366 | ParentID = partID; | 376 | ParentID = partID; |
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) |