/// <summary> /// Tries to teleport agent to landmark. /// </summary> /// <param name="remoteClient"></param> /// <param name="regionHandle"></param> /// <param name="position"></param> public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); if (lm.Gatekeeper == string.Empty) { base.RequestTeleportLandmark(remoteClient, lm); return; } GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); // Local region? if (info != null) { ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); return; } else { // Foreign region Scene scene = (Scene)(remoteClient.Scene); GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion gatekeeper = new GridRegion(); gatekeeper.ServerURI = lm.Gatekeeper; GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); if (finalDestination != null) { ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); IEntityTransferModule transferMod = scene.RequestModuleInterface <IEntityTransferModule>(); IEventQueue eq = sp.Scene.RequestModuleInterface <IEventQueue>(); if (transferMod != null && sp != null && eq != null) { transferMod.DoTeleport(sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark), eq); } } } // can't find the region: Tell viewer and abort remoteClient.SendTeleportFailed("The teleport destination could not be found."); }
private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper) { gatekeeper = new GridRegion(); gatekeeper.ExternalHostName = domainName; gatekeeper.HttpPort = port; gatekeeper.RegionName = regionName; gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); UUID regionID; ulong handle; string imageURL = string.Empty, reason = string.Empty; if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) { GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID); return(destination); } return(null); }
protected override GridRegion GetFinalDestination(GridRegion region) { int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); if (real_destination != null) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: GetFinalDestination serveruri -> {0}", real_destination.ServerURI); } else { m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); } return(real_destination); } return(region); }
private void Lure(IClientAPI client, uint teleportflags, GridInstantMessage im) { Scene scene = (Scene)(client.Scene); GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID)); if (region != null) { scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags); } else // we don't have that region here. Check if it's HG { string[] parts = im.message.Split(new char[] { '@' }); if (parts.Length > 1) { string url = parts[parts.Length - 1]; // the last part if (url.Trim(new char[] { '/' }) != m_ThisGridURL.Trim(new char[] { '/' })) { m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position); GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion gatekeeper = new GridRegion(); gatekeeper.ServerURI = url; GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID)); if (finalDestination != null) { ScenePresence sp = scene.GetScenePresence(client.AgentId); IEntityTransferModule transferMod = scene.RequestModuleInterface <IEntityTransferModule>(); if (transferMod != null && sp != null) { transferMod.DoTeleport( sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags); } } } } } }
protected override GridRegion GetFinalDestination(GridRegion region, UUID agentID, string agentHomeURI, out string message) { int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionName, flags); message = null; if ((flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region is hyperlink"); GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID, agentID, agentHomeURI, out message); if (real_destination != null) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: GetFinalDestination: ServerURI={0}", real_destination.ServerURI); } else { m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion of region {0} from Gatekeeper {1} failed: {2}", region.RegionID, region.ServerURI, message); } return(real_destination); } return(region); }
/// <summary> /// Tries to teleport agent to landmark. /// </summary> /// <param name="remoteClient"></param> /// <param name="regionHandle"></param> /// <param name="position"></param> public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", (string.IsNullOrEmpty(lm.Gatekeeper)) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId); if (sp == null || sp.IsDeleted || sp.IsInTransit || sp.IsChildAgent || sp.IsNPC) { return; } GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); // Local region? if (info != null) { //check if region on same position and fix local offset if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, info.RegionLocX, info.RegionLocY, info.RegionSizeX, info.RegionSizeY, out Vector3 offset)) { Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } else //region may had move to other grid slot. assume the lm position is good { Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } return; } if (string.IsNullOrEmpty(lm.Gatekeeper)) { remoteClient.SendTeleportFailed("Landmark region not found"); return; } // Foreign region GridRegion gatekeeper = MakeGateKeeperRegion(lm.Gatekeeper); if (gatekeeper == null) { remoteClient.SendTeleportFailed("Could not parse landmark destiny gatekeeper"); return; } string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId); GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, lm.RegionID, remoteClient.AgentId, homeURI, out string message); if (finalDestination == null) { remoteClient.SendTeleportFailed(message); } // Validate assorted conditions if (!ValidateGenericConditions(sp, gatekeeper, finalDestination, 0, out string reason)) { remoteClient.SendTeleportFailed(reason); return; } if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionSizeX, finalDestination.RegionSizeY, out Vector3 roffset)) { DoTeleport(sp, gatekeeper, finalDestination, roffset, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); return; } remoteClient.SendTeleportFailed("landmark region not found"); }
/// <summary> /// Tries to teleport agent to landmark. /// </summary> /// <param name="remoteClient"></param> /// <param name="regionHandle"></param> /// <param name="position"></param> public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); if (lm.Gatekeeper == string.Empty) { base.RequestTeleportLandmark(remoteClient, lm); return; } GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); // Local region? if (info != null) { Scene.RequestTeleportLocation( remoteClient, info.RegionHandle, lm.Position, Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } else { // Foreign region GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion gatekeeper = new GridRegion(); gatekeeper.ServerURI = lm.Gatekeeper; string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId); string message; GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID), remoteClient.AgentId, homeURI, out message); if (finalDestination != null) { ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId); if (sp != null) { if (message != null) { sp.ControllingClient.SendAgentAlertMessage(message, true); } // Validate assorted conditions string reason = string.Empty; if (!ValidateGenericConditions(sp, gatekeeper, finalDestination, 0, out reason)) { sp.ControllingClient.SendTeleportFailed(reason); return; } DoTeleport( sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } } else { remoteClient.SendTeleportFailed(message); } } }