From aa497a18678c6cc9a7425986c5bf5ca91415bd1d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 19 Dec 2008 19:47:11 +0000 Subject: * refactor: move saved named prims to xml2 method out into the serialization module --- .../Interfaces/IRegionSerialiserModule.cs | 2 ++ .../Modules/World/Serialiser/SceneXmlLoader.cs | 29 +++++++++++++++++++--- .../Modules/World/Serialiser/SerialiserModule.cs | 5 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 22 ---------------- OpenSim/Region/Environment/Scenes/SceneManager.cs | 4 ++- 5 files changed, 36 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Interfaces/IRegionSerialiserModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionSerialiserModule.cs index 29d5d47..b89f869 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionSerialiserModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionSerialiserModule.cs @@ -102,6 +102,8 @@ namespace OpenSim.Region.Environment.Interfaces /// /// void SavePrimListToXml2(List entityList, TextWriter stream, Vector3 min, Vector3 max); + + void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName); /// /// Deserializes a scene object from its xml2 representation. This does not load the object into the scene. diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index c856b5b..2e9c551 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -28,10 +28,10 @@ using System; using System.Collections.Generic; using System.IO; -//using System.Reflection; +using System.Reflection; using System.Xml; using OpenMetaverse; -//using log4net; +using log4net; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; @@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes /// public class SceneXmlLoader { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) { @@ -213,6 +213,29 @@ namespace OpenSim.Region.Environment.Scenes SavePrimListToXml2(EntityList, stream, min, max); } + + public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) + { + m_log.InfoFormat( + "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}", + primName, scene.RegionInfo.RegionName, fileName); + + List entityList = scene.GetEntities(); + List primList = new List(); + + foreach (EntityBase ent in entityList) + { + if (ent is SceneObjectGroup) + { + if (ent.Name == primName) + { + primList.Add(ent); + } + } + } + + SavePrimListToXml2(primList, fileName); + } public static void SavePrimListToXml2(List entityList, string fileName) { diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index 8b5dd2c..c1af947 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs @@ -116,6 +116,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser { SceneXmlLoader.SavePrimsToXml2(scene, stream, min, max); } + + public void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) + { + SceneXmlLoader.SaveNamedPrimsToXml2(scene, primName, fileName); + } public SceneObjectGroup DeserializeGroupFromXml2(string xmlString) { diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index eaf04ea..70cd45e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1880,28 +1880,6 @@ namespace OpenSim.Region.Environment.Scenes return false; } - public void SaveNamedPrimsToXml2(string primName, string fileName) - { - m_log.InfoFormat( - "[SCENE]: Saving prims with name {0} in xml2 format for region {1} to {2}", primName, RegionInfo.RegionName, fileName); - - List entityList = GetEntities(); - List primList = new List(); - - foreach (EntityBase ent in entityList) - { - if (ent is SceneObjectGroup) - { - if (ent.Name == primName) - { - primList.Add(ent); - } - } - } - - m_serialiser.SavePrimListToXml2(primList, fileName); - } - /// /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 9e83f25..d585b48 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -215,7 +215,9 @@ namespace OpenSim.Region.Environment.Scenes public void SaveNamedPrimsToXml2(string primName, string filename) { - CurrentOrFirstScene.SaveNamedPrimsToXml2( primName, filename); + IRegionSerialiserModule serialiser = CurrentOrFirstScene.RequestModuleInterface(); + if (serialiser != null) + serialiser.SaveNamedPrimsToXml2(CurrentOrFirstScene, primName, filename); } /// -- cgit v1.1