Added IRegistryCore and RegistryCore to OpenSim.Framework.

Added a ApplicationRegistry to OpenSimBase.
Changed LoadRegionsPlugin so it registers itself to that application registry.
Added a event to LoadRegionsPlugin, that is triggered when it creates a new scene ,although maybe this event should actually be in opensimBase incase other plugins are creating regions (like the RemoteAdminPlugin).
This commit is contained in:
MW
2009-02-26 20:01:20 +00:00
parent c0c1a31f61
commit 33e7c09b7b
8 changed files with 153 additions and 48 deletions

View File

@@ -38,13 +38,19 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
using OpenSim.Region.CoreModules.Scripting.XMLRPC;
using OpenSim.Framework.Servers;
namespace OpenSim.ApplicationPlugins.LoadRegions
{
public delegate void NewRegionCreated(IScene scene);
public class LoadRegionsPlugin : IApplicationPlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event NewRegionCreated OnNewRegionCreated;
private NewRegionCreated m_newRegionCreatedHandler;
#region IApplicationPlugin Members
// TODO: required by IPlugin, but likely not at all right
@@ -56,6 +62,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
protected OpenSimBase m_openSim;
public void Initialise()
{
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
@@ -65,6 +72,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
public void Initialise(OpenSimBase openSim)
{
m_openSim = openSim;
m_openSim.ApplicationRegistry.RegisterInterface<LoadRegionsPlugin>(this);
}
public void PostInitialise()
@@ -99,9 +107,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
for (int i = 0; i < regionsToLoad.Length; i++)
{
IScene scene;
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() +
")");
m_openSim.CreateRegion(regionsToLoad[i], true);
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
if (scene != null)
{
m_newRegionCreatedHandler = OnNewRegionCreated;
if (m_newRegionCreatedHandler != null)
{
m_newRegionCreatedHandler(scene);
}
}
}
m_openSim.ModuleLoader.PostInitialise();
@@ -182,9 +199,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
{
if (regionhandle == regionsToLoad[i].RegionHandle)
{
IScene scene;
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
Thread.CurrentThread.ManagedThreadId.ToString() + ")");
openSim.CreateRegion(regionsToLoad[i], true);
openSim.CreateRegion(regionsToLoad[i], true, out scene);
}
}
}

View File

@@ -563,8 +563,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
region.RegionID, regionXmlPath);
region.SaveRegionToFile("dynamic region", regionXmlPath);
}
m_app.CreateRegion(region);
IScene newscene;
m_app.CreateRegion(region, out newscene);
responseData["success"] = "true";
responseData["region_name"] = region.RegionName;