29 using System.Collections.Generic;
31 using System.IO.Compression;
33 using System.Reflection;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Monitoring;
40 using OpenSim.Framework.Serialization;
41 using OpenSim.Framework.Serialization.External;
42 using OpenSim.Region.CoreModules.World.Terrain;
43 using OpenSim.Region.CoreModules.World.Land;
44 using OpenSim.Region.Framework.Interfaces;
45 using OpenSim.Region.Framework.Scenes;
46 using OpenSim.Region.Framework.Scenes.Serialization;
47 using OpenSim.Services.Interfaces;
48 using System.Threading;
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62 private class DearchiveContext
66 public List<string> SerialisedSceneObjects {
get; set; }
68 public List<string> SerialisedParcels {
get; set; }
70 public List<SceneObjectGroup> SceneObjects {
get; set; }
72 public DearchiveContext(
Scene scene)
75 SerialisedSceneObjects =
new List<string>();
76 SerialisedParcels =
new List<string>();
77 SceneObjects =
new List<SceneObjectGroup>();
86 public static int MAX_MAJOR_VERSION = 1;
91 public bool ControlFileLoaded {
get;
private set; }
123 protected Vector3 m_displacement = Vector3.Zero;
128 protected float m_rotation = 0f;
133 protected Vector3 m_incomingRegionSize =
new Vector3(256f, 256f,
float.MaxValue);
138 protected Vector3 m_rotationCenter =
new Vector3(128f, 128f, 0f);
143 protected Vector3 m_boundingOrigin = Vector3.Zero;
150 protected bool m_noObjects =
false;
151 protected bool m_boundingBox =
false;
152 protected bool m_debug =
false;
157 private IDictionary<UUID, bool> m_validUserUuids =
new Dictionary<UUID, bool>();
164 if (m_UserMan == null)
175 private IDictionary<UUID, bool> m_validGroupUuids =
new Dictionary<UUID, bool>();
181 private UUID m_defaultUser;
187 if (options.ContainsKey(
"default-user"))
189 m_defaultUser = (
UUID)options[
"default-user"];
190 m_log.InfoFormat(
"Using User {0} as default user", m_defaultUser.ToString());
194 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
197 m_loadPath = loadPath;
200 m_loadStream =
new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress);
202 catch (EntryPointNotFoundException e)
205 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
206 +
"If you've manually installed Mono, have you appropriately updated zlib1g as well?");
210 m_errorMessage = String.Empty;
212 m_merge = options.ContainsKey(
"merge");
213 m_forceTerrain = options.ContainsKey(
"force-terrain");
214 m_forceParcels = options.ContainsKey(
"force-parcels");
215 m_noObjects = options.ContainsKey(
"no-objects");
216 m_skipAssets = options.ContainsKey(
"skipAssets");
217 m_requestId = requestId;
218 m_displacement = options.ContainsKey(
"displacement") ? (Vector3)options[
"displacement"] : Vector3.Zero;
219 m_rotation = options.ContainsKey(
"rotation") ? (
float)options[
"rotation"] : 0f;
221 m_boundingOrigin = Vector3.Zero;
224 if (options.ContainsKey(
"bounding-origin"))
226 Vector3 boOption = (Vector3)options[
"bounding-origin"];
227 if (boOption != m_boundingOrigin)
229 m_boundingOrigin = boOption;
230 m_boundingBox =
true;
234 if (options.ContainsKey(
"bounding-size"))
236 Vector3 bsOption = (Vector3)options[
"bounding-size"];
238 if (bsOption.X <= 0 || bsOption.X > m_boundingSize.X)
240 bsOption.X = m_boundingSize.X;
243 if (bsOption.Y <= 0 || bsOption.Y > m_boundingSize.Y)
245 bsOption.Y = m_boundingSize.Y;
248 if (bsOption != m_boundingSize)
250 m_boundingSize = bsOption;
251 m_boundingBox =
true;
253 if (clip) m_log.InfoFormat(
"[ARCHIVER]: The bounding cube specified is larger than the destination region! Clipping to {0}.", m_boundingSize.ToString());
256 m_debug = options.ContainsKey(
"debug");
259 m_validUserUuids[UUID.Zero] =
false;
260 m_validGroupUuids[UUID.Zero] =
false;
262 m_groupsModule = m_rootScene.RequestModuleInterface<
IGroupsModule>();
263 m_assetService = m_rootScene.AssetService;
270 m_loadStream = loadStream;
271 m_skipAssets = options.ContainsKey(
"skipAssets");
272 m_merge = options.ContainsKey(
"merge");
273 m_requestId = requestId;
275 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
278 m_validUserUuids[UUID.Zero] =
false;
280 m_groupsModule = m_rootScene.RequestModuleInterface<
IGroupsModule>();
281 m_assetService = m_rootScene.AssetService;
289 int successfulAssetRestores = 0;
290 int failedAssetRestores = 0;
296 Dictionary<UUID, DearchiveContext> sceneContexts =
new Dictionary<UUID, DearchiveContext>();
298 string fullPath =
"NONE";
301 TarArchiveReader.TarEntryType entryType;
305 FindAndLoadControlFile(out archive, out dearchivedScenes);
307 while ((data = archive.ReadEntry(out fullPath, out entryType)) != null)
320 if (!dearchivedScenes.GetRegionFromPath(fullPath, out scene, out filePath))
323 DearchiveContext sceneContext = null;
326 if (!sceneContexts.TryGetValue(scene.RegionInfo.RegionID, out sceneContext))
328 sceneContext =
new DearchiveContext(scene);
329 sceneContexts.Add(scene.RegionInfo.RegionID, sceneContext);
338 sceneContext.SerialisedSceneObjects.Add(Encoding.UTF8.GetString(data));
342 if (LoadAsset(filePath, data))
343 successfulAssetRestores++;
345 failedAssetRestores++;
347 if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
348 m_log.Debug(
"[ARCHIVER]: Loaded " + successfulAssetRestores +
" assets and failed to load " + failedAssetRestores +
" assets...");
352 LoadTerrain(scene, filePath, data);
356 LoadRegionSettings(scene, filePath, data, dearchivedScenes);
360 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
373 String.Format(
"[ARCHIVER]: Aborting load with error in archive file {0} ", fullPath), e);
374 m_errorMessage += e.ToString();
375 m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId,
new List<UUID>(), m_errorMessage);
386 m_log.InfoFormat(
"[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
388 if (failedAssetRestores > 0)
390 m_log.ErrorFormat(
"[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
391 m_errorMessage += String.Format(
"Failed to load {0} assets", failedAssetRestores);
395 foreach (DearchiveContext sceneContext
in sceneContexts.Values)
397 m_log.InfoFormat(
"[ARCHIVER]: Loading region {0}", sceneContext.Scene.RegionInfo.RegionName);
401 m_log.Info(
"[ARCHIVER]: Clearing all existing scene objects");
402 sceneContext.Scene.DeleteAllSceneObjects();
407 LoadParcels(sceneContext.Scene, sceneContext.SerialisedParcels);
408 LoadObjects(sceneContext.Scene, sceneContext.SerialisedSceneObjects, sceneContext.SceneObjects);
413 if (estateModule != null)
414 estateModule.TriggerRegionInfoChange();
418 m_log.Error(
"[ARCHIVER]: Error loading parcels or objects ", e);
419 m_errorMessage += e.ToString();
420 m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId,
new List<UUID>(), m_errorMessage);
428 WorkManager.RunInThread(o =>
431 m_log.Info(
"[ARCHIVER]: Starting scripts in scene objects");
433 foreach (DearchiveContext sceneContext
in sceneContexts.Values)
437 sceneObject.CreateScriptInstances(0,
false, sceneContext.Scene.DefaultScriptEngine, 0);
438 sceneObject.ResumeScripts();
441 sceneContext.SceneObjects.Clear();
443 }, null, string.Format(
"ReadArchiveStartScripts (request {0})", m_requestId));
445 m_log.InfoFormat(
"[ARCHIVER]: Successfully loaded archive");
447 m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId, dearchivedScenes.GetLoadedScenes(), m_errorMessage);
467 TarArchiveReader.TarEntryType entryType;
468 bool firstFile =
true;
470 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
477 LoadControlFile(filePath, data, dearchivedScenes);
481 SceneManager.Instance.ForEachScene(delegate(
Scene scene2)
483 simulatorScenes.AddScene(scene2);
485 simulatorScenes.CalcSceneLocations();
486 dearchivedScenes.SetSimulatorScenes(m_rootScene, simulatorScenes);
491 m_log.Warn(
"[ARCHIVER]: Control file wasn't the first file in the archive");
492 if (m_loadStream.CanSeek)
494 m_loadStream.Seek(0, SeekOrigin.Begin);
496 else if (m_loadPath != null)
500 m_loadStream.Close();
502 m_loadStream =
new GZipStream(ArchiveHelpers.GetStream(m_loadPath), CompressionMode.Decompress);
508 throw new Exception(
"[ARCHIVER]: Error reading archive: control file wasn't the first file, and the input stream doesn't allow seeking");
518 throw new Exception(
"[ARCHIVER]: Control file not found");
524 protected void LoadObjects(
Scene scene, List<string> serialisedSceneObjects, List<SceneObjectGroup> sceneObjects)
527 m_log.InfoFormat(
"[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
530 double rotation = Math.PI * m_rotation / 180f;
532 OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, (float)rotation);
534 UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject;
537 int sceneObjectsLoadedCount = 0;
538 Vector3 boundingExtent =
new Vector3(m_boundingOrigin.X + m_boundingSize.X, m_boundingOrigin.Y + m_boundingSize.Y, m_boundingOrigin.Z + m_boundingSize.Z);
540 foreach (
string serialisedSceneObject
in serialisedSceneObjects)
556 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
558 Vector3 pos = sceneObject.AbsolutePosition;
560 m_log.DebugFormat(
"[ARCHIVER]: Loading object from OAR with original scene position {0}.", pos.ToString());
565 if (m_rotation != 0f)
569 m_rotationCenter.X = m_incomingRegionSize.X / 2;
570 m_rotationCenter.Y = m_incomingRegionSize.Y / 2;
573 sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation;
575 Vector3 offset = pos - m_rotationCenter;
579 pos = m_rotationCenter + offset;
580 if (m_debug) m_log.DebugFormat(
"[ARCHIVER]: After rotation, object from OAR is at scene position {0}.", pos.ToString());
584 if (pos.X < m_boundingOrigin.X || pos.X >= boundingExtent.X
585 || pos.Y < m_boundingOrigin.Y || pos.Y >= boundingExtent.Y
586 || pos.Z < m_boundingOrigin.Z || pos.Z >= boundingExtent.Z)
588 if (m_debug) m_log.DebugFormat(
"[ARCHIVER]: Skipping object from OAR in scene because it's position {0} is outside of bounding cube.", pos.ToString());
592 pos.X -= m_boundingOrigin.X;
593 pos.Y -= m_boundingOrigin.Y;
595 if (m_displacement != Vector3.Zero)
597 pos += m_displacement;
598 if (m_debug) m_log.DebugFormat(
"[ARCHIVER]: After displacement, object from OAR is at scene position {0}.", pos.ToString());
600 sceneObject.AbsolutePosition = pos;
603 m_log.DebugFormat(
"[ARCHIVER]: Placing object from OAR in scene at position {0}. ", pos.ToString());
605 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID !=
UUID.Zero);
610 sceneObject.ResetIDs();
615 scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID;
616 scene.RegionInfo.RegionSettings.Save();
617 oldTelehubUUID = UUID.Zero;
620 ModifySceneObject(scene, sceneObject);
622 if (scene.AddRestoredSceneObject(sceneObject,
true,
false))
624 sceneObjectsLoadedCount++;
625 sceneObject.CreateScriptInstances(0,
false, scene.DefaultScriptEngine, 0);
626 sceneObject.ResumeScripts();
630 m_log.InfoFormat(
"[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjectsLoadedCount);
632 int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;
634 if (ignoredObjects > 0)
635 m_log.WarnFormat(
"[ARCHIVER]: Ignored {0} scene objects that already existed in the scene or were out of bounds", ignoredObjects);
637 if (oldTelehubUUID !=
UUID.Zero)
639 m_log.WarnFormat(
"[ARCHIVER]: Telehub object not found: {0}", oldTelehubUUID);
640 scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
641 scene.RegionInfo.RegionSettings.ClearSpawnPoints();
657 if (!ResolveUserUuid(scene, part.
CreatorID))
658 part.CreatorID = m_defaultUser;
660 if (UserManager != null)
661 UserManager.AddUser(part.CreatorID, part.CreatorData);
663 if (!(ResolveUserUuid(scene, part.
OwnerID) || ResolveGroupUuid(part.
OwnerID)))
669 if (!ResolveGroupUuid(part.
GroupID))
689 part.TaskInventory.LockItemsForRead(
true);
692 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp
in inv)
694 if (!(ResolveUserUuid(scene, kvp.Value.OwnerID) || ResolveGroupUuid(kvp.Value.OwnerID)))
696 kvp.Value.OwnerID = m_defaultUser;
699 if (
string.IsNullOrEmpty(kvp.Value.CreatorData))
701 if (!ResolveUserUuid(scene, kvp.Value.CreatorID))
702 kvp.Value.CreatorID = m_defaultUser;
705 if (UserManager != null)
706 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
708 if (!ResolveGroupUuid(kvp.Value.GroupID))
709 kvp.Value.GroupID =
UUID.Zero;
711 part.TaskInventory.LockItemsForRead(
false);
725 m_log.InfoFormat(
"[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
726 List<LandData> landData =
new List<LandData>();
728 List<ILandObject> parcels;
729 Vector3 parcelDisp =
new Vector3(m_displacement.X, m_displacement.Y, 0f);
730 Vector2 displacement =
new Vector2(m_displacement.X, m_displacement.Y);
731 Vector2 boundingOrigin =
new Vector2(m_boundingOrigin.X, m_boundingOrigin.Y);
732 Vector2 boundingSize =
new Vector2(m_boundingSize.X, m_boundingSize.Y);
737 parcels = scene.LandChannel.AllParcels();
739 foreach (
string serialisedParcel
in serialisedParcels)
741 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
742 bool overrideRegionSize =
true;
752 landObject.LandData = parcel;
754 bool[,] srcLandBitmap = landObject.ConvertBytesToLandBitmap(overrideRegionSize);
755 if (landObject.IsLandBitmapEmpty(srcLandBitmap))
757 m_log.InfoFormat(
"[ARCHIVER]: Skipping source parcel {0} with GlobalID: {1} LocalID: {2} that has no claimed land.",
758 parcel.Name, parcel.GlobalID, parcel.LocalID);
765 bool[,] dstLandBitmap = landObject.RemapLandBitmap(srcLandBitmap, displacement, m_rotation, boundingOrigin, boundingSize, regionSize, out isEmptyNow, out AABBMin, out AABBMax);
768 m_log.WarnFormat(
"[ARCHIVER]: Not adding destination parcel {0} with GlobalID: {1} LocalID: {2} because, after applying rotation, bounding and displacement, it has no claimed land.",
769 parcel.Name, parcel.GlobalID, parcel.LocalID);
776 landObject.LandBitmap = dstLandBitmap;
777 parcel.Bitmap = landObject.ConvertLandBitmapToBytes();
778 parcel.AABBMin = AABBMin;
779 parcel.AABBMax = AABBMax;
784 parcel.GlobalID = UUID.Random();
788 for (
int i = 0; i < parcels.Count; i++)
790 if (parcels[i] != null)
792 bool[,] modLandBitmap = parcels[i].ConvertBytesToLandBitmap(overrideRegionSize);
793 modLandBitmap = parcels[i].RemoveFromLandBitmap(modLandBitmap, dstLandBitmap, out isEmptyNow, out AABBMin, out AABBMax);
800 parcels[i].LandBitmap = modLandBitmap;
801 parcels[i].LandData.Bitmap = parcels[i].ConvertLandBitmapToBytes();
802 parcels[i].LandData.AABBMin = AABBMin;
803 parcels[i].LandData.AABBMax = AABBMax;
811 if (!ResolveGroupUuid(parcel.
GroupID))
819 parcel.OwnerID = parcel.GroupID;
823 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
824 parcel.IsGroupOwned =
false;
829 if (!ResolveUserUuid(scene, parcel.
OwnerID))
830 parcel.
OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
833 List<LandAccessEntry> accessList =
new List<LandAccessEntry>();
836 if (ResolveUserUuid(scene, entry.
AgentID))
837 accessList.Add(entry);
840 parcel.ParcelAccessList = accessList;
842 if (m_debug) m_log.DebugFormat(
"[ARCHIVER]: Adding parcel {0}, local id {1}, owner {2}, group {3}, isGroupOwned {4}, area {5}",
843 parcel.Name, parcel.LocalID, parcel.OwnerID, parcel.GroupID, parcel.IsGroupOwned, parcel.Area);
845 landData.Add(parcel);
850 for (
int i = 0; i < parcels.Count; i++)
852 if (parcels[i] != null) landData.Add(parcels[i]
.LandData);
856 m_log.InfoFormat(
"[ARCHIVER]: Clearing {0} parcels.", parcels.Count);
857 bool setupDefaultParcel = (landData.Count == 0);
858 scene.LandChannel.Clear(setupDefaultParcel);
859 scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
860 m_log.InfoFormat(
"[ARCHIVER]: Restored {0} parcels.", landData.Count);
869 private bool ResolveUserUuid(
Scene scene, UUID uuid)
871 lock (m_validUserUuids)
873 if (!m_validUserUuids.ContainsKey(uuid))
877 UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid);
878 m_validUserUuids.Add(uuid, account != null);
881 return m_validUserUuids[uuid];
890 private bool ResolveGroupUuid(UUID uuid)
892 lock (m_validGroupUuids)
894 if (!m_validGroupUuids.ContainsKey(uuid))
897 if (m_groupsModule == null)
905 exists = (m_groupsModule.GetGroupRecord(uuid) != null);
907 m_validGroupUuids.Add(uuid, exists);
910 return m_validGroupUuids[uuid];
919 private bool LoadAsset(
string assetPath, byte[] data)
922 string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
923 int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
928 "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
929 assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
934 string extension = filename.Substring(i);
935 string uuid = filename.Remove(filename.Length - extension.Length);
937 if (m_assetService.GetMetadata(uuid) != null)
945 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
947 if (assetType == (sbyte)AssetType.Unknown)
949 m_log.WarnFormat(
"[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid);
951 else if (assetType == (sbyte)AssetType.Object)
953 data = SceneObjectSerializer.ModifySerializedObject(UUID.Parse(uuid), data,
956 ModifySceneObject(m_rootScene, sog);
971 m_assetService.Store(asset);
989 "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
990 assetPath, extension);
1006 private bool LoadRegionSettings(
Scene scene,
string settingsPath, byte[] data, DearchiveScenesInfo dearchivedScenes)
1012 loadedRegionSettings = RegionSettingsSerializer.Deserialize(data);
1017 "[ARCHIVER]: Could not parse region settings file {0}. Ignoring. Exception was {1}",
1024 currentRegionSettings.AgentLimit = loadedRegionSettings.AgentLimit;
1025 currentRegionSettings.AllowDamage = loadedRegionSettings.AllowDamage;
1026 currentRegionSettings.AllowLandJoinDivide = loadedRegionSettings.AllowLandJoinDivide;
1027 currentRegionSettings.AllowLandResell = loadedRegionSettings.AllowLandResell;
1028 currentRegionSettings.BlockFly = loadedRegionSettings.BlockFly;
1029 currentRegionSettings.BlockShowInSearch = loadedRegionSettings.BlockShowInSearch;
1030 currentRegionSettings.BlockTerraform = loadedRegionSettings.BlockTerraform;
1031 currentRegionSettings.DisableCollisions = loadedRegionSettings.DisableCollisions;
1032 currentRegionSettings.DisablePhysics = loadedRegionSettings.DisablePhysics;
1033 currentRegionSettings.DisableScripts = loadedRegionSettings.DisableScripts;
1034 currentRegionSettings.Elevation1NE = loadedRegionSettings.Elevation1NE;
1035 currentRegionSettings.Elevation1NW = loadedRegionSettings.Elevation1NW;
1036 currentRegionSettings.Elevation1SE = loadedRegionSettings.Elevation1SE;
1037 currentRegionSettings.Elevation1SW = loadedRegionSettings.Elevation1SW;
1038 currentRegionSettings.Elevation2NE = loadedRegionSettings.Elevation2NE;
1039 currentRegionSettings.Elevation2NW = loadedRegionSettings.Elevation2NW;
1040 currentRegionSettings.Elevation2SE = loadedRegionSettings.Elevation2SE;
1041 currentRegionSettings.Elevation2SW = loadedRegionSettings.Elevation2SW;
1042 currentRegionSettings.FixedSun = loadedRegionSettings.FixedSun;
1043 currentRegionSettings.SunPosition = loadedRegionSettings.SunPosition;
1044 currentRegionSettings.ObjectBonus = loadedRegionSettings.ObjectBonus;
1045 currentRegionSettings.RestrictPushing = loadedRegionSettings.RestrictPushing;
1046 currentRegionSettings.TerrainLowerLimit = loadedRegionSettings.TerrainLowerLimit;
1047 currentRegionSettings.TerrainRaiseLimit = loadedRegionSettings.TerrainRaiseLimit;
1048 currentRegionSettings.TerrainTexture1 = loadedRegionSettings.TerrainTexture1;
1049 currentRegionSettings.TerrainTexture2 = loadedRegionSettings.TerrainTexture2;
1050 currentRegionSettings.TerrainTexture3 = loadedRegionSettings.TerrainTexture3;
1051 currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4;
1052 currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun;
1053 currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight;
1054 currentRegionSettings.TelehubObject = loadedRegionSettings.TelehubObject;
1055 currentRegionSettings.ClearSpawnPoints();
1059 currentRegionSettings.LoadedCreationDateTime = dearchivedScenes.LoadedCreationDateTime;
1060 currentRegionSettings.LoadedCreationID = dearchivedScenes.GetOriginalRegionID(scene.RegionInfo.RegionID).ToString();
1062 currentRegionSettings.Save();
1064 scene.TriggerEstateSunUpdate();
1067 if (estateModule != null)
1068 estateModule.sendRegionHandshakeToAll();
1082 private bool LoadTerrain(
Scene scene,
string terrainPath, byte[] data)
1085 using (MemoryStream ms =
new MemoryStream(data))
1087 if (m_displacement != Vector3.Zero || m_rotation != 0f || m_boundingBox)
1089 Vector2 boundingOrigin =
new Vector2(m_boundingOrigin.X, m_boundingOrigin.Y);
1090 Vector2 boundingSize =
new Vector2(m_boundingSize.X, m_boundingSize.Y);
1091 terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, boundingOrigin, boundingSize, ms); ;
1095 terrainModule.LoadFromStream(terrainPath, ms);
1099 m_log.DebugFormat(
"[ARCHIVER]: Restored terrain {0}", terrainPath);
1112 XmlNamespaceManager nsmgr =
new XmlNamespaceManager(
new NameTable());
1113 XmlParserContext context =
new XmlParserContext(null, nsmgr, null, XmlSpace.None);
1114 XmlTextReader xtr =
new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
1117 dearchivedScenes.LoadedCreationDateTime = 0;
1118 dearchivedScenes.DefaultOriginalID =
"";
1120 bool multiRegion =
false;
1124 if (xtr.NodeType == XmlNodeType.Element)
1126 if (xtr.Name.ToString() ==
"archive")
1128 int majorVersion = int.Parse(xtr[
"major_version"]);
1129 int minorVersion = int.Parse(xtr[
"minor_version"]);
1130 string version = string.Format(
"{0}.{1}", majorVersion, minorVersion);
1132 if (majorVersion > MAX_MAJOR_VERSION)
1134 throw new Exception(
1136 "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below",
1137 majorVersion, MAX_MAJOR_VERSION));
1140 m_log.InfoFormat(
"[ARCHIVER]: Loading OAR with version {0}", version);
1142 else if (xtr.Name.ToString() ==
"datetime")
1145 if (Int32.TryParse(xtr.ReadElementContentAsString(), out value))
1146 dearchivedScenes.LoadedCreationDateTime = value;
1148 else if (xtr.Name.ToString() ==
"row")
1151 dearchivedScenes.StartRow();
1153 else if (xtr.Name.ToString() ==
"region")
1155 dearchivedScenes.StartRegion();
1157 else if (xtr.Name.ToString() ==
"id")
1159 string id = xtr.ReadElementContentAsString();
1160 dearchivedScenes.DefaultOriginalID = id;
1162 dearchivedScenes.SetRegionOriginalID(id);
1164 else if (xtr.Name.ToString() ==
"dir")
1166 dearchivedScenes.SetRegionDirectory(xtr.ReadElementContentAsString());
1168 else if (xtr.Name.ToString() ==
"size_in_meters")
1171 string size =
"<" + xtr.ReadElementContentAsString() +
",0>";
1172 if (Vector3.TryParse(size, out value))
1174 m_incomingRegionSize = value;
1176 dearchivedScenes.SetRegionSize(m_incomingRegionSize);
1177 m_log.DebugFormat(
"[ARCHIVER]: Found region_size info {0}",
1178 m_incomingRegionSize.ToString());
1184 dearchivedScenes.MultiRegionFormat = multiRegion;
1188 dearchivedScenes.StartRow();
1189 dearchivedScenes.StartRegion();
1190 dearchivedScenes.SetRegionOriginalID(dearchivedScenes.DefaultOriginalID);
1191 dearchivedScenes.SetRegionDirectory(
"");
1192 dearchivedScenes.SetRegionSize(m_incomingRegionSize);
1195 ControlFileLoaded =
true;
1197 return dearchivedScenes;
Temporary code to do the bare minimum required to read a tar archive for our purposes ...
const string OBJECTS_PATH
The regions included in an OAR file.
A group of regions arranged in a rectangle, possibly with holes.
const uint MaximumRegionSize
Constants for the archiving module
OpenSim.Framework.Serialization.TarArchiveReader TarArchiveReader
uint RegionSizeX
X dimension of the region.
const string CONTROL_FILE_PATH
A dictionary containing task inventory items. Indexed by item UUID.
uint RegionSizeY
X dimension of the region.
OpenSim.Framework.RegionSettings RegionSettings
void AddSpawnPoint(SpawnPoint point)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
static readonly IDictionary< string, sbyte > EXTENSION_TO_ASSET_TYPE
void LoadParcels(Scene scene, List< string > serialisedParcels)
Load serialized parcels.
Ionic.Zlib.GZipStream GZipStream
Asset class. All Assets are reference by this class or a class derived from this class ...
const string TERRAINS_PATH
Keeps track of a specific piece of land's information
ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary< string, object > options)
DearchiveScenesInfo LoadControlFile(string path, byte[] data, DearchiveScenesInfo dearchivedScenes)
Load oar control file
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
UUID GroupID
Unique ID of the Group that owns
string CreatorData
Data about the creator in the form home_url;name
TaskInventoryDictionary TaskInventory
const string LANDDATA_PATH
Details of a Parcel of land
void LoadObjects(Scene scene, List< string > serialisedSceneObjects, List< SceneObjectGroup > sceneObjects)
Load serialized scene objects.
bool IsGroupOwned
Returns true if the Land Parcel is owned by a group
ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary< string, object > options)
List< SpawnPoint > SpawnPoints()
void DearchiveRegion()
Dearchive the region embodied in this request.
virtual RegionInfo RegionInfo
This maintains the relationship between a UUID and a user name.
const string SETTINGS_PATH
bool IsAttachment
Is this scene object acting as an attachment?
Handles an individual archive read request
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...