29 using System.Collections.Generic;
30 using System.Reflection;
31 using System.Threading;
34 using OpenSim.Framework;
35 using OpenSim.Region.CoreModules.Agent.AssetTransaction;
36 using OpenSim.Region.CoreModules.Avatar.InstantMessage;
37 using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
38 using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
39 using OpenSim.Region.CoreModules.Scripting.XMLRPC;
40 using OpenSim.Services.Interfaces;
43 namespace OpenSim.ApplicationPlugins.LoadRegions
45 [Extension(Path=
"/OpenSim/Startup", Id=
"LoadRegions", NodeName=
"Plugin")]
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 #region IApplicationPlugin Members
56 private string m_name =
"LoadRegionsPlugin";
57 private string m_version =
"0.0";
61 get {
return m_version; }
66 get {
return m_name; }
73 m_log.Error(
"[LOAD REGIONS PLUGIN]: " + Name +
" cannot be default-initialized!");
80 m_openSim.ApplicationRegistry.RegisterInterface<
IRegionCreator>(
this);
88 if (m_openSim.ConfigSource.Source.Configs[
"Startup"].GetString(
"region_info_source",
"filesystem") ==
"filesystem")
90 m_log.Info(
"[LOAD REGIONS PLUGIN]: Loading region configurations from filesystem");
95 m_log.Info(
"[LOAD REGIONS PLUGIN]: Loading region configurations from web");
99 regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source);
100 RegionInfo[] regionsToLoad = regionLoader.LoadRegions();
102 m_log.Info(
"[LOAD REGIONS PLUGIN]: Loading specific shared modules...");
111 m_log.Info(
"[LOAD REGIONS PLUGIN]: Done.");
113 if (!CheckRegionsForSanity(regionsToLoad))
115 m_log.Error(
"[LOAD REGIONS PLUGIN]: Halting startup due to conflicts in region configurations");
119 List<IScene> createdScenes =
new List<IScene>();
121 for (
int i = 0; i < regionsToLoad.Length; i++)
124 m_log.Debug(
"[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName +
" (ThreadID: " +
125 Thread.CurrentThread.ManagedThreadId.ToString() +
128 bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
130 m_openSim.CreateRegion(regionsToLoad[i],
true, out scene);
131 createdScenes.Add(scene);
134 m_openSim.EstateDataService.StoreEstateSettings(regionsToLoad[i]
.EstateSettings);
137 foreach (
IScene scene
in createdScenes)
141 m_newRegionCreatedHandler = OnNewRegionCreated;
142 if (m_newRegionCreatedHandler != null)
144 m_newRegionCreatedHandler(scene);
160 private bool CheckRegionsForSanity(
RegionInfo[] regions)
162 if (regions.Length == 0)
170 "[LOAD REGIONS PLUGIN]: Region {0} has invalid UUID {1}",
171 region.RegionName, region.RegionID);
176 for (
int i = 0; i < regions.Length - 1; i++)
178 for (
int j = i + 1; j < regions.Length; j++)
180 if (regions[i].RegionID == regions[j].RegionID)
183 "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same UUID {2}",
184 regions[i].RegionName, regions[j].RegionName, regions[i].RegionID);
188 regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY)
191 "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same grid location ({2}, {3})",
192 regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY);
195 else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port)
198 "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same internal IP port {2}",
199 regions[i].RegionName, regions[j].RegionName, regions[i].InternalEndPoint.Port);
delegate void NewRegionCreated(IScene scene)
OpenSimulator Application Plugin framework interface
void Initialise()
Default-initialises the plugin
void PostInitialise()
Called when the application loading is completed
NewRegionCreated OnNewRegionCreated
void Initialise(OpenSimBase openSim)
Initialize the Plugin
Exception thrown if Initialise has been called, but failed.
Common OpenSimulator simulator code