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 ++++++++++----------- 4 files changed, 130 insertions(+), 128 deletions(-) (limited to 'OpenSim/Framework/Communications') 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 -- cgit v1.1