public void LoadLibraries()
        {
            if (!m_enabled)
            {
                return;
            }
            else if (!File.Exists("DefaultInventory/Inventory.ini") &&
                     !File.Exists("DefaultInventory/Inventory.ini.example"))
            {
                MainConsole.Instance.Error(
                    "Could not find DefaultInventory/Inventory.ini or DefaultInventory/Inventory.ini.example");
                return;
            }
            List <IDefaultLibraryLoader> Loaders = AuroraModuleLoader.PickupModules <IDefaultLibraryLoader>();

            try
            {
                if (!File.Exists("DefaultInventory/Inventory.ini"))
                {
                    File.Copy("DefaultInventory/Inventory.ini.example", "DefaultInventory/Inventory.ini");
                }
                IniConfigSource iniSource = new IniConfigSource("DefaultInventory/Inventory.ini",
                                                                IniFileType.AuroraStyle);
                if (iniSource != null)
                {
                    foreach (IDefaultLibraryLoader loader in Loaders)
                    {
                        loader.LoadLibrary(this, iniSource, m_registry);
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #2
0
        private void SetUpConsole(IConfigSource config, IRegistryCore registry)
        {
            List <ICommandConsole> Plugins = AuroraModuleLoader.PickupModules <ICommandConsole>();

            foreach (ICommandConsole plugin in Plugins)
            {
                plugin.Initialize(config, registry.RequestModuleInterface <ISimulationBase>());
            }

            if (MainConsole.Instance == null)
            {
                Console.WriteLine("[Console]: No Console located");
                return;
            }

            MainConsole.Instance.Threshold = Level.Info;

            MainConsole.Instance.Fatal(String.Format("[Console]: Console log level is {0}",
                                                     MainConsole.Instance.Threshold));

            MainConsole.Instance.Commands.AddCommand("set log level", "set log level [level]",
                                                     "Set the console logging level", HandleLogLevel, false, true);

            MainConsole.Instance.Commands.AddCommand("get log level", "get log level",
                                                     "Returns the current console logging level", HandleGetLogLevel, false, true);
        }
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            IConfig handlerConfig = config.Configs["Handlers"];

            if (handlerConfig.GetString("AgentInfoHandler", "") != Name)
            {
                return;
            }

            string localAssetHandler          = handlerConfig.GetString("LocalAgentInfoHandler", "AgentInfoService");
            List <IAgentInfoService> services = AuroraModuleLoader.PickupModules <IAgentInfoService>();

#if (!ISWIN)
            foreach (IAgentInfoService s in services)
            {
                if (s.GetType().Name == localAssetHandler)
                {
                    m_localService = s;
                }
            }
#else
            foreach (IAgentInfoService s in services.Where(s => s.GetType().Name == localAssetHandler))
            {
                m_localService = s;
            }
#endif
            if (m_localService == null)
            {
                m_localService = new AgentInfoService();
            }
            m_localService.Initialize(config, registry);
            registry.RegisterModuleInterface <IAgentInfoService>(this);
            m_registry = registry;
            Init(registry, Name);
        }
        public void Initialize(ISimulationBase openSim)
        {
            m_openSim = openSim;

            IConfig handlerConfig = openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("RegionModulesControllerPlugin", "") != Name)
            {
                return;
            }

            m_openSim.ApplicationRegistry.RegisterModuleInterface <IRegionModulesController>(this);
            // Scan modules and load all that aren't disabled
            m_sharedInstances = AuroraModuleLoader.PickupModules <ISharedRegionModule>();
            foreach (ISharedRegionModule module in m_sharedInstances)
            {
                try
                {
                    module.Initialise(m_openSim.ConfigSource);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
            }
        }
Beispiel #5
0
        public void Initialise(IConfigSource source, IRegistryCore simBase, List <Type> types)
        {
            IConfig m_config = source.Configs["AuroraData"];

            if (m_config != null)
            {
                StorageProvider  = m_config.GetString("StorageProvider", StorageProvider);
                ConnectionString = m_config.GetString("ConnectionString", ConnectionString);
            }

            IGenericData DataConnector = null;

            if (StorageProvider == "MySQL")
            //Allow for fallback when AuroraData isn't set
            {
                MySQLDataLoader GenericData = new MySQLDataLoader();

                DataConnector = GenericData;
            }

            /*else if (StorageProvider == "MSSQL2008")
             * {
             * MSSQLDataLoader GenericData = new MSSQLDataLoader();
             *
             * DataConnector = GenericData;
             * }
             * else if (StorageProvider == "MSSQL7")
             * {
             * MSSQLDataLoader GenericData = new MSSQLDataLoader();
             *
             * DataConnector = GenericData;
             * }*/
            else if (StorageProvider == "SQLite")
            //Allow for fallback when AuroraData isn't set
            {
                SQLiteLoader GenericData = new SQLiteLoader();

                DataConnector = GenericData;
            }

            foreach (Type t in types)
            {
                List <dynamic> Plugins = AuroraModuleLoader.PickupModules(t);
                foreach (dynamic plugin in Plugins)
                {
                    try
                    {
                        plugin.Initialize(DataConnector.Copy(), source, simBase, ConnectionString);
                    }
                    catch (Exception ex)
                    {
                        if (MainConsole.Instance != null)
                        {
                            MainConsole.Instance.Warn("[DataService]: Exeception occured starting data plugin " +
                                                      plugin.Name + ", " + ex.ToString());
                        }
                    }
                }
            }
        }
        public MigrationManager(IDataConnector genericData, string migratorName, bool validateTables)
        {
            this.genericData    = genericData;
            this.migratorName   = migratorName;
            this.validateTables = validateTables;
            List <IMigrator> allMigrators = AuroraModuleLoader.PickupModules <IMigrator>();

#if (!ISWIN)
            foreach (IMigrator m in allMigrators)
            {
                if (m.MigrationName != null)
                {
                    if (m.MigrationName == migratorName)
                    {
                        migrators.Add((Migrator)m);
                    }
                }
            }
#else
            foreach (IMigrator m in allMigrators.Where(m => m.MigrationName != null).Where(m => m.MigrationName == migratorName))
            {
                migrators.Add((Migrator)m);
            }
#endif
        }
Beispiel #7
0
        public void PostStart()
        {
            IConfig handlerConfig = m_openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("LoadRegionsPlugin", "") != Name)
            {
                return;
            }

            List <IRegionLoader> regionLoaders = AuroraModuleLoader.PickupModules <IRegionLoader>();
            List <RegionInfo[]>  regions       = new List <RegionInfo[]>();
            SceneManager         manager       = m_openSim.ApplicationRegistry.RequestModuleInterface <SceneManager>();

            foreach (IRegionLoader loader in regionLoaders)
            {
                loader.Initialise(m_openSim.ConfigSource, m_openSim);

                if (!loader.Enabled)
                {
                    continue;
                }

                m_log.Info("[LoadRegionsPlugin]: Checking for region configurations from " + loader.Name + " plugin...");

                while (true)
                {
                    RegionInfo[] regionsToLoad = loader.LoadRegions();
                    if (regionsToLoad == null)
                    {
                        break; //No regions, end
                    }
                    string reason;
                    if (!CheckRegionsForSanity(regionsToLoad, out reason))
                    {
                        m_log.Error("[LoadRegionsPlugin]: Halting startup due to conflicts in region configurations");
                        if (!loader.FailedToStartRegions(reason))
                        {
                            throw new Exception(); //If it doesn't fix it, end the program
                        }
                    }
                    else
                    {
                        //They are sanitized, load them
                        manager.AllRegions += regionsToLoad.Length;
                        regions.Add(regionsToLoad);
                        break;
                    }
                }
            }
            foreach (RegionInfo[] regionsToLoad in regions)
            {
                for (int i = 0; i < regionsToLoad.Length; i++)
                {
                    IScene scene = null;
                    m_log.Info("[LoadRegionsPlugin]: Creating Region: " + regionsToLoad[i].RegionName);
                    manager.CreateRegion(regionsToLoad[i], out scene);
                }
            }
        }
Beispiel #8
0
        public void PostStart()
        {
            IConfig handlerConfig = m_openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("LoadRegionsPlugin", "") != Name || !Enabled)
            {
                return;
            }

            List <IRegionLoader> regionLoaders = AuroraModuleLoader.PickupModules <IRegionLoader>();
            List <RegionInfo[]>  regions       = new List <RegionInfo[]>();
            SceneManager         manager       = m_openSim.ApplicationRegistry.RequestModuleInterface <SceneManager>();

            foreach (IRegionLoader loader in regionLoaders)
            {
                loader.Initialise(m_openSim.ConfigSource, m_openSim);

                if (!loader.Enabled)
                {
                    continue;
                }

                MainConsole.Instance.Info("[LoadRegionsPlugin]: Checking for region configurations from " + loader.Name + " plugin...");
                RegionInfo[] regionsToLoad = loader.LoadRegions();
                if (regionsToLoad == null)
                {
                    continue; //No regions, end for this module
                }
                string reason;
                if (!CheckRegionsForSanity(regionsToLoad, out reason))
                {
                    MainConsole.Instance.Error("[LoadRegionsPlugin]: Halting startup due to conflicts in region configurations");
                    if (!loader.FailedToStartRegions(reason))
                    {
                        throw new Exception(); //If it doesn't fix it, end the program
                    }
                }
                else
                {
                    //They are sanitized, load them
                    manager.AllRegions += regionsToLoad.Length;
                    regions.Add(regionsToLoad);
                }
            }
#if (!ISWIN)
            foreach (RegionInfo[] regionsToLoad in regions)
            {
                foreach (RegionInfo t in regionsToLoad)
                {
                    manager.StartNewRegion(t);
                }
            }
#else
            foreach (RegionInfo t in regions.SelectMany(regionsToLoad => regionsToLoad))
            {
                manager.StartNewRegion(t);
            }
#endif
        }
 public virtual void InitializeModules()
 {
     m_applicationPlugins = AuroraModuleLoader.PickupModules <IApplicationPlugin>();
     foreach (IApplicationPlugin plugin in m_applicationPlugins)
     {
         plugin.PreStartup(this);
     }
 }
Beispiel #10
0
 public List <ICapsServiceConnector> GetServiceConnectors()
 {
     if (m_connectors.Count == 0)
     {
         m_connectors = AuroraModuleLoader.PickupModules <ICapsServiceConnector>();
     }
     return(m_connectors);
 }
Beispiel #11
0
 private void FindChatPlugins()
 {
     AllChatPlugins = AuroraModuleLoader.PickupModules <IChatPlugin>();
     foreach (IChatPlugin plugin in AllChatPlugins)
     {
         plugin.Initialize(this);
     }
 }
Beispiel #12
0
 private void SetupCompilers()
 {
     converters = AuroraModuleLoader.PickupModules <IScriptConverter>();
     foreach (IScriptConverter convert in converters)
     {
         convert.Initialise(this);
     }
 }
Beispiel #13
0
        public void Initialise(IConfigSource source, IRegistryCore simBase)
        {
            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = source.Configs["DatabaseService"];

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

            //
            // [AuroraData] section overrides [DatabaseService], if it exists
            //
            IConfig m_config = source.Configs["AuroraData"];

            if (m_config != null)
            {
                StorageProvider  = m_config.GetString("StorageProvider", StorageProvider);
                ConnectionString = m_config.GetString("ConnectionString", ConnectionString);
            }

            IGenericData DataConnector = null;

            if (StorageProvider == "MySQL" || StorageProvider == "OpenSim.Data.MySQL.dll") //Allow for fallback when AuroraData isn't set
            {
                MySQLDataLoader GenericData = new MySQLDataLoader();

                DataConnector = GenericData;
            }
            else if (StorageProvider == "MSSQL2008")
            {
                MSSQLDataLoader GenericData = new MSSQLDataLoader();

                DataConnector = GenericData;
            }
            else if (StorageProvider == "MSSQL7")
            {
                MSSQLDataLoader GenericData = new MSSQLDataLoader();

                DataConnector = GenericData;
            }
            else if (StorageProvider == "SQLite" || StorageProvider == "OpenSim.Data.SQLite.dll") //Allow for fallback when AuroraData isn't set
            {
                SQLiteLoader GenericData = new SQLiteLoader();

                DataConnector = GenericData;
            }

            List <IAuroraDataPlugin> Plugins = AuroraModuleLoader.PickupModules <IAuroraDataPlugin>();

            foreach (IAuroraDataPlugin plugin in Plugins)
            {
                plugin.Initialize(DataConnector.Copy(), source, simBase, ConnectionString);
            }
        }
Beispiel #14
0
        public void Initialize(ISimulationBase openSim)
        {
            m_OpenSimBase = openSim;

            IConfig handlerConfig = openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("SceneManager", "") != Name)
            {
                return;
            }

            m_config = openSim.ConfigSource;

            string name = String.Empty;
            // Try reading the [SimulationDataStore] section
            IConfig simConfig = openSim.ConfigSource.Configs["SimulationDataStore"];

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

            ISimulationDataStore[] stores     = AuroraModuleLoader.PickupModules <ISimulationDataStore> ().ToArray();
            List <string>          storeNames = new List <string>();

            foreach (ISimulationDataStore store in stores)
            {
                if (store.Name.ToLower() == name.ToLower())
                {
                    m_simulationDataService = store;
                    break;
                }
                storeNames.Add(store.Name);
            }

            if (m_simulationDataService == null)
            {
                MainConsole.Instance.ErrorFormat("[SceneManager]: FAILED TO LOAD THE SIMULATION SERVICE AT '{0}', ONLY OPTIONS ARE {1}, QUITING...", name, string.Join(", ", storeNames.ToArray()));
                Console.Read(); //Wait till they see
                Environment.Exit(0);
            }
            m_simulationDataService.Initialise();

            AddConsoleCommands();

            //Load the startup modules for the region
            m_startupPlugins = AuroraModuleLoader.PickupModules <ISharedRegionStartupModule>();

            //Register us!
            m_OpenSimBase.ApplicationRegistry.RegisterModuleInterface <SceneManager>(this);
            m_OpenSimBase.EventManager.RegisterEventHandler("RegionInfoChanged", RegionInfoChanged);
        }
Beispiel #15
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            Registry = registry;

            var webPages = AuroraModuleLoader.PickupModules <IWebInterfacePage>();

            foreach (var pages in webPages)
            {
                foreach (var page in pages.FilePath)
                {
                    _pages.Add(page, pages);
                }
            }

            _translators       = AuroraModuleLoader.PickupModules <ITranslator>();
            _defaultTranslator = _translators[0];
        }
Beispiel #16
0
        public void Initialize(ISimulationBase openSim)
        {
            m_openSim = openSim;

            IConfig handlerConfig = openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("RegionModulesControllerPlugin", "") != Name)
            {
                return;
            }

            m_openSim.ApplicationRegistry.RegisterModuleInterface <IRegionModulesController>(this);
            // Scan modules and load all that aren't disabled
            m_sharedInstances = AuroraModuleLoader.PickupModules <ISharedRegionModule>();
            foreach (ISharedRegionModule module in m_sharedInstances)
            {
                module.Initialise(m_openSim.ConfigSource);
            }
        }
Beispiel #17
0
        /// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <returns></returns>
        public IScene CreateScene(ISimulationDataStore dataStore, RegionInfo regionInfo)
        {
            AgentCircuitManager         circuitManager   = new AgentCircuitManager();
            List <IClientNetworkServer> clientServers    = AuroraModuleLoader.PickupModules <IClientNetworkServer>();
            List <IClientNetworkServer> allClientServers = new List <IClientNetworkServer>();

            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialise((uint)regionInfo.RegionPort, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            Scene scene = new Scene();

            scene.AddModuleInterfaces(m_simBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, dataStore, circuitManager, allClientServers);

            return(scene);
        }
Beispiel #18
0
        /// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="configSource"></param>
        /// <returns></returns>
        protected IScene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager         circuitManager   = new AgentCircuitManager();
            List <IClientNetworkServer> clientServers    = AuroraModuleLoader.PickupModules <IClientNetworkServer>();
            List <IClientNetworkServer> allClientServers = new List <IClientNetworkServer>();

            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialise(MainServer.Instance.Port, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            AsyncScene scene = new AsyncScene();

            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, allClientServers);

            return(scene);
        }
Beispiel #19
0
        public void Start()
        {
            IConfig handlerConfig = m_openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("ServicesLoader", "") != Name)
            {
                return;
            }

            List <IService> serviceConnectors = AuroraModuleLoader.PickupModules <IService>();

            foreach (IService connector in serviceConnectors)
            {
                try
                {
                    connector.Initialize(m_openSim.ConfigSource, m_openSim.ApplicationRegistry);
                }
                catch
                {
                }
            }
            foreach (IService connector in serviceConnectors)
            {
                try
                {
                    connector.Start(m_openSim.ConfigSource, m_openSim.ApplicationRegistry);
                }
                catch
                {
                }
            }
            foreach (IService connector in serviceConnectors)
            {
                try
                {
                    connector.FinishedStartup();
                }
                catch
                {
                }
            }
        }
Beispiel #20
0
        public virtual void InitializeModules()
        {
            LocalDataService lds = new LocalDataService();

            lds.Initialise(ConfigSource, ApplicationRegistry, m_dataPlugins);

            List <dynamic> modules = new List <dynamic>();

            foreach (Type t in m_servicePlugins)
            {
                var mods = AuroraModuleLoader.PickupModules(t);
                modules.AddRange(mods);
            }

            foreach (dynamic service in modules)
            {
                if (!(service is IService))
                {
                    continue;
                }
                ((IService)service).Initialize(ConfigSource, ApplicationRegistry);
            }
            foreach (dynamic service in modules)
            {
                if (!(service is IService))
                {
                    continue;
                }
                ((IService)service).Start(ConfigSource, ApplicationRegistry);
            }
            foreach (dynamic service in modules)
            {
                if (!(service is IService))
                {
                    continue;
                }
                ((IService)service).FinishedStartup();
            }
        }
