Last position will be stored in the DB on logout, and the avatar can continue from the same position in the next login (only with MySQL at the moment)
parent
bbddc0dbe7
commit
040a887b9c
|
@ -154,6 +154,10 @@ namespace OpenSim.Framework.UserManagement
|
|||
|
||||
if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
|
||||
{
|
||||
//TODO: The following statements can cause trouble:
|
||||
// If agentOnline could not turn from true back to false normally
|
||||
// because of some problem, for instance, the crashment of server or client,
|
||||
// the user cannot log in any longer.
|
||||
userProfile.currentAgent = null;
|
||||
m_userManager.CommitAgent(ref userProfile);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -337,7 +338,7 @@ namespace OpenSim.Framework.UserManagement
|
|||
/// <param name="request">The users loginrequest</param>
|
||||
public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
|
||||
{
|
||||
//Hashtable requestData = (Hashtable) request.Params[0];
|
||||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
|
||||
UserAgentData agent = new UserAgentData();
|
||||
|
||||
|
@ -362,9 +363,24 @@ namespace OpenSim.Framework.UserManagement
|
|||
agent.currentPos = profile.homeLocation;
|
||||
|
||||
// If user specified additional start, use that
|
||||
// if (requestData.ContainsKey("start"))
|
||||
// {
|
||||
// string startLoc = ((string) requestData["start"]).Trim();
|
||||
if (requestData.ContainsKey("start"))
|
||||
{
|
||||
string startLoc = ((string)requestData["start"]).Trim();
|
||||
if (("last" == startLoc) && (profile.currentAgent != null))
|
||||
{
|
||||
if ((profile.currentAgent.currentPos.X > 0)
|
||||
&& (profile.currentAgent.currentPos.Y > 0)
|
||||
&& (profile.currentAgent.currentPos.Z > 0)
|
||||
)
|
||||
{
|
||||
// TODO: Right now, currentRegion has not been used in GridServer for requesting region.
|
||||
// TODO: It is only using currentHandle.
|
||||
agent.currentRegion = profile.currentAgent.currentRegion;
|
||||
agent.currentHandle = profile.currentAgent.currentHandle;
|
||||
agent.currentPos = profile.currentAgent.currentPos;
|
||||
}
|
||||
}
|
||||
|
||||
// if (!(startLoc == "last" || startLoc == "home"))
|
||||
// {
|
||||
// // Format: uri:Ahern&162&213&34
|
||||
|
@ -381,7 +397,7 @@ namespace OpenSim.Framework.UserManagement
|
|||
// {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// What time did the user login?
|
||||
agent.loginTime = Util.UnixTimeSinceEpoch();
|
||||
|
@ -424,7 +440,7 @@ namespace OpenSim.Framework.UserManagement
|
|||
{
|
||||
userAgent.agentOnline = false;
|
||||
userAgent.logoutTime = Util.UnixTimeSinceEpoch();
|
||||
userAgent.sessionID = LLUUID.Zero;
|
||||
//userAgent.sessionID = LLUUID.Zero;
|
||||
if (regionid != null)
|
||||
{
|
||||
userAgent.currentRegion = regionid;
|
||||
|
@ -493,8 +509,12 @@ namespace OpenSim.Framework.UserManagement
|
|||
/// <returns>Successful?</returns>
|
||||
public bool CommitAgent(ref UserProfileData profile)
|
||||
{
|
||||
// TODO: how is this function different from setUserProfile?
|
||||
return setUserProfile(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 & setUserProfile(profile);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -558,5 +578,26 @@ namespace OpenSim.Framework.UserManagement
|
|||
public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
|
||||
public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
|
||||
public abstract UserProfileData SetupMasterUser(LLUUID uuid);
|
||||
|
||||
/// <summary>
|
||||
/// Add agent to DB
|
||||
/// </summary>
|
||||
/// <param name="agentdata">The agent data to be added</param>
|
||||
public bool AddUserAgent(UserAgentData agentdata)
|
||||
{
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.Value.AddNewUserAgent(agentdata);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Key + "(" + e.ToString() + ")");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,14 +397,14 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
// Agent Who?
|
||||
retval.agentIP = (string) reader["agentIP"];
|
||||
retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
|
||||
retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
|
||||
retval.agentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString()));
|
||||
|
||||
// Login/Logout times (UNIX Epoch)
|
||||
retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString());
|
||||
retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
|
||||
|
||||
// Current position
|
||||
retval.currentRegion = (string) reader["currentRegion"];
|
||||
retval.currentRegion = new LLUUID((string)reader["currentRegion"]);
|
||||
retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
|
||||
LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
|
||||
}
|
||||
|
@ -859,5 +859,53 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new agent and inserts it into the database
|
||||
/// </summary>
|
||||
/// <param name="agentdata">The agent data to be inserted</param>
|
||||
/// <returns>Success?</returns>
|
||||
public bool insertAgentRow(UserAgentData agentdata)
|
||||
{
|
||||
string sql = String.Empty;
|
||||
sql += "REPLACE INTO ";
|
||||
sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES ";
|
||||
sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);";
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
|
||||
parameters["?UUID"] = agentdata.UUID.ToString();
|
||||
parameters["?sessionID"] = agentdata.sessionID.ToString();
|
||||
parameters["?secureSessionID"] = agentdata.secureSessionID.ToString();
|
||||
parameters["?agentIP"] = agentdata.agentIP.ToString();
|
||||
parameters["?agentPort"] = agentdata.agentPort.ToString();
|
||||
parameters["?agentOnline"] = (agentdata.agentOnline == true) ? "1" : "0";
|
||||
parameters["?loginTime"] = agentdata.loginTime.ToString();
|
||||
parameters["?logoutTime"] = agentdata.logoutTime.ToString();
|
||||
parameters["?currentRegion"] = agentdata.currentRegion.ToString();
|
||||
parameters["?currentHandle"] = agentdata.currentHandle.ToString();
|
||||
parameters["?currentPos"] = "<" + ((int)agentdata.currentPos.X).ToString() + "," + ((int)agentdata.currentPos.Y).ToString() + "," + ((int)agentdata.currentPos.Z).ToString() + ">";
|
||||
|
||||
bool returnval = false;
|
||||
|
||||
try
|
||||
{
|
||||
IDbCommand result = Query(sql, parameters);
|
||||
|
||||
//Console.WriteLine(result.CommandText);
|
||||
int x;
|
||||
if ((x = result.ExecuteNonQuery()) > 0)
|
||||
{
|
||||
returnval = true;
|
||||
}
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,7 +585,18 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
/// <param name="agent">The agent to create</param>
|
||||
public void AddNewUserAgent(UserAgentData agent)
|
||||
{
|
||||
// Do nothing.
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
database.insertAgentRow(agent);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue