Skip to content

Commit

Permalink
Add hypergrid teleporting support to user profiles picks
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueWall committed Oct 27, 2014
1 parent c995b07 commit b463870
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 19 deletions.
8 changes: 6 additions & 2 deletions OpenSim/Data/MySQL/MySQLUserProfilesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId);
UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId);
pick.GlobalPos = (string)reader["posglobal"];
pick.Gatekeeper = (string)reader["gatekeeper"];
bool.TryParse((string)reader["toppick"], out pick.TopPick);
bool.TryParse((string)reader["enabled"], out pick.Enabled);
pick.Name = (string)reader["name"];
Expand Down Expand Up @@ -436,14 +437,16 @@ public bool UpdatePicksRecord(UserProfilePick pick)
query += "?SimName,";
query += "?GlobalPos,";
query += "?SortOrder,";
query += "?Enabled) ";
query += "?Enabled,";
query += "?Gatekeeper)";
query += "ON DUPLICATE KEY UPDATE ";
query += "parceluuid=?ParcelId,";
query += "name=?Name,";
query += "description=?Desc,";
query += "snapshotuuid=?SnapshotId,";
query += "pickuuid=?PickId,";
query += "posglobal=?GlobalPos";
query += "posglobal=?GlobalPos,";
query += "gatekeeper=?Gatekeeper";

try
{
Expand All @@ -463,6 +466,7 @@ public bool UpdatePicksRecord(UserProfilePick pick)
cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString());
cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString());
cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos);
cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper);
cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ());
cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString());

Expand Down
7 changes: 6 additions & 1 deletion OpenSim/Data/MySQL/Resources/UserProfiles.migrations
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ CREATE TABLE IF NOT EXISTS `usersettings` (
`email` varchar(254) NOT NULL,
PRIMARY KEY (`useruuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
commit;
commit;

:VERSION 4 # -------------------------------
begin;
ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255);
commit;
1 change: 1 addition & 0 deletions OpenSim/Framework/UserProfiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class UserProfilePick
public string User = string.Empty;
public string SimName = string.Empty;
public string GlobalPos = "<0,0,0>";
public string Gatekeeper = string.Empty;
public int SortOrder = 0;
public bool Enabled = false;
}
Expand Down
113 changes: 97 additions & 16 deletions OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
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
{
Expand Down Expand Up @@ -78,7 +80,8 @@ public Scene Scene
/// <value>
/// The configuration
/// </value>
public IConfigSource Config {
public IConfigSource Config
{
get;
set;
}
Expand All @@ -89,7 +92,8 @@ public IConfigSource Config {
/// <value>
/// The profile server URI.
/// </value>
public string ProfileServerUri {
public string ProfileServerUri
{
get;
set;
}
Expand All @@ -111,11 +115,17 @@ IUserManagement UserManagementModule
/// <value>
/// <c>true</c> if enabled; otherwise, <c>false</c>.
/// </value>
public bool Enabled {
public bool Enabled
{
get;
set;
}

public string MyGatekeeper
{
get; private set;
}


#region IRegionModuleBase implementation
/// <summary>
Expand Down Expand Up @@ -152,6 +162,9 @@ public void Initialise(IConfigSource source)
m_log.Debug("[PROFILES]: Full Profiles Enabled");
ReplaceableInterface = null;
Enabled = true;

MyGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI",
new string[] { "Startup", "Hypergrid", "UserProfiles" }, String.Empty);
}

/// <summary>
Expand Down Expand Up @@ -599,30 +612,64 @@ public void PickInfoRequest(Object sender, string method, List<String> args)
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);
Expand Down Expand Up @@ -659,7 +706,8 @@ public void PickInfoRequest(Object sender, string method, List<String> args)
/// Enabled.
/// </param>
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();
Expand Down Expand Up @@ -699,6 +747,7 @@ public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID,
avaPos.X, avaPos.Y, p.Scene.Name);
}


pick.PickId = pickID;
pick.CreatorId = creatorID;
pick.TopPick = topPick;
Expand All @@ -708,6 +757,7 @@ public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID,
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;
Expand Down Expand Up @@ -1259,6 +1309,37 @@ bool GetUserAccountData(UUID userID, out Dictionary<string, object> userInfo)
}
}

/// <summary>
/// Gets the user gatekeeper server URI.
/// </summary>
/// <returns>
/// The user gatekeeper server URI.
/// </returns>
/// <param name='userID'>
/// If set to <c>true</c> user URI.
/// </param>
/// <param name='serverURI'>
/// If set to <c>true</c> server URI.
/// </param>
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;
}
}

/// <summary>
/// Gets the user profile server UR.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions OpenSim/Services/LLLoginService/LLLoginService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,13 @@ private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account)
m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
}

if (!account.ServiceURLs.ContainsKey("GatekeeperURI") && !string.IsNullOrEmpty(m_GatekeeperURL))
{
m_log.DebugFormat("[LLLOGIN SERVICE]: adding gatekeeper uri {0}", m_GatekeeperURL);
account.ServiceURLs["GatekeeperURI"] = m_GatekeeperURL;
newUrls = true;
}

// The grid operator decided to override the defaults in the
// [LoginService] configuration. Let's store the correct ones.
if (newUrls)
Expand Down
35 changes: 35 additions & 0 deletions prebuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,40 @@
</Files>
</Project>

<Project frameworkVersion="v4_0" name="OpenSim.Services.SearchService" path="OpenSim/Services/SearchService" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>

<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Services.UserAccountService"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="OpenSim.Services.Base"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/>

<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>

<Project frameworkVersion="v4_0" name="OpenSim.Server.Handlers" path="OpenSim/Server/Handlers" type="Library">
<Configuration name="Debug">
Expand Down Expand Up @@ -1530,6 +1564,7 @@
<Reference name="System.Xml.Linq"/>
<Reference name="System.Drawing"/>
<Reference name="System.Web"/>
<Reference name="Microsoft.CSharp" />
<Reference name="NDesk.Options" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
Expand Down

0 comments on commit b463870

Please sign in to comment.