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);
                    }
                }
            }
Exemple #2
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);
                        }
                    }
                }
            }