From 0b2fcbfec4ae06b3e3f278d9e42f84c88f556587 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 7 Jul 2008 18:54:11 +0000 Subject: [PATCH] * Start scripts loaded from an archive --- .../Framework/Communications/Cache/AssetCache.cs | 6 +++--- OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../Modules/World/Archiver/ArchiveReadRequest.cs | 12 ++++++++++-- .../Modules/World/Serialiser/IRegionSerialiser.cs | 3 ++- .../Modules/World/Serialiser/SceneXmlLoader.cs | 14 ++++++++++---- .../Modules/World/Serialiser/SerialiserModule.cs | 4 ++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f160ce40c3..70997600e9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -348,7 +348,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { - if (asset.Type == 0) + if (asset.Type == (int)AssetType.Texture) { if (!Textures.ContainsKey(asset.FullID)) { @@ -365,9 +365,9 @@ namespace OpenSim.Framework.Communications.Cache } } else - { + { if (!Assets.ContainsKey(asset.FullID)) - { + { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 2c2ec09cf8..37daf881cc 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -494,7 +494,7 @@ namespace OpenSim if (string.IsNullOrEmpty(m_scriptEngine)) { - m_log.Info("[MODULES]: No script engien module specified"); + m_log.Info("[MODULES]: No script engine module specified"); } else { diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 15bc265f8c..0f179f4f64 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -100,10 +100,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects", serialisedSceneObjects.Count); IRegionSerialiser serialiser = m_scene.RequestModuleInterface(); + ICollection sceneObjects = new List(); foreach (string serialisedSceneObject in serialisedSceneObjects) { - serialiser.LoadGroupFromXml2(m_scene, serialisedSceneObject); + sceneObjects.Add(serialiser.LoadGroupFromXml2(m_scene, serialisedSceneObject)); + } + + m_log.Debug("[ARCHIVER]: Starting scripts"); + + foreach (SceneObjectGroup sceneObject in sceneObjects) + { + sceneObject.CreateScriptInstances(0, true); } m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); @@ -126,7 +134,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; - m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); + m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty); asset.Type = assetType; diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs index 3ae7a5436e..0fc8ac3042 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs @@ -85,7 +85,8 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser /// /// /// - void LoadGroupFromXml2(Scene scene, string xmlString); + /// The scene object created + SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString); /// /// Serialize an individual scene object into the xml2 format diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 9bab2b68b0..f283ecbd92 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Scenes return grp.ToXmlString2(); } - public static void LoadGroupFromXml2(Scene scene, string xmlString) + public static SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString) { XmlDocument doc = new XmlDocument(); XmlNode rootNode; @@ -126,11 +126,14 @@ namespace OpenSim.Region.Environment.Scenes { CreatePrimFromXml2(scene, aPrimNode.OuterXml); } + + // There is only ever one prim, but it's easiest to return null here since this part should disappear post 0.5.9 anyway + return null; } else { - CreatePrimFromXml2(scene, rootNode.OuterXml); - } + return CreatePrimFromXml2(scene, rootNode.OuterXml); + } } /// @@ -177,11 +180,14 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - protected static void CreatePrimFromXml2(Scene scene, string xmlData) + /// The scene object created + protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) { SceneObjectGroup obj = new SceneObjectGroup(xmlData); scene.AddRestoredSceneObject(obj, true); + + return obj; } public static void SavePrimsToXml2(Scene scene, string fileName) diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index c7b5fa59ce..eb3ab2e854 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs @@ -112,9 +112,9 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser SceneXmlLoader.SavePrimsToXml2(scene, fileName); } - public void LoadGroupFromXml2(Scene scene, string xmlString) + public SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString) { - SceneXmlLoader.LoadGroupFromXml2(scene, xmlString); + return SceneXmlLoader.LoadGroupFromXml2(scene, xmlString); } public string SaveGroupToXml2(SceneObjectGroup grp)