diff options
author | Melanie | 2012-11-11 16:31:01 +0000 |
---|---|---|
committer | Melanie | 2012-11-11 16:31:01 +0000 |
commit | 389077345f9fc78fddcaa39e29daa532a32815d6 (patch) | |
tree | a455d88d93ac5fe984ebf5342276ca1ddc831442 /OpenSim/Region/CoreModules/World | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Deleted 2 obsolete modules: OGSRadmin and OpenGridProtocol. They were still I... (diff) | |
download | opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.zip opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.gz opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.bz2 opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
5 files changed, 248 insertions, 145 deletions
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs index 5fa3dc2..2ec6ff9 100644 --- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs +++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Scenes; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.CoreModules | 36 | namespace OpenSim.Region.CoreModules |
37 | { | 37 | { |
38 | public class CloudModule : ICloudModule | 38 | public class CloudModule : ICloudModule, INonSharedRegionModule |
39 | { | 39 | { |
40 | // private static readonly log4net.ILog m_log | 40 | // private static readonly log4net.ILog m_log |
41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules | |||
48 | private float m_cloudDensity = 1.0F; | 48 | private float m_cloudDensity = 1.0F; |
49 | private float[] cloudCover = new float[16 * 16]; | 49 | private float[] cloudCover = new float[16 * 16]; |
50 | 50 | ||
51 | public void Initialise(Scene scene, IConfigSource config) | 51 | public void Initialise(IConfigSource config) |
52 | { | 52 | { |
53 | IConfig cloudConfig = config.Configs["Cloud"]; | 53 | IConfig cloudConfig = config.Configs["Cloud"]; |
54 | 54 | ||
@@ -59,21 +59,40 @@ namespace OpenSim.Region.CoreModules | |||
59 | m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); | 59 | m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); |
60 | } | 60 | } |
61 | 61 | ||
62 | if (m_enabled) | 62 | } |
63 | { | ||
64 | 63 | ||
65 | m_scene = scene; | 64 | public void AddRegion(Scene scene) |
65 | { | ||
66 | if (!m_enabled) | ||
67 | return; | ||
66 | 68 | ||
67 | scene.EventManager.OnNewClient += CloudsToClient; | 69 | m_scene = scene; |
68 | scene.RegisterModuleInterface<ICloudModule>(this); | ||
69 | scene.EventManager.OnFrame += CloudUpdate; | ||
70 | 70 | ||
71 | GenerateCloudCover(); | 71 | scene.EventManager.OnNewClient += CloudsToClient; |
72 | scene.RegisterModuleInterface<ICloudModule>(this); | ||
73 | scene.EventManager.OnFrame += CloudUpdate; | ||
72 | 74 | ||
73 | m_ready = true; | 75 | GenerateCloudCover(); |
74 | 76 | ||
75 | } | 77 | m_ready = true; |
78 | } | ||
79 | |||
80 | public void RemoveRegion(Scene scene) | ||
81 | { | ||
82 | if (!m_enabled) | ||
83 | return; | ||
76 | 84 | ||
85 | m_ready = false; | ||
86 | // Remove our hooks | ||
87 | m_scene.EventManager.OnNewClient -= CloudsToClient; | ||
88 | m_scene.EventManager.OnFrame -= CloudUpdate; | ||
89 | m_scene.UnregisterModuleInterface<ICloudModule>(this); | ||
90 | |||
91 | m_scene = null; | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
77 | } | 96 | } |
78 | 97 | ||
79 | public void PostInitialise() | 98 | public void PostInitialise() |
@@ -82,13 +101,6 @@ namespace OpenSim.Region.CoreModules | |||
82 | 101 | ||
83 | public void Close() | 102 | public void Close() |
84 | { | 103 | { |
85 | if (m_enabled) | ||
86 | { | ||
87 | m_ready = false; | ||
88 | // Remove our hooks | ||
89 | m_scene.EventManager.OnNewClient -= CloudsToClient; | ||
90 | m_scene.EventManager.OnFrame -= CloudUpdate; | ||
91 | } | ||
92 | } | 104 | } |
93 | 105 | ||
94 | public string Name | 106 | public string Name |
@@ -96,12 +108,11 @@ namespace OpenSim.Region.CoreModules | |||
96 | get { return "CloudModule"; } | 108 | get { return "CloudModule"; } |
97 | } | 109 | } |
98 | 110 | ||
99 | public bool IsSharedModule | 111 | public Type ReplaceableInterface |
100 | { | 112 | { |
101 | get { return false; } | 113 | get { return null; } |
102 | } | 114 | } |
103 | 115 | ||
104 | |||
105 | public float CloudCover(int x, int y, int z) | 116 | public float CloudCover(int x, int y, int z) |
106 | { | 117 | { |
107 | float cover = 0f; | 118 | float cover = 0f; |
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 9a954b8..bdbf273 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -267,26 +267,17 @@ namespace OpenSim.Region.CoreModules | |||
267 | return GetCurrentSunHour() + 6.0f; | 267 | return GetCurrentSunHour() + 6.0f; |
268 | } | 268 | } |
269 | 269 | ||
270 | #region IRegion Methods | 270 | #region INonSharedRegion Methods |
271 | 271 | ||
272 | // Called immediately after the module is loaded for a given region | 272 | // Called immediately after the module is loaded for a given region |
273 | // i.e. Immediately after instance creation. | 273 | // i.e. Immediately after instance creation. |
274 | public void Initialise(Scene scene, IConfigSource config) | 274 | public void Initialise(IConfigSource config) |
275 | { | 275 | { |
276 | m_scene = scene; | ||
277 | m_frame = 0; | 276 | m_frame = 0; |
278 | 277 | ||
279 | // This one puts an entry in the main help screen | 278 | // This one puts an entry in the main help screen |
280 | // 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); |
281 | 280 | ||
282 | // This one enables the ability to type just "sun" without any parameters | ||
283 | // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); | ||
284 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
285 | { | ||
286 | string sunCommand = string.Format("sun {0}", kvp.Key); | ||
287 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | ||
288 | } | ||
289 | |||
290 | TimeZone local = TimeZone.CurrentTimeZone; | 281 | TimeZone local = TimeZone.CurrentTimeZone; |
291 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 282 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
292 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); | 283 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); |
@@ -358,15 +349,6 @@ namespace OpenSim.Region.CoreModules | |||
358 | HorizonShift = m_HorizonShift; // Z axis translation | 349 | HorizonShift = m_HorizonShift; // Z axis translation |
359 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; | 350 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; |
360 | 351 | ||
361 | // Insert our event handling hooks | ||
362 | |||
363 | scene.EventManager.OnFrame += SunUpdate; | ||
364 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
365 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
366 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
367 | |||
368 | ready = true; | ||
369 | |||
370 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); | 352 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); |
371 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | 353 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); |
372 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); | 354 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); |
@@ -376,14 +358,37 @@ namespace OpenSim.Region.CoreModules | |||
376 | break; | 358 | break; |
377 | } | 359 | } |
378 | 360 | ||
379 | scene.RegisterModuleInterface<ISunModule>(this); | ||
380 | } | 361 | } |
381 | 362 | ||
382 | public void PostInitialise() | 363 | public Type ReplaceableInterface |
383 | { | 364 | { |
365 | get { return null; } | ||
384 | } | 366 | } |
385 | 367 | ||
386 | public void Close() | 368 | public void AddRegion(Scene scene) |
369 | { | ||
370 | m_scene = scene; | ||
371 | // Insert our event handling hooks | ||
372 | |||
373 | scene.EventManager.OnFrame += SunUpdate; | ||
374 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
375 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
376 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
377 | |||
378 | scene.RegisterModuleInterface<ISunModule>(this); | ||
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; | ||
389 | } | ||
390 | |||
391 | public void RemoveRegion(Scene scene) | ||
387 | { | 392 | { |
388 | ready = false; | 393 | ready = false; |
389 | 394 | ||
@@ -394,14 +399,17 @@ namespace OpenSim.Region.CoreModules | |||
394 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; | 399 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; |
395 | } | 400 | } |
396 | 401 | ||
397 | public string Name | 402 | public void RegionLoaded(Scene scene) |
398 | { | 403 | { |
399 | get { return "SunModule"; } | ||
400 | } | 404 | } |
401 | 405 | ||
402 | public bool IsSharedModule | 406 | public void Close() |
403 | { | 407 | { |
404 | get { return false; } | 408 | } |
409 | |||
410 | public string Name | ||
411 | { | ||
412 | get { return "SunModule"; } | ||
405 | } | 413 | } |
406 | 414 | ||
407 | #endregion | 415 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs index f5f35bb..528da0e3 100644 --- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs +++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs | |||
@@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.Avatar.Vegetation | 37 | namespace OpenSim.Region.CoreModules.Avatar.Vegetation |
38 | { | 38 | { |
39 | public class VegetationModule : IRegionModule, IVegetationModule | 39 | public class VegetationModule : INonSharedRegionModule, IVegetationModule |
40 | { | 40 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
@@ -45,16 +45,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation | |||
45 | protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; | 45 | protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; |
46 | public PCode[] CreationCapabilities { get { return creationCapabilities; } } | 46 | public PCode[] CreationCapabilities { get { return creationCapabilities; } } |
47 | 47 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 48 | public void Initialise(IConfigSource source) |
49 | { | ||
50 | } | ||
51 | |||
52 | public void AddRegion(Scene scene) | ||
49 | { | 53 | { |
50 | m_scene = scene; | 54 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IVegetationModule>(this); | 55 | m_scene.RegisterModuleInterface<IVegetationModule>(this); |
52 | } | 56 | } |
53 | 57 | ||
54 | public void PostInitialise() {} | 58 | public void RemoveRegion(Scene scene) |
59 | { | ||
60 | m_scene.UnregisterModuleInterface<IVegetationModule>(this); | ||
61 | } | ||
62 | |||
55 | public void Close() {} | 63 | public void Close() {} |
56 | public string Name { get { return "Vegetation Module"; } } | 64 | public string Name { get { return "Vegetation Module"; } } |
57 | public bool IsSharedModule { get { return false; } } | 65 | |
66 | public Type ReplaceableInterface | ||
67 | { | ||
68 | get { return null; } | ||
69 | } | ||
70 | |||
71 | public void RegionLoaded(Scene scene) | ||
72 | { | ||
73 | } | ||
58 | 74 | ||
59 | public SceneObjectGroup AddTree( | 75 | public SceneObjectGroup AddTree( |
60 | UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) | 76 | UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) |
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/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 2417b1a..dc0c110 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
@@ -37,16 +38,21 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.World.WorldMap | 39 | namespace OpenSim.Region.CoreModules.World.WorldMap |
39 | { | 40 | { |
40 | public class MapSearchModule : IRegionModule | 41 | public class MapSearchModule : ISharedRegionModule |
41 | { | 42 | { |
42 | private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
45 | Scene m_scene = null; // only need one for communication with GridService | 46 | Scene m_scene = null; // only need one for communication with GridService |
46 | List<Scene> m_scenes = new List<Scene>(); | 47 | List<Scene> m_scenes = new List<Scene>(); |
48 | List<UUID> m_Clients; | ||
47 | 49 | ||
48 | #region IRegionModule Members | 50 | #region ISharedRegionModule Members |
49 | public void Initialise(Scene scene, IConfigSource source) | 51 | public void Initialise(IConfigSource source) |
52 | { | ||
53 | } | ||
54 | |||
55 | public void AddRegion(Scene scene) | ||
50 | { | 56 | { |
51 | if (m_scene == null) | 57 | if (m_scene == null) |
52 | { | 58 | { |
@@ -55,6 +61,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
55 | 61 | ||
56 | m_scenes.Add(scene); | 62 | m_scenes.Add(scene); |
57 | scene.EventManager.OnNewClient += OnNewClient; | 63 | scene.EventManager.OnNewClient += OnNewClient; |
64 | m_Clients = new List<UUID>(); | ||
65 | } | ||
66 | |||
67 | public void RemoveRegion(Scene scene) | ||
68 | { | ||
69 | m_scenes.Remove(scene); | ||
70 | if (m_scene == scene && m_scenes.Count > 0) | ||
71 | m_scene = m_scenes[0]; | ||
72 | |||
73 | scene.EventManager.OnNewClient -= OnNewClient; | ||
58 | } | 74 | } |
59 | 75 | ||
60 | public void PostInitialise() | 76 | public void PostInitialise() |
@@ -72,16 +88,44 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
72 | get { return "MapSearchModule"; } | 88 | get { return "MapSearchModule"; } |
73 | } | 89 | } |
74 | 90 | ||
75 | public bool IsSharedModule | 91 | public Type ReplaceableInterface |
76 | { | 92 | { |
77 | get { return true; } | 93 | get { return null; } |
78 | } | 94 | } |
79 | 95 | ||
96 | public void RegionLoaded(Scene scene) | ||
97 | { | ||
98 | } | ||
80 | #endregion | 99 | #endregion |
81 | 100 | ||
82 | private void OnNewClient(IClientAPI client) | 101 | private void OnNewClient(IClientAPI client) |
83 | { | 102 | { |
84 | client.OnMapNameRequest += OnMapNameRequest; | 103 | client.OnMapNameRequest += OnMapNameRequestHandler; |
104 | } | ||
105 | |||
106 | private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags) | ||
107 | { | ||
108 | lock (m_Clients) | ||
109 | { | ||
110 | if (m_Clients.Contains(remoteClient.AgentId)) | ||
111 | return; | ||
112 | |||
113 | m_Clients.Add(remoteClient.AgentId); | ||
114 | } | ||
115 | |||
116 | Util.FireAndForget(delegate | ||
117 | { | ||
118 | try | ||
119 | { | ||
120 | OnMapNameRequest(remoteClient, mapName, flags); | ||
121 | } | ||
122 | finally | ||
123 | { | ||
124 | lock (m_Clients) | ||
125 | m_Clients.Remove(remoteClient.AgentId); | ||
126 | } | ||
127 | }); | ||
128 | |||
85 | } | 129 | } |
86 | 130 | ||
87 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 131 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
@@ -175,6 +219,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
175 | }); | 219 | }); |
176 | } | 220 | } |
177 | 221 | ||
222 | private void AddFinalBlock(List<MapBlockData> blocks) | ||
223 | { | ||
224 | // final block, closing the search result | ||
225 | MapBlockData data = new MapBlockData(); | ||
226 | data.Agents = 0; | ||
227 | data.Access = 255; | ||
228 | data.MapImageId = UUID.Zero; | ||
229 | data.Name = ""; | ||
230 | data.RegionFlags = 0; | ||
231 | data.WaterHeight = 0; // not used | ||
232 | data.X = 0; | ||
233 | data.Y = 0; | ||
234 | blocks.Add(data); | ||
235 | } | ||
178 | // private Scene GetClientScene(IClientAPI client) | 236 | // private Scene GetClientScene(IClientAPI client) |
179 | // { | 237 | // { |
180 | // foreach (Scene s in m_scenes) | 238 | // foreach (Scene s in m_scenes) |