From 73934c7cae0d295bbe0fde8f8502b0ccece2ba15 Mon Sep 17 00:00:00 2001
From: onefang
Date: Thu, 25 Jul 2019 00:23:57 +1000
Subject: Combine LureModule and HGLureModule.
Still need to clean up after this, LureModule.cs isn't needed anymore.
---
OpenSim/Framework/Constants.cs | 2 +-
.../Region/CoreModules/Avatar/Lure/HGLureModule.cs | 170 ++++++++++++---------
2 files changed, 102 insertions(+), 70 deletions(-)
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index ac99a92..28055b8 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Framework
ViaLogin = 1 << 7,
/// Linden Summoned
ViaGodlikeLure = 1 << 8,
- /// Linden Forced me
+ /// "Linden Forced me" it used to say, but the code says "This user will be a God in the destination scene, too", but then is ignored.
Godlike = 1 << 9,
///
NineOneOne = 1 << 10,
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
index 10781e9..381bb4d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
@@ -29,10 +29,9 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
+using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
-using Mono.Addins;
-
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -45,8 +44,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGLureModule")]
public class HGLureModule : ISharedRegionModule
{
- private static readonly ILog m_log = LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly List m_scenes = new List();
@@ -69,6 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty);
// Legacy. Remove soon!
m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL);
+
m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name);
}
}
@@ -154,19 +153,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
void OnIncomingInstantMessage(GridInstantMessage im)
{
- if (im.dialog == (byte)InstantMessageDialog.RequestTeleport
- || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport)
+ if (im.dialog == (byte)InstantMessageDialog.RequestTeleport || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport)
{
- UUID sessionID = new UUID(im.imSessionID);
-
- if (!m_PendingLures.Contains(sessionID))
+ if (1 == im.binaryBucket[0])
{
- m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
- m_PendingLures.Add(sessionID, im, 7200); // 2 hours
+ UUID sessionID = new UUID(im.imSessionID);
+
+ if (!m_PendingLures.Contains(sessionID))
+ {
+ m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
+ m_PendingLures.Add(sessionID, im, 7200); // 2 hours
+ }
}
- // Forward. We do this, because the IM module explicitly rejects
- // IMs of this type
+ // Forward. We do this, because the IM module explicitly rejects IMs of this type
if (m_TransferModule != null)
m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
}
@@ -179,22 +179,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
Scene scene = (Scene)(client.Scene);
ScenePresence presence = scene.GetScenePresence(client.AgentId);
+ ScenePresence target = scene.GetScenePresence(targetid);
+ Guid start = client.Scene.RegionInfo.RegionID.Guid;
+ UUID dest;
+ byte reqType = (byte)InstantMessageDialog.RequestTeleport;
+ byte[] bucket = new Byte[1];
- message += "@" + m_ThisGridURL;
+ m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1} {2} {3} {4}", message, lureType, scene.Permissions.IsAdministrator(client.AgentId), presence.IsViewerUIGod, (!scene.Permissions.IsAdministrator(targetid)));
- m_log.DebugFormat("[HG LURE MODULE]: TP invite with message {0}", message);
+ GridInstantMessage m;
- UUID sessionID = UUID.Random();
+ GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(start));
+ if (region != null)
+ {
+ bucket[0] = 0;
+ dest = Util.BuildFakeParcelID(scene.RegionInfo.RegionHandle,
+ (uint)presence.AbsolutePosition.X, (uint)presence.AbsolutePosition.Y, (uint)presence.AbsolutePosition.Z);
+ if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid)))
+ {
+ reqType = (byte)InstantMessageDialog.GodLikeRequestTeleport;
+ m_log.DebugFormat("[LURE MODULE]: TP FORCE GOD LURE with message {0}, type {1}", message, lureType);
+ }
+ else
+ m_log.DebugFormat("[LURE MODULE]: TP lure with message {0}, type {1}", message, lureType);
+ }
+ else
+ {
+ m_log.DebugFormat("[LURE MODULE]: HG lure with message {0}, type {1}", message, lureType);
+ bucket[0] = 1;
+ message += "@" + m_ThisGridURL;
+ dest = UUID.Random();
+ }
- GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
- client.FirstName+" "+client.LastName, targetid,
- (byte)InstantMessageDialog.RequestTeleport, false,
- message, sessionID, false, presence.AbsolutePosition,
- new Byte[0], true);
- m.RegionID = client.Scene.RegionInfo.RegionID.Guid;
+ m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid,
+ reqType, false, message, dest, false, presence.AbsolutePosition, bucket, true);
- m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message);
- m_PendingLures.Add(sessionID, m, 7200); // 2 hours
+ if (region == null)
+ {
+ m.RegionID = start;
+ m_log.DebugFormat("[LURE MODULE]: Hypergrid RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message);
+ m_PendingLures.Add(dest, m, 7200); // 2 hours
+ }
if (m_TransferModule != null)
{
@@ -208,64 +233,71 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
if (!(client.Scene is Scene))
return;
-// Scene scene = (Scene)(client.Scene);
-
+ Scene scene = (Scene)(client.Scene);
GridInstantMessage im = null;
+
if (m_PendingLures.TryGetValue(lureID, out im))
{
m_PendingLures.Remove(lureID);
- Lure(client, teleportFlags, im);
- }
- else
- m_log.DebugFormat("[HG LURE MODULE]: pending lure {0} not found", lureID);
-
- }
-
- 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)
+ 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, 2f), Vector3.UnitX, teleportFlags);
+ else // we don't have that region here. Check if it's HG
{
- string url = parts[parts.Length - 1]; // the last part
- if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'}))
+ string[] parts = im.message.Split(new char[] { '@' });
+ if (parts.Length > 1)
{
- 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;
- string homeURI = scene.GetAgentHomeURI(client.AgentId);
-
- string message;
- GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message);
- if (finalDestination != null)
+ string url = parts[parts.Length - 1]; // the last part
+ if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'}))
{
- ScenePresence sp = scene.GetScenePresence(client.AgentId);
- IEntityTransferModule transferMod = scene.RequestModuleInterface();
-
- if (transferMod != null && sp != null)
+ m_log.DebugFormat("[HG LURE MODULE]: Luring agent to remote grid {0} region {1} position {2}", url, im.RegionID, im.Position);
+ GatekeeperServiceConnector gConn = new GatekeeperServiceConnector();
+ GridRegion gatekeeper = new GridRegion();
+ gatekeeper.ServerURI = url;
+ string homeURI = scene.GetAgentHomeURI(client.AgentId);
+
+ string message;
+ GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message);
+ if (finalDestination != null)
{
- if (message != null)
- sp.ControllingClient.SendAgentAlertMessage(message, true);
+ ScenePresence sp = scene.GetScenePresence(client.AgentId);
+ IEntityTransferModule transferMod = scene.RequestModuleInterface();
- transferMod.DoTeleport(
- sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f),
- Vector3.UnitX, teleportflags);
+ if (transferMod != null && sp != null)
+ {
+ if (message != null)
+ sp.ControllingClient.SendAgentAlertMessage(message, true);
+
+ transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 2f), Vector3.UnitX, teleportFlags);
+ }
+ }
+ else
+ {
+ m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message);
+ client.SendAgentAlertMessage(message, true);
}
- }
- else
- {
- m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message);
- client.SendAgentAlertMessage(message, true);
}
}
}
}
+ else
+ {
+ ulong handle = 0;
+ uint x = 128;
+ uint y = 128;
+ uint z = 70;
+
+ Util.ParseFakeParcelID(lureID, out handle, out x, out y, out z);
+
+ Vector3 position = new Vector3();
+ position.X = (float)x;
+ position.Y = (float)y;
+ position.Z = (float)z;
+
+ m_log.DebugFormat("[LURE MODULE]: Luring agent to local region {0}, position {1}", scene.Name, position);
+ scene.RequestTeleportLocation(client, handle, position + new Vector3(0.5f, 0.5f, 2f), Vector3.Zero, teleportFlags);
+ }
+
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1