aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorHomer Horwitz2009-04-13 21:23:33 +0000
committerHomer Horwitz2009-04-13 21:23:33 +0000
commit6db21bbf97b33bca017dcbc3b83687daa33f50b5 (patch)
treebc8244d0f3387ec9578f5c17eb2bf88603252cfb /OpenSim
parentRemove m_moduleCommands. It wasn't used anywhere; probably a left-over from b... (diff)
downloadopensim-SC-6db21bbf97b33bca017dcbc3b83687daa33f50b5.zip
opensim-SC-6db21bbf97b33bca017dcbc3b83687daa33f50b5.tar.gz
opensim-SC-6db21bbf97b33bca017dcbc3b83687daa33f50b5.tar.bz2
opensim-SC-6db21bbf97b33bca017dcbc3b83687daa33f50b5.tar.xz
- Moved TerrainModule to the new region-module system.
- Fixed some locking issues. Either lock, or don't (if you don't have to). Only locking access half of the time won't work reliably. - Had to adapt test helpers that use the "old" IRegionModule. TerrainModule isn't one anymore.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs70
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs35
3 files changed, 70 insertions, 37 deletions
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 6db1042..8b5f26f 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -8,7 +8,7 @@
8 </Dependencies> 8 </Dependencies>
9 9
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11<!-- <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> --> 11 <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" />
12 </Extension> 12 </Extension>
13 13
14 <Extension path = "/OpenSim/WindModule"> 14 <Extension path = "/OpenSim/WindModule">
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 7793aa5..9f1867f 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -42,7 +42,7 @@ using OpenSim.Region.Framework.Scenes;
42 42
43namespace OpenSim.Region.CoreModules.World.Terrain 43namespace OpenSim.Region.CoreModules.World.Terrain
44{ 44{
45 public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule 45 public class TerrainModule : INonSharedRegionModule, ICommandableModule, ITerrainModule
46 { 46 {
47 #region StandardTerrainEffects enum 47 #region StandardTerrainEffects enum
48 48
@@ -93,49 +93,62 @@ namespace OpenSim.Region.CoreModules.World.Terrain
93 93
94 #endregion 94 #endregion
95 95
96 #region IRegionModule Members 96 #region INonSharedRegionModule Members
97 97
98 /// <summary> 98 /// <summary>
99 /// Creates and initialises a terrain module for a region 99 /// Creates and initialises a terrain module for a region
100 /// </summary> 100 /// </summary>
101 /// <param name="scene">Region initialising</param> 101 /// <param name="scene">Region initialising</param>
102 /// <param name="config">Config for the region</param> 102 /// <param name="config">Config for the region</param>
103 public void Initialise(Scene scene, IConfigSource config) 103 public void Initialise(IConfigSource config)
104 {
105 }
106
107 public void AddRegion(Scene scene)
104 { 108 {
105 m_scene = scene; 109 m_scene = scene;
106 110
107 // Install terrain module in the simulator 111 // Install terrain module in the simulator
108 if (m_scene.Heightmap == null) 112 lock (m_scene)
109 { 113 {
110 lock (m_scene) 114 if (m_scene.Heightmap == null)
111 { 115 {
112 m_channel = new TerrainChannel(); 116 m_channel = new TerrainChannel();
113 m_scene.Heightmap = m_channel; 117 m_scene.Heightmap = m_channel;
114 m_revert = new TerrainChannel(); 118 m_revert = new TerrainChannel();
115 UpdateRevertMap(); 119 UpdateRevertMap();
116 } 120 }
117 } 121 else
118 else 122 {
119 { 123 m_channel = m_scene.Heightmap;
120 m_channel = m_scene.Heightmap; 124 m_revert = new TerrainChannel();
121 m_revert = new TerrainChannel(); 125 UpdateRevertMap();
122 UpdateRevertMap(); 126 }
127
128 m_scene.RegisterModuleInterface<ITerrainModule>(this);
129 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
130 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
131 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
132 InstallInterfaces();
123 } 133 }
124 134
125 m_scene.RegisterModuleInterface<ITerrainModule>(this); 135 InstallDefaultEffects();
126 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 136 LoadPlugins();
127 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
128 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
129 } 137 }
130 138
131 /// <summary> 139 public void RemoveRegion(Scene scene)
132 /// Enables terrain module when called
133 /// </summary>
134 public void PostInitialise()
135 { 140 {
136 InstallDefaultEffects(); 141 lock (m_scene)
137 InstallInterfaces(); 142 {
138 LoadPlugins(); 143 // remove the commands
144 m_scene.UnregisterModuleCommander(m_commander.Name);
145 // remove the event-handlers
146 m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick;
147 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole;
148 m_scene.EventManager.OnNewClient -= EventManager_OnNewClient;
149 // remove the interface
150 m_scene.UnregisterModuleInterface<ITerrainModule>(this);
151 }
139 } 152 }
140 153
141 public void Close() 154 public void Close()
@@ -147,11 +160,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
147 get { return "TerrainModule"; } 160 get { return "TerrainModule"; }
148 } 161 }
149 162
150 public bool IsSharedModule
151 {
152 get { return false; }
153 }
154
155 #endregion 163 #endregion
156 164
157 #region ITerrainModule Members 165 #region ITerrainModule Members
@@ -207,7 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
207 return; 215 return;
208 } 216 }
209 } 217 }
210 218
211 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format."); 219 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format.");
212 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); 220 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
213 } 221 }
@@ -268,7 +276,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
268 throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); 276 throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
269 } 277 }
270 } 278 }
271 279
272 CheckForTerrainUpdates(); 280 CheckForTerrainUpdates();
273 m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); 281 m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
274 return; 282 return;
@@ -288,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
288 public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId) 296 public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId)
289 { 297 {
290 client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId); 298 client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
291 } 299 }
292 300
293 /// <summary> 301 /// <summary>
294 /// Saves the current heightmap to a specified stream. 302 /// Saves the current heightmap to a specified stream.
@@ -501,7 +509,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
501 m_commander.ProcessConsoleCommand("help", new string[0]); 509 m_commander.ProcessConsoleCommand("help", new string[0]);
502 return; 510 return;
503 } 511 }
504 512
505 string[] tmpArgs = new string[args.Length - 2]; 513 string[] tmpArgs = new string[args.Length - 2];
506 int i; 514 int i;
507 for (i = 2; i < args.Length; i++) 515 for (i = 2; i < args.Length; i++)
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index d4c2daa..8f2f5a0 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Net; 29using System.Net;
30using System.Collections.Generic;
30using Nini.Config; 31using Nini.Config;
31using OpenMetaverse; 32using OpenMetaverse;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -109,7 +110,7 @@ namespace OpenSim.Tests.Common.Setup
109 /// </summary> 110 /// </summary>
110 /// <param name="scene"></param> 111 /// <param name="scene"></param>
111 /// <param name="modules"></param> 112 /// <param name="modules"></param>
112 public static void SetupSceneModules(Scene scene, params IRegionModule[] modules) 113 public static void SetupSceneModules(Scene scene, params object[] modules)
113 { 114 {
114 SetupSceneModules(scene, null, modules); 115 SetupSceneModules(scene, null, modules);
115 } 116 }
@@ -120,12 +121,36 @@ namespace OpenSim.Tests.Common.Setup
120 /// <param name="scene"></param> 121 /// <param name="scene"></param>
121 /// <param name="config"></param> 122 /// <param name="config"></param>
122 /// <param name="modules"></param> 123 /// <param name="modules"></param>
123 public static void SetupSceneModules(Scene scene, IConfigSource config, params IRegionModule[] modules) 124 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules)
124 { 125 {
125 foreach (IRegionModule module in modules) 126 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
127 foreach (object module in modules)
126 { 128 {
127 module.Initialise(scene, config); 129 if (module is IRegionModule)
128 scene.AddModule(module.Name, module); 130 {
131 IRegionModule m = (IRegionModule)module;
132 m.Initialise(scene, config);
133 scene.AddModule(m.Name, m);
134 }
135 else if(module is IRegionModuleBase)
136 {
137 // for the new system, everything has to be initialised first,
138 // shared modules have to be post-initialised, then all get an AddRegion with the scene
139 IRegionModuleBase m = (IRegionModuleBase)module;
140 m.Initialise(config);
141 newModules.Add(m);
142 }
143 }
144
145 foreach (IRegionModuleBase module in newModules)
146 {
147 if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise();
148 }
149
150 foreach (IRegionModuleBase module in newModules)
151 {
152 module.AddRegion(scene);
153 scene.AddRegionModule(module.Name, module);
129 } 154 }
130 155
131 scene.SetModuleInterfaces(); 156 scene.SetModuleInterfaces();