Beispiel #21
0
        /// <summary>
        /// Start the application modules
        /// </summary>
        public virtual void StartModules()
        {
            m_applicationPlugins = AuroraModuleLoader.PickupModules <IApplicationPlugin>();
            foreach (IApplicationPlugin plugin in m_applicationPlugins)
            {
                plugin.Initialize(this);
            }

            foreach (IApplicationPlugin plugin in m_applicationPlugins)
            {
                plugin.PostInitialise();
            }

            foreach (IApplicationPlugin plugin in m_applicationPlugins)
            {
                plugin.Start();
            }

            foreach (IApplicationPlugin plugin in m_applicationPlugins)
            {
                plugin.PostStart();
            }
        }
Beispiel #22
0
        /// <summary>
        ///   Create a scene and its initial base structures.
        /// </summary>
        /// <param name = "regionInfo"></param>
        /// <param name = "proxyOffset"></param>
        /// <param name = "configSource"></param>
        /// <param name = "clientServer"> </param>
        /// <returns></returns>
        protected IScene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager         circuitManager   = new AgentCircuitManager();
            List <IClientNetworkServer> clientServers    = AuroraModuleLoader.PickupModules <IClientNetworkServer>();
            List <IClientNetworkServer> allClientServers = new List <IClientNetworkServer>();

            foreach (IClientNetworkServer clientServer in clientServers)
            {
                foreach (int port in regionInfo.UDPPorts)
                {
                    IClientNetworkServer copy = clientServer.Copy();
                    copy.Initialise(port, m_configSource, circuitManager);
                    allClientServers.Add(copy);
                }
            }

            Scene scene = new Scene();

            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, allClientServers);

            return(scene);
        }
