From e595f82489ae91c2a913f2ac8445b3d5dbe160d0 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 10 Dec 2007 00:46:56 +0000 Subject: * Hooked up the GridComm event ChildDataUpdate to the scene. * Added List m_neighbours to Scene * Hooked up the OnRegionUp event to m_neighbours list * Modified RegionInfo to have a bool commFailTF value so that we can skip neighbors that fail. (when the region comes up, this gets reset to false and the region will try again. * Added SetChildAgentThrottle(byte[]) to IClientAPI * Several other insignificant changes related to passing child pertanant agent data from sim to sim. --- OpenSim/Region/Environment/Scenes/Scene.cs | 47 +++++++++++++++++++++- .../Scenes/SceneCommunicationService.cs | 43 ++++++++++++++++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 14 +++++++ 3 files changed, 103 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 6bdb8a3..b6ca566 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -60,6 +60,7 @@ namespace OpenSim.Region.Environment.Scenes protected Timer m_restartWaitTimer = new Timer(); protected List m_regionRestartNotifyList = new List(); + protected List m_neighbours = new List(); public InnerScene m_innerScene; @@ -266,13 +267,37 @@ namespace OpenSim.Region.Environment.Scenes public override bool OtherRegionUp(RegionInfo otherRegion) { - // Another region is up. We have to tell all our ScenePresences about it + // Another region is up. + // We have to tell all our ScenePresences about it.. + //and add it to the neighbor list. if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) { + for (int i = 0; i < m_neighbours.Count; i++) + { + // The purpose of this loop is to re-update the known neighbors + // when another region comes up on top of another one. + // The latest region in that location ends up in the + // 'known neighbors list' + // Additionally, the commFailTF property gets reset to false. + if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) + { + m_neighbours[i] = otherRegion; + } + } + + // If the value isn't in the neighbours, add it. + // If the RegionInfo isn't exact but is for the same XY World location, + // then the above loop will fix that. + + if (!(m_neighbours.Contains(otherRegion))) + { + m_neighbours.Add(otherRegion); + } + if (!(m_regionRestartNotifyList.Contains(otherRegion))) { m_regionRestartNotifyList.Add(otherRegion); @@ -1112,6 +1137,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; m_sceneGridService.OnCloseAgentConnection += CloseConnection; m_sceneGridService.OnRegionUp += OtherRegionUp; + m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; m_sceneGridService.KillObject = SendKillObject; } @@ -1121,6 +1147,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UnRegisterReginWithComms() { + m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_sceneGridService.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; @@ -1182,6 +1209,24 @@ namespace OpenSim.Region.Environment.Scenes } } + public virtual bool IncomingChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) + { + ScenePresence childAgentUpdate = GetScenePresence(new LLUUID(cAgentData.AgentID)); + if (!(childAgentUpdate.Equals(null))) + { + // I can't imagine *yet* why we would get an update if the agent is a root agent.. + // however to avoid a race condition crossing borders.. + if (childAgentUpdate.IsChildAgent) + { + //Send Data to ScenePresence + childAgentUpdate.ChildAgentDataUpdate(cAgentData); + // Not Implemented: + //TODO: Do we need to pass the message on to one of our neighbors? + + } + } + return true; + } /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 04228de..4d2379b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -23,6 +23,7 @@ namespace OpenSim.Region.Environment.Scenes public event CloseAgentConnection OnCloseAgentConnection; public event PrimCrossing OnPrimCrossingIntoRegion; public event RegionUp OnRegionUp; + public event ChildAgentUpdate OnChildAgentUpdate; public KillObjectDelegate KillObject; public string _debugRegionName = ""; @@ -59,6 +60,8 @@ namespace OpenSim.Region.Environment.Scenes regionCommsHost.OnPrimCrossingIntoRegion += PrimCrossing; regionCommsHost.OnCloseAgentConnection += CloseConnection; regionCommsHost.OnRegionUp += newRegionUp; + regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; + } else { @@ -70,6 +73,7 @@ namespace OpenSim.Region.Environment.Scenes { if (regionCommsHost != null) { + regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; regionCommsHost.OnRegionUp -= newRegionUp; regionCommsHost.OnExpectUser -= NewUserConnection; regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; @@ -105,6 +109,14 @@ namespace OpenSim.Region.Environment.Scenes } return true; } + protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) + { + if (OnChildAgentUpdate != null) + OnChildAgentUpdate(regionHandle, cAgentData); + + + return true; + } protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { @@ -262,6 +274,37 @@ namespace OpenSim.Region.Environment.Scenes //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } + public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); + + private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) + { + MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); + bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle,cAgentData); + + if (regionAccepted) + { + MainLog.Instance.Notice("INTERGRID", "Completed sending a neighbor an update about my agent"); + } + else + { + MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent"); + } + } + private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) + { + SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState; + icon.EndInvoke(iar); + } + public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) + { + // This assumes that we know what our neighbors are. + SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; + d.BeginInvoke(regionHandle, cAgentData, + SendChildAgentDataUpdateCompleted, + d); + + } + /// /// diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f8571a9..ebd08b4 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.Environment.Scenes private uint m_requestedSitTargetID = 0; private LLVector3 m_requestedSitOffset = new LLVector3(); private float m_sitAvatarHeight = 2.0f; + private float m_godlevel = 0; private bool m_isTyping = false; private bool m_setAlwaysRun = false; @@ -1255,7 +1256,20 @@ namespace OpenSim.Region.Environment.Scenes respondPacket.AgentData = adb; ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task); } + public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData) + { + // + m_DrawDistance = cAgentData.drawdistance; + m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z); + m_CameraCenter = new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); + m_godlevel = cAgentData.godlevel; + ControllingClient.SetChildAgentThrottle(cAgentData.throttles); + //cAgentData.AVHeight; + //cAgentData.regionHandle; + //m_velocity = cAgentData.Velocity; + + } /// /// /// -- cgit v1.1