- 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.
0.6.5-rc1
Homer Horwitz 2009-04-13 21:23:33 +00:00
parent b717f991ed
commit 6db21bbf97
3 changed files with 70 additions and 37 deletions

View File

@ -8,7 +8,7 @@
</Dependencies>
<Extension path = "/OpenSim/RegionModules">
<!-- <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> -->
<RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" />
</Extension>
<Extension path = "/OpenSim/WindModule">

View File

@ -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,28 +93,31 @@ namespace OpenSim.Region.CoreModules.World.Terrain
#endregion
#region IRegionModule Members
#region INonSharedRegionModule Members
/// <summary>
/// Creates and initialises a terrain module for a region
/// </summary>
/// <param name="scene">Region initialising</param>
/// <param name="config">Config for the region</param>
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)
{
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;
@ -126,18 +129,28 @@ namespace OpenSim.Region.CoreModules.World.Terrain
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
InstallInterfaces();
}
/// <summary>
/// Enables terrain module when called
/// </summary>
public void PostInitialise()
{
InstallDefaultEffects();
InstallInterfaces();
LoadPlugins();
}
public void RemoveRegion(Scene scene)
{
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<ITerrainModule>(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

View File

@ -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
/// </summary>
/// <param name="scene"></param>
/// <param name="modules"></param>
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
/// <param name="scene"></param>
/// <param name="config"></param>
/// <param name="modules"></param>
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<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
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();