From 08d3452092a2782f19c0db2190520dade44f0ea3 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 22 Jan 2015 23:12:10 +0000 Subject: [PATCH] Fix regression where the stored state of every second script in an object rezzed from inventory (e.g. attachments) was no longer loaded. Likely a regression since f132f642 (2014-08-28) Relates to http://opensimulator.org/mantis/view.php?id=7278 --- .../InventoryAccess/InventoryAccessModule.cs | 5 ++- .../Framework/Scenes/SceneObjectGroup.cs | 38 +++++++++++-------- .../Scenes/SceneObjectPartInventory.cs | 8 +++- .../Shared/Instance/ScriptInstance.cs | 3 ++ 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index f537124e9a..f958510da3 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -297,6 +297,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { if (item != null && item.Owner == ownerID && asset != null) { +// m_log.DebugFormat( +// "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}", +// item.Name, item.ID, asset.ID); + item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; @@ -314,7 +318,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess (item == null || asset == null? "null item or asset" : "wrong owner")); return false; } - } public virtual List CopyToInventory( diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ec37836ef2..19e557f06c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -911,28 +911,36 @@ namespace OpenSim.Region.Framework.Scenes public void LoadScriptState(XmlReader reader) { -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Looking for script state for {0} in {1}", Name); +// m_log.DebugFormat("[SCENE OBJECT GROUP]: Looking for script state for {0}", Name); - while (reader.ReadToFollowing("SavedScriptState")) + while (true) { -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Loading script state for {0}", Name); - - if (m_savedScriptState == null) - m_savedScriptState = new Dictionary(); - - string uuid = reader.GetAttribute("UUID"); - - if (uuid != null) + if (reader.Name == "SavedScriptState" && reader.NodeType == XmlNodeType.Element) { -// m_log.DebugFormat("[SCENE OBJECT GROUP]: Found state for item ID {0} in object {1}", uuid, Name); +// m_log.DebugFormat("[SCENE OBJECT GROUP]: Loading script state for {0}", Name); - UUID itemid = new UUID(uuid); - if (itemid != UUID.Zero) - m_savedScriptState[itemid] = reader.ReadInnerXml(); + if (m_savedScriptState == null) + m_savedScriptState = new Dictionary(); + + string uuid = reader.GetAttribute("UUID"); + + if (uuid != null) + { +// m_log.DebugFormat("[SCENE OBJECT GROUP]: Found state for item ID {0} in object {1}", uuid, Name); + + UUID itemid = new UUID(uuid); + if (itemid != UUID.Zero) + m_savedScriptState[itemid] = reader.ReadInnerXml(); + } + else + { + m_log.WarnFormat("[SCENE OBJECT GROUP]: SavedScriptState element had no UUID in object {0}", Name); + } } else { - m_log.WarnFormat("[SCENE OBJECT GROUP]: SavedScriptState element had no UUID in object {0}", Name); + if (!reader.Read()) + break; } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 578909cdc5..ec39726054 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -400,6 +400,10 @@ namespace OpenSim.Region.Framework.Scenes private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) { +// m_log.DebugFormat( +// "[PRIM INVENTORY]: Restoring scripted state for item {0}, oldID {1}, loadedID {2}", +// newID, oldID, loadedID); + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); if (engines.Length == 0) // No engine at all return oldID; @@ -412,7 +416,7 @@ namespace OpenSim.Region.Framework.Scenes XmlDocument doc = new XmlDocument(); doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); - + ////////// CRUFT WARNING /////////////////////////////////// // // Old objects will have ... @@ -442,6 +446,8 @@ namespace OpenSim.Region.Framework.Scenes // This created document has only the minimun data // necessary for XEngine to parse it successfully +// m_log.DebugFormat("[PRIM INVENTORY]: Adding legacy state {0} in {1}", stateID, newID); + m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 9498aa880a..ea3e0e8b1e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -1040,6 +1040,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public void SetVars(Dictionary vars) { +// foreach (KeyValuePair kvp in vars) +// m_log.DebugFormat("[SCRIPT INSTANCE]: Setting var {0}={1}", kvp.Key, kvp.Value); + m_Script.SetVars(vars); }