From dd4100db4c5b221b4feba4f873f40407d50fd4e1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 24 May 2008 19:21:57 +0000 Subject: * Get the xml2 entities serialization representation in the archiver module * Not yet reusing serialization module - this will happen in the future * No user functionality yet --- .../Modules/Grid/Interregion/InterregionModule.cs | 25 +++++----- .../Modules/World/Archiver/ArchiverModule.cs | 56 ++++++++++++++++++++-- .../Modules/World/Archiver/IRegionArchiver.cs | 8 ++-- OpenSim/Region/Environment/Scenes/Scene.cs | 4 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 4 +- 5 files changed, 71 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs index 423f0b5..89ee61a 100644 --- a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs +++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs @@ -152,18 +152,19 @@ namespace OpenSim.Region.Environment.Modules.Grid.Interregion public void PostInitialise() { - if (m_enabled) - { - try - { - m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort); - } - catch - { - } - - internal_CreateRemotingObjects(); - } + // Commenting out to remove 'unreachable code' warning since m_enabled is never true +// if (m_enabled) +// { +// try +// { +// m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort); +// } +// catch +// { +// } +// +// internal_CreateRemotingObjects(); +// } } public void Close() diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs index cba04c4..ce78f21 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs @@ -26,7 +26,9 @@ */ using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules.World.Serialiser; using OpenSim.Region.Environment.Scenes; +using System.Collections.Generic; using System.Reflection; using log4net; using Nini.Config; @@ -39,32 +41,76 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public class ArchiverModule : IRegionModule, IRegionArchiver { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Scene to which this module belongs + /// + /// + /// + private Scene m_scene; public string Name { get { return "ArchiverModule"; } } - public bool IsSharedModule { get { return true; } } + public bool IsSharedModule { get { return false; } } public void Initialise(Scene scene, IConfigSource source) { - scene.RegisterModuleInterface(this); + m_scene = scene; + + m_scene.RegisterModuleInterface(this); } public void PostInitialise() - { + { } public void Close() { } - public void ArchiveRegion(Scene scene, string savePath) + public void ArchiveRegion(string savePath) { m_log.Warn("[ARCHIVER]: Archive region not yet implemented"); + + List entities = m_scene.GetEntities(); + string serEntities = SerializeObjects(entities); + + if (serEntities != null && serEntities.Length > 0) + { + m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); + } } - public void DearchiveRegion(Scene scene, string loadPath) + public void DearchiveRegion(string loadPath) { m_log.Warn("[ARCHIVER]: Dearchive region not yet implemented"); } + + /// + /// Get an xml representation of the given scene objects. + /// + /// + /// + private static string SerializeObjects(List entities) + { + string serialization = ""; + + List serObjects = new List(); + + foreach (EntityBase ent in entities) + { + if (ent is SceneObjectGroup) + { + serObjects.Add(((SceneObjectGroup) ent).ToXmlString2()); + } + } + + foreach (string serObject in serObjects) + serialization += serObject; + + serialization += ""; + + return serialization; + } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/IRegionArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/IRegionArchiver.cs index 1cebb50..485cf02 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/IRegionArchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/IRegionArchiver.cs @@ -35,17 +35,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public interface IRegionArchiver { /// - /// Archive a region to the given path + /// Archive the region to the given path /// - /// /// - void ArchiveRegion(Scene scene, string savePath); + void ArchiveRegion(string savePath); /// /// Dearchive the given region archive into the scene /// - /// /// - void DearchiveRegion(Scene scene, string loadPath); + void DearchiveRegion(string loadPath); } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index a42bad5..60ba898 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1378,7 +1378,7 @@ namespace OpenSim.Region.Environment.Scenes public void LoadPrimsFromArchive(string filePath) { IRegionArchiver archiver = RequestModuleInterface(); - archiver.DearchiveRegion(this, filePath); + archiver.DearchiveRegion(filePath); } /// @@ -1388,7 +1388,7 @@ namespace OpenSim.Region.Environment.Scenes public void SavePrimsToArchive(string filePath) { IRegionArchiver archiver = RequestModuleInterface(); - archiver.ArchiveRegion(this, filePath); + archiver.ArchiveRegion(filePath); } /// diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 2baef9d..eae041b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -201,7 +201,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SaveCurrentSceneToArchive(string filename) { - CurrentOrFirstScene.LoadPrimsFromArchive(filename); + CurrentOrFirstScene.SavePrimsToArchive(filename); } /// @@ -217,7 +217,7 @@ namespace OpenSim.Region.Environment.Scenes [Obsolete("TODO: Remove this warning by 0.7")] public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) { - m_log.Warn("DEPRECIATED: The terrain engine has been replaced with a new terrain plugin module. Please type 'plugin terrain help' for new commands."); + m_log.Warn("DEPRECATED: The terrain engine has been replaced with a new terrain plugin module. Please type 'plugin terrain help' for new commands."); return false; } -- cgit v1.1