aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Serialiser
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Serialiser')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs70
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs72
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs248
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs104
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs336
5 files changed, 415 insertions, 415 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
index fc3f75d..77a418f 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
@@ -1,36 +1,36 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 OpenSim.Region.Environment.Scenes; 28using OpenSim.Region.Environment.Scenes;
29 29
30namespace OpenSim.Region.Environment.Modules.ExportSerialiser 30namespace OpenSim.Region.Environment.Modules.ExportSerialiser
31{ 31{
32 internal interface IFileSerialiser 32 internal interface IFileSerialiser
33 { 33 {
34 string WriteToFile(Scene scene, string dir); 34 string WriteToFile(Scene scene, string dir);
35 } 35 }
36} \ No newline at end of file 36} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
index 0ea2f30..e1721ff 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs
@@ -1,37 +1,37 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 System.Collections.Generic; 28using System.Collections.Generic;
29using OpenSim.Region.Environment.Scenes; 29using OpenSim.Region.Environment.Scenes;
30 30
31namespace OpenSim.Region.Environment.Modules.ExportSerialiser 31namespace OpenSim.Region.Environment.Modules.ExportSerialiser
32{ 32{
33 public interface IRegionSerialiser 33 public interface IRegionSerialiser
34 { 34 {
35 List<string> SerialiseRegion(Scene scene, string saveDir); 35 List<string> SerialiseRegion(Scene scene, string saveDir);
36 } 36 }
37} \ No newline at end of file 37} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
index ef90fd4..40e1771 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
@@ -1,125 +1,125 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.IO.Compression; 30using System.IO.Compression;
31using System.Text; 31using System.Text;
32using System.Xml; 32using System.Xml;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34 34
35namespace OpenSim.Region.Environment.Modules.ExportSerialiser 35namespace OpenSim.Region.Environment.Modules.ExportSerialiser
36{ 36{
37 internal class SerialiseObjects : IFileSerialiser 37 internal class SerialiseObjects : IFileSerialiser
38 { 38 {
39 #region IFileSerialiser Members 39 #region IFileSerialiser Members
40 40
41 public string WriteToFile(Scene scene, string dir) 41 public string WriteToFile(Scene scene, string dir)
42 { 42 {
43 string targetFileName = dir + "objects.xml"; 43 string targetFileName = dir + "objects.xml";
44 44
45 SaveSerialisedToFile(targetFileName, scene); 45 SaveSerialisedToFile(targetFileName, scene);
46 46
47 return "objects.xml"; 47 return "objects.xml";
48 } 48 }
49 49
50 #endregion 50 #endregion
51 51
52 public void SaveSerialisedToFile(string fileName, Scene scene) 52 public void SaveSerialisedToFile(string fileName, Scene scene)
53 { 53 {
54 string xmlstream = GetObjectXml(scene); 54 string xmlstream = GetObjectXml(scene);
55 55
56 MemoryStream stream = ReformatXmlString(xmlstream); 56 MemoryStream stream = ReformatXmlString(xmlstream);
57 57
58 stream.Seek(0, SeekOrigin.Begin); 58 stream.Seek(0, SeekOrigin.Begin);
59 CreateXmlFile(stream, fileName); 59 CreateXmlFile(stream, fileName);
60 60
61 stream.Seek(0, SeekOrigin.Begin); 61 stream.Seek(0, SeekOrigin.Begin);
62 CreateCompressedXmlFile(stream, fileName); 62 CreateCompressedXmlFile(stream, fileName);
63 } 63 }
64 64
65 private static MemoryStream ReformatXmlString(string xmlstream) 65 private static MemoryStream ReformatXmlString(string xmlstream)
66 { 66 {
67 MemoryStream stream = new MemoryStream(); 67 MemoryStream stream = new MemoryStream();
68 XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8); 68 XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8);
69 XmlDocument doc = new XmlDocument(); 69 XmlDocument doc = new XmlDocument();
70 70
71 doc.LoadXml(xmlstream); 71 doc.LoadXml(xmlstream);
72 formatter.Formatting = Formatting.Indented; 72 formatter.Formatting = Formatting.Indented;
73 doc.WriteContentTo(formatter); 73 doc.WriteContentTo(formatter);
74 formatter.Flush(); 74 formatter.Flush();
75 return stream; 75 return stream;
76 } 76 }
77 77
78 private static string GetObjectXml(Scene scene) 78 private static string GetObjectXml(Scene scene)
79 { 79 {
80 string xmlstream = "<scene>"; 80 string xmlstream = "<scene>";
81 81
82 List<EntityBase> EntityList = scene.GetEntities(); 82 List<EntityBase> EntityList = scene.GetEntities();
83 List<string> EntityXml = new List<string>(); 83 List<string> EntityXml = new List<string>();
84 84
85 foreach (EntityBase ent in EntityList) 85 foreach (EntityBase ent in EntityList)
86 { 86 {
87 if (ent is SceneObjectGroup) 87 if (ent is SceneObjectGroup)
88 { 88 {
89 EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2()); 89 EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
90 } 90 }
91 } 91 }
92 EntityXml.Sort(); 92 EntityXml.Sort();
93 93
94 foreach (string xml in EntityXml) 94 foreach (string xml in EntityXml)
95 xmlstream += xml; 95 xmlstream += xml;
96 96
97 xmlstream += "</scene>"; 97 xmlstream += "</scene>";
98 return xmlstream; 98 return xmlstream;
99 } 99 }
100 100
101 private static void CreateXmlFile(MemoryStream xmlStream, string fileName) 101 private static void CreateXmlFile(MemoryStream xmlStream, string fileName)
102 { 102 {
103 FileStream objectsFile = new FileStream(fileName, FileMode.Create); 103 FileStream objectsFile = new FileStream(fileName, FileMode.Create);
104 104
105 xmlStream.WriteTo(objectsFile); 105 xmlStream.WriteTo(objectsFile);
106 objectsFile.Flush(); 106 objectsFile.Flush();
107 objectsFile.Close(); 107 objectsFile.Close();
108 } 108 }
109 109
110 private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) 110 private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
111 { 111 {
112 #region GZip Compressed Version 112 #region GZip Compressed Version
113 113
114 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); 114 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
115 MemoryStream gzipMSStream = new MemoryStream(); 115 MemoryStream gzipMSStream = new MemoryStream();
116 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); 116 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
117 xmlStream.WriteTo(gzipStream); 117 xmlStream.WriteTo(gzipStream);
118 gzipMSStream.WriteTo(objectsFileCompressed); 118 gzipMSStream.WriteTo(objectsFileCompressed);
119 objectsFileCompressed.Flush(); 119 objectsFileCompressed.Flush();
120 objectsFileCompressed.Close(); 120 objectsFileCompressed.Close();
121 121
122 #endregion 122 #endregion
123 } 123 }
124 } 124 }
125} \ No newline at end of file 125} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
index 03824e8..dacdbc8 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
@@ -1,53 +1,53 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 OpenSim.Region.Environment.Modules.World.Terrain; 28using OpenSim.Region.Environment.Modules.World.Terrain;
29using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; 29using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
30using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
31 31
32namespace OpenSim.Region.Environment.Modules.ExportSerialiser 32namespace OpenSim.Region.Environment.Modules.ExportSerialiser
33{ 33{
34 internal class SerialiseTerrain : IFileSerialiser 34 internal class SerialiseTerrain : IFileSerialiser
35 { 35 {
36 #region IFileSerialiser Members 36 #region IFileSerialiser Members
37 37
38 public string WriteToFile(Scene scene, string dir) 38 public string WriteToFile(Scene scene, string dir)
39 { 39 {
40 ITerrainLoader fileSystemExporter = new RAW32(); 40 ITerrainLoader fileSystemExporter = new RAW32();
41 string targetFileName = dir + "heightmap.r32"; 41 string targetFileName = dir + "heightmap.r32";
42 42
43 lock (scene.Heightmap) 43 lock (scene.Heightmap)
44 { 44 {
45 fileSystemExporter.SaveFile(targetFileName, scene.Heightmap); 45 fileSystemExporter.SaveFile(targetFileName, scene.Heightmap);
46 } 46 }
47 47
48 return "heightmap.r32"; 48 return "heightmap.r32";
49 } 49 }
50 50
51 #endregion 51 #endregion
52 } 52 }
53} \ No newline at end of file 53} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index b626f16..75fc428 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -1,169 +1,169 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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 System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using Nini.Config; 31using Nini.Config;
32using OpenSim.Region.Environment.Interfaces; 32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Modules.ExportSerialiser; 33using OpenSim.Region.Environment.Modules.ExportSerialiser;
34using OpenSim.Region.Environment.Modules.Framework; 34using OpenSim.Region.Environment.Modules.Framework;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36
37namespace OpenSim.Region.Environment.Modules.World.Serialiser 37namespace OpenSim.Region.Environment.Modules.World.Serialiser
38{ 38{
39 public class SerialiserModule : IRegionModule, IRegionSerialiser 39 public class SerialiserModule : IRegionModule, IRegionSerialiser
40 { 40 {
41 private Commander m_commander = new Commander("Export"); 41 private Commander m_commander = new Commander("Export");
42 private List<Scene> m_regions = new List<Scene>(); 42 private List<Scene> m_regions = new List<Scene>();
43 private string m_savedir = "exports" + "/"; 43 private string m_savedir = "exports" + "/";
44 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); 44 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
45 45
46 #region IRegionModule Members 46 #region IRegionModule Members
47 47
48 public void Initialise(Scene scene, IConfigSource source) 48 public void Initialise(Scene scene, IConfigSource source)
49 { 49 {
50 scene.RegisterModuleCommander("Export", m_commander); 50 scene.RegisterModuleCommander("Export", m_commander);
51 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 51 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
52 scene.RegisterModuleInterface<IRegionSerialiser>(this); 52 scene.RegisterModuleInterface<IRegionSerialiser>(this);
53 53
54 lock (m_regions) 54 lock (m_regions)
55 { 55 {
56 m_regions.Add(scene); 56 m_regions.Add(scene);
57 } 57 }
58 } 58 }
59 59
60 public void PostInitialise() 60 public void PostInitialise()
61 { 61 {
62 lock (m_serialisers) 62 lock (m_serialisers)
63 { 63 {
64 m_serialisers.Add(new SerialiseTerrain()); 64 m_serialisers.Add(new SerialiseTerrain());
65 m_serialisers.Add(new SerialiseObjects()); 65 m_serialisers.Add(new SerialiseObjects());
66 } 66 }
67 67
68 LoadCommanderCommands(); 68 LoadCommanderCommands();
69 } 69 }
70 70
71 public void Close() 71 public void Close()
72 { 72 {
73 m_regions.Clear(); 73 m_regions.Clear();
74 } 74 }
75 75
76 public string Name 76 public string Name
77 { 77 {
78 get { return "ExportSerialisationModule"; } 78 get { return "ExportSerialisationModule"; }
79 } 79 }
80 80
81 public bool IsSharedModule 81 public bool IsSharedModule
82 { 82 {
83 get { return true; } 83 get { return true; }
84 } 84 }
85 85
86 #endregion 86 #endregion
87 87
88 #region IRegionSerialiser Members 88 #region IRegionSerialiser Members
89 89
90 public List<string> SerialiseRegion(Scene scene, string saveDir) 90 public List<string> SerialiseRegion(Scene scene, string saveDir)
91 { 91 {
92 List<string> results = new List<string>(); 92 List<string> results = new List<string>();
93 93
94 if (!Directory.Exists(saveDir)) 94 if (!Directory.Exists(saveDir))
95 { 95 {
96 Directory.CreateDirectory(saveDir); 96 Directory.CreateDirectory(saveDir);
97 } 97 }
98 98
99 lock (m_serialisers) 99 lock (m_serialisers)
100 { 100 {
101 foreach (IFileSerialiser serialiser in m_serialisers) 101 foreach (IFileSerialiser serialiser in m_serialisers)
102 { 102 {
103 results.Add(serialiser.WriteToFile(scene, saveDir)); 103 results.Add(serialiser.WriteToFile(scene, saveDir));
104 } 104 }
105 } 105 }
106 106
107 TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); 107 TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT");
108 regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); 108 regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
109 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); 109 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
110 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); 110 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
111 regionInfoWriter.WriteLine("Serialise Version: 0.1"); 111 regionInfoWriter.WriteLine("Serialise Version: 0.1");
112 regionInfoWriter.Close(); 112 regionInfoWriter.Close();
113 113
114 TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); 114 TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest");
115 foreach (string line in results) 115 foreach (string line in results)
116 { 116 {
117 manifestWriter.WriteLine(line); 117 manifestWriter.WriteLine(line);
118 } 118 }
119 manifestWriter.Close(); 119 manifestWriter.Close();
120 120
121 return results; 121 return results;
122 } 122 }
123 123
124 #endregion 124 #endregion
125 125
126 private void EventManager_OnPluginConsole(string[] args) 126 private void EventManager_OnPluginConsole(string[] args)
127 { 127 {
128 if (args[0] == "export") 128 if (args[0] == "export")
129 { 129 {
130 string[] tmpArgs = new string[args.Length - 2]; 130 string[] tmpArgs = new string[args.Length - 2];
131 int i = 0; 131 int i = 0;
132 for (i = 2; i < args.Length; i++) 132 for (i = 2; i < args.Length; i++)
133 tmpArgs[i - 2] = args[i]; 133 tmpArgs[i - 2] = args[i];
134 134
135 m_commander.ProcessConsoleCommand(args[1], tmpArgs); 135 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
136 } 136 }
137 } 137 }
138 138
139 private void InterfaceSaveRegion(Object[] args) 139 private void InterfaceSaveRegion(Object[] args)
140 { 140 {
141 foreach (Scene region in m_regions) 141 foreach (Scene region in m_regions)
142 { 142 {
143 if (region.RegionInfo.RegionName == (string) args[0]) 143 if (region.RegionInfo.RegionName == (string) args[0])
144 { 144 {
145 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 145 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 private void InterfaceSaveAllRegions(Object[] args) 150 private void InterfaceSaveAllRegions(Object[] args)
151 { 151 {
152 foreach (Scene region in m_regions) 152 foreach (Scene region in m_regions)
153 { 153 {
154 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 154 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
155 } 155 }
156 } 156 }
157 157
158 private void LoadCommanderCommands() 158 private void LoadCommanderCommands()
159 { 159 {
160 Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); 160 Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory.");
161 serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); 161 serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String");
162 162
163 Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); 163 Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory.");
164 164
165 m_commander.RegisterCommand("save", serialiseSceneCommand); 165 m_commander.RegisterCommand("save", serialiseSceneCommand);
166 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); 166 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
167 } 167 }
168 } 168 }
169} \ No newline at end of file 169} \ No newline at end of file