From 19aab3e6fea9c14d28c952c4e1f38919a4cc4363 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 16:28:30 -0800 Subject: Converted the WindModule to the new region module interface (38 to go). Also added both the WindModule and the SunModule to the Plugin manifest. --- .../Resources/CoreModulePlugin.addin.xml | 2 + OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 16 +- .../Region/CoreModules/World/Wind/WindModule.cs | 182 +++++++++++---------- OpenSim/Region/Framework/Interfaces/IWindModule.cs | 2 +- 4 files changed, 107 insertions(+), 95 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 6c73d91..2ddd0b6 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -38,6 +38,8 @@ + + diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index df025bf..bdbf273 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -278,14 +278,6 @@ namespace OpenSim.Region.CoreModules // This one puts an entry in the main help screen // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); - // This one enables the ability to type just "sun" without any parameters -// m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); - foreach (KeyValuePair kvp in GetParamList()) - { - string sunCommand = string.Format("sun {0}", kvp.Key); - m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} []", sunCommand), kvp.Value, "", HandleSunConsoleCommand); - } - TimeZone local = TimeZone.CurrentTimeZone; TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); @@ -385,6 +377,14 @@ namespace OpenSim.Region.CoreModules scene.RegisterModuleInterface(this); + // This one enables the ability to type just "sun" without any parameters + // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); + foreach (KeyValuePair kvp in GetParamList()) + { + string sunCommand = string.Format("sun {0}", kvp.Key); + m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} []", sunCommand), kvp.Value, "", HandleSunConsoleCommand); + } + ready = true; } diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 7b6fbda..0186a41 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -52,31 +52,31 @@ namespace OpenSim.Region.CoreModules private bool m_ready = false; private bool m_enabled = false; - + private IConfig m_windConfig; private IWindModelPlugin m_activeWindPlugin = null; - private const string m_dWindPluginName = "SimpleRandomWind"; + private string m_dWindPluginName = "SimpleRandomWind"; private Dictionary m_availableWindPlugins = new Dictionary(); // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m private Vector2[] windSpeeds = new Vector2[16 * 16]; - #region IRegion Methods + #region INonSharedRegionModule Methods - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - IConfig windConfig = config.Configs["Wind"]; + m_windConfig = config.Configs["Wind"]; string desiredWindPlugin = m_dWindPluginName; - if (windConfig != null) + if (m_windConfig != null) { - m_enabled = windConfig.GetBoolean("enabled", true); + m_enabled = m_windConfig.GetBoolean("enabled", true); - m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150); + m_frameUpdateRate = m_windConfig.GetInt("wind_update_rate", 150); // Determine which wind model plugin is desired - if (windConfig.Contains("wind_plugin")) + if (m_windConfig.Contains("wind_plugin")) { - desiredWindPlugin = windConfig.GetString("wind_plugin"); + m_dWindPluginName = m_windConfig.GetString("wind_plugin", m_dWindPluginName); } } @@ -84,104 +84,111 @@ namespace OpenSim.Region.CoreModules { m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); - m_scene = scene; - m_frame = 0; - - // Register all the Wind Model Plug-ins - foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) - { - m_log.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]; + } - m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin); + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; - if (windConfig != null) - { - m_activeWindPlugin.Initialise(); - m_activeWindPlugin.WindConfig(m_scene, windConfig); - } - } + m_scene = scene; + m_frame = 0; + // Register all the Wind Model Plug-ins + foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) + { + m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name); + m_availableWindPlugins.Add(windPlugin.Name, windPlugin); + } - // if the plug-in wasn't found, default to no wind. - if (m_activeWindPlugin == null) - { - m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin); - m_log.ErrorFormat("[WIND] Defaulting to no wind."); - } + // Check for desired plugin + if (m_availableWindPlugins.ContainsKey(m_dWindPluginName)) + { + m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName]; - // This one puts an entry in the main help screen -// m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind [value] - Get or Update Wind paramaters", null); - - // This one enables the ability to type just the base command without any parameters -// m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); + m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName); - // Get a list of the parameters for each plugin - foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) + if (m_windConfig != null) { -// m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); - m_scene.AddCommand( - "Regions", - this, - "wind base wind_update_rate", - "wind base wind_update_rate []", - "Get or set the wind update rate.", - "", - HandleConsoleBaseCommand); - - foreach (KeyValuePair kvp in windPlugin.WindParams()) - { - string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); - m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} []", windCommand), kvp.Value, "", HandleConsoleParamCommand); - } + m_activeWindPlugin.Initialise(); + m_activeWindPlugin.WindConfig(m_scene, m_windConfig); } + } - // 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(this); + // if the plug-in wasn't found, default to no wind. + if (m_activeWindPlugin == null) + { + m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName); + m_log.ErrorFormat("[WIND] Defaulting to no wind."); + } - // Generate initial wind values - GenWindPos(); + // This one puts an entry in the main help screen + // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind [value] - Get or Update Wind paramaters", null); - // Mark Module Ready for duty - m_ready = true; + // This one enables the ability to type just the base command without any parameters + // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); + // Get a list of the parameters for each plugin + foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) + { + // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); + m_scene.AddCommand( + "Regions", + this, + "wind base wind_update_rate", + "wind base wind_update_rate []", + "Get or set the wind update rate.", + "", + HandleConsoleBaseCommand); + + foreach (KeyValuePair kvp in windPlugin.WindParams()) + { + string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); + m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} []", windCommand), 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; - public void PostInitialise() - { + // Register the wind module + m_scene.RegisterModuleInterface(this); + + // Generate initial wind values + GenWindPos(); + + // Mark Module Ready for duty + m_ready = true; } - public void Close() + public void RemoveRegion(Scene scene) { - if (m_enabled) + if (!m_enabled) + return; + + m_ready = false; + + // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? + m_activeWindPlugin = null; + foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) { - m_ready = false; + windPlugin.Dispose(); + } - // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? - m_activeWindPlugin = null; - foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) - { - windPlugin.Dispose(); - } + m_availableWindPlugins.Clear(); - m_availableWindPlugins.Clear(); + // Remove our hooks + m_scene.EventManager.OnFrame -= WindUpdate; + m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; - // Remove our hooks - m_scene.EventManager.OnFrame -= WindUpdate; - m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; - } + } + + public void Close() + { } public string Name @@ -189,11 +196,14 @@ namespace OpenSim.Region.CoreModules get { return "WindModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } + public void RegionLoaded(Scene scene) + { + } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/IWindModule.cs b/OpenSim/Region/Framework/Interfaces/IWindModule.cs index 10ecc32..4a26a71 100644 --- a/OpenSim/Region/Framework/Interfaces/IWindModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWindModule.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { - public interface IWindModule : IRegionModule + public interface IWindModule : INonSharedRegionModule { /// -- cgit v1.1