29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Interfaces;
37 namespace OpenSim.
Region.Framework.Scenes
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 public bool AllRegionsReady
63 return m_allRegionsReady;
68 if (m_allRegionsReady != value)
70 m_allRegionsReady = value;
71 Action<SceneManager> handler = OnRegionsReadyStatusChange;
74 foreach (Action<SceneManager> d
in handler.GetInvocationList())
82 m_log.ErrorFormat(
"[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}",
83 e.Message, e.StackTrace);
90 private bool m_allRegionsReady;
96 if (m_instance == null)
102 private readonly DoubleDictionary<UUID, string, Scene> m_localScenes =
new DoubleDictionary<UUID, string, Scene>();
104 public List<Scene> Scenes
106 get {
return new List<Scene>(m_localScenes.FindAll(delegate(
Scene s) {
return true; })); }
115 public Scene CurrentScene {
get;
private set; }
117 public Scene CurrentOrFirstScene
121 if (CurrentScene == null)
123 List<Scene> sceneList = Scenes;
124 if (sceneList.Count == 0)
138 m_localScenes =
new DoubleDictionary<UUID, string, Scene>();
143 List<Scene> localScenes = null;
147 localScenes = Scenes;
150 for (
int i = 0; i < localScenes.Count; i++)
152 localScenes[i].Close();
166 m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene);
168 scene.OnRestart += HandleRestart;
169 scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
174 Scene restartedScene = null;
178 m_localScenes.TryGetValue(rdata.RegionID, out restartedScene);
179 m_localScenes.Remove(rdata.RegionID);
184 if (CurrentScene == restartedScene)
191 private void HandleRegionReadyStatusChange(
IScene scene)
194 AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0;
197 public
void SendSimOnlineNotification(ulong regionHandle)
201 Scene s = m_localScenes.FindValue(delegate(
Scene x)
210 List<Scene> sceneList = Scenes;
212 for (
int i = 0; i < sceneList.Count; i++)
214 if (sceneList[i]!= s)
223 m_log.Error(
"[REGION]: Unable to notify Other regions of this Region coming up");
234 if (serialiser != null)
235 serialiser.SavePrimsToXml(CurrentOrFirstScene, filename);
247 if (serialiser != null)
248 serialiser.LoadPrimsFromXml(CurrentOrFirstScene, filename, generateNewIDs, loadOffset);
258 if (serialiser != null)
259 serialiser.SavePrimsToXml2(CurrentOrFirstScene, filename);
265 if (serialiser != null)
266 serialiser.SaveNamedPrimsToXml2(CurrentOrFirstScene, primName, filename);
275 if (serialiser != null)
276 serialiser.LoadPrimsFromXml2(CurrentOrFirstScene, filename);
287 if (archiver != null)
288 archiver.HandleSaveOarConsoleCommand(string.Empty, cmdparams);
299 if (archiver != null)
300 archiver.HandleLoadOarConsoleCommand(string.Empty, cmdparams);
305 return CurrentOrFirstScene.Heightmap.SaveToXmlString();
310 CurrentOrFirstScene.Heightmap.LoadFromXmlString(mapData);
315 ForEachSelectedScene(delegate(
Scene scene) { scene.SendCommandToPlugins(cmdparams); });
320 ForEachSelectedScene(delegate(
Scene scene) { scene.Permissions.SetBypassPermissions(bypassPermissions); });
325 if (CurrentScene == null)
333 ForEachSelectedScene(delegate(
Scene scene) { scene.RestartNow(); });
338 ForEachSelectedScene(delegate(
Scene scene) { scene.Backup(
true); });
343 if ((
String.Compare(regionName,
"root") == 0)
344 || (
String.Compare(regionName,
"..") == 0)
345 || (
String.Compare(regionName,
"/") == 0))
354 if (m_localScenes.TryGetValue(regionName, out s))
370 if (m_localScenes.TryGetValue(regionID, out s))
381 return m_localScenes.TryGetValue(regionName, out scene);
386 return m_localScenes.TryGetValue(regionID, out scene);
391 List<Scene> sceneList = Scenes;
392 foreach (
Scene mscene
in sceneList)
408 List<Scene> sceneList = Scenes;
409 foreach (
Scene mscene
in sceneList)
425 List<ScenePresence> avatars =
new List<ScenePresence>();
427 ForEachSelectedScene(
428 delegate(
Scene scene)
430 scene.ForEachRootScenePresence(delegate(
ScenePresence scenePresence)
432 avatars.Add(scenePresence);
442 List<ScenePresence> presences =
new List<ScenePresence>();
444 ForEachSelectedScene(delegate(
Scene scene)
458 if (m_localScenes.TryGetValue(regionID, out s))
468 ForEachSelectedScene(delegate(
Scene scene) { scene.ForceClientUpdate(); });
473 ForEachSelectedScene(delegate(
Scene scene) { scene.HandleEditCommand(cmdparams); });
478 List<Scene> sceneList = Scenes;
479 foreach (
Scene scene
in sceneList)
493 List<Scene> sceneList = Scenes;
494 foreach (
Scene scene
in sceneList)
496 avatar = scene.GetScenePresence(avatarId);
498 if (avatar != null && !avatar.IsChildAgent)
509 m_localScenes.Remove(scene.RegionInfo.RegionID);
516 List<Scene> sceneList = Scenes;
517 foreach (
Scene scene
in sceneList)
531 List<Scene> sceneList = Scenes;
532 foreach (
Scene scene
in sceneList)
534 sp = scene.GetScenePresence(firstName, lastName);
535 if (sp != null && !sp.IsChildAgent)
545 List<Scene> sceneList = Scenes;
546 sceneList.ForEach(action);
bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene)
bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
bool TrySetCurrentScene(string regionName)
void LoadCurrentSceneFromXml2(string filename)
Load an xml file of prims in OpenSimulator's current 'xml2' file format to the current scene ...
void RestartCurrentScene()
List< ScenePresence > GetCurrentScenePresences()
List< ScenePresence > GetCurrentSceneAvatars()
OpenSim.Framework.RegionInfo RegionInfo
void SaveCurrentSceneToArchive(string[] cmdparams)
Save the current scene to an OpenSimulator archive. This archive will eventually include the prim's a...
void LoadArchiveToCurrentScene(string[] cmdparams)
Load an OpenSim archive into the current scene. This will load both the shapes of the prims and uploa...
void HandleRestart(RegionInfo rdata)
bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
Interface to region archive functionality
bool TryGetScene(UUID regionID, out Scene scene)
RegionInfo GetRegionInfo(UUID regionID)
IPEndPoint InternalEndPoint
void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
void HandleEditCommandOnCurrentScene(string[] cmdparams)
bool TryGetScene(uint locX, uint locY, out Scene scene)
void LoadCurrentSceneFromXml(string filename, bool generateNewIDs, Vector3 loadOffset)
Load an xml file of prims in OpenSimulator's original 'xml' file format to the current scene ...
bool TrySetCurrentScene(UUID regionID)
void SaveCurrentSceneToXml(string filename)
Save the prims in the current scene to an xml file in OpenSimulator's original 'xml' format ...
bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
void CloseScene(Scene scene)
delegate void RestartSim(RegionInfo thisregion)
void ForEachSelectedScene(Action< Scene > func)
Manager for adding, closing and restarting scenes.
bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp)
override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
Try to get a scene presence from the scene
void LoadCurrenSceneMapFromXmlString(string mapData)
void SendCommandToPluginModules(string[] cmdparams)
void SaveNamedPrimsToXml2(string primName, string filename)
Action< SceneManager > OnRegionsReadyStatusChange
Fired when either all regions are ready for use or at least one region has become unready for use whe...
void ForceCurrentSceneClientUpdate()
void SaveCurrentSceneToXml2(string filename)
Save the prims in the current scene to an xml file in OpenSimulator's current 'xml2' format ...
bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar)
virtual RegionInfo RegionInfo
string SaveCurrentSceneMapToXmlString()
uint RegionLocY
The y co-ordinate of this region in map tiles (e.g. 1000). Coordinate is scaled as world coordinates ...
void ForEachScene(Action< Scene > action)
uint RegionLocX
The x co-ordinate of this region in map tiles (e.g. 1000). Coordinate is scaled as world coordinates ...
void BackupCurrentScene()
bool TryGetScene(string regionName, out Scene scene)