From 8fa03afb5c464fb198d495ca42d1fec69b61653d Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 25 May 2011 15:47:00 -0700 Subject: [PATCH] Added forwarding of teleport request, if the teleport is within the same region, from CM to PSA. Both the hosting CM and PSA will trigger the same region teleport code, PSA will then sync the new position to other CMs. --- OpenSim/Framework/IClientAPI.cs | 6 ++++++ .../ClientStack/Linden/UDP/LLClientView.cs | 18 +++++++++++++++++ .../RegionSyncModule/RegionSyncAvatar.cs | 3 +++ .../RegionSyncModule/RegionSyncClient.cs | 10 ++++++++++ .../RegionSyncModule/RegionSyncClientView.cs | 20 +++++++++++++++++++ .../RegionSyncModule/RegionSyncMessage.cs | 1 + .../Examples/SimpleModule/MyNpcCharacter.cs | 3 +++ .../Server/IRCClientView.cs | 3 +++ .../OptionalModules/World/NPC/NPCAvatar.cs | 3 +++ OpenSim/Tests/Common/Mock/TestClient.cs | 3 +++ 10 files changed, 70 insertions(+) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c9bccb065b..1568ee67f2 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -83,6 +83,9 @@ namespace OpenSim.Framework public delegate void TeleportLocationRequest( IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags); + //DSG: + public delegate void SameRegionTeleportlRequest(IClientAPI remoteClient, byte[] tpLocReq); + public delegate void TeleportLandmarkRequest( IClientAPI remoteClient, UUID regionID, Vector3 position); @@ -784,6 +787,9 @@ namespace OpenSim.Framework event RequestMapBlocks OnRequestMapBlocks; event RequestMapName OnMapNameRequest; event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG event DisconnectUser OnDisconnectUser; event RequestAvatarProperties OnRequestAvatarProperties; event SetAlwaysRun OnSetAlwaysRun; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index e0ece5b3f1..614fa77c0d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -143,6 +143,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event TeleportLandmarkRequest OnTeleportLandmarkRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; @@ -8471,6 +8474,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest; + + //DSG: KittyL -- added to support same region teleport + if (tpLocReq.Info.RegionHandle == m_scene.RegionInfo.RegionHandle) + { + SameRegionTeleportlRequest handlerSameRegionTeleportlRequest = OnSameRegionTeleportlRequest; + if (handlerSameRegionTeleportlRequest != null) + { + byte[] xb = new byte[tpLocReq.Length]; + int i = 0; + xb = tpLocReq.ToBytes(); + handlerSameRegionTeleportlRequest(this, xb); + //return true; + } + } + if (handlerTeleportLocationRequest != null) { handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs index 87d26689ee..1786ef359f 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs @@ -79,6 +79,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event TeleportLandmarkRequest OnTeleportLandmarkRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index 1a07b04919..592bc003de 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -202,6 +202,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule RemoveLocalClient(kvp.Key, m_scene); // Remove the agent update handler from the client kvp.Value.OnAgentUpdateRaw -= HandleAgentUpdateRaw; + kvp.Value.OnSameRegionTeleportlRequest -= HandleAgentSameRegionTeleport; } } catch (Exception e) @@ -848,6 +849,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Register for interesting client events which will be forwarded to auth sim // These are the raw packet data blocks from the client, intercepted and sent up to the sim client.OnAgentUpdateRaw += HandleAgentUpdateRaw; + client.OnSameRegionTeleportlRequest += HandleAgentSameRegionTeleport; //DSG SYNC: do not subscribe to OnChatFromClientRaw: RegionSyncModule + Scene.EventManager will handle this. //client.OnChatFromClientRaw += HandleChatFromClientRaw; client.OnAgentRequestSit += HandleAgentRequestSit; @@ -932,6 +934,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentUpdate, agentData)); } + //KittyL: Added to support teleporting within the same region + public void HandleAgentSameRegionTeleport(object sender, byte[] tpLocReq) + { + Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentSameRegionTeleport, tpLocReq)); + } + public void HandleAgentRequestSit(object sender, UUID agentID, UUID targetID, Vector3 offset) { // m_log.DebugFormat("{0} HandleAgentRequestSit for {1}", LogHeader(), agentID.ToString()); @@ -1133,6 +1141,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // These are the raw packet data blocks from the client, intercepted and sent up to the sim client.OnAgentUpdateRaw += HandleAgentUpdateRaw; client.OnChatFromClientRaw += HandleChatFromClientRaw; + //KittyL: added to support same region teleport + client.OnSameRegionTeleportlRequest += HandleAgentSameRegionTeleport; presence.IsSyncedAvatar = false; } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs index 70dea077d0..6b2c9720af 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs @@ -420,6 +420,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } } + case RegionSyncMessage.MsgType.AgentSameRegionTeleport: + //KittyL: added to support same region teleporting + int lent = 0; + TeleportLocationRequestPacket tpLocReq = new TeleportLocationRequestPacket(msg.Data, ref lent); + + RegionSyncAvatar avatar; + bool avFound; + lock (m_syncRoot) + { + avFound = m_syncedAvatars.TryGetValue(tpLocReq.AgentData.AgentID, out avatar); + } + if (!avFound) + { + RegionSyncMessage.HandleWarning(LogHeader, msg, String.Format("Received agent update for avatar not owned by this client view {0}", tpLocReq.AgentData.AgentID)); + return; + } + + m_scene.RequestTeleportLocation(avatar, m_scene.RegionInfo.RegionHandle, tpLocReq.Info.Position, + tpLocReq.Info.LookAt, 16); + return; case RegionSyncMessage.MsgType.AgentRemove: { // Get the data from message and error check diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs index ecd9d047e1..24db38cf6b 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ActorConnect, AgentAdd, AgentUpdate, + AgentSameRegionTeleport, AgentRemove, AgentRequestSit, AgentSit, diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index c59e23c707..e17226966c 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -76,6 +76,9 @@ namespace OpenSim.Region.Examples.SimpleModule public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event TeleportLandmarkRequest OnTeleportLandmarkRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 44c83f0c45..3fba662338 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -676,6 +676,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; public event SetAlwaysRun OnSetAlwaysRun; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 5ffc80d211..551e33b106 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -184,6 +184,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event TeleportLandmarkRequest OnTeleportLandmarkRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 39cc765174..210a780f04 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -88,6 +88,9 @@ namespace OpenSim.Tests.Common.Mock public event RequestMapBlocks OnRequestMapBlocks; public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; + //DSG: + public event SameRegionTeleportlRequest OnSameRegionTeleportlRequest; + //end of DSG public event TeleportLandmarkRequest OnTeleportLandmarkRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties;