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/Framework/IClientAPI.cs | 2 +- OpenSim/Framework/RegionInfo.cs | 1 + OpenSim/Region/ClientStack/ClientView.cs | 5 ++- .../Region/Communications/OGS1/OGS1GridServices.cs | 7 ++-- OpenSim/Region/Environment/Scenes/Scene.cs | 47 +++++++++++++++++++++- .../Scenes/SceneCommunicationService.cs | 43 ++++++++++++++++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 14 +++++++ .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 5 ++- 8 files changed, 117 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 773b5eb..43c8c70 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -480,7 +480,7 @@ namespace OpenSim.Framework void SendCoarseLocationUpdate(List CoarseLocations); void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint); - + void SetChildAgentThrottle(byte[] throttle); void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction); diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 770107f..ac040c5 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -186,6 +186,7 @@ namespace OpenSim.Framework public string DataStore = ""; public bool isSandbox = false; + public bool commFailTF = false; public LLUUID MasterAvatarAssignedUUID = LLUUID.Zero; public string MasterAvatarFirstName = ""; diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 3fb21e3..540536e 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -2015,7 +2015,10 @@ namespace OpenSim.Region.ClientStack this.OutPacket(mbReply, ThrottleOutPacketType.Land); */ } - + public void SetChildAgentThrottle(byte[] throttles) + { + PacketQueue.SetThrottleFromClient(throttles); + } // Previously ClientView.PacketQueue protected PacketQueue PacketQueue; diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index c556188..fbb83fc 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -710,9 +710,10 @@ namespace OpenSim.Region.Communications.OGS1 } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); + // This line errors with a Null Reference Exception.. Why? @.@ + //MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + + // ":" + regInfo.RemotingPort + + //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); MainLog.Instance.Debug(e.ToString()); return false; } 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; + + } /// /// /// diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 87e66ab..82272f8 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -202,10 +202,13 @@ namespace SimpleApp { } + public virtual void SendKillObject(ulong regionHandle, uint localID) { } - + public virtual void SetChildAgentThrottle(byte[] throttle) + { + } public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { } -- cgit v1.1