aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2012-11-09 16:28:30 -0800
committerDiva Canto2012-11-09 16:28:30 -0800
commit19aab3e6fea9c14d28c952c4e1f38919a4cc4363 (patch)
tree3aec4ee8dcfd1b8bbae05789603fb6116bbb24a8
parentConverted the SunModule to the new region module interface. (39 to go...) (diff)
downloadopensim-SC_OLD-19aab3e6fea9c14d28c952c4e1f38919a4cc4363.zip
opensim-SC_OLD-19aab3e6fea9c14d28c952c4e1f38919a4cc4363.tar.gz
opensim-SC_OLD-19aab3e6fea9c14d28c952c4e1f38919a4cc4363.tar.bz2
opensim-SC_OLD-19aab3e6fea9c14d28c952c4e1f38919a4cc4363.tar.xz
Converted the WindModule to the new region module interface (38 to go). Also added both the WindModule and the SunModule to the Plugin manifest.
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml2
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs182
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWindModule.cs2
4 files changed, 107 insertions, 95 deletions
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 @@
38 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> 38 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" />
39 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> 39 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/>
40 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> 40 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/>
41 <RegionModule id="SunModule" type="OpenSim.Region.CoreModules.SunModule"/>
42 <RegionModule id="WindModule" type="OpenSim.Region.CoreModules.WindModule"/>
41 <!-- Service connectors OUT modules --> 43 <!-- Service connectors OUT modules -->
42 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> 44 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" />
43 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> 45 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" />
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
278 // This one puts an entry in the main help screen 278 // This one puts an entry in the main help screen
279// m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); 279// m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null);
280 280
281 // This one enables the ability to type just "sun" without any parameters
282// m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand);
283 foreach (KeyValuePair<string, string> kvp in GetParamList())
284 {
285 string sunCommand = string.Format("sun {0}", kvp.Key);
286 m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand);
287 }
288
289 TimeZone local = TimeZone.CurrentTimeZone; 281 TimeZone local = TimeZone.CurrentTimeZone;
290 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; 282 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
291 m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); 283 m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset);
@@ -385,6 +377,14 @@ namespace OpenSim.Region.CoreModules
385 377
386 scene.RegisterModuleInterface<ISunModule>(this); 378 scene.RegisterModuleInterface<ISunModule>(this);
387 379
380 // This one enables the ability to type just "sun" without any parameters
381 // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand);
382 foreach (KeyValuePair<string, string> kvp in GetParamList())
383 {
384 string sunCommand = string.Format("sun {0}", kvp.Key);
385 m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand);
386 }
387
388 ready = true; 388 ready = true;
389 } 389 }
390 390
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
52 private bool m_ready = false; 52 private bool m_ready = false;
53 53
54 private bool m_enabled = false; 54 private bool m_enabled = false;
55 55 private IConfig m_windConfig;
56 private IWindModelPlugin m_activeWindPlugin = null; 56 private IWindModelPlugin m_activeWindPlugin = null;
57 private const string m_dWindPluginName = "SimpleRandomWind"; 57 private string m_dWindPluginName = "SimpleRandomWind";
58 private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>(); 58 private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>();
59 59
60 // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m 60 // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
61 private Vector2[] windSpeeds = new Vector2[16 * 16]; 61 private Vector2[] windSpeeds = new Vector2[16 * 16];
62 62
63 #region IRegion Methods 63 #region INonSharedRegionModule Methods
64 64
65 public void Initialise(Scene scene, IConfigSource config) 65 public void Initialise(IConfigSource config)
66 { 66 {
67 IConfig windConfig = config.Configs["Wind"]; 67 m_windConfig = config.Configs["Wind"];
68 string desiredWindPlugin = m_dWindPluginName; 68 string desiredWindPlugin = m_dWindPluginName;
69 69
70 if (windConfig != null) 70 if (m_windConfig != null)
71 { 71 {
72 m_enabled = windConfig.GetBoolean("enabled", true); 72 m_enabled = m_windConfig.GetBoolean("enabled", true);
73 73
74 m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150); 74 m_frameUpdateRate = m_windConfig.GetInt("wind_update_rate", 150);
75 75
76 // Determine which wind model plugin is desired 76 // Determine which wind model plugin is desired
77 if (windConfig.Contains("wind_plugin")) 77 if (m_windConfig.Contains("wind_plugin"))
78 { 78 {
79 desiredWindPlugin = windConfig.GetString("wind_plugin"); 79 m_dWindPluginName = m_windConfig.GetString("wind_plugin", m_dWindPluginName);
80 } 80 }
81 } 81 }
82 82
@@ -84,104 +84,111 @@ namespace OpenSim.Region.CoreModules
84 { 84 {
85 m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); 85 m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);
86 86
87 m_scene = scene; 87 }
88 m_frame = 0;
89
90 // Register all the Wind Model Plug-ins
91 foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
92 {
93 m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
94 m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
95 }
96 88
97 // Check for desired plugin 89 }
98 if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
99 {
100 m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];
101 90
102 m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin); 91 public void AddRegion(Scene scene)
92 {
93 if (!m_enabled)
94 return;
103 95
104 if (windConfig != null) 96 m_scene = scene;
105 { 97 m_frame = 0;
106 m_activeWindPlugin.Initialise();
107 m_activeWindPlugin.WindConfig(m_scene, windConfig);
108 }
109 }
110 98
99 // Register all the Wind Model Plug-ins
100 foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
101 {
102 m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
103 m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
104 }
111 105
112 // if the plug-in wasn't found, default to no wind. 106 // Check for desired plugin
113 if (m_activeWindPlugin == null) 107 if (m_availableWindPlugins.ContainsKey(m_dWindPluginName))
114 { 108 {
115 m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin); 109 m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName];
116 m_log.ErrorFormat("[WIND] Defaulting to no wind.");
117 }
118 110
119 // This one puts an entry in the main help screen 111 m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName);
120// m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);
121
122 // This one enables the ability to type just the base command without any parameters
123// m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);
124 112
125 // Get a list of the parameters for each plugin 113 if (m_windConfig != null)
126 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
127 { 114 {
128// m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); 115 m_activeWindPlugin.Initialise();
129 m_scene.AddCommand( 116 m_activeWindPlugin.WindConfig(m_scene, m_windConfig);
130 "Regions",
131 this,
132 "wind base wind_update_rate",
133 "wind base wind_update_rate [<value>]",
134 "Get or set the wind update rate.",
135 "",
136 HandleConsoleBaseCommand);
137
138 foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
139 {
140 string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
141 m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
142 }
143 } 117 }
118 }
144 119
145 // Register event handlers for when Avatars enter the region, and frame ticks
146 m_scene.EventManager.OnFrame += WindUpdate;
147 m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
148 120
149 // Register the wind module 121 // if the plug-in wasn't found, default to no wind.
150 m_scene.RegisterModuleInterface<IWindModule>(this); 122 if (m_activeWindPlugin == null)
123 {
124 m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName);
125 m_log.ErrorFormat("[WIND] Defaulting to no wind.");
126 }
151 127
152 // Generate initial wind values 128 // This one puts an entry in the main help screen
153 GenWindPos(); 129 // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);
154 130
155 // Mark Module Ready for duty 131 // This one enables the ability to type just the base command without any parameters
156 m_ready = true; 132 // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);
157 133
134 // Get a list of the parameters for each plugin
135 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
136 {
137 // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand);
138 m_scene.AddCommand(
139 "Regions",
140 this,
141 "wind base wind_update_rate",
142 "wind base wind_update_rate [<value>]",
143 "Get or set the wind update rate.",
144 "",
145 HandleConsoleBaseCommand);
146
147 foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
148 {
149 string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
150 m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
151 }
158 } 152 }
159 153
160 } 154 // Register event handlers for when Avatars enter the region, and frame ticks
155 m_scene.EventManager.OnFrame += WindUpdate;
156 m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
161 157
162 public void PostInitialise() 158 // Register the wind module
163 { 159 m_scene.RegisterModuleInterface<IWindModule>(this);
160
161 // Generate initial wind values
162 GenWindPos();
163
164 // Mark Module Ready for duty
165 m_ready = true;
164 } 166 }
165 167
166 public void Close() 168 public void RemoveRegion(Scene scene)
167 { 169 {
168 if (m_enabled) 170 if (!m_enabled)
171 return;
172
173 m_ready = false;
174
175 // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
176 m_activeWindPlugin = null;
177 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
169 { 178 {
170 m_ready = false; 179 windPlugin.Dispose();
180 }
171 181
172 // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? 182 m_availableWindPlugins.Clear();
173 m_activeWindPlugin = null;
174 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
175 {
176 windPlugin.Dispose();
177 }
178 183
179 m_availableWindPlugins.Clear(); 184 // Remove our hooks
185 m_scene.EventManager.OnFrame -= WindUpdate;
186 m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
180 187
181 // Remove our hooks 188 }
182 m_scene.EventManager.OnFrame -= WindUpdate; 189
183 m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; 190 public void Close()
184 } 191 {
185 } 192 }
186 193
187 public string Name 194 public string Name
@@ -189,11 +196,14 @@ namespace OpenSim.Region.CoreModules
189 get { return "WindModule"; } 196 get { return "WindModule"; }
190 } 197 }
191 198
192 public bool IsSharedModule 199 public Type ReplaceableInterface
193 { 200 {
194 get { return false; } 201 get { return null; }
195 } 202 }
196 203
204 public void RegionLoaded(Scene scene)
205 {
206 }
197 207
198 #endregion 208 #endregion
199 209
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;
29 29
30namespace OpenSim.Region.Framework.Interfaces 30namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public interface IWindModule : IRegionModule 32 public interface IWindModule : INonSharedRegionModule
33 { 33 {
34 34
35 /// <summary> 35 /// <summary>