コード例 #1
0
        protected internal void Save(ICollection <UUID> assetsFoundUuids, ICollection <UUID> assetsNotFoundUuids)
        {
            foreach (UUID uuid in assetsNotFoundUuids)
            {
                m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
            }

//            m_log.InfoFormat(
//                "[ARCHIVER]: Received {0} of {1} assets requested",
//                assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);

            m_log.InfoFormat("[ARCHIVER]: Creating archive file.  This may take some time.");

            // Write out control file
            m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
            m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

            // Write out region settings
            string settingsPath
                = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);

            m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));

            m_log.InfoFormat("[ARCHIVER]: Added region settings to archive.");

            // Write out land data (aka parcel) settings
            List <ILandObject> landObjects = m_scene.LandChannel.AllParcels();

            foreach (ILandObject lo in landObjects)
            {
                LandData landData     = lo.LandData;
                string   landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH,
                                                      landData.GlobalID.ToString());
                m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData));
            }
            m_log.InfoFormat("[ARCHIVER]: Added parcel settings to archive.");

            // Write out terrain
            string terrainPath
                = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);

            MemoryStream ms = new MemoryStream();

            m_terrainModule.SaveToStream(terrainPath, ms);
            m_archiveWriter.WriteFile(terrainPath, ms.ToArray());
            ms.Close();

            m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");

            // Write out scene object metadata
            foreach (SceneObjectGroup sceneObject in m_sceneObjects)
            {
                //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());

                string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject);
                m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
            }

            m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
        }
コード例 #2
0
        protected void Save(Scene scene, List <SceneObjectGroup> sceneObjects, string regionDir)
        {
            if (regionDir != string.Empty)
            {
                regionDir = ArchiveConstants.REGIONS_PATH + regionDir + "/";
            }

            m_log.InfoFormat("[ARCHIVER]: Adding region settings to archive.");

            // Write out region settings
            string settingsPath = String.Format("{0}{1}{2}.xml",
                                                regionDir, ArchiveConstants.SETTINGS_PATH, scene.RegionInfo.RegionName);

            m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(scene.RegionInfo.RegionSettings, scene.RegionEnvironment));

            m_log.InfoFormat("[ARCHIVER]: Adding parcel settings to archive.");

            // Write out land data (aka parcel) settings
            List <ILandObject> landObjects = scene.LandChannel.AllParcels();

            foreach (ILandObject lo in landObjects)
            {
                LandData landData = lo.LandData;
                string   landDataPath
                    = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData));
                m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options));
            }

            m_log.InfoFormat("[ARCHIVER]: Adding terrain information to archive.");

            // Write out terrain
            string terrainPath = String.Format("{0}{1}{2}.r32",
                                               regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName);

            using (MemoryStream ms = new MemoryStream())
            {
                scene.RequestModuleInterface <ITerrainModule>().SaveToStream(terrainPath, ms);
                m_archiveWriter.WriteFile(terrainPath, ms.ToArray());
            }

            m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive.");

            // Write out scene object metadata
            IRegionSerialiserModule serializer = scene.RequestModuleInterface <IRegionSerialiserModule>();

            foreach (SceneObjectGroup sceneObject in sceneObjects)
            {
                //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
                if (sceneObject.IsDeleted || sceneObject.inTransit)
                {
                    continue;
                }
                string serializedObject = serializer.SerializeGroupToXml2(sceneObject, m_options);
                string objectPath       = string.Format("{0}{1}", regionDir, ArchiveHelpers.CreateObjectPath(sceneObject));
                m_archiveWriter.WriteFile(objectPath, serializedObject);
            }
        }
コード例 #3
0
        protected internal void ReceivedAllAssets(
            ICollection <UUID> assetsFoundUuids, ICollection <UUID> assetsNotFoundUuids)
        {
            foreach (UUID uuid in assetsNotFoundUuids)
            {
                m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
            }

//            m_log.InfoFormat(
//                "[ARCHIVER]: Received {0} of {1} assets requested",
//                assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);

            m_log.InfoFormat("[ARCHIVER]: Creating archive file.  This may take some time.");

            // Write out control file
            m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
            m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

            // Write out region settings
            string settingsPath
                = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);

            m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));

            m_log.InfoFormat("[ARCHIVER]: Added region settings to archive.");

            // Write out terrain
            string terrainPath
                = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);

            MemoryStream ms = new MemoryStream();

            m_terrainModule.SaveToStream(terrainPath, ms);
            m_archiveWriter.WriteFile(terrainPath, ms.ToArray());
            ms.Close();

            m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");

            // Write out scene object metadata
            foreach (SceneObjectGroup sceneObject in m_sceneObjects)
            {
                //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());

                Vector3 position = sceneObject.AbsolutePosition;

                string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject);
                string filename
                    = string.Format(
                          "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml",
                          ArchiveConstants.OBJECTS_PATH, sceneObject.Name,
                          Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z),
                          sceneObject.UUID);

                m_archiveWriter.WriteFile(filename, serializedObject);
            }

            m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");

            m_archiveWriter.Close();

            m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);

            m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
        }