Ejemplo n.º 1
0
            /// <summary>
            /// Loads all Parcel data from the datastore for region identified by regionID
            /// </summary>
            public void LoadAllLandObjectsFromStorage()
            {
                if (m_haveLoadedParcels || !m_shouldLoadParcels)
                {
                    return;
                }
                m_haveLoadedParcels = true;

                m_log.Info("[BackupModule]: Loading Land Objects from database... ");
                IParcelServiceConnector conn        = DataManager.DataManager.RequestPlugin <IParcelServiceConnector>();
                List <LandData>         LandObjects = m_scene.SimulationDataService.LoadLandObjects(m_scene.RegionInfo.RegionID);

                if (conn != null)
                {
                    //Read from the old database as well
                    if (LandObjects.Count != 0)
                    {
                        foreach (LandData land in LandObjects)
                        {
                            //Store it in the new database
                            conn.StoreLandObject(land);
                            //Remove it from the old
                            m_scene.SimulationDataService.RemoveLandObject(m_scene.RegionInfo.RegionID, land.GlobalID);
                        }
                    }
                    m_scene.EventManager.TriggerIncomingLandDataFromStorage(conn.LoadLandObjects(m_scene.RegionInfo.RegionID));
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        ///   Checks whether an older style database exists
        /// </summary>
        /// <returns>Whether an older style database exists</returns>
        protected virtual bool CheckForOldDataBase()
        {
            string connString = "";
            string name       = "";
            // Try reading the [DatabaseService] section, if it exists
            IConfig dbConfig = m_scene.Config.Configs["DatabaseService"];

            if (dbConfig != null)
            {
                connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            // Try reading the [SimulationDataStore] section
            IConfig simConfig = m_scene.Config.Configs["SimulationDataStore"];

            if (simConfig != null)
            {
                name       = simConfig.GetString("LegacyDatabaseLoaderName", "FileBasedDatabase");
                connString = simConfig.GetString("ConnectionString", connString);
            }

            ILegacySimulationDataStore[] stores =
                AuroraModuleLoader.PickupModules <ILegacySimulationDataStore>().ToArray();
#if (!ISWIN)
            ILegacySimulationDataStore simStore = null;
            foreach (ILegacySimulationDataStore store in stores)
            {
                if (store.Name == name)
                {
                    simStore = store;
                    break;
                }
            }
#else
            ILegacySimulationDataStore simStore = stores.FirstOrDefault(store => store.Name == name);
#endif
            if (simStore == null)
            {
                return(false);
            }

            try
            {
                if (!m_hasShownFileBasedWarning)
                {
                    m_hasShownFileBasedWarning = true;
                    IConfig startupConfig = m_scene.Config.Configs["Startup"];
                    if (startupConfig == null || startupConfig.GetBoolean("NoGUI", false))
                    {
                        DoNoGUIWarning();
                    }
                    else if (!m_scene.RegionInfo.NewRegion)
                    {
                        MessageBox.Show(
                            @"Your sim has been updated to use the FileBased Simulation Service.
Your sim is now saved in a .abackup file in the bin/ directory with the same name as your region.
More configuration options and info can be found in the Configuration/Data/FileBased.ini file.",
                            "WARNING");
                    }
                }
            }
            catch
            {
                DoNoGUIWarning();
            }

            simStore.Initialise(connString);

            IParcelServiceConnector conn = DataManager.DataManager.RequestPlugin <IParcelServiceConnector>();
            m_parcels = simStore.LoadLandObjects(m_scene.RegionInfo.RegionID);
            m_parcels.AddRange(conn.LoadLandObjects(m_scene.RegionInfo.RegionID));
            m_groups = simStore.LoadObjects(m_scene.RegionInfo.RegionID, m_scene);
            if (m_groups.Count != 0 || m_parcels.Count != 0)
            {
                try
                {
                    m_shortterrain = simStore.LoadTerrain(m_scene, false, m_scene.RegionInfo.RegionSizeX,
                                                          m_scene.RegionInfo.RegionSizeY);
                    m_shortrevertTerrain = simStore.LoadTerrain(m_scene, true, m_scene.RegionInfo.RegionSizeX,
                                                                m_scene.RegionInfo.RegionSizeY);
                    //Remove these so that we don't get stuck loading them later
                    conn.RemoveAllLandObjects(m_scene.RegionInfo.RegionID);
                    simStore.RemoveAllLandObjects(m_scene.RegionInfo.RegionID);
                }
                catch
                { }
                return(true);
            }
            return(false);
        }