/// <summary>
 /// Loads the estate settings from an archive.
 /// </summary>
 /// <param name="data">Data.</param>
 /// <param name="filePath">File path.</param>
 /// <param name="type">Type.</param>
 /// <param name="scene">Scene.</param>
 public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
 {
     if (filePath.StartsWith("estatesettings/"))
     {
         EstateSettings settings = new EstateSettings();
         settings.FromOSD((OSDMap)OSDParser.DeserializeLLSDBinary(data));
         scene.RegionInfo.EstateSettings = settings;
     }
     else if (filePath.StartsWith("regioninfo/"))
     {
         string m_merge =
             MainConsole.Instance.Prompt(
                 "Should we load the region information from the archive (region name, region position, etc)?",
                 "false");
         RegionInfo settings = new RegionInfo();
         settings.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeLLSDBinary(data));
         if (m_merge == "false")
         {
             //Still load the region settings though
             scene.RegionInfo.RegionSettings = settings.RegionSettings;
             return;
         }
         settings.RegionSettings = scene.RegionInfo.RegionSettings;
         settings.EstateSettings = scene.RegionInfo.EstateSettings;
         scene.RegionInfo        = settings;
     }
 }
Beispiel #2
0
 public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
 {
     if (filePath.StartsWith("windlight/"))
     {
         OSDMap map = (OSDMap)OSDParser.DeserializeLLSDBinary(data);
         RegionLightShareData lsd = new RegionLightShareData();
         lsd.FromOSD(map);
         SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
     }
 }
        /// <summary>
        /// Load inventory file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="entryType"></param>
        /// <param name="data"></param>
        protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
        {
            if (!ControlFileLoaded)
            {
                throw new Exception(
                          string.Format(
                              "The IAR you are trying to load does not list {0} before {1}.  Aborting load",
                              ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
            }

            if (m_assetsLoaded)
            {
                throw new Exception(
                          string.Format(
                              "The IAR you are trying to load does not list all {0} before {1}.  Aborting load",
                              ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
            }

            path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);

            // Trim off the file portion if we aren't already dealing with a directory path
            if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
            {
                path = path.Remove(path.LastIndexOf("/") + 1);
            }

            InventoryFolderBase foundFolder
                = ReplicateArchivePathToUserInventory(
                      path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);

            if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
            {
                InventoryItemBase item = LoadItem(data, foundFolder);

                if (item != null)
                {
                    m_successfulItemRestores++;

                    // If we aren't loading the folder containing the item then well need to update the
                    // viewer separately for that item.
                    if (!m_loadedNodes.ContainsKey(foundFolder.ID))
                    {
                        m_loadedNodes[foundFolder.ID] = item;
                    }
                }
            }

            m_inventoryNodesLoaded = true;
        }
        /// <summary>
        /// Load inventory file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="entryType"></param>
        /// <param name="data"></param>
        private void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
        {
            if (!ControlFileLoaded)
            {
                throw new Exception(
                          string.Format(
                              "The IAR you are trying to load does not list {0} before {1}.  Aborting load",
                              ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
            }

            if (m_assetsLoaded)
            {
                throw new Exception(
                          string.Format(
                              "The IAR you are trying to load does not list all {0} before {1}.  Aborting load",
                              ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
            }

            path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);

            // Trim off the file portion if we aren't already dealing with a directory path
            if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
            {
                path = path.Remove(path.LastIndexOf("/") + 1);
            }

            InventoryFolderBase foundFolder
                = ReplicateArchivePathToUserInventory(
                      path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);

            if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
            {
                LoadItem(data, foundFolder);
            }

            m_inventoryNodesLoaded = true;
        }
Beispiel #5
0
            public void LoadModuleFromArchive(byte [] data, string filePath, TarArchiveReader.TarEntryType type,
                                              IScene scene)
            {
                if (filePath.StartsWith("parcels/", StringComparison.Ordinal))
                {
                    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/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();
                    terrainModule.TerrainMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith("newstylerevertterrain/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();
                    terrainModule.TerrainRevertMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith("newstylewater/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();
                    terrainModule.TerrainWaterMap = ReadTerrain(data, scene);
                }
                else if (filePath.StartsWith("newstylerevertwater/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();
                    terrainModule.TerrainWaterRevertMap = ReadTerrain(data, scene);
                }
                #endregion
                #region Old Style Terrain Loading

                else if (filePath.StartsWith("terrain/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();

                    MemoryStream ms = new MemoryStream(data);
                    terrainModule.LoadFromStream(filePath, ms, 0, 0);
                    ms.Close();
                }
                else if (filePath.StartsWith("revertterrain/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();

                    MemoryStream ms = new MemoryStream(data);
                    terrainModule.LoadRevertMapFromStream(filePath, ms, 0, 0);
                    ms.Close();
                }
                else if (filePath.StartsWith("water/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();

                    MemoryStream ms = new MemoryStream(data);
                    terrainModule.LoadWaterFromStream(filePath, ms, 0, 0);
                    ms.Close();
                }
                else if (filePath.StartsWith("revertwater/", StringComparison.Ordinal))
                {
                    ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule> ();

                    MemoryStream ms = new MemoryStream(data);
                    terrainModule.LoadWaterRevertMapFromStream(filePath, ms, 0, 0);
                    ms.Close();
                }
                #endregion

                else if (filePath.StartsWith("entities/", StringComparison.Ordinal))
                {
                    MemoryStream ms          = new MemoryStream(data);
                    ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer.FromXml2Format(ref ms, scene);
                    ms.Close();
                    m_groups.Add(sceneObject);
                }
                else if (filePath.StartsWith("assets/", StringComparison.Ordinal))
                {
                    if (m_loadAssets)
                    {
                        AssetBase asset = new AssetBase();
                        asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data)));
                        scene.AssetService.Store(asset);
                    }
                }
            }
Beispiel #6
0
            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);
                    }
                }
                else if (filePath.StartsWith("terrain/"))
                {
                    ITerrainModule terrainModule = m_scene.RequestModuleInterface <ITerrainModule>();

                    MemoryStream ms = new MemoryStream(data);
                    terrainModule.LoadFromStream(filePath, ms, 0, 0);
                    ms.Close();
                }
                else if (filePath.StartsWith("entities/"))
                {
                    MemoryStream     ms          = new MemoryStream(data);
                    SceneObjectGroup sceneObject = OpenSim.Region.Framework.Scenes.Serialization.SceneObjectSerializer.FromXml2Format(ms, (Scene)scene);
                    foreach (SceneObjectPart part in sceneObject.ChildrenList)
                    {
                        if (!ResolveUserUuid(part.CreatorID))
                        {
                            part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.OwnerID))
                        {
                            part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.LastOwnerID))
                        {
                            part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        // And zap any troublesome sit target information
                        part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
                        part.SitTargetPosition    = new Vector3(0, 0, 0);

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory)
                        {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                            {
                                if (!ResolveUserUuid(kvp.Value.OwnerID))
                                {
                                    kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                                if (!ResolveUserUuid(kvp.Value.CreatorID))
                                {
                                    kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                            }
                        }
                    }

                    if (m_scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        sceneObject.HasGroupChanged = true;
                        sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate);
                        sceneObject.CreateScriptInstances(0, false, 0, UUID.Zero);
                        sceneObject.ResumeScripts();
                    }
                }
            }
Beispiel #7
0
            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
                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();
                }
                else if (filePath.StartsWith("entities/"))
                {
                    MemoryStream     ms          = new MemoryStream(data);
                    SceneObjectGroup sceneObject = OpenSim.Region.Framework.Scenes.Serialization.SceneObjectSerializer.FromXml2Format(ref ms, scene);
                    ms.Close();
                    ms   = null;
                    data = null;
                    foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        if (!ResolveUserUuid(part.CreatorID))
                        {
                            part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.OwnerID))
                        {
                            part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.LastOwnerID))
                        {
                            part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory)
                        {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                            {
                                if (!ResolveUserUuid(kvp.Value.OwnerID))
                                {
                                    kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                                if (!ResolveUserUuid(kvp.Value.CreatorID))
                                {
                                    kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                            }
                        }
                    }

                    if (scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        sceneObject.HasGroupChanged = true;
                        sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                        sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero);
                    }
                }
                else if (filePath.StartsWith("assets/"))
                {
                    if (m_loadAssets)
                    {
                        AssetBase asset = new AssetBase();
                        asset.Unpack(OSDParser.DeserializeJson(Encoding.UTF8.GetString(data)));
                        bool exists = scene.AssetService.Get(asset.IDString) != null;
                        if (!exists)
                        {
                            scene.AssetService.Store(asset);
                        }
                    }
                }
            }