Beispiel #23
0
        public void LoadLibraries(IRegistryCore registry)
        {
            if (!m_enabled)
            {
                return;
            }
            List <IDefaultLibraryLoader> Loaders = AuroraModuleLoader.PickupModules <IDefaultLibraryLoader>();

            try
            {
                IniConfigSource iniSource = new IniConfigSource("DefaultInventory/Inventory.ini",
                                                                IniFileType.AuroraStyle);
                if (iniSource != null)
                {
                    foreach (IDefaultLibraryLoader loader in Loaders)
                    {
                        loader.LoadLibrary(this, iniSource, registry);
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #24
0
        public void AddRegion(IScene scene)
        {
            m_scene = scene;
            if (m_enabled)
            {
                //MainConsole.Instance.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_frame = 0;

                // Register all the Wind Model Plug-ins
                foreach (IWindModelPlugin windPlugin in AuroraModuleLoader.PickupModules <IWindModelPlugin>())
                {
                    //MainConsole.Instance.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                    m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
                }

                // Check for desired plugin
                if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];

                    //MainConsole.Instance.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                    if (windConfig != null)
                    {
                        m_activeWindPlugin.Initialise();
                        m_activeWindPlugin.WindConfig(m_scene, windConfig);
                    }
                }


                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    MainConsole.Instance.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}",
                                                     desiredWindPlugin);
                    MainConsole.Instance.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                if (MainConsole.Instance != null)
                {
                    // Get a list of the parameters for each plugin
                    foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                    {
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_plugin {0}", windPlugin.Name),
                            String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "",
                            HandleConsoleBaseCommand);
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_update_rate"), "Change the wind update rate.", "",
                            HandleConsoleBaseCommand);

                        foreach (KeyValuePair <string, string> kvp in windPlugin.WindParams())
                        {
                            MainConsole.Instance.Commands.AddCommand(
                                String.Format("wind {0} {1}", windPlugin.Name, kvp.Key),
                                String.Format("{0} : {1} - {2}", windPlugin.Name, kvp.Key, kvp.Value), "",
                                HandleConsoleParamCommand);
                        }
                    }
                }


                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame         += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module
                m_scene.RegisterModuleInterface <IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
