diff options
3 files changed, 28 insertions, 14 deletions
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index ba2a306..d4bbbfb 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; | 67 | private UUID _oldID; |
68 | private UUID _loadedID = UUID.Zero; | ||
68 | 69 | ||
69 | private bool _ownerChanged = false; | 70 | private bool _ownerChanged = false; |
70 | 71 | ||
@@ -231,6 +232,15 @@ namespace OpenSim.Framework | |||
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
235 | public UUID LoadedItemID { | ||
236 | get { | ||
237 | return _loadedID; | ||
238 | } | ||
239 | set { | ||
240 | _loadedID = value; | ||
241 | } | ||
242 | } | ||
243 | |||
234 | public UUID LastOwnerID { | 244 | public UUID LastOwnerID { |
235 | get { | 245 | get { |
236 | return _lastOwnerID; | 246 | return _lastOwnerID; |
@@ -347,6 +357,7 @@ namespace OpenSim.Framework | |||
347 | /// <param name="partID">The new part ID to which this item belongs</param> | 357 | /// <param name="partID">The new part ID to which this item belongs</param> |
348 | public void ResetIDs(UUID partID) | 358 | public void ResetIDs(UUID partID) |
349 | { | 359 | { |
360 | LoadedItemID = OldItemID; | ||
350 | OldItemID = ItemID; | 361 | OldItemID = ItemID; |
351 | ItemID = UUID.Random(); | 362 | ItemID = UUID.Random(); |
352 | ParentPartID = partID; | 363 | ParentPartID = partID; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index daddb90..0c36dcd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -307,14 +307,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
307 | else | 307 | else |
308 | { | 308 | { |
309 | if (m_part.ParentGroup.m_savedScriptState != null) | 309 | if (m_part.ParentGroup.m_savedScriptState != null) |
310 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 310 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
311 | 311 | ||
312 | lock (m_items) | 312 | lock (m_items) |
313 | { | 313 | { |
314 | m_items[item.ItemID].OldItemID = item.OldItemID; | ||
314 | m_items[item.ItemID].PermsMask = 0; | 315 | m_items[item.ItemID].PermsMask = 0; |
315 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 316 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
316 | } | 317 | } |
317 | 318 | ||
318 | string script = Utils.BytesToString(asset.Data); | 319 | string script = Utils.BytesToString(asset.Data); |
319 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 320 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
320 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 321 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -324,17 +325,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | } | 325 | } |
325 | } | 326 | } |
326 | 327 | ||
327 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 328 | private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) |
328 | { | 329 | { |
329 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 330 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
330 | if (engines.Length == 0) // No engine at all | 331 | if (engines.Length == 0) // No engine at all |
331 | return; | 332 | return oldID; |
332 | 333 | ||
333 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | 334 | UUID stateID = oldID; |
335 | if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) | ||
336 | stateID = loadedID; | ||
337 | if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID)) | ||
334 | { | 338 | { |
335 | XmlDocument doc = new XmlDocument(); | 339 | XmlDocument doc = new XmlDocument(); |
336 | 340 | ||
337 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); | 341 | doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); |
338 | 342 | ||
339 | ////////// CRUFT WARNING /////////////////////////////////// | 343 | ////////// CRUFT WARNING /////////////////////////////////// |
340 | // | 344 | // |
@@ -351,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | 355 | ||
352 | XmlElement rootN = newDoc.CreateElement("", "State", ""); | 356 | XmlElement rootN = newDoc.CreateElement("", "State", ""); |
353 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); | 357 | XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); |
354 | uuidA.Value = oldID.ToString(); | 358 | uuidA.Value = stateID.ToString(); |
355 | rootN.Attributes.Append(uuidA); | 359 | rootN.Attributes.Append(uuidA); |
356 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); | 360 | XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); |
357 | engineA.Value = "XEngine"; | 361 | engineA.Value = "XEngine"; |
@@ -365,20 +369,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
365 | // This created document has only the minimun data | 369 | // This created document has only the minimun data |
366 | // necessary for XEngine to parse it successfully | 370 | // necessary for XEngine to parse it successfully |
367 | 371 | ||
368 | m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; | 372 | m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; |
369 | } | 373 | } |
370 | 374 | ||
371 | foreach (IScriptModule e in engines) | 375 | foreach (IScriptModule e in engines) |
372 | { | 376 | { |
373 | if (e != null) | 377 | if (e != null) |
374 | { | 378 | { |
375 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) | 379 | if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID])) |
376 | break; | 380 | break; |
377 | } | 381 | } |
378 | } | 382 | } |
379 | 383 | ||
380 | m_part.ParentGroup.m_savedScriptState.Remove(oldID); | 384 | m_part.ParentGroup.m_savedScriptState.Remove(stateID); |
381 | } | 385 | } |
386 | |||
387 | return stateID; | ||
382 | } | 388 | } |
383 | 389 | ||
384 | /// <summary> | 390 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3a08271..b54fcb7 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -794,10 +794,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
794 | 794 | ||
795 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) | 795 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) |
796 | { | 796 | { |
797 | Util.ReadUUID(reader, "OldItemID"); | 797 | item.OldItemID = Util.ReadUUID(reader, "OldItemID"); |
798 | // On deserialization, the old item id MUST BE UUID.Zero!!!!! | ||
799 | // Setting this to the saved value will BREAK script persistence! | ||
800 | // item.OldItemID = Util.ReadUUID(reader, "OldItemID"); | ||
801 | } | 798 | } |
802 | 799 | ||
803 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) | 800 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) |