From 52a4c4d82f9c5b808e6c61fd51c1c70e42865565 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 12 Sep 2008 20:12:03 +0000
Subject: * Check in first part of
http://opensimulator.org/mantis/view.php?id=2073 * This patch aims to
introduce look at direction persistence between logins. It won't be active
until the second part of the patch is committed in about two weeks time. At
this point, region servers that haven't upgraded past this revision may run
into problems * This checkin upgrades the user database. As always, we
recommend you have backups in case something goes wrong. * Many thanks to
tyre for this patch.
---
.../Communications/CommunicationsManager.cs | 14 +-
OpenSim/Framework/Communications/IUserService.cs | 13 +-
OpenSim/Framework/Communications/LoginService.cs | 35 +---
.../Framework/Communications/UserManagerBase.cs | 196 ++++++++++-----------
OpenSim/Framework/Constants.cs | 48 ++++-
OpenSim/Framework/UserAgentData.cs | 98 ++++++-----
OpenSim/Framework/Util.cs | 2 +
7 files changed, 235 insertions(+), 171 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index e6413e8..969bdd8 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -276,13 +276,25 @@ namespace OpenSim.Framework.Communications
///
///
///
+ ///
+ ///
+ public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
+ {
+ m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat);
+ }
+
+ ///
+ /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27)
+ ///
+ ///
+ ///
+ ///
///
///
///
public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
{
m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
-
}
///
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 07ea437..7e3c77b 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -106,7 +106,18 @@ namespace OpenSim.Framework.Communications
/// Logs off a user on the user server
///
/// UUID of the user
- /// UUID of the Region
+ /// UUID of the Region
+ /// regionhandle
+ /// final position
+ /// final lookat
+ void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat);
+
+ ///
+ /// Logs off a user on the user server (deprecated as of 2008-08-27)
+ ///
+ /// UUID of the user
+ /// UUID of the Region
+ /// regionhandle
/// final position x
/// final position y
/// final position z
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 7cdbf6c..26ae3c6 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -258,30 +258,19 @@ namespace OpenSim.Framework.Communications
InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
ArrayList InventoryLibRoot = new ArrayList();
InventoryLibRoot.Add(InventoryLibRootHash);
- logResponse.InventoryLibRoot = InventoryLibRoot;
+ logResponse.InventoryLibRoot = InventoryLibRoot;
logResponse.InventoryLibraryOwner = GetLibraryOwner();
-
logResponse.InventoryRoot = InventoryRoot;
logResponse.InventorySkeleton = AgentInventoryArray;
logResponse.InventoryLibrary = GetInventoryLibrary();
- // Circuit Code
- uint circode = (uint) (Util.RandomClass.Next());
-
+ logResponse.CircuitCode = (Int32)Util.RandomClass.Next();
logResponse.Lastname = userProfile.SurName;
logResponse.Firstname = userProfile.FirstName;
logResponse.AgentID = agentID.ToString();
logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString();
logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString();
-
- logResponse.CircuitCode = (Int32) circode;
- //logResponse.RegionX = 0; //overwritten
- //logResponse.RegionY = 0; //overwritten
- logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
- //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
- //logResponse.SimAddress = "127.0.0.1"; //overwritten
- //logResponse.SimPort = 0; //overwritten
logResponse.Message = GetMessage();
logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
logResponse.StartLocation = startLocationRequest;
@@ -322,6 +311,11 @@ namespace OpenSim.Framework.Communications
}
}
+ ///
+ /// Called when we receive the client's initial LLSD login_to_simulator request message
+ ///
+ /// The LLSD request
+ /// The response to send
public LLSD LLSDLoginMethod(LLSD request)
{
// Temporary fix
@@ -432,30 +426,19 @@ namespace OpenSim.Framework.Communications
InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
ArrayList InventoryLibRoot = new ArrayList();
InventoryLibRoot.Add(InventoryLibRootHash);
- logResponse.InventoryLibRoot = InventoryLibRoot;
+ logResponse.InventoryLibRoot = InventoryLibRoot;
logResponse.InventoryLibraryOwner = GetLibraryOwner();
-
logResponse.InventoryRoot = InventoryRoot;
logResponse.InventorySkeleton = AgentInventoryArray;
logResponse.InventoryLibrary = GetInventoryLibrary();
- // Circuit Code
- uint circode = (uint)(Util.RandomClass.Next());
-
+ logResponse.CircuitCode = (Int32)Util.RandomClass.Next();
logResponse.Lastname = userProfile.SurName;
logResponse.Firstname = userProfile.FirstName;
logResponse.AgentID = agentID.ToString();
logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString();
logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString();
-
- logResponse.CircuitCode = (Int32)circode;
- //logResponse.RegionX = 0; //overwritten
- //logResponse.RegionY = 0; //overwritten
- logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
- //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
- //logResponse.SimAddress = "127.0.0.1"; //overwritten
- //logResponse.SimPort = 0; //overwritten
logResponse.Message = GetMessage();
logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
logResponse.StartLocation = startLocationRequest;
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index b6564bf..75c4dc1 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -388,84 +388,115 @@ namespace OpenSim.Framework.Communications
// Profile UUID
agent.ProfileID = profile.ID;
- // Current position (from Home)
- agent.Handle = profile.HomeRegion;
- agent.Position = profile.HomeLocation;
-
- // If user specified additional start, use that
- if (requestData.ContainsKey("start"))
+ // Current location/position/alignment
+ if (profile.CurrentAgent != null)
{
- string startLoc = ((string)requestData["start"]).Trim();
- if (("last" == startLoc) && (profile.CurrentAgent != null))
- {
- if ((profile.CurrentAgent.Position.X > 0)
- && (profile.CurrentAgent.Position.Y > 0)
- && (profile.CurrentAgent.Position.Z > 0)
- )
- {
- // TODO: Right now, currentRegion has not been used in GridServer for requesting region.
- // TODO: It is only using currentHandle.
- agent.Region = profile.CurrentAgent.Region;
- agent.Handle = profile.CurrentAgent.Handle;
- agent.Position = profile.CurrentAgent.Position;
- }
- }
-
-// if (!(startLoc == "last" || startLoc == "home"))
-// {
-// // Format: uri:Ahern&162&213&34
-// try
-// {
-// string[] parts = startLoc.Remove(0, 4).Split('&');
-// //string region = parts[0];
-//
-// ////////////////////////////////////////////////////
-// //SimProfile SimInfo = new SimProfile();
-// //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
-// }
-// catch (Exception)
-// {
-// }
-// }
+ agent.Region = profile.CurrentAgent.Region;
+ agent.Handle = profile.CurrentAgent.Handle;
+ agent.Position = profile.CurrentAgent.Position;
+ agent.LookAt = profile.CurrentAgent.LookAt;
+ }
+ else
+ {
+ agent.Region = profile.HomeRegionID;
+ agent.Handle = profile.HomeRegion;
+ agent.Position = profile.HomeLocation;
+ agent.LookAt = profile.HomeLookAt;
}
// What time did the user login?
agent.LoginTime = Util.UnixTimeSinceEpoch();
agent.LogoutTime = 0;
- // Current location
- agent.InitialRegion = UUID.Zero; // Fill in later
- agent.Region = UUID.Zero; // Fill in later
+ profile.CurrentAgent = agent;
+ }
+
+ public void CreateAgent(UserProfileData profile, LLSD request)
+ {
+ UserAgentData agent = new UserAgentData();
+
+ // User connection
+ agent.AgentOnline = true;
+
+ //if (request.Params.Count > 1)
+ //{
+ // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
+ // agent.AgentIP = RemoteIPEndPoint.Address.ToString();
+ // agent.AgentPort = (uint)RemoteIPEndPoint.Port;
+ //}
+
+ // Generate sessions
+ RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
+ byte[] randDataS = new byte[16];
+ byte[] randDataSS = new byte[16];
+ rand.GetBytes(randDataS);
+ rand.GetBytes(randDataSS);
+
+ agent.SecureSessionID = new UUID(randDataSS, 0);
+ agent.SessionID = new UUID(randDataS, 0);
+
+ // Profile UUID
+ agent.ProfileID = profile.ID;
+
+ // Current location/position/alignment
+ if (profile.CurrentAgent != null)
+ {
+ agent.Region = profile.CurrentAgent.Region;
+ agent.Handle = profile.CurrentAgent.Handle;
+ agent.Position = profile.CurrentAgent.Position;
+ agent.LookAt = profile.CurrentAgent.LookAt;
+ }
+ else
+ {
+ agent.Region = profile.HomeRegionID;
+ agent.Handle = profile.HomeRegion;
+ agent.Position = profile.HomeLocation;
+ agent.LookAt = profile.HomeLookAt;
+ }
+
+ // What time did the user login?
+ agent.LoginTime = Util.UnixTimeSinceEpoch();
+ agent.LogoutTime = 0;
profile.CurrentAgent = agent;
}
///
+ /// Saves a target agent to the database
+ ///
+ /// The users profile
+ /// Successful?
+ public bool CommitAgent(ref UserProfileData profile)
+ {
+ // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents"
+ // TODO: what is the logic should be?
+ bool ret = false;
+ ret = AddUserAgent(profile.CurrentAgent);
+ ret = ret & UpdateUserProfile(profile);
+ return ret;
+ }
+
+ ///
/// Process a user logoff from OpenSim.
///
///
///
///
- ///
- ///
- ///
- public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
+ ///
+ ///
+ public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
{
if (StatsManager.UserStats != null)
StatsManager.UserStats.AddLogout();
- UserProfileData userProfile;
- UserAgentData userAgent;
- Vector3 currentPos = new Vector3(posx, posy, posz);
-
- userProfile = GetUserProfile(userid);
+ UserProfileData userProfile = GetUserProfile(userid);
if (userProfile != null)
{
// This line needs to be in side the above if statement or the UserServer will crash on some logouts.
- m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")");
+ m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + position.X + "," + position.Y + "," + position.Z + ")");
- userAgent = userProfile.CurrentAgent;
+ UserAgentData userAgent = userProfile.CurrentAgent;
if (userAgent != null)
{
userAgent.AgentOnline = false;
@@ -475,10 +506,11 @@ namespace OpenSim.Framework.Communications
{
userAgent.Region = regionid;
}
-
userAgent.Handle = regionhandle;
- userAgent.Position = currentPos;
- userProfile.CurrentAgent = userAgent;
+ userAgent.Position = position;
+ userAgent.LookAt = lookat;
+ //userProfile.CurrentAgent = userAgent;
+ userProfile.LastLogin = userAgent.LogoutTime;
CommitAgent(ref userProfile);
}
@@ -494,54 +526,18 @@ namespace OpenSim.Framework.Communications
}
}
- public void CreateAgent(UserProfileData profile, LLSD request)
- {
- UserAgentData agent = new UserAgentData();
-
- // User connection
- agent.AgentOnline = true;
-
- // Generate sessions
- RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
- byte[] randDataS = new byte[16];
- byte[] randDataSS = new byte[16];
- rand.GetBytes(randDataS);
- rand.GetBytes(randDataSS);
-
- agent.SecureSessionID = new UUID(randDataSS, 0);
- agent.SessionID = new UUID(randDataS, 0);
-
- // Profile UUID
- agent.ProfileID = profile.ID;
-
- // Current position (from Home)
- agent.Handle = profile.HomeRegion;
- agent.Position = profile.HomeLocation;
-
- // What time did the user login?
- agent.LoginTime = Util.UnixTimeSinceEpoch();
- agent.LogoutTime = 0;
-
- // Current location
- agent.InitialRegion = UUID.Zero; // Fill in later
- agent.Region = UUID.Zero; // Fill in later
-
- profile.CurrentAgent = agent;
- }
-
///
- /// Saves a target agent to the database
+ /// Process a user logoff from OpenSim (deprecated as of 2008-08-27)
///
- /// The users profile
- /// Successful?
- public bool CommitAgent(ref UserProfileData profile)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
{
- // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents"
- // TODO: what is the logic should be?
- bool ret = false;
- ret = AddUserAgent(profile.CurrentAgent);
- ret = ret & UpdateUserProfile(profile);
- return ret;
+ LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3());
}
#endregion
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 316d2a3..61eb35e 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -24,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
namespace OpenSim.Framework
{
@@ -40,5 +41,50 @@ namespace OpenSim.Framework
EstateBans = 20,
EstateManagers = 24
}
+
+ [Flags]public enum TeleportFlags : uint
+ {
+ /// No flags set, or teleport failed
+ Default = 0,
+ /// Set when newbie leaves help island for first time
+ SetHomeToTarget = 1 << 0,
+ ///
+ SetLastToTarget = 1 << 1,
+ /// Via Lure
+ ViaLure = 1 << 2,
+ /// Via Landmark
+ ViaLandmark = 1 << 3,
+ /// Via Location
+ ViaLocation = 1 << 4,
+ /// Via Home
+ ViaHome = 1 << 5,
+ /// Via Telehub
+ ViaTelehub = 1 << 6,
+ /// Via Login
+ ViaLogin = 1 << 7,
+ /// Linden Summoned
+ ViaGodlikeLure = 1 << 8,
+ /// Linden Forced me
+ Godlike = 1 << 9,
+ ///
+ NineOneOne = 1 << 10,
+ /// Agent Teleported Home via Script
+ DisableCancel = 1 << 11,
+ ///
+ ViaRegionID = 1 << 12,
+ ///
+ IsFlying = 1 << 13,
+ ///
+ ResetHome = 1 << 14,
+ /// forced to new location for example when avatar is banned or ejected
+ ForceRedirect = 1 << 15,
+ /// Teleport Finished via a Lure
+ FinishedViaLure = 1 << 26,
+ /// Finished, Sim Changed
+ FinishedViaNewSim = 1 << 28,
+ /// Finished, Same Sim
+ FinishedViaSameSim = 1 << 29
+ }
+
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/UserAgentData.cs b/OpenSim/Framework/UserAgentData.cs
index 03a65c5..506a5e0 100644
--- a/OpenSim/Framework/UserAgentData.cs
+++ b/OpenSim/Framework/UserAgentData.cs
@@ -36,34 +36,35 @@ namespace OpenSim.Framework
public class UserAgentData
{
///
- /// The IP address of the user
+ /// The UUID of the users avatar (not the agent!)
///
- private string agentIP = String.Empty;
+ private UUID UUID;
///
- /// Is the user online?
+ /// The session ID for the user (also the agent ID)
///
- private bool agentOnline;
+ private UUID sessionID;
///
- /// The port of the user
+ /// The "secure" session ID for the user
///
- private uint agentPort;
+ /// Not very secure. Dont rely on it for anything more than Linden Lab does.
+ private UUID secureSessionID;
///
- /// Region handle of the current region the user is in
+ /// The IP address of the user
///
- private ulong currentHandle;
+ private string agentIP = String.Empty;
///
- /// The position of the user within the region
+ /// The port of the user
///
- private Vector3 currentPos;
+ private uint agentPort;
///
- /// Current region the user is logged into
+ /// Is the user online?
///
- private UUID currentRegion;
+ private bool agentOnline;
///
/// A unix timestamp from when the user logged in
@@ -76,25 +77,29 @@ namespace OpenSim.Framework
private int logoutTime;
///
- /// The region the user logged into initially
+ /// Region ID the user is logged into
///
private UUID regionID;
///
- /// The "secure" session ID for the user
+ /// Region handle of the current region the user is in
///
- /// Not very secure. Dont rely on it for anything more than Linden Lab does.
- private UUID secureSessionID;
+ private ulong regionHandle;
///
- /// The session ID for the user (also the agent ID)
+ /// The position of the user within the region
///
- private UUID sessionID;
+ private Vector3 currentPos;
///
- /// The UUID of the users avatar (not the agent!)
+ /// Current direction the user is looking at
///
- private UUID UUID;
+ private Vector3 currentLookAt = Vector3.Zero;
+
+ ///
+ /// The region the user logged into initially
+ ///
+ private UUID originRegionID;
public virtual UUID ProfileID
{
@@ -102,6 +107,18 @@ namespace OpenSim.Framework
set { UUID = value; }
}
+ public virtual UUID SessionID
+ {
+ get { return sessionID; }
+ set { sessionID = value; }
+ }
+
+ public virtual UUID SecureSessionID
+ {
+ get { return secureSessionID; }
+ set { secureSessionID = value; }
+ }
+
public virtual string AgentIP
{
get { return agentIP; }
@@ -120,24 +137,6 @@ namespace OpenSim.Framework
set { agentOnline = value; }
}
- public virtual UUID SessionID
- {
- get { return sessionID; }
- set { sessionID = value; }
- }
-
- public virtual UUID SecureSessionID
- {
- get { return secureSessionID; }
- set { secureSessionID = value; }
- }
-
- public virtual UUID InitialRegion
- {
- get { return regionID; }
- set { regionID = value; }
- }
-
public virtual int LoginTime
{
get { return loginTime; }
@@ -152,14 +151,14 @@ namespace OpenSim.Framework
public virtual UUID Region
{
- get { return currentRegion; }
- set { currentRegion = value; }
+ get { return regionID; }
+ set { regionID = value; }
}
public virtual ulong Handle
{
- get { return currentHandle; }
- set { currentHandle = value; }
+ get { return regionHandle; }
+ set { regionHandle = value; }
}
public virtual Vector3 Position
@@ -168,6 +167,7 @@ namespace OpenSim.Framework
set { currentPos = value; }
}
+/* 2008-08-28-tyre: Not really useful
public virtual float PositionX
{
get { return currentPos.X; }
@@ -185,5 +185,19 @@ namespace OpenSim.Framework
get { return currentPos.Z; }
set { currentPos.Z = value; }
}
+*/
+
+ public virtual Vector3 LookAt
+ {
+ get { return currentLookAt; }
+ set { currentLookAt = value; }
+ }
+
+ public virtual UUID InitialRegion
+ {
+ get { return originRegionID; }
+ set { originRegionID = value; }
+ }
+
}
}
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index d289978..333ab81 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -678,6 +678,7 @@ namespace OpenSim.Framework
}
}
+/* 2008-08-28-tyre: Obsolete (see LocalLoginService UserLoginService)
public static string[] ParseStartLocationRequest(string startLocationRequest)
{
string[] returnstring = new string[4];
@@ -715,6 +716,7 @@ namespace OpenSim.Framework
}
return returnstring;
}
+*/
public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args)
{
--
cgit v1.1