diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 6db10429f7..8b5f26fd6f 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -8,7 +8,7 @@ - + diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 7793aa5da3..9f1867f759 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; namespace OpenSim.Region.CoreModules.World.Terrain { - public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule + public class TerrainModule : INonSharedRegionModule, ICommandableModule, ITerrainModule { #region StandardTerrainEffects enum @@ -93,49 +93,62 @@ namespace OpenSim.Region.CoreModules.World.Terrain #endregion - #region IRegionModule Members + #region INonSharedRegionModule Members /// /// Creates and initialises a terrain module for a region /// /// Region initialising /// Config for the region - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) + { + } + + public void AddRegion(Scene scene) { m_scene = scene; // Install terrain module in the simulator - if (m_scene.Heightmap == null) + lock (m_scene) { - lock (m_scene) + if (m_scene.Heightmap == null) { m_channel = new TerrainChannel(); m_scene.Heightmap = m_channel; m_revert = new TerrainChannel(); UpdateRevertMap(); } - } - else - { - m_channel = m_scene.Heightmap; - m_revert = new TerrainChannel(); - UpdateRevertMap(); + else + { + m_channel = m_scene.Heightmap; + m_revert = new TerrainChannel(); + UpdateRevertMap(); + } + + m_scene.RegisterModuleInterface(this); + m_scene.EventManager.OnNewClient += EventManager_OnNewClient; + m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; + m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; + InstallInterfaces(); } - m_scene.RegisterModuleInterface(this); - m_scene.EventManager.OnNewClient += EventManager_OnNewClient; - m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; - m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; + InstallDefaultEffects(); + LoadPlugins(); } - /// - /// Enables terrain module when called - /// - public void PostInitialise() + public void RemoveRegion(Scene scene) { - InstallDefaultEffects(); - InstallInterfaces(); - LoadPlugins(); + lock (m_scene) + { + // remove the commands + m_scene.UnregisterModuleCommander(m_commander.Name); + // remove the event-handlers + m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick; + m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; + m_scene.EventManager.OnNewClient -= EventManager_OnNewClient; + // remove the interface + m_scene.UnregisterModuleInterface(this); + } } public void Close() @@ -147,11 +160,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain get { return "TerrainModule"; } } - public bool IsSharedModule - { - get { return false; } - } - #endregion #region ITerrainModule Members @@ -207,7 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain return; } } - + m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format."); throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); } @@ -268,7 +276,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); } } - + CheckForTerrainUpdates(); m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); return; @@ -288,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId) { client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId); - } + } /// /// Saves the current heightmap to a specified stream. @@ -501,7 +509,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain m_commander.ProcessConsoleCommand("help", new string[0]); return; } - + string[] tmpArgs = new string[args.Length - 2]; int i; for (i = 2; i < args.Length; i++) diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index d4c2daaa7b..8f2f5a0e3c 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -27,6 +27,7 @@ using System; using System.Net; +using System.Collections.Generic; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -109,7 +110,7 @@ namespace OpenSim.Tests.Common.Setup /// /// /// - public static void SetupSceneModules(Scene scene, params IRegionModule[] modules) + public static void SetupSceneModules(Scene scene, params object[] modules) { SetupSceneModules(scene, null, modules); } @@ -120,12 +121,36 @@ namespace OpenSim.Tests.Common.Setup /// /// /// - public static void SetupSceneModules(Scene scene, IConfigSource config, params IRegionModule[] modules) + public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) { - foreach (IRegionModule module in modules) + List newModules = new List(); + foreach (object module in modules) { - module.Initialise(scene, config); - scene.AddModule(module.Name, module); + if (module is IRegionModule) + { + IRegionModule m = (IRegionModule)module; + m.Initialise(scene, config); + scene.AddModule(m.Name, m); + } + else if(module is IRegionModuleBase) + { + // for the new system, everything has to be initialised first, + // shared modules have to be post-initialised, then all get an AddRegion with the scene + IRegionModuleBase m = (IRegionModuleBase)module; + m.Initialise(config); + newModules.Add(m); + } + } + + foreach (IRegionModuleBase module in newModules) + { + if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); + } + + foreach (IRegionModuleBase module in newModules) + { + module.AddRegion(scene); + scene.AddRegionModule(module.Name, module); } scene.SetModuleInterfaces();