- 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
parent
b717f991ed
commit
6db21bbf97
|
@ -8,7 +8,7 @@
|
||||||
</Dependencies>
|
</Dependencies>
|
||||||
|
|
||||||
<Extension path = "/OpenSim/RegionModules">
|
<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>
|
||||||
|
|
||||||
<Extension path = "/OpenSim/WindModule">
|
<Extension path = "/OpenSim/WindModule">
|
||||||
|
|
|
@ -42,7 +42,7 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.World.Terrain
|
namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule
|
public class TerrainModule : INonSharedRegionModule, ICommandableModule, ITerrainModule
|
||||||
{
|
{
|
||||||
#region StandardTerrainEffects enum
|
#region StandardTerrainEffects enum
|
||||||
|
|
||||||
|
@ -93,49 +93,62 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IRegionModule Members
|
#region INonSharedRegionModule Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates and initialises a terrain module for a region
|
/// Creates and initialises a terrain module for a region
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scene">Region initialising</param>
|
/// <param name="scene">Region initialising</param>
|
||||||
/// <param name="config">Config for the region</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;
|
m_scene = scene;
|
||||||
|
|
||||||
// Install terrain module in the simulator
|
// 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_channel = new TerrainChannel();
|
||||||
m_scene.Heightmap = m_channel;
|
m_scene.Heightmap = m_channel;
|
||||||
m_revert = new TerrainChannel();
|
m_revert = new TerrainChannel();
|
||||||
UpdateRevertMap();
|
UpdateRevertMap();
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_channel = m_scene.Heightmap;
|
||||||
m_channel = m_scene.Heightmap;
|
m_revert = new TerrainChannel();
|
||||||
m_revert = new TerrainChannel();
|
UpdateRevertMap();
|
||||||
UpdateRevertMap();
|
}
|
||||||
|
|
||||||
|
m_scene.RegisterModuleInterface<ITerrainModule>(this);
|
||||||
|
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
|
||||||
|
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||||
|
m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
|
||||||
|
InstallInterfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.RegisterModuleInterface<ITerrainModule>(this);
|
InstallDefaultEffects();
|
||||||
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
|
LoadPlugins();
|
||||||
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
|
||||||
m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void RemoveRegion(Scene scene)
|
||||||
/// Enables terrain module when called
|
|
||||||
/// </summary>
|
|
||||||
public void PostInitialise()
|
|
||||||
{
|
{
|
||||||
InstallDefaultEffects();
|
lock (m_scene)
|
||||||
InstallInterfaces();
|
{
|
||||||
LoadPlugins();
|
// 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()
|
public void Close()
|
||||||
|
@ -147,11 +160,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
get { return "TerrainModule"; }
|
get { return "TerrainModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSharedModule
|
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ITerrainModule Members
|
#region ITerrainModule Members
|
||||||
|
@ -207,7 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format.");
|
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));
|
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));
|
throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckForTerrainUpdates();
|
CheckForTerrainUpdates();
|
||||||
m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
|
m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
|
||||||
return;
|
return;
|
||||||
|
@ -288,7 +296,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId)
|
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);
|
client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the current heightmap to a specified stream.
|
/// 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]);
|
m_commander.ProcessConsoleCommand("help", new string[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] tmpArgs = new string[args.Length - 2];
|
string[] tmpArgs = new string[args.Length - 2];
|
||||||
int i;
|
int i;
|
||||||
for (i = 2; i < args.Length; i++)
|
for (i = 2; i < args.Length; i++)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -109,7 +110,7 @@ namespace OpenSim.Tests.Common.Setup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="modules"></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);
|
SetupSceneModules(scene, null, modules);
|
||||||
}
|
}
|
||||||
|
@ -120,12 +121,36 @@ namespace OpenSim.Tests.Common.Setup
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="modules"></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);
|
if (module is IRegionModule)
|
||||||
scene.AddModule(module.Name, module);
|
{
|
||||||
|
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();
|
scene.SetModuleInterfaces();
|
||||||
|
|
Loading…
Reference in New Issue