aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2012-02-02 01:52:17 +0000
committerMelanie2012-02-02 01:52:17 +0000
commit567f4c51f85e61205c8b1caaab207bc6f979f04f (patch)
tree1b56fcc63de25d7c6c8fc0739843381bd1a7662e /OpenSim/Region/Framework
parentSmall optimization to last commit (diff)
downloadopensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.zip
opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.tar.gz
opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.tar.bz2
opensim-SC_OLD-567f4c51f85e61205c8b1caaab207bc6f979f04f.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.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs5
2 files changed, 17 insertions, 14 deletions
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)