Beispiel #25
0
        public void Initialize(ISimulationBase openSim)
        {
            m_OpenSimBase = openSim;

            IConfig handlerConfig = openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("SceneManager", "") != Name)
            {
                return;
            }

            m_localScenes = new List <Scene>();

            m_config = openSim.ConfigSource;

            string StorageDLL = "";

            string dllName    = String.Empty;
            string connString = String.Empty;

            // Try reading the [DatabaseService] section, if it exists
            IConfig dbConfig = openSim.ConfigSource.Configs["DatabaseService"];

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

            // Try reading the [SimulationDataStore] section
            IConfig simConfig = openSim.ConfigSource.Configs["SimulationDataStore"];

            if (simConfig != null)
            {
                dllName    = simConfig.GetString("StorageProvider", dllName);
                connString = simConfig.GetString("ConnectionString", connString);
            }

            // We tried, but this doesn't exist. We can't proceed
            if (dllName == String.Empty)
            {
                dllName = "OpenSim.Data.Null.dll";
            }

            m_simulationDataService = AuroraModuleLoader.LoadPlugin <ISimulationDataStore>(Util.BasePathCombine(dllName));

            if (m_simulationDataService == null)
            {
                m_log.ErrorFormat("[SceneManager]: FAILED TO LOAD THE SIMULATION SERVICE AT '{0}', QUITING...", StorageDLL);
                System.Threading.Thread.Sleep(10000);
                Environment.Exit(0);
            }
            m_simulationDataService.Initialise(connString);

            AddConsoleCommands();

            //Load the startup modules for the region
            m_startupPlugins = AuroraModuleLoader.PickupModules <ISharedRegionStartupModule>();

            //Register us!
            m_OpenSimBase.ApplicationRegistry.RegisterModuleInterface <SceneManager>(this);
        }
        private void SetUpConsole(IConfigSource config, IRegistryCore registry)
        {
            List <ICommandConsole> Plugins = AuroraModuleLoader.PickupModules <ICommandConsole>();

            foreach (ICommandConsole plugin in Plugins)
            {
                plugin.Initialize(config, registry.RequestModuleInterface <ISimulationBase>());
            }

            List <INotificationService> NotificationPlugins = AuroraModuleLoader.PickupModules <INotificationService>();

            foreach (INotificationService plugin in NotificationPlugins)
            {
                plugin.Init(config, registry);
            }

            ILoggerRepository repository = LogManager.GetRepository();

            IAppender[] appenders = repository.GetAppenders();
            foreach (IAppender appender in appenders)
            {
                if (appender.Name == "Console")
                {
                    m_consoleAppender = (OpenSimAppender)appender;
                    break;
                }
            }

            if (null != m_consoleAppender)
            {
                m_consoleAppender.Console = MainConsole.Instance;
                // If there is no threshold set then the threshold is effectively everything.
                if (null == m_consoleAppender.Threshold)
                {
                    m_consoleAppender.Threshold = Level.All;
                }
                repository.Threshold = m_consoleAppender.Threshold;
                foreach (ILogger log in repository.GetCurrentLoggers())
                {
                    log.Level = m_consoleAppender.Threshold;
                }
            }
            IAppender logFileAppender = null;

            foreach (IAppender appender in appenders)
            {
                if (appender.Name == "LogFileAppender")
                {
                    logFileAppender = appender;
                }
            }

            if (logFileAppender != null)
            {
                if (logFileAppender is FileAppender)
                {
                    FileAppender appender      = (FileAppender)logFileAppender;
                    IConfig      startupConfig = config.Configs["Startup"];
                    string       fileName      = startupConfig.GetString("LogFile", String.Empty);
                    if (fileName != String.Empty)
                    {
                        appender.File = fileName;
                        appender.ActivateOptions();
                    }
                }
            }
            if (MainConsole.Instance == null)
            {
                m_log.Info("[Console]: No Console located");
                return;
            }

            MainConsole.Instance.MaxLogLevel = m_consoleAppender.Threshold;
            if (m_consoleAppender != null)
            {
                MainConsole.Instance.Fatal(String.Format("[Console]: Console log level is {0}", m_consoleAppender.Threshold));
            }

            MainConsole.Instance.Commands.AddCommand("set log level", "set log level [level]", "Set the console logging level", HandleLogLevel);

            MainConsole.Instance.Commands.AddCommand("get log level", "get log level", "Returns the current console logging level", HandleGetLogLevel);
        }
        public void PostStart()
        {
            IConfig handlerConfig = m_openSim.ConfigSource.Configs["ApplicationPlugins"];

            if (handlerConfig.GetString("LoadRegionsPlugin", "") != Name || !Enabled)
            {
                return;
            }

            List <IRegionLoader> regionLoaders = AuroraModuleLoader.PickupModules <IRegionLoader>();
            ISceneManager        manager       = m_openSim.ApplicationRegistry.RequestModuleInterface <ISceneManager>();

            MainConsole.Instance.DefaultPrompt = "Region (root)";//Set this up
reload:
            List <RegionInfo[]> regions = new List <RegionInfo[]>();

            foreach (IRegionLoader loader in regionLoaders)
            {
                loader.Initialise(m_openSim.ConfigSource, m_openSim);

                if (!loader.Enabled)
                {
                    continue;
                }

                MainConsole.Instance.Info("[LoadRegions]: Checking for regions from " + loader.Name + "");
                RegionInfo[] regionsToLoad = loader.LoadRegions();
                if (regionsToLoad == null)
                {
                    continue; //No regions, end for this module
                }
                string reason;
                if (!CheckRegionsForSanity(regionsToLoad, out reason))
                {
                    MainConsole.Instance.Error("[LoadRegions]: Halting startup due to conflicts in region configurations");
                    if (!loader.FailedToStartRegions(reason))
                    {
                        bool foundSomeRegions = false;
                        foreach (IRegionLoader l in regionLoaders)
                        {
                            l.Initialise(m_openSim.ConfigSource, m_openSim);

                            if (!loader.Enabled)
                            {
                                continue;
                            }

                            RegionInfo[] rs = loader.LoadRegions();
                            if (rs == null)
                            {
                                continue; //No regions, end for this module
                            }
                            if (CheckRegionsForSanity(regionsToLoad, out reason))
                            {
                                foundSomeRegions = true;
                                break;
                            }
                        }
                        if (!foundSomeRegions)
                        {
                            throw new Exception(); //If it doesn't fix it, and we don't have regions now, end the program
                        }
                    }
                    goto reload;
                }
                else
                {
                    //They are sanitized, load them
                    manager.AllRegions += regionsToLoad.Length;
                    regions.Add(regionsToLoad);
                }
            }
            while (regions.Count == 0)
            {
                foreach (IRegionLoader loader in regionLoaders)
                {
                    if (loader.Default && loader.Enabled)
                    {
                        MainConsole.Instance.Info("[LoadRegions]: Attempting to create new region with " + loader.Name);
                        loader.CreateRegion();
                        goto reload;
                    }
                }
            }
#if (!ISWIN)
            foreach (RegionInfo[] regionsToLoad in regions)
            {
                foreach (RegionInfo r in regionsToLoad)
                {
                    RegionInfo reg = r;
                    //System.Threading.Thread t = new System.Threading.Thread(delegate()
                    //    {
                    manager.StartNewRegion(reg);
                    //    });
                    //t.Start();
                }
            }
#else
            foreach (RegionInfo t in regions.SelectMany(regionsToLoad => regionsToLoad))
            {
                manager.StartNewRegion(t);
            }
#endif
        }
        public void AddRegionToModules(IScene scene)
        {
            Dictionary <Type, ISharedRegionModule> deferredSharedModules =
                new Dictionary <Type, ISharedRegionModule>();
            Dictionary <Type, INonSharedRegionModule> deferredNonSharedModules =
                new Dictionary <Type, INonSharedRegionModule>();

            // We need this to see if a module has already been loaded and
            // has defined a replaceable interface. It's a generic call,
            // so this can't be used directly. It will be used later
            Type       s  = scene.GetType();
            MethodInfo mi = s.GetMethod("RequestModuleInterface");

            // This will hold the shared modules we actually load
            List <ISharedRegionModule> sharedlist =
                new List <ISharedRegionModule>();

            // Iterate over the shared modules that have been loaded
            // Add them to the new Scene
            foreach (ISharedRegionModule module in m_sharedInstances)
            {
                try
                {
                    // Here is where we check if a replaceable interface
                    // is defined. If it is, the module is checked against
                    // the interfaces already defined. If the interface is
                    // defined, we simply skip the module. Else, if the module
                    // defines a replaceable interface, we add it to the deferred
                    // list.
                    Type replaceableInterface = module.ReplaceableInterface;
                    if (replaceableInterface != null)
                    {
                        MethodInfo mii = mi.MakeGenericMethod(replaceableInterface);

                        if (mii.Invoke(scene, new object[0]) != null)
                        {
                            MainConsole.Instance.DebugFormat(
                                "[REGIONMODULE]: Not loading {0} because another module has registered {1}", module.Name,
                                replaceableInterface);
                            continue;
                        }

                        deferredSharedModules[replaceableInterface] = module;
                        //MainConsole.Instance.DebugFormat("[REGIONMODULE]: Deferred load of {0}", module.Name);
                        continue;
                    }

                    //MainConsole.Instance.DebugFormat("[REGIONMODULE]: Adding scene {0} to shared module {1}",
                    //                  scene.RegionInfo.RegionName, module.Name);
                    try
                    {
                        module.AddRegion(scene);
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                    }
                    AddRegionModule(scene, module.Name, module);

                    IRegionModuleBaseModules.Add(module);
                    sharedlist.Add(module);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.Warn("[RegionModulePlugin]: Failed to load plugin, " + ex);
                }
            }

            // Scan for, and load, nonshared modules
            List <INonSharedRegionModule> list = new List <INonSharedRegionModule>();
            List <INonSharedRegionModule> m_nonSharedModules = AuroraModuleLoader.PickupModules <INonSharedRegionModule>();

            foreach (INonSharedRegionModule module in m_nonSharedModules)
            {
                Type replaceableInterface = module.ReplaceableInterface;
                if (replaceableInterface != null)
                {
                    MethodInfo mii = mi.MakeGenericMethod(replaceableInterface);

                    if (mii.Invoke(scene, new object[0]) != null)
                    {
                        MainConsole.Instance.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}",
                                                         module.Name, replaceableInterface);
                        continue;
                    }

                    deferredNonSharedModules[replaceableInterface] = module;
                    MainConsole.Instance.DebugFormat("[REGIONMODULE]: Deferred load of {0}", module.Name);
                    continue;
                }

                if (module is ISharedRegionModule) //Don't load IShared!
                {
                    continue;
                }

                //MainConsole.Instance.DebugFormat("[REGIONMODULE]: Adding scene {0} to non-shared module {1}",
                //                  scene.RegionInfo.RegionName, module.Name);

                // Initialise the module
                module.Initialise(m_openSim.ConfigSource);

                IRegionModuleBaseModules.Add(module);
                list.Add(module);
            }

            // Now add the modules that we found to the scene. If a module
            // wishes to override a replaceable interface, it needs to
            // register it in Initialise, so that the deferred module
            // won't load.
            foreach (INonSharedRegionModule module in list)
            {
                try
                {
                    module.AddRegion(scene);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
                AddRegionModule(scene, module.Name, module);
            }

            // Now all modules without a replaceable base interface are loaded
            // Replaceable modules have either been skipped, or omitted.
            // Now scan the deferred modules here
            foreach (ISharedRegionModule module in deferredSharedModules.Values)
            {
                // Determine if the interface has been replaced
                Type       replaceableInterface = module.ReplaceableInterface;
                MethodInfo mii = mi.MakeGenericMethod(replaceableInterface);

                if (mii.Invoke(scene, new object[0]) != null)
                {
                    MainConsole.Instance.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}",
                                                     module.Name, replaceableInterface);
                    continue;
                }

                MainConsole.Instance.DebugFormat("[REGIONMODULE]: Adding scene {0} to shared module {1} (deferred)",
                                                 scene.RegionInfo.RegionName, module.Name);

                // Not replaced, load the module
                try
                {
                    module.AddRegion(scene);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
                AddRegionModule(scene, module.Name, module);

                IRegionModuleBaseModules.Add(module);
                sharedlist.Add(module);
            }

            // Same thing for nonshared modules, load them unless overridden
            List <INonSharedRegionModule> deferredlist =
                new List <INonSharedRegionModule>();

            foreach (INonSharedRegionModule module in deferredNonSharedModules.Values)
            {
                // Check interface override
                Type replaceableInterface = module.ReplaceableInterface;
                if (replaceableInterface != null)
                {
                    MethodInfo mii = mi.MakeGenericMethod(replaceableInterface);

                    if (mii.Invoke(scene, new object[0]) != null)
                    {
                        MainConsole.Instance.DebugFormat("[REGIONMODULE]: Not loading {0} because another module has registered {1}",
                                                         module.Name, replaceableInterface);
                        continue;
                    }
                }

                MainConsole.Instance.DebugFormat("[REGIONMODULE]: Adding scene {0} to non-shared module {1} (deferred)",
                                                 scene.RegionInfo.RegionName, module.Name);

                try
                {
                    module.Initialise(m_openSim.ConfigSource);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }

                IRegionModuleBaseModules.Add(module);
                list.Add(module);
                deferredlist.Add(module);
            }

            // Finally, load valid deferred modules
            foreach (INonSharedRegionModule module in deferredlist)
            {
                try
                {
                    module.AddRegion(scene);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
                AddRegionModule(scene, module.Name, module);
            }

            // This is needed for all module types. Modules will register
            // Interfaces with scene in AddScene, and will also need a means
            // to access interfaces registered by other modules. Without
            // this extra method, a module attempting to use another modules's
            // interface would be successful only depending on load order,
            // which can't be depended upon, or modules would need to resort
            // to ugly kludges to attempt to request interfaces when needed
            // and unneccessary caching logic repeated in all modules.
            // The extra function stub is just that much cleaner
            //
            foreach (ISharedRegionModule module in sharedlist)
            {
                try
                {
                    module.RegionLoaded(scene);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
            }

            foreach (INonSharedRegionModule module in list)
            {
                try
                {
                    module.RegionLoaded(scene);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.ErrorFormat("[RegionModulesControllerPlugin]: Failed to load module {0}: {1}", module.Name, ex.ToString());
                }
            }
        }
Beispiel #29
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);
        }
