aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-30 17:52:14 +0000
committerJustin Clarke Casey2008-05-30 17:52:14 +0000
commit4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307 (patch)
tree728db0e5d0691b553b8ebe4e5a13560c4657c7e2 /OpenSim
parentMantis#1422. Thank you kindly, Xantor for your llLoopSound() (diff)
downloadopensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.zip
opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.gz
opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.bz2
opensim-SC-4f237f3ae3b8561de0dacd1ec0e937ec7a8e0307.tar.xz
* Crudely migrate SceneXmlLoader into the Serializer module
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs17
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs (renamed from OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs)58
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs35
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs30
4 files changed, 91 insertions, 49 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
index 331b460..752b5b6 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using libsecondlife;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
30 31
@@ -32,6 +33,18 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
32{ 33{
33 public interface IRegionSerialiser 34 public interface IRegionSerialiser
34 { 35 {
35 List<string> SerialiseRegion(Scene scene, string saveDir); 36 List<string> SerialiseRegion(Scene scene, string saveDir);
37
38 void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset);
39
40 void SavePrimsToXml(Scene scene, string fileName);
41
42 void LoadPrimsFromXml2(Scene scene, string fileName);
43
44 void SavePrimsToXml2(Scene scene, string fileName);
45
46 void LoadGroupFromXml2String(Scene scene, string xmlString);
47
48 string SavePrimGroupToXML2String(SceneObjectGroup grp);
36 } 49 }
37} \ No newline at end of file 50}
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
index 742996e..7f51b58 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
@@ -36,20 +36,12 @@ using OpenSim.Region.Physics.Manager;
36 36
37namespace OpenSim.Region.Environment.Scenes 37namespace OpenSim.Region.Environment.Scenes
38{ 38{
39 public class SceneXmlLoader // can move to a module? 39 /// <summary>
40 /// Static methods to serialize and deserialize scene objects to and from XML
41 /// </summary>
42 public class SceneXmlLoader
40 { 43 {
41 protected InnerScene m_innerScene; 44 public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset)
42 protected RegionInfo m_regInfo;
43 protected Scene m_parentScene;
44
45 public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
46 {
47 m_parentScene = parentScene;
48 m_innerScene = innerScene;
49 m_regInfo = regionInfo;
50 }
51
52 public void LoadPrimsFromXml(string fileName, bool newIDS, LLVector3 loadOffset)
53 { 45 {
54 XmlDocument doc = new XmlDocument(); 46 XmlDocument doc = new XmlDocument();
55 XmlNode rootNode; 47 XmlNode rootNode;
@@ -63,8 +55,8 @@ namespace OpenSim.Region.Environment.Scenes
63 rootNode = doc.FirstChild; 55 rootNode = doc.FirstChild;
64 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 56 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
65 { 57 {
66 SceneObjectGroup obj = new SceneObjectGroup(m_parentScene, 58 SceneObjectGroup obj = new SceneObjectGroup(scene, scene.RegionInfo.RegionHandle, aPrimNode.OuterXml);
67 m_regInfo.RegionHandle, aPrimNode.OuterXml); 59
68 if (newIDS) 60 if (newIDS)
69 { 61 {
70 obj.ResetIDs(); 62 obj.ResetIDs();
@@ -72,16 +64,16 @@ namespace OpenSim.Region.Environment.Scenes
72 //if we want this to be a import method then we need new uuids for the object to avoid any clashes 64 //if we want this to be a import method then we need new uuids for the object to avoid any clashes
73 //obj.RegenerateFullIDs(); 65 //obj.RegenerateFullIDs();
74 66
75 m_innerScene.AddSceneObject(obj); 67 scene.AddSceneObject(obj);
76 68
77 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 69 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
78 // Apply loadOffsets for load/import and move combinations 70 // Apply loadOffsets for load/import and move combinations
79 rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; 71 rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
80 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && 72 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
81 m_parentScene.m_physicalPrim); 73 scene.m_physicalPrim);
82 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) 74 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
83 { 75 {
84 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( 76 rootPart.PhysActor = scene.PhysicsScene.AddPrimShape(
85 rootPart.Name, 77 rootPart.Name,
86 rootPart.Shape, 78 rootPart.Shape,
87 new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X, 79 new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X,
@@ -108,14 +100,14 @@ namespace OpenSim.Region.Environment.Scenes
108 } 100 }
109 } 101 }
110 102
111 public void SavePrimsToXml(string fileName) 103 public static void SavePrimsToXml(Scene scene, string fileName)
112 { 104 {
113 FileStream file = new FileStream(fileName, FileMode.Create); 105 FileStream file = new FileStream(fileName, FileMode.Create);
114 StreamWriter stream = new StreamWriter(file); 106 StreamWriter stream = new StreamWriter(file);
115 int primCount = 0; 107 int primCount = 0;
116 stream.WriteLine("<scene>\n"); 108 stream.WriteLine("<scene>\n");
117 109
118 List<EntityBase> EntityList = m_innerScene.GetEntities(); 110 List<EntityBase> EntityList = scene.GetEntities();
119 111
120 foreach (EntityBase ent in EntityList) 112 foreach (EntityBase ent in EntityList)
121 { 113 {
@@ -130,17 +122,16 @@ namespace OpenSim.Region.Environment.Scenes
130 file.Close(); 122 file.Close();
131 } 123 }
132 124
133 public string SavePrimGroupToXML2String(SceneObjectGroup grp) 125 public static string SavePrimGroupToXML2String(SceneObjectGroup grp)
134 { 126 {
135 string returnstring = ""; 127 string returnstring = "";
136 returnstring += "<scene>\n"; 128 returnstring += "<scene>\n";
137 returnstring += grp.ToXmlString2(); 129 returnstring += grp.ToXmlString2();
138 returnstring += "</scene>\n"; 130 returnstring += "</scene>\n";
139 return returnstring; 131 return returnstring;
140
141 } 132 }
142 133
143 public void LoadGroupFromXml2String(string xmlString) 134 public static void LoadGroupFromXml2String(Scene scene, string xmlString)
144 { 135 {
145 XmlDocument doc = new XmlDocument(); 136 XmlDocument doc = new XmlDocument();
146 XmlNode rootNode; 137 XmlNode rootNode;
@@ -152,12 +143,11 @@ namespace OpenSim.Region.Environment.Scenes
152 rootNode = doc.FirstChild; 143 rootNode = doc.FirstChild;
153 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 144 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
154 { 145 {
155 CreatePrimFromXml(aPrimNode.OuterXml); 146 CreatePrimFromXml(scene, aPrimNode.OuterXml);
156 } 147 }
157
158 } 148 }
159 149
160 public void LoadPrimsFromXml2(string fileName) 150 public static void LoadPrimsFromXml2(Scene scene, string fileName)
161 { 151 {
162 XmlDocument doc = new XmlDocument(); 152 XmlDocument doc = new XmlDocument();
163 XmlNode rootNode; 153 XmlNode rootNode;
@@ -170,7 +160,7 @@ namespace OpenSim.Region.Environment.Scenes
170 rootNode = doc.FirstChild; 160 rootNode = doc.FirstChild;
171 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 161 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
172 { 162 {
173 CreatePrimFromXml(aPrimNode.OuterXml); 163 CreatePrimFromXml(scene, aPrimNode.OuterXml);
174 } 164 }
175 } 165 }
176 else 166 else
@@ -179,19 +169,19 @@ namespace OpenSim.Region.Environment.Scenes
179 } 169 }
180 } 170 }
181 171
182 public void CreatePrimFromXml(string xmlData) 172 public static void CreatePrimFromXml(Scene scene, string xmlData)
183 { 173 {
184 SceneObjectGroup obj = new SceneObjectGroup(xmlData); 174 SceneObjectGroup obj = new SceneObjectGroup(xmlData);
185 LLVector3 receivedVelocity = obj.RootPart.Velocity; 175 LLVector3 receivedVelocity = obj.RootPart.Velocity;
186 //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); 176 //System.Console.WriteLine(obj.RootPart.Velocity.ToString());
187 m_innerScene.AddSceneObjectFromStorage(obj); 177 scene.AddSceneObjectFromStorage(obj);
188 178
189 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 179 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
190 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && 180 bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
191 m_parentScene.m_physicalPrim); 181 scene.m_physicalPrim);
192 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) 182 if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
193 { 183 {
194 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( 184 rootPart.PhysActor = scene.PhysicsScene.AddPrimShape(
195 rootPart.Name, 185 rootPart.Name,
196 rootPart.Shape, 186 rootPart.Shape,
197 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 187 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
@@ -213,14 +203,14 @@ namespace OpenSim.Region.Environment.Scenes
213 obj.ScheduleGroupForFullUpdate(); 203 obj.ScheduleGroupForFullUpdate();
214 } 204 }
215 205
216 public void SavePrimsToXml2(string fileName) 206 public static void SavePrimsToXml2(Scene scene, string fileName)
217 { 207 {
218 FileStream file = new FileStream(fileName, FileMode.Create); 208 FileStream file = new FileStream(fileName, FileMode.Create);
219 StreamWriter stream = new StreamWriter(file); 209 StreamWriter stream = new StreamWriter(file);
220 int primCount = 0; 210 int primCount = 0;
221 stream.WriteLine("<scene>\n"); 211 stream.WriteLine("<scene>\n");
222 212
223 List<EntityBase> EntityList = m_innerScene.GetEntities(); 213 List<EntityBase> EntityList = scene.GetEntities();
224 214
225 foreach (EntityBase ent in EntityList) 215 foreach (EntityBase ent in EntityList)
226 { 216 {
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index bd8a0f4..bfa0a43 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using libsecondlife;
31using Nini.Config; 32using Nini.Config;
32using OpenSim.Region.Environment.Interfaces; 33using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; 34using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander;
@@ -85,7 +86,37 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
85 #endregion 86 #endregion
86 87
87 #region IRegionSerialiser Members 88 #region IRegionSerialiser Members
88 89
90 public void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset)
91 {
92 SceneXmlLoader.LoadPrimsFromXml(scene, fileName, newIDS, loadOffset);
93 }
94
95 public void SavePrimsToXml(Scene scene, string fileName)
96 {
97 SceneXmlLoader.SavePrimsToXml(scene, fileName);
98 }
99
100 public void LoadPrimsFromXml2(Scene scene, string fileName)
101 {
102 SceneXmlLoader.LoadPrimsFromXml2(scene, fileName);
103 }
104
105 public void SavePrimsToXml2(Scene scene, string fileName)
106 {
107 SceneXmlLoader.SavePrimsToXml2(scene, fileName);
108 }
109
110 public void LoadGroupFromXml2String(Scene scene, string xmlString)
111 {
112 SceneXmlLoader.LoadGroupFromXml2String(scene, xmlString);
113 }
114
115 public string SavePrimGroupToXML2String(SceneObjectGroup grp)
116 {
117 return SceneXmlLoader.SavePrimGroupToXML2String(grp);
118 }
119
89 public List<string> SerialiseRegion(Scene scene, string saveDir) 120 public List<string> SerialiseRegion(Scene scene, string saveDir)
90 { 121 {
91 List<string> results = new List<string>(); 122 List<string> results = new List<string>();
@@ -165,4 +196,4 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
165 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); 196 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
166 } 197 }
167 } 198 }
168} \ No newline at end of file 199}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index c1e8602..26f3499 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
42using OpenSim.Region.Environment.Interfaces; 42using OpenSim.Region.Environment.Interfaces;
43using OpenSim.Region.Environment.Modules.World.Archiver; 43using OpenSim.Region.Environment.Modules.World.Archiver;
44using OpenSim.Region.Environment.Modules.World.Serialiser;
44using OpenSim.Region.Environment.Modules.World.Terrain; 45using OpenSim.Region.Environment.Modules.World.Terrain;
45using OpenSim.Region.Environment.Scenes.Scripting; 46using OpenSim.Region.Environment.Scenes.Scripting;
46using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.Physics.Manager;
@@ -94,7 +95,6 @@ namespace OpenSim.Region.Environment.Scenes
94 public CommunicationsManager CommsManager; 95 public CommunicationsManager CommsManager;
95 96
96 protected SceneCommunicationService m_sceneGridService; 97 protected SceneCommunicationService m_sceneGridService;
97 protected SceneXmlLoader m_sceneXmlLoader;
98 98
99 /// <summary> 99 /// <summary>
100 /// Each agent has its own capabilities handler. 100 /// Each agent has its own capabilities handler.
@@ -268,8 +268,6 @@ namespace OpenSim.Region.Environment.Scenes
268 // Operating system has killed the plugin 268 // Operating system has killed the plugin
269 m_innerScene.UnRecoverableError += RestartNow; 269 m_innerScene.UnRecoverableError += RestartNow;
270 270
271 m_sceneXmlLoader = new SceneXmlLoader(this, m_innerScene, m_regInfo);
272
273 RegisterDefaultSceneEvents(); 271 RegisterDefaultSceneEvents();
274 272
275 m_httpListener = httpServer; 273 m_httpListener = httpServer;
@@ -1400,22 +1398,26 @@ namespace OpenSim.Region.Environment.Scenes
1400 1398
1401 public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) 1399 public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset)
1402 { 1400 {
1403 m_sceneXmlLoader.LoadPrimsFromXml(fileName, newIdsFlag, loadOffset); 1401 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1402 loader.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset);
1404 } 1403 }
1405 1404
1406 public void SavePrimsToXml(string fileName) 1405 public void SavePrimsToXml(string fileName)
1407 { 1406 {
1408 m_sceneXmlLoader.SavePrimsToXml(fileName); 1407 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1408 loader.SavePrimsToXml(this, fileName);
1409 } 1409 }
1410 1410
1411 public void LoadPrimsFromXml2(string fileName) 1411 public void LoadPrimsFromXml2(string fileName)
1412 { 1412 {
1413 m_sceneXmlLoader.LoadPrimsFromXml2(fileName); 1413 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1414 loader.LoadPrimsFromXml2(this, fileName);
1414 } 1415 }
1415 1416
1416 public void SavePrimsToXml2(string fileName) 1417 public void SavePrimsToXml2(string fileName)
1417 { 1418 {
1418 m_sceneXmlLoader.SavePrimsToXml2(fileName); 1419 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1420 loader.SavePrimsToXml2(this, fileName);
1419 } 1421 }
1420 1422
1421 /// <summary> 1423 /// <summary>
@@ -1505,15 +1507,20 @@ namespace OpenSim.Region.Environment.Scenes
1505 grp.OffsetForNewRegion(pos); 1507 grp.OffsetForNewRegion(pos);
1506 1508
1507 CrossPrimGroupIntoNewRegion(newRegionHandle, grp); 1509 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1508
1509 } 1510 }
1511
1510 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) 1512 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp)
1511 { 1513 {
1512 int primcrossingXMLmethod = 0; 1514 int primcrossingXMLmethod = 0;
1513 if (newRegionHandle != 0) 1515 if (newRegionHandle != 0)
1514 { 1516 {
1515 bool successYN = false; 1517 bool successYN = false;
1516 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod); 1518
1519 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1520 successYN
1521 = m_sceneGridService.PrimCrossToNeighboringRegion(
1522 newRegionHandle, grp.UUID, loader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod);
1523
1517 if (successYN) 1524 if (successYN)
1518 { 1525 {
1519 // We remove the object here 1526 // We remove the object here
@@ -1545,7 +1552,9 @@ namespace OpenSim.Region.Environment.Scenes
1545 m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); 1552 m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor");
1546 if (XMLMethod == 0) 1553 if (XMLMethod == 0)
1547 { 1554 {
1548 m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); 1555 IRegionSerialiser loader = RequestModuleInterface<IRegionSerialiser>();
1556 loader.LoadGroupFromXml2String(this, objXMLData);
1557
1549 SceneObjectPart RootPrim = GetSceneObjectPart(primID); 1558 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
1550 if (RootPrim != null) 1559 if (RootPrim != null)
1551 { 1560 {
@@ -3025,7 +3034,6 @@ namespace OpenSim.Region.Environment.Scenes
3025 3034
3026 public bool pipeEventsForScript(uint localID) 3035 public bool pipeEventsForScript(uint localID)
3027 { 3036 {
3028
3029 SceneObjectPart part = GetSceneObjectPart(localID); 3037 SceneObjectPart part = GetSceneObjectPart(localID);
3030 if (part != null) 3038 if (part != null)
3031 { 3039 {