public override void FromOSD(OpenMetaverse.StructuredData.OSDMap map) { GlobalPosX = map["GlobalPosX"]; GlobalPosY = map["GlobalPosY"]; LandData = new LandData(); LandData.FromOSD((OSDMap) map["LandData"]); RegionName = map["RegionName"]; RegionType = map["RegionType"]; }
public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene) { if (filePath.StartsWith("parcels/")) { if (!m_merge) { //Only use if we are not merging LandData parcel = new LandData(); OSD parcelData = OSDParser.DeserializeLLSDBinary(data); parcel.FromOSD((OSDMap) parcelData); m_parcels.Add(parcel); } } #region New Style Terrain Loading else if (filePath.StartsWith("newstyleterrain/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); terrainModule.TerrainMap = ReadTerrain(data, scene); } else if (filePath.StartsWith("newstylerevertterrain/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); terrainModule.TerrainRevertMap = ReadTerrain(data, scene); } else if (filePath.StartsWith("newstylewater/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); terrainModule.TerrainWaterMap = ReadTerrain(data, scene); } else if (filePath.StartsWith("newstylerevertwater/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); terrainModule.TerrainWaterRevertMap = ReadTerrain(data, scene); } #endregion #region Old Style Terrain Loading else if (filePath.StartsWith("terrain/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); MemoryStream ms = new MemoryStream(data); terrainModule.LoadFromStream(filePath, ms, 0, 0); ms.Close(); } else if (filePath.StartsWith("revertterrain/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); MemoryStream ms = new MemoryStream(data); terrainModule.LoadRevertMapFromStream(filePath, ms, 0, 0); ms.Close(); } else if (filePath.StartsWith("water/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); MemoryStream ms = new MemoryStream(data); terrainModule.LoadWaterFromStream(filePath, ms, 0, 0); ms.Close(); } else if (filePath.StartsWith("revertwater/")) { ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); MemoryStream ms = new MemoryStream(data); terrainModule.LoadWaterRevertMapFromStream(filePath, ms, 0, 0); ms.Close(); } #endregion else if (filePath.StartsWith("entities/")) { MemoryStream ms = new MemoryStream(data); ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer.FromXml2Format(ref ms, scene); ms.Close(); ms = null; data = null; m_groups.Add(sceneObject); } else if (filePath.StartsWith("assets/")) { if (m_loadAssets) { AssetBase asset = new AssetBase(); asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data))); scene.AssetService.Store(asset); } } }
public RegionData LoadBackup(string file) { if (!File.Exists(file)) return null; var stream = ArchiveHelpers.GetStream(file); if (stream == null) return null; GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); List<uint> foundLocalIDs = new List<uint>(); RegionData regiondata = new RegionData(); regiondata.Init(); byte[] data; string filePath; TarArchiveReader.TarEntryType entryType; System.Collections.Concurrent.ConcurrentQueue<byte[]> groups = new System.Collections.Concurrent.ConcurrentQueue<byte[]>(); //Load the archive data that we need while ((data = reader.ReadEntry(out filePath, out entryType)) != null) { if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) continue; if (filePath.StartsWith("parcels/")) { //Only use if we are not merging LandData parcel = new LandData(); OSD parcelData = OSDParser.DeserializeLLSDBinary(data); parcel.FromOSD((OSDMap) parcelData); if (parcel.OwnerID != UUID.Parse("05948863-b678-433e-87a4-e44d17678d1d")) //The default owner of the 'default' region regiondata.Parcels.Add(parcel); } else if (filePath.StartsWith("newstyleterrain/")) { regiondata.Terrain = data; } else if (filePath.StartsWith("newstylerevertterrain/")) { regiondata.RevertTerrain = data; } else if (filePath.StartsWith("newstylewater/")) { regiondata.Water = data; } else if (filePath.StartsWith("newstylerevertwater/")) { regiondata.RevertWater = data; } else if (filePath.StartsWith("entities/")) { groups.Enqueue(data); } else if (filePath.StartsWith("regioninfo/")) { RegionInfo info = new RegionInfo(); info.FromOSD((OSDMap) OSDParser.DeserializeLLSDBinary(data)); regiondata.RegionInfo = info; } data = null; } m_loadStream.Close(); m_loadStream = null; int threadCount = groups.Count > 16 ? 16 : groups.Count; System.Threading.Thread[] threads = new System.Threading.Thread[threadCount]; for (int i = 0; i < threadCount; i++) { threads[i] = new System.Threading.Thread(() => { byte[] groupData; while (groups.TryDequeue(out groupData)) { MemoryStream ms = new MemoryStream(groupData); ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer .FromXml2Format(ref ms, null); ms.Close(); ms = null; data = null; if (sceneObject != null) { foreach ( ISceneChildEntity part in sceneObject.ChildrenEntities()) { lock (foundLocalIDs) { if ( !foundLocalIDs.Contains( part.LocalId)) foundLocalIDs.Add(part.LocalId); else part.LocalId = 0; //Reset it! Only use it once! } } regiondata.Groups.Add( sceneObject as SceneObjectGroup); } } }); threads[i].Start(); } for (int i = 0; i < threadCount; i++) threads[i].Join(); foundLocalIDs.Clear(); return regiondata; }