Ejemplo n.º 1
0
        /// <summary>
        ///     Load terrain data
        /// </summary>
        /// <param name="terrainPath"></param>
        /// <param name="data"></param>
        /// <returns>
        ///     true if terrain was resolved successfully, false otherwise.
        /// </returns>
        private void LoadTerrain(string terrainPath, byte[] data)
        {
            ITerrainModule terrainModule = m_scene.RequestModuleInterface <ITerrainModule>();

            MemoryStream ms = new MemoryStream(data);

            terrainModule.LoadFromStream(terrainPath, ms, m_offsetX, m_offsetY);
            ms.Close();

            MainConsole.Instance.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load terrain data
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="terrainPath"></param>
        /// <param name="data"></param>
        /// <returns>
        /// true if terrain was resolved successfully, false otherwise.
        /// </returns>
        private bool LoadTerrain(Scene scene, string terrainPath, byte[] data)
        {
            ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule>();

            using (MemoryStream ms = new MemoryStream(data))
            {
                if (m_displacement != Vector3.Zero || m_rotation != 0f)
                {
                    Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y);
                    terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms);
                }
                else
                {
                    terrainModule.LoadFromStream(terrainPath, ms);
                }
            }

            m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load terrain data
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="terrainPath"></param>
        /// <param name="data"></param>
        /// <returns>
        /// true if terrain was resolved successfully, false otherwise.
        /// </returns>
        private bool LoadTerrain(Scene scene, string terrainPath, byte[] data)
        {
            ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();

            MemoryStream ms = new MemoryStream(data);
            terrainModule.LoadFromStream(terrainPath, ms);
            ms.Close();

            m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);

            return true;
        }
        public virtual short[] LoadTerrain(IScene scene, bool RevertMap, int RegionSizeX, int RegionSizeY)
        {
            if (!m_loaded)
            {
                m_loaded = true;
                ReadConfig(scene, scene.Config.Configs["FileBasedSimulationData"]);
                ReadBackup(scene);
            }
            ITerrainModule terrainModule = scene.RequestModuleInterface <ITerrainModule>();

            if (RevertMap)
            {
                if (m_revertTerrain == null)
                {
                    if (m_shortrevertTerrain != null) //OpenSim style
                    {
                        terrainModule.TerrainRevertMap = new TerrainChannel(m_shortrevertTerrain, scene);
                    }
                    else if (m_oldstylerevertTerrain != null)
                    {
                        MemoryStream ms = new MemoryStream(m_oldstylerevertTerrain);
                        if (terrainModule != null)
                        {
                            terrainModule.LoadRevertMapFromStream(".r32", ms, 0, 0);
                        }
                    }
                }
                else
                {
                    //New style
                    terrainModule.TerrainRevertMap = ReadFromData(m_revertTerrain, scene);
                }
                //Make sure the size is right!
                if (terrainModule.TerrainRevertMap != null &&
                    terrainModule.TerrainRevertMap.Height != scene.RegionInfo.RegionSizeX)
                {
                    terrainModule.TerrainRevertMap = null;
                }
                m_revertTerrain         = null;
                m_oldstylerevertTerrain = null;
                m_shortrevertTerrain    = null;
                return(null);
            }
            else
            {
                if (m_terrain == null)
                {
                    if (m_shortterrain != null) //OpenSim style
                    {
                        terrainModule.TerrainMap = new TerrainChannel(m_shortterrain, scene);
                    }
                    else if (m_oldstyleterrain != null)
                    {
//Old style
                        MemoryStream ms = new MemoryStream(m_oldstyleterrain);
                        if (terrainModule != null)
                        {
                            terrainModule.LoadFromStream(".r32", ms, 0, 0);
                        }
                    }
                }
                else
                {
                    //New style
                    terrainModule.TerrainMap = ReadFromData(m_terrain, scene);
                }
                //Make sure the size is right!
                if (terrainModule.TerrainMap != null &&
                    terrainModule.TerrainMap.Height != scene.RegionInfo.RegionSizeX)
                {
                    terrainModule.TerrainMap = null;
                }
                m_terrain         = null;
                m_oldstyleterrain = null;
                m_shortterrain    = null;
                return(null);
            }
        }
Ejemplo n.º 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);
                    }
                }
            }
Ejemplo n.º 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();
                    }
                }
            }
Ejemplo n.º 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);
                        }
                    }
                }
            }