From b46387091470f3d1465c05625a656228ca54fd61 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Mon, 27 Oct 2014 17:27:42 -0400
Subject: Add hypergrid teleporting support to user profiles picks
---
.../Avatar/UserProfiles/UserProfileModule.cs | 113 ++++++++++++++++++---
1 file changed, 97 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index f4a4f17..8337a2f 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -48,6 +48,8 @@ using Mono.Addins;
using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.UserProfilesService;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using Microsoft.CSharp;
namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{
@@ -78,7 +80,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// The configuration
///
- public IConfigSource Config {
+ public IConfigSource Config
+ {
get;
set;
}
@@ -89,7 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// The profile server URI.
///
- public string ProfileServerUri {
+ public string ProfileServerUri
+ {
get;
set;
}
@@ -111,11 +115,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// true if enabled; otherwise, false.
///
- public bool Enabled {
+ public bool Enabled
+ {
get;
set;
}
+ public string MyGatekeeper
+ {
+ get; private set;
+ }
+
#region IRegionModuleBase implementation
///
@@ -152,6 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
m_log.Debug("[PROFILES]: Full Profiles Enabled");
ReplaceableInterface = null;
Enabled = true;
+
+ MyGatekeeper = Util.GetConfigVarFromSections(source, "GatekeeperURI",
+ new string[] { "Startup", "Hypergrid", "UserProfiles" }, String.Empty);
}
///
@@ -599,30 +612,64 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return;
UUID targetID;
- UUID.TryParse(args[0], out targetID);
+ UUID.TryParse (args [0], out targetID);
string serverURI = string.Empty;
- GetUserProfileServerURI(targetID, out serverURI);
+ GetUserProfileServerURI (targetID, out serverURI);
+
+ string theirGatekeeperURI;
+ GetUserGatekeeperURI (targetID, out theirGatekeeperURI);
+
IClientAPI remoteClient = (IClientAPI)sender;
- UserProfilePick pick = new UserProfilePick();
- UUID.TryParse(args[0], out pick.CreatorId);
- UUID.TryParse(args[1], out pick.PickId);
+ UserProfilePick pick = new UserProfilePick ();
+ UUID.TryParse (args [0], out pick.CreatorId);
+ UUID.TryParse (args [1], out pick.PickId);
object Pick = (object)pick;
- if(!rpc.JsonRpcRequest(ref Pick, "pickinforequest", serverURI, UUID.Random().ToString()))
- {
- remoteClient.SendAgentAlertMessage(
+ if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) {
+ remoteClient.SendAgentAlertMessage (
"Error selecting pick", false);
return;
}
- pick = (UserProfilePick) Pick;
-
- Vector3 globalPos;
- Vector3.TryParse(pick.GlobalPos,out globalPos);
+ pick = (UserProfilePick)Pick;
+
+ Vector3 globalPos = new Vector3(Vector3.Zero);
+
+ // Smoke and mirrors
+ if (pick.Gatekeeper == MyGatekeeper)
+ {
+ Vector3.TryParse(pick.GlobalPos,out globalPos);
+ }
+ else
+ {
+ // Setup the illusion
+ string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName);
+ GridRegion target = Scene.GridService.GetRegionByName(Scene.RegionInfo.ScopeID, region);
+
+ if(target == null)
+ {
+ // This is a dead or unreachable region
+ }
+ else
+ {
+ // Work our slight of hand
+ int x = target.RegionLocX;
+ int y = target.RegionLocY;
+
+ dynamic synthX = globalPos.X - (globalPos.X/Constants.RegionSize) * Constants.RegionSize;
+ synthX += x;
+ globalPos.X = synthX;
+
+ dynamic synthY = globalPos.Y - (globalPos.Y/Constants.RegionSize) * Constants.RegionSize;
+ synthY += y;
+ globalPos.Y = synthY;
+ }
+ }
m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString());
+ // Pull the rabbit out of the hat
remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name,
pick.Desc,pick.SnapshotId,pick.User,pick.OriginalName,pick.SimName,
globalPos,pick.SortOrder,pick.Enabled);
@@ -659,7 +706,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// Enabled.
///
public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
- {
+ {
+ //TODO: See how this works with NPC, May need to test
m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
UserProfilePick pick = new UserProfilePick();
@@ -699,6 +747,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
avaPos.X, avaPos.Y, p.Scene.Name);
}
+
pick.PickId = pickID;
pick.CreatorId = creatorID;
pick.TopPick = topPick;
@@ -708,6 +757,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
pick.SnapshotId = snapshotID;
pick.User = landOwnerName;
pick.SimName = remoteClient.Scene.RegionInfo.RegionName;
+ pick.Gatekeeper = MyGatekeeper;
pick.GlobalPos = posGlobal.ToString();
pick.SortOrder = sortOrder;
pick.Enabled = enabled;
@@ -1260,6 +1310,37 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
}
///
+ /// Gets the user gatekeeper server URI.
+ ///
+ ///
+ /// The user gatekeeper server URI.
+ ///
+ ///
+ /// If set to true user URI.
+ ///
+ ///
+ /// If set to true server URI.
+ ///
+ bool GetUserGatekeeperURI(UUID userID, out string serverURI)
+ {
+ bool local;
+ local = UserManagementModule.IsLocalGridUser(userID);
+
+ if (!local)
+ {
+ serverURI = UserManagementModule.GetUserServerURL(userID, "GatekeeperURI");
+ // Is Foreign
+ return true;
+ }
+ else
+ {
+ serverURI = MyGatekeeper;
+ // Is local
+ return false;
+ }
+ }
+
+ ///
/// Gets the user profile server UR.
///
///
--
cgit v1.1