Beispiel #30
0
        public void Initialise(IConfigSource source, IRegistryCore simBase)
        {
            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = source.Configs["DatabaseService"];

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

            //
            // [AuroraData] section overrides [DatabaseService], if it exists
            //
            IConfig m_config = source.Configs["AuroraData"];

            if (m_config != null)
            {
                StorageProvider  = m_config.GetString("StorageProvider", StorageProvider);
                ConnectionString = m_config.GetString("ConnectionString", ConnectionString);
            }

            IGenericData DataConnector = null;

            if (StorageProvider == "MySQL" || StorageProvider == "Aurora.DataManager.MySQL.dll")
            //Allow for fallback when AuroraData isn't set
            {
                MySQLDataLoader GenericData = new MySQLDataLoader();

                DataConnector = GenericData;
            }

            /*else if (StorageProvider == "MSSQL2008")
             * {
             *  MSSQLDataLoader GenericData = new MSSQLDataLoader();
             *
             *  DataConnector = GenericData;
             * }
             * else if (StorageProvider == "MSSQL7")
             * {
             *  MSSQLDataLoader GenericData = new MSSQLDataLoader();
             *
             *  DataConnector = GenericData;
             * }*/
            else if (StorageProvider == "SQLite" || StorageProvider == "Aurora.DataManager.SQLite.dll")
            //Allow for fallback when AuroraData isn't set
            {
                SQLiteLoader GenericData = new SQLiteLoader();

                DataConnector = GenericData;
            }

            List <IAuroraDataPlugin> Plugins = AuroraModuleLoader.PickupModules <IAuroraDataPlugin>();

            foreach (IAuroraDataPlugin plugin in Plugins)
            {
                try
                {
                    plugin.Initialize(DataConnector.Copy(), source, simBase, ConnectionString);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.Warn("[DataService]: Exeception occured starting data plugin " + plugin.Name + ", " + ex.ToString());
                }
            }
        }