/// <summary>
        /// Load an OpenSim archive into the current scene.  This will load both the shapes of the prims and upload
        /// their assets to the asset service.
        /// </summary>
        /// <param name="cmdparams"></param>
        public void LoadArchiveToCurrentScene(string[] cmdparams)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.HandleLoadOarConsoleCommand(string.Empty, cmdparams);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Save a region to a file, including all the assets needed to restore it.
        /// </summary>
        /// <param name="cmdparams"></param>
        protected void SaveOar(string module, string[] cmdparams)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.HandleSaveOarConsoleCommand(string.Empty, cmdparams);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Load an OpenSim archive into the current scene.  This will load both the shapes of the prims and upload
        /// their assets to the asset service.
        /// </summary>
        /// <param name="filename"></param>
        public void LoadArchiveToCurrentScene(string filename)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.DearchiveRegion(filename);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Load an OpenSim archive into the current scene.  This will load both the shapes of the prims and upload
        /// their assets to the asset service.
        /// </summary>
        /// <param name="filename"></param>
        public void LoadArchiveToCurrentScene(string filename, bool allowUserReassignment, bool ignoreErorrs)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.DearchiveRegion(filename, allowUserReassignment, ignoreErorrs);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Save the current scene to an OpenSimulator archive.  This archive will eventually include the prim's assets
        /// as well as the details of the prims themselves.
        /// </summary>
        /// <param name="filename"></param>
        public void SaveCurrentSceneToArchive(string filename, bool storeAssets)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.ArchiveRegion(filename, storeAssets);
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Save a region to a file, including all the assets needed to restore it.
        /// </summary>
        /// <param name="cmdparams"></param>
        protected void SaveOar(IScene scene, string[] cmdparams)
        {
            IRegionArchiverModule archiver = scene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.HandleSaveOarConsoleCommand(cmdparams);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Sets the debug level on loading or scanning an OpenSim archive.
        /// </summary>
        /// <param name="level"></param>
        public void SetOARDebug(int level)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.SetDebug(level);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Load an xml file of prims in OpenSimulator's current 'xml2' file format to the current scene
        /// </summary>
        /// <summary>
        /// Scans objects in an OAR file for creator IDs to save for assets.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="saveCreators">true to save in database</param>
        public void ScanSceneForCreators(string filename)
        {
            IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                archiver.ScanArchiveForAssetCreatorIDs(filename);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Save an OAR, register for the callback for when it's done, then call the AutoBackupScript (if applicable).
        /// </summary>
        /// <param name="scene"></param>
        private void DoRegionBackup(IScene scene)
        {
            if (!scene.Ready)
            {
                // We won't backup a region that isn't operating normally.
                m_log.Warn("[AUTO BACKUP]: Not backing up region " + scene.RegionInfo.RegionName +
                           " because its status is " + scene.RegionStatus);
                return;
            }

            m_busy = true;

            AutoBackupModuleState state;

            if (!m_states.TryGetValue(scene, out state))
            {
                return;
            }

            if (state == null || !state.Enabled)
            {
                return;
            }

            IRegionArchiverModule iram = scene.RequestModuleInterface <IRegionArchiverModule>();

            if (iram == null)
            {
                return;
            }

            string savePath = BuildOarPath(scene.RegionInfo.RegionName,
                                           m_backupDir,
                                           state.NamingType);

            if (savePath == null)
            {
                m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed");
                return;
            }

            Guid guid = Guid.NewGuid();

            m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName);

            // Must pass options, even if dictionary is empty!
            Dictionary <string, object> options = new Dictionary <string, object>();

            if (state.SkipAssets)
            {
                options["noassets"] = true;
            }

            iram.ArchiveRegion(savePath, guid, options);
            ExecuteScript(state.Script, savePath);
        }
        /// <summary>
        /// Load an OAR file into a region..
        /// <summary>
        /// <param name="request">incoming XML RPC request</param>
        /// <remarks>
        /// XmlRpcLoadOARMethod takes the following XMLRPC parameters
        /// <list type="table">
        /// <listheader><term>parameter name</term><description>description</description></listheader>
        /// <item><term>session</term>
        ///       <description>An authenticated session ID</description></item>
        /// <item><term>region_uuid</term>
        ///       <description>UUID of the region</description></item>
        /// <item><term>filename</term>
        ///       <description>file name of the OAR file</description></item>
        /// </list>
        ///
        /// Returns
        /// <list type="table">
        /// <listheader><term>name</term><description>description</description></listheader>
        /// <item><term>success</term>
        ///       <description>true or false</description></item>
        /// </list>
        /// </remarks>
        public object RegionRestoreHandler(IList args, IPEndPoint remoteClient)
        {
            m_admin.CheckSessionValid(new UUID((string)args[0]));

            Scene scene;

            if (!m_app.SceneManager.TryGetScene((string)args[1], out scene))
            {
                throw new Exception("region not found");
            }

            String filename = (string)args[2];
            bool   allowUserReassignment = Convert.ToBoolean(args[3]);
            bool   skipErrorGroups       = Convert.ToBoolean(args[4]);
            bool   debug = false;

            if (args.Count > 5)
            {
                debug = Convert.ToBoolean(args[5]);
            }

            m_log.Info("[RADMIN]: Received Region Restore Administrator Request");

            lock (rslock)
            {
                try
                {
                    IRegionArchiverModule archiver = scene.RequestModuleInterface <IRegionArchiverModule>();
                    if (archiver != null)
                    {
                        archiver.DearchiveRegion(filename, allowUserReassignment, skipErrorGroups, null);
                    }
                    else
                    {
                        throw new Exception("Archiver module not present for scene");
                    }

                    m_log.Info("[RADMIN]: Load OAR Administrator Request complete");
                    return(true);
                }
                catch (Exception e)
                {
                    m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message);
                    m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString());
                }

                return(false);
            }
        }
Esempio n. 11
0
 /// <summary>
 ///     Load a whole region from an opensimulator archive.
 /// </summary>
 /// <param name="cmdparams"></param>
 protected void LoadOar(IScene scene, string[] cmdparams)
 {
     try
     {
         IRegionArchiverModule archiver = scene.RequestModuleInterface <IRegionArchiverModule>();
         if (archiver != null)
         {
             archiver.HandleLoadOarConsoleCommand(cmdparams);
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.Error(e.ToString());
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Load a whole region from an opensimulator archive.
 /// </summary>
 /// <param name="cmdparams"></param>
 protected void LoadOar(string module, string[] cmdparams)
 {
     try
     {
         IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface <IRegionArchiverModule>();
         if (archiver != null)
         {
             archiver.HandleLoadOarConsoleCommand(string.Empty, cmdparams);
         }
     }
     catch (Exception e)
     {
         m_log.Error(e.ToString());
     }
 }
Esempio n. 13
0
        public void SaveExplicitOar(string regionName, string oarFilename, bool storeAssets)
        {
            Scene targetScene = this.FindSceneByName(regionName);

            if (targetScene == null)
            {
                throw new Exception(String.Format("Region {0} was not found", regionName));
            }

            if (!HasScriptEngine(targetScene))
            {
                m_log.Warn("[SCENE]: Warning: Script engine disabled. No script states will be saved in OAR file.");
            }

            IRegionArchiverModule archiver = targetScene.RequestModuleInterface <IRegionArchiverModule>();

            if (archiver != null)
            {
                try
                {
                    archiver.ArchiveRegion(oarFilename, storeAssets);

                    //create a file for external code to know we're done writing this OAR
                    //cheap and fragile IPC, but Im not yet taking the time to allow interaction
                    //by anything but the console.
                    using (FileStream completedfile = System.IO.File.Create(OarStatusNameFromRegionName(regionName)))
                    {
                        completedfile.WriteByte(1);
                        completedfile.Close();
                    }
                }
                catch (Exception e)
                {
                    using (FileStream completedfile = System.IO.File.Create(OarStatusNameFromRegionName(regionName)))
                    {
                        completedfile.WriteByte(0);
                        byte[] errorMessage = System.Text.Encoding.UTF8.GetBytes(e.Message);
                        completedfile.Write(errorMessage, 0, errorMessage.Length);
                        completedfile.Close();
                    }

                    throw;
                }
            }
        }
        /// <summary>
        /// Save an OAR, register for the callback for when it's done, then call the AutoBackupScript (if applicable).
        /// </summary>
        /// <param name="scene"></param>
        private void DoRegionBackup(IScene scene)
        {
            if (!scene.Ready)
            {
                // We won't backup a region that isn't operating normally.
                m_log.Warn("[AUTO BACKUP]: Not backing up region " + scene.RegionInfo.RegionName +
                           " because its status is " + scene.RegionStatus);
                return;
            }

            AutoBackupModuleState state = this.m_states[scene];
            IRegionArchiverModule iram  = scene.RequestModuleInterface <IRegionArchiverModule>();
            string savePath             = BuildOarPath(scene.RegionInfo.RegionName,
                                                       state.BackupDir,
                                                       state.NamingType);

            if (savePath == null)
            {
                m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed");
                return;
            }
            Guid guid = Guid.NewGuid();

            m_pendingSaves.Add(guid, scene);
            state.LiveRequests.Add(guid, savePath);
            ((Scene)scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved);

            m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName);

            // Must pass options, even if dictionary is empty!
            Dictionary <string, object> options = new Dictionary <string, object>();

            if (state.SkipAssets)
            {
                options["noassets"] = true;
            }

            iram.ArchiveRegion(savePath, guid, options);
        }
Esempio n. 15
0
 void OnChat(Object sender, OSChatMessage chat)
 {
     if ((chat.Channel != m_listenChannel) || (m_resetRequested))
     {
         return;
     }
     else if (chat.Message.ToLower() == "kill")
     {
         //Immediately stop accepting commands from the simulation
         m_resetRequested = true;
         m_dialogmod.SendGeneralAlert("Manager Module: Deleting all objects and resetting module.  Please be patient...");
         //Remove all objects, clear the list of recyclables and reset the population size limit.
         m_scene.DeleteAllSceneObjects();
         m_overLimit   = false;
         m_recyclables = new Queue <ScriptAndHostPair>();
         if (m_dialogmod != null)
         {
             m_dialogmod.SendGeneralAlert("Manager Module: Cleared old population.  Reloading region with default objects...");
         }
         //Start accepting commands from the simulation again
         m_resetRequested = false;
         //Reload content from the default oar file
         try
         {
             IRegionArchiverModule archivermod = m_scene.RequestModuleInterface <IRegionArchiverModule>();
             if (archivermod != null)
             {
                 string oarFilePath = System.IO.Path.Combine(m_oarPath, "vpgsim_default_content.oar");
                 archivermod.DearchiveRegion(oarFilePath);
                 m_dialogmod.SendGeneralAlert("Manager Module: Loaded default objects...");
             }
         }
         catch
         {
             m_dialogmod.SendGeneralAlert("Manager Module: Couldn't load default objects!");
             m_log.WarnFormat("[vpgManager] Couldn't load default objects...");
         }
     }
     else if (chat.Message.Length > 9)
     {
         if (chat.Message.Substring(0, 3).ToLower() == "oar")
         {
             IRegionArchiverModule archivermod = m_scene.RequestModuleInterface <IRegionArchiverModule>();
             if (chat.Message.Substring(3, 5).ToLower() == "-load")
             {
                 //Load the specified oar file
                 if (archivermod != null)
                 {
                     //Immediately stop accepting commands from the simulation
                     m_resetRequested = true;
                     m_dialogmod.SendGeneralAlert("Manager Module: Loading archive file.  Please be patient...");
                     //Remove all objects from the scene.  The Archiver Module does this anyway,
                     //but we need to be able to reset the list of recyclables after the scene
                     //objects are deleted but before the new objects start to load, so the module
                     //is ready to receive registration requests from recyclables in the oar.
                     m_scene.DeleteAllSceneObjects();
                     m_overLimit   = false;
                     m_recyclables = new Queue <ScriptAndHostPair>();
                     //Start accepting commands from the simulation again
                     m_resetRequested = false;
                     try
                     {
                         string oarFilePath = System.IO.Path.Combine(m_oarPath, chat.Message.Substring(9));
                         archivermod.DearchiveRegion(oarFilePath);
                         m_dialogmod.SendGeneralAlert("Manager Module: Loaded archive file...");
                     }
                     catch
                     {
                         m_dialogmod.SendGeneralAlert("Manager Module: Couldn't load archive file!");
                         m_log.WarnFormat("[vpgManager] Couldn't load archive file...");
                     }
                 }
             }
             else if (chat.Message.Substring(3, 5).ToLower() == "-save")
             {
                 //Save the specified oar file
                 if (archivermod != null)
                 {
                     m_dialogmod.SendGeneralAlert("Manager Module: Saving archive file.  Please be patient...");
                     try
                     {
                         string oarFilePath = System.IO.Path.Combine(m_oarPath, chat.Message.Substring(9));
                         archivermod.ArchiveRegion(oarFilePath, new Dictionary <string, object>());
                         if (m_dialogmod != null)
                         {
                             m_dialogmod.SendGeneralAlert("Manager Module: Saved archive file...");
                         }
                     }
                     catch
                     {
                         m_dialogmod.SendGeneralAlert("Manager Module: Couldn't save archive file!");
                         m_log.WarnFormat("[vpgManager] Couldn't save archive file..");
                     }
                 }
             }
         }
         else
         {
             //Try to parse the string as a new plant generation command
             string[] parsedMessage = chat.Message.Split(',');
             if (parsedMessage.Length != 7)
             {
                 //Invalid message string
                 m_log.WarnFormat("[vpgManager] Invalid new plant generation string...");
                 m_dialogmod.SendGeneralAlert("Manager Module: Invalid command - wrong number of arguments.  No new plants generated...");
             }
             else
             {
                 m_dialogmod.SendGeneralAlert("Manager Module: Processing request.  Please be patient...");
                 string geneticInfo    = parsedMessage[0];
                 int    xMin           = int.Parse(parsedMessage[1]);
                 int    xMax           = int.Parse(parsedMessage[2]);
                 int    yMin           = int.Parse(parsedMessage[3]);
                 int    yMax           = int.Parse(parsedMessage[4]);
                 int    quantity       = int.Parse(parsedMessage[5]);
                 int    strictQuantity = int.Parse(parsedMessage[6]);
                 bool   errorStatus    = false;
                 int    failureCount   = 0;
                 int    successCount   = 0;
                 //The webform already checks these same things before creating the input string, but check them again in case the user manually edits the input string
                 if ((xMin < 0) || (xMin > 256) || (xMax < 0) || (xMax > 256) || (yMin < 0) || (yMin > 256) || (yMax < 0) || (yMax > 256) || (xMin >= xMax) || (yMin >= yMax) || (quantity <= 0) || (quantity > 500) || !((geneticInfo.Length == 5) || (geneticInfo.Length == 10)))
                 {
                     m_dialogmod.SendGeneralAlert("Manager Module: Invalid command string.");
                     errorStatus = true;
                 }
                 while ((quantity > 0) && (!errorStatus) && (failureCount < m_maxFailures))
                 {
                     int     randomGenotype = GenerateGenotype(geneticInfo);
                     Vector3 randomLocation = GenerateRandomLocation(xMin, xMax, yMin, yMax);
                     if (randomGenotype < 0)
                     {
                         m_dialogmod.SendGeneralAlert("Manager Module: Invalid command - Incorrect genotype format.  No new plants generated...");
                         errorStatus = true;
                     }
                     else if (randomLocation.Z > WaterLevel(randomLocation))
                     {
                         ScriptAndHostPair messageTarget = new ScriptAndHostPair();
                         lock (m_recyclables)
                         {
                             if (m_recyclables.Count == 0) //Nothing available to recycle
                             {
                                 //Nothing available to recycle. vpgPlanter will need to rez a new one
                                 messageTarget.scriptUUID = m_vpgPlanter.scriptUUID;
                             }
                             else
                             {
                                 //There are objects available to recycle.  Recycle one from the queue
                                 messageTarget = m_recyclables.Dequeue();
                             }
                         }
                         //Format the coordinates in the vector format expected by the LSL script
                         string coordinates = '<' + randomLocation.X.ToString() + ',' + randomLocation.Y.ToString() + ',' + randomLocation.Z.ToString() + '>';
                         //Send message to vpgPlanter or plant to be recycled
                         m_scriptmod.DispatchReply(messageTarget.scriptUUID, randomGenotype, coordinates, "");
                         //We have to pause between messages or the vpgPlanter gets overloaded and puts all the plants in the same location.
                         Thread.Sleep(50);
                         successCount++;
                         quantity--;
                     }
                     else if (strictQuantity == 0)
                     {
                         failureCount++;
                         quantity--;
                     }
                     else
                     {
                         failureCount++;
                         if (failureCount == m_maxFailures)
                         {
                             m_dialogmod.SendGeneralAlert("Manager Module: Too many failed attempts.  Are you sure there is dry land in the selected range? Successfully planted:" + successCount.ToString() + "  Failures:" + failureCount.ToString());
                             errorStatus = true;
                         }
                     }
                 }
                 if (m_dialogmod != null)
                 {
                     if (errorStatus == false)
                     {
                         m_dialogmod.SendGeneralAlert("Manager Module: Successfully planted:" + successCount.ToString() + "  Failures:" + failureCount.ToString());
                     }
                 }
             }
         }
     }
 }