Exemplo n.º 1
0
        /// <summary>
        /// Creates the new region using addition options.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        private void CreateNewRegionExtended(IScene scene, string[] cmd)
        {
            string defaultDir = "";
            string defaultExt = ".xml";
            string regionName = "";
            string regionFile = "";

            List<string> newParams = new List<string>(cmd);
            foreach (string param in cmd)
            {
                if (param.StartsWith("--config", StringComparison.CurrentCultureIgnoreCase))
                {
                    regionFile = param.Remove(0, 9);
                    newParams.Remove(param);
                }
            }

            if (newParams.Count == 3)
            {
                regionName = newParams [2];
            }

            if (regionFile == "" )
            {
                CreateNewRegion (regionName);
                return;
            }

            // we have a config file and possibly a region name
            IConfig config = m_config.Configs["FileBasedSimulationData"];
            if (config != null)
                defaultDir = PathHelpers.ComputeFullPath (config.GetString ("StoreBackupDirectory", "Regions"));

            regionFile = PathHelpers.VerifyReadFile (regionFile, defaultExt, defaultDir);
            if (regionFile == "")
                return;

            // let's do it...
            MainConsole.Instance.Info ( "[SceneManager]: Loading region definition...." );
            RegionInfo loadRegion = new RegionInfo ();
            loadRegion.LoadRegionConfig( regionFile );

            if (loadRegion.RegionName != regionName)
            {
                if ( MainConsole.Instance.Prompt("You have specified a different name than what is specified in the configuration file\n"+
                    "Do you wish to rename the region to '" + regionName +"'? (yes/no): ") == "yes" )
                {
                    loadRegion.RegionName = regionName;
                }
            }

            //check for an existing Scene
            IScene region = m_scenes.Find((s) => s.RegionInfo.RegionName.ToLower() == regionName);
            if (region != null)
            {
                MainConsole.Instance.InfoFormat(
                    "ERROR: The region '{0}' already exists, please retry", regionName);
                return;
            }

            // indicate this is a new region
            loadRegion.NewRegion = true;

            // get some current details
            var currentInfo = FindCurrentRegionInfo ();

            // let's do it
            ISimulationDataStore store = m_selectedDataService.Copy ();
            //StartRegion (store, store.CreateNewRegion (m_OpenSimBase, newRegion, currentInfo));

            var newRegion = store.CreateNewRegion (m_OpenSimBase, loadRegion, currentInfo);
            if (newRegion.RegionName != "abort")
            {
                StartRegion (store, newRegion);

                // backup all our work
                foreach (ISimulationDataStore st in m_simulationDataServices)
                    st.ForceBackup ();
            }
        }