diff options
author | Jeff Ames | 2008-04-15 10:02:06 +0000 |
---|---|---|
committer | Jeff Ames | 2008-04-15 10:02:06 +0000 |
commit | 06d05bd339e9c2407392119b89305ec028f04b57 (patch) | |
tree | baff869a089595716b01510a644b780848551bec /OpenSim | |
parent | * Added support for serialising objects to ExportSerialisationModule via Seri... (diff) | |
download | opensim-SC-06d05bd339e9c2407392119b89305ec028f04b57.zip opensim-SC-06d05bd339e9c2407392119b89305ec028f04b57.tar.gz opensim-SC-06d05bd339e9c2407392119b89305ec028f04b57.tar.bz2 opensim-SC-06d05bd339e9c2407392119b89305ec028f04b57.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim')
4 files changed, 201 insertions, 201 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs index adb607a..8613e77 100644 --- a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs +++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs | |||
@@ -1,143 +1,143 @@ | |||
1 | | 1 | |
2 | using System; | 2 | using System; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Drawing; | 4 | using System.Drawing; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using Nini.Config; | 6 | using Nini.Config; |
7 | using OpenSim.Framework; | 7 | using OpenSim.Framework; |
8 | using OpenSim.Region.Environment.Interfaces; | 8 | using OpenSim.Region.Environment.Interfaces; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 10 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
11 | using System.IO; | 11 | using System.IO; |
12 | 12 | ||
13 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 13 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
14 | { | 14 | { |
15 | public class ExportSerialisationModule : IRegionModule | 15 | public class ExportSerialisationModule : IRegionModule |
16 | { | 16 | { |
17 | private List<Scene> m_regions = new List<Scene>(); | 17 | private List<Scene> m_regions = new List<Scene>(); |
18 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); | 18 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); |
19 | private Commander m_commander = new Commander("Export"); | 19 | private Commander m_commander = new Commander("Export"); |
20 | private string m_savedir = "exports" + "/"; | 20 | private string m_savedir = "exports" + "/"; |
21 | 21 | ||
22 | private List<string> SerialiseRegion(Scene scene) | 22 | private List<string> SerialiseRegion(Scene scene) |
23 | { | 23 | { |
24 | List<string> results = new List<string>(); | 24 | List<string> results = new List<string>(); |
25 | 25 | ||
26 | string saveDir = m_savedir + scene.RegionInfo.RegionID.ToString() + "/"; | 26 | string saveDir = m_savedir + scene.RegionInfo.RegionID.ToString() + "/"; |
27 | 27 | ||
28 | if (!Directory.Exists(saveDir)) | 28 | if (!Directory.Exists(saveDir)) |
29 | { | 29 | { |
30 | Directory.CreateDirectory(saveDir); | 30 | Directory.CreateDirectory(saveDir); |
31 | } | 31 | } |
32 | 32 | ||
33 | lock (m_serialisers) | 33 | lock (m_serialisers) |
34 | { | 34 | { |
35 | foreach (IFileSerialiser serialiser in m_serialisers) | 35 | foreach (IFileSerialiser serialiser in m_serialisers) |
36 | { | 36 | { |
37 | results.Add(serialiser.WriteToFile(scene, saveDir)); | 37 | results.Add(serialiser.WriteToFile(scene, saveDir)); |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); | 41 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); |
42 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); | 42 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); |
43 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); | 43 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); |
44 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); | 44 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); |
45 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); | 45 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); |
46 | regionInfoWriter.Close(); | 46 | regionInfoWriter.Close(); |
47 | 47 | ||
48 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); | 48 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); |
49 | foreach (string line in results) | 49 | foreach (string line in results) |
50 | { | 50 | { |
51 | manifestWriter.WriteLine(line); | 51 | manifestWriter.WriteLine(line); |
52 | } | 52 | } |
53 | manifestWriter.Close(); | 53 | manifestWriter.Close(); |
54 | 54 | ||
55 | return results; | 55 | return results; |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | #region IRegionModule Members | 59 | #region IRegionModule Members |
60 | 60 | ||
61 | public void Initialise(Scene scene, IConfigSource source) | 61 | public void Initialise(Scene scene, IConfigSource source) |
62 | { | 62 | { |
63 | scene.RegisterModuleCommander("Export", m_commander); | 63 | scene.RegisterModuleCommander("Export", m_commander); |
64 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 64 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
65 | 65 | ||
66 | lock (m_regions) | 66 | lock (m_regions) |
67 | { | 67 | { |
68 | m_regions.Add(scene); | 68 | m_regions.Add(scene); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void EventManager_OnPluginConsole(string[] args) | 72 | void EventManager_OnPluginConsole(string[] args) |
73 | { | 73 | { |
74 | if (args[0] == "export") | 74 | if (args[0] == "export") |
75 | { | 75 | { |
76 | string[] tmpArgs = new string[args.Length - 2]; | 76 | string[] tmpArgs = new string[args.Length - 2]; |
77 | int i = 0; | 77 | int i = 0; |
78 | for (i = 2; i < args.Length; i++) | 78 | for (i = 2; i < args.Length; i++) |
79 | tmpArgs[i - 2] = args[i]; | 79 | tmpArgs[i - 2] = args[i]; |
80 | 80 | ||
81 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | 81 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | private void InterfaceSaveRegion(Object[] args) | 85 | private void InterfaceSaveRegion(Object[] args) |
86 | { | 86 | { |
87 | foreach (Scene region in m_regions) | 87 | foreach (Scene region in m_regions) |
88 | { | 88 | { |
89 | if (region.RegionInfo.RegionName == (string)args[0]) | 89 | if (region.RegionInfo.RegionName == (string)args[0]) |
90 | { | 90 | { |
91 | List<string> results = SerialiseRegion(region); | 91 | List<string> results = SerialiseRegion(region); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | private void InterfaceSaveAllRegions(Object[] args) | 96 | private void InterfaceSaveAllRegions(Object[] args) |
97 | { | 97 | { |
98 | foreach (Scene region in m_regions) | 98 | foreach (Scene region in m_regions) |
99 | { | 99 | { |
100 | List<string> results = SerialiseRegion(region); | 100 | List<string> results = SerialiseRegion(region); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | private void LoadCommanderCommands() | 104 | private void LoadCommanderCommands() |
105 | { | 105 | { |
106 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); | 106 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); |
107 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); | 107 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); |
108 | 108 | ||
109 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); | 109 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); |
110 | 110 | ||
111 | m_commander.RegisterCommand("save", serialiseSceneCommand); | 111 | m_commander.RegisterCommand("save", serialiseSceneCommand); |
112 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); | 112 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); |
113 | } | 113 | } |
114 | 114 | ||
115 | public void PostInitialise() | 115 | public void PostInitialise() |
116 | { | 116 | { |
117 | lock (m_serialisers) | 117 | lock (m_serialisers) |
118 | { | 118 | { |
119 | m_serialisers.Add(new SerialiseTerrain()); | 119 | m_serialisers.Add(new SerialiseTerrain()); |
120 | m_serialisers.Add(new SerialiseObjects()); | 120 | m_serialisers.Add(new SerialiseObjects()); |
121 | } | 121 | } |
122 | 122 | ||
123 | LoadCommanderCommands(); | 123 | LoadCommanderCommands(); |
124 | } | 124 | } |
125 | 125 | ||
126 | public void Close() | 126 | public void Close() |
127 | { | 127 | { |
128 | m_regions.Clear(); | 128 | m_regions.Clear(); |
129 | } | 129 | } |
130 | 130 | ||
131 | public string Name | 131 | public string Name |
132 | { | 132 | { |
133 | get { return "ExportSerialisationModule"; } | 133 | get { return "ExportSerialisationModule"; } |
134 | } | 134 | } |
135 | 135 | ||
136 | public bool IsSharedModule | 136 | public bool IsSharedModule |
137 | { | 137 | { |
138 | get { return true; } | 138 | get { return true; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | } | 142 | } |
143 | } | 143 | } |
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs index 4d5e42b..e35c2f5 100644 --- a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs | |||
@@ -1,13 +1,13 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Region.Environment.Scenes; | 5 | using OpenSim.Region.Environment.Scenes; |
6 | 6 | ||
7 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 7 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
8 | { | 8 | { |
9 | interface IFileSerialiser | 9 | interface IFileSerialiser |
10 | { | 10 | { |
11 | string WriteToFile(Scene scene, string dir); | 11 | string WriteToFile(Scene scene, string dir); |
12 | } | 12 | } |
13 | } | 13 | } |
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs index d8cae6e..50c36d6 100644 --- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs +++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs | |||
@@ -1,20 +1,20 @@ | |||
1 | using OpenSim.Region.Environment.Scenes; | 1 | using OpenSim.Region.Environment.Scenes; |
2 | 2 | ||
3 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 3 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
4 | { | 4 | { |
5 | class SerialiseObjects : IFileSerialiser | 5 | class SerialiseObjects : IFileSerialiser |
6 | { | 6 | { |
7 | #region IFileSerialiser Members | 7 | #region IFileSerialiser Members |
8 | 8 | ||
9 | public string WriteToFile(Scene scene, string dir) | 9 | public string WriteToFile(Scene scene, string dir) |
10 | { | 10 | { |
11 | string targetFileName = dir + "objects.xml"; | 11 | string targetFileName = dir + "objects.xml"; |
12 | 12 | ||
13 | scene.SavePrimsToXml2(targetFileName); | 13 | scene.SavePrimsToXml2(targetFileName); |
14 | 14 | ||
15 | return "objects.xml"; | 15 | return "objects.xml"; |
16 | } | 16 | } |
17 | 17 | ||
18 | #endregion | 18 | #endregion |
19 | } | 19 | } |
20 | } | 20 | } |
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs index 0c79999..155256b 100644 --- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs +++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs | |||
@@ -1,25 +1,25 @@ | |||
1 | using OpenSim.Region.Environment.Modules.Terrain; | 1 | using OpenSim.Region.Environment.Modules.Terrain; |
2 | using OpenSim.Region.Environment.Scenes; | 2 | using OpenSim.Region.Environment.Scenes; |
3 | 3 | ||
4 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 4 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
5 | { | 5 | { |
6 | class SerialiseTerrain : IFileSerialiser | 6 | class SerialiseTerrain : IFileSerialiser |
7 | { | 7 | { |
8 | #region IFileSerialiser Members | 8 | #region IFileSerialiser Members |
9 | 9 | ||
10 | public string WriteToFile(Scene scene, string dir) | 10 | public string WriteToFile(Scene scene, string dir) |
11 | { | 11 | { |
12 | ITerrainLoader fileSystemExporter = new Terrain.FileLoaders.RAW32(); | 12 | ITerrainLoader fileSystemExporter = new Terrain.FileLoaders.RAW32(); |
13 | string targetFileName = dir + "heightmap.r32"; | 13 | string targetFileName = dir + "heightmap.r32"; |
14 | 14 | ||
15 | lock (scene.Heightmap) | 15 | lock (scene.Heightmap) |
16 | { | 16 | { |
17 | fileSystemExporter.SaveFile(targetFileName, scene.Heightmap); | 17 | fileSystemExporter.SaveFile(targetFileName, scene.Heightmap); |
18 | } | 18 | } |
19 | 19 | ||
20 | return "heightmap.r32"; | 20 | return "heightmap.r32"; |
21 | } | 21 | } |
22 | 22 | ||
23 | #endregion | 23 | #endregion |
24 | } | 24 | } |
25 | } | 25 | } |