From 175b6115f19f9bad7c81fde625250b3a7f8a33f2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 26 Nov 2007 05:02:18 +0000 Subject: * Restarting regions with the estate tools works in sandbox mode. I'm still working on grid mode, however. It doesn't break anything, but that feature doesn't work in grid mode yet either. --- OpenSim/Region/Environment/Scenes/Scene.cs | 41 +++++++++++++++------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 3 +- .../Scenes/SceneCommunicationService.cs | 33 +++++++++++++---- OpenSim/Region/Environment/Scenes/SceneManager.cs | 22 ++++++++++-- 4 files changed, 77 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index fd17d56..a9791ee 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -216,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; - RegisterRegionWithComms(); + m_physicalPrim = physicalPrim; m_sendTasksToChild = SendTasksToChild; @@ -244,6 +244,7 @@ namespace OpenSim.Region.Environment.Scenes httpListener = httpServer; m_dumpAssetsToFile = dumpAssetsToFile; + RegisterRegionWithComms(); } #endregion @@ -257,21 +258,29 @@ namespace OpenSim.Region.Environment.Scenes m_eventManager.OnPermissionError += SendPermissionAlert; } - public override void OtherRegionUp(RegionInfo otherRegion) + public override bool OtherRegionUp(RegionInfo otherRegion) { // Another region is up. We have to tell all our ScenePresences about it // This fails to get the desired effect and needs further work. - - ForEachScenePresence(delegate(ScenePresence agent) + try { - if (!(agent.IsChildAgent)) - { - InformClientOfNeighbor(agent, otherRegion); - this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - + + ForEachScenePresence(delegate(ScenePresence agent) + { + if (!(agent.IsChildAgent)) + { + this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, otherRegion); + } } + + ); } - ); + catch (System.NullReferenceException) + { + // This means that we're not booted up completely yet. + } + return true; } public virtual void Restart(float seconds) { @@ -1068,9 +1077,13 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnExpectUser += NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; m_sceneGridService.OnCloseAgentConnection += CloseConnection; + m_sceneGridService.OnRegionUp += OtherRegionUp; + // Tell Other regions that I'm here. + m_sceneGridService.InformNeighborsThatRegionisUp(RegionInfo); } public void UnRegisterReginWithComms() { + m_sceneGridService.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; m_sceneGridService.OnCloseAgentConnection -= CloseConnection; @@ -1578,9 +1591,13 @@ namespace OpenSim.Region.Environment.Scenes /// public void ForEachScenePresence(Action action) { - foreach (ScenePresence presence in m_scenePresences.Values) + // We don't want to try to send messages if there are no avatar. + if (!(m_scenePresences.Equals(null))) { - action(presence); + foreach (ScenePresence presence in m_scenePresences.Values) + { + action(presence); + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 4359374..2db3bdc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -41,7 +41,6 @@ namespace OpenSim.Region.Environment.Scenes #region Events public event restart OnRestart; - public event regionup OnRegionUp; #endregion @@ -160,7 +159,7 @@ namespace OpenSim.Region.Environment.Scenes } - public abstract void OtherRegionUp(RegionInfo thisRegion); + public abstract bool OtherRegionUp(RegionInfo thisRegion); #endregion diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 9a10c51..ae44acb 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -21,6 +21,7 @@ namespace OpenSim.Region.Environment.Scenes public event ExpectUserDelegate OnExpectUser; public event CloseAgentConnection OnCloseAgentConnection; public event PrimCrossing OnPrimCrossingIntoRegion; + public event RegionUp OnRegionUp; public SceneCommunicationService(CommunicationsManager commsMan) @@ -38,6 +39,7 @@ namespace OpenSim.Region.Environment.Scenes regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; regionCommsHost.OnPrimCrossingIntoRegion += PrimCrossing; regionCommsHost.OnCloseAgentConnection += CloseConnection; + regionCommsHost.OnRegionUp += newRegionUp; } @@ -45,12 +47,16 @@ namespace OpenSim.Region.Environment.Scenes public void Close() { - regionCommsHost.OnExpectUser -= NewUserConnection; - regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - regionCommsHost.OnPrimCrossingIntoRegion -= PrimCrossing; - regionCommsHost.OnCloseAgentConnection -= CloseConnection; - m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - regionCommsHost = null; + if (regionCommsHost != null) + { + regionCommsHost.OnRegionUp -= newRegionUp; + regionCommsHost.OnExpectUser -= NewUserConnection; + regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; + regionCommsHost.OnPrimCrossingIntoRegion -= PrimCrossing; + regionCommsHost.OnCloseAgentConnection -= CloseConnection; + m_commsProvider.GridService.DeregisterRegion(m_regionInfo); + regionCommsHost = null; + } } #region CommsManager Event handlers @@ -59,6 +65,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// + /// protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent) { if (OnExpectUser != null) @@ -67,6 +74,15 @@ namespace OpenSim.Region.Environment.Scenes } } + protected bool newRegionUp(RegionInfo region) + { + if (OnRegionUp != null) + { + OnRegionUp(region); + } + return true; + } + protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (OnAvatarCrossingIntoRegion != null) @@ -249,6 +265,11 @@ namespace OpenSim.Region.Environment.Scenes return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); } + public void InformNeighborsThatRegionisUp(RegionInfo region) + { + bool val = m_commsProvider.InterRegion.RegionUp(region); + } + public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, LLVector3 position, bool isPhysical) { return m_commsProvider.InterRegion.ExpectPrimCrossing(regionhandle, primID, position, isPhysical); diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 4360d97..c28269e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -121,17 +121,35 @@ namespace OpenSim.Region.Environment.Scenes public void SendSimOnlineNotification(ulong regionHandle) { + RegionInfo Result = null; for (int i = 0; i < m_localScenes.Count; i++) { - if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) + + if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) { + // Inform other regions to tell their avatar about me - m_localScenes[i].OtherRegionUp(m_localScenes[i].RegionInfo); + Result = m_localScenes[i].RegionInfo; } } + if (!(Result.Equals(null))) + { + for (int i = 0; i < m_localScenes.Count; i++) + { + if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) + { + // Inform other regions to tell their avatar about me + //m_localScenes[i].OtherRegionUp(Result); + } + } + } + else + { + MainLog.Instance.Error("REGION", "Unable to notify Other regions of this Region coming up"); + } } public void SaveCurrentSceneToXml(string filename) { -- cgit v1.1