29 using System.Collections.Generic;
31 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Console;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
49 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"ArchiverModule")]
52 private static readonly ILog m_log =
53 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 protected const string DEFAULT_OAR_BACKUP_FILENAME =
"region.oar";
65 get {
return "RegionArchiverModule"; }
68 public Type ReplaceableInterface
105 bool mergeOar =
false;
106 bool skipAssets =
false;
107 bool forceTerrain =
false;
108 bool forceParcels =
false;
109 bool noObjects =
false;
110 Vector3 displacement =
new Vector3(0f, 0f, 0f);
114 Vector3 boundingOrigin =
new Vector3(0f, 0f, 0f);
118 OptionSet
options =
new OptionSet();
119 options.Add(
"m|merge", delegate(
string v) { mergeOar = (v != null); });
120 options.Add(
"s|skip-assets", delegate(
string v) { skipAssets = (v != null); });
121 options.Add(
"force-terrain", delegate(
string v) { forceTerrain = (v != null); });
122 options.Add(
"forceterrain", delegate(
string v) { forceTerrain = (v != null); });
123 options.Add(
"force-parcels", delegate(
string v) { forceParcels = (v != null); });
124 options.Add(
"forceparcels", delegate(
string v) { forceParcels = (v != null); });
125 options.Add(
"no-objects", delegate(
string v) { noObjects = (v != null); });
126 options.Add(
"default-user=", delegate(
string v) { defaultUser = (v == null) ?
"" : v; });
127 options.Add(
"displacement=", delegate(
string v)
131 displacement = v == null ? Vector3.Zero : Vector3.Parse(v);
135 m_log.ErrorFormat(
"[ARCHIVER MODULE] failure parsing displacement");
136 m_log.ErrorFormat(
"[ARCHIVER MODULE] Must be represented as vector3: --displacement \"<128,128,0>\"");
140 options.Add(
"rotation=", delegate(
string v)
144 rotation = v == null ? 0f : float.Parse(v);
148 m_log.ErrorFormat(
"[ARCHIVER MODULE] failure parsing rotation");
149 m_log.ErrorFormat(
"[ARCHIVER MODULE] Must be an angle in degrees between -360 and +360: --rotation 45");
153 rotation = Util.Clamp<
float>(
rotation, -359f, 359f);
155 options.Add(
"rotation-center=", delegate(
string v)
159 m_log.Info(
"[ARCHIVER MODULE] Warning: --rotation-center no longer does anything and will be removed soon!");
160 rotationCenter = v == null ? Vector3.Zero : Vector3.Parse(v);
164 m_log.ErrorFormat(
"[ARCHIVER MODULE] failure parsing rotation displacement");
165 m_log.ErrorFormat(
"[ARCHIVER MODULE] Must be represented as vector3: --rotation-center \"<128,128,0>\"");
169 options.Add(
"bounding-origin=", delegate(
string v)
173 boundingOrigin = v == null ? Vector3.Zero : Vector3.Parse(v);
177 m_log.ErrorFormat(
"[ARCHIVER MODULE] failure parsing bounding cube origin");
178 m_log.ErrorFormat(
"[ARCHIVER MODULE] Must be represented as vector3: --bounding-origin \"<128,128,0>\"");
182 options.Add(
"bounding-size=", delegate(
string v)
190 m_log.ErrorFormat(
"[ARCHIVER MODULE] failure parsing bounding cube size");
191 m_log.ErrorFormat(
"[ARCHIVER MODULE] Must be represented as a positive vector3: --bounding-size \"<256,256,4096>\"");
195 options.Add(
"d|debug", delegate(
string v) { debug = (v != null); });
207 List<string> mainParams = options.Parse(cmdparams);
214 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
215 if (mergeOar) archiveOptions.Add(
"merge", null);
216 if (skipAssets) archiveOptions.Add(
"skipAssets", null);
217 if (forceTerrain) archiveOptions.Add(
"force-terrain", null);
218 if (forceParcels) archiveOptions.Add(
"force-parcels", null);
219 if (noObjects) archiveOptions.Add(
"no-objects", null);
220 if (defaultUser !=
"")
222 UUID defaultUserUUID = UUID.Zero;
225 defaultUserUUID = Scene.UserManagementModule.GetUserIdByName(defaultUser);
229 m_log.ErrorFormat(
"[ARCHIVER MODULE] default user must be in format \"First Last\"", defaultUser);
231 if (defaultUserUUID ==
UUID.Zero)
233 m_log.ErrorFormat(
"[ARCHIVER MODULE] cannot find specified default user {0}", defaultUser);
238 archiveOptions.Add(
"default-user", defaultUserUUID);
241 archiveOptions.Add(
"displacement", displacement);
242 archiveOptions.Add(
"rotation",
rotation);
243 archiveOptions.Add(
"rotation-center", rotationCenter);
244 archiveOptions.Add(
"bounding-origin", boundingOrigin);
245 archiveOptions.Add(
"bounding-size", boundingSize);
246 if (debug) archiveOptions.Add(
"debug", null);
248 if (mainParams.Count > 2)
250 DearchiveRegion(mainParams[2], Guid.Empty, archiveOptions);
254 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, Guid.Empty, archiveOptions);
264 Dictionary<string, object>
options =
new Dictionary<string, object>();
266 OptionSet ops =
new OptionSet();
269 ops.Add(
"p|profile=", delegate(
string v) { Console.WriteLine(
"\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); });
271 ops.Add(
"h|home=", delegate(
string v) { options[
"home"] = v; });
273 ops.Add(
"noassets", delegate(
string v) { options[
"noassets"] = v != null; });
274 ops.Add(
"publish", v => options[
"wipe-owners"] = v != null);
275 ops.Add(
"perm=", delegate(
string v) { options[
"checkPermissions"] = v; });
276 ops.Add(
"all", delegate(
string v) { options[
"all"] = v != null; });
278 List<string> mainParams = ops.Parse(cmdparams);
281 if (mainParams.Count > 2)
282 path = mainParams[2];
284 path = DEFAULT_OAR_BACKUP_FILENAME;
291 ArchiveRegion(path, options);
296 ArchiveRegion(savePath, Guid.Empty, options);
302 "[ARCHIVER]: Writing archive for region {0} to {1}", Scene.RegionInfo.RegionName, savePath);
309 ArchiveRegion(saveStream, Guid.Empty);
314 ArchiveRegion(saveStream, requestId,
new Dictionary<string, object>());
324 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
325 DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
331 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
338 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
339 DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
Load a whole region from an opensimulator archive.
uint RegionSizeX
X dimension of the region.
void DearchiveRegion(string loadPath, Guid requestId, Dictionary< string, object > options)
Dearchive the given region archive. This replaces the existing scene.
uint RegionSizeY
X dimension of the region.
Interface to region archive functionality
void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary< string, object > options)
Archive the region to a stream.
void ArchiveRegion(Stream saveStream, Guid requestId)
Archive the region to a stream.
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void DearchiveRegion(Stream loadStream)
Dearchive a region from a stream. This replaces the existing scene.
void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
Save a region to a file, including all the assets needed to restore it.
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary< string, object > options)
Dearchive a region from a stream. This replaces the existing scene.
void ArchiveRegion(Stream saveStream)
void ArchiveRegion(string savePath, Dictionary< string, object > options)
Archive the region to the given path
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void DearchiveRegion(string loadPath)
Dearchive the given region archive. This replaces the existing scene.
This module loads and saves OpenSimulator region archives
Prepare to write out an archive.
virtual RegionInfo RegionInfo
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void ArchiveRegion(string savePath, Guid requestId, Dictionary< string, object > options)
Archive the region to the given path
Handles an individual archive read request