diff options
author | Johan Berntsson | 2008-03-18 01:38:07 +0000 |
---|---|---|
committer | Johan Berntsson | 2008-03-18 01:38:07 +0000 |
commit | 040a887b9c5f22a79de3fdff3947b69d87221379 (patch) | |
tree | 401793a60499cd010ed360b6fbf991d42eb87798 /OpenSim/Framework/Data.MySQL | |
parent | * Move missing texture request forward so that we don't actually ask the Asse... (diff) | |
download | opensim-SC-040a887b9c5f22a79de3fdff3947b69d87221379.zip opensim-SC-040a887b9c5f22a79de3fdff3947b69d87221379.tar.gz opensim-SC-040a887b9c5f22a79de3fdff3947b69d87221379.tar.bz2 opensim-SC-040a887b9c5f22a79de3fdff3947b69d87221379.tar.xz |
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)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 52 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 13 |
2 files changed, 62 insertions, 3 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 0410643..46fd1bc 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -397,14 +397,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
397 | // Agent Who? | 397 | // Agent Who? |
398 | retval.agentIP = (string) reader["agentIP"]; | 398 | retval.agentIP = (string) reader["agentIP"]; |
399 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | 399 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); |
400 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); | 400 | retval.agentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); |
401 | 401 | ||
402 | // Login/Logout times (UNIX Epoch) | 402 | // Login/Logout times (UNIX Epoch) |
403 | retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); | 403 | retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); |
404 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | 404 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); |
405 | 405 | ||
406 | // Current position | 406 | // Current position |
407 | retval.currentRegion = (string) reader["currentRegion"]; | 407 | retval.currentRegion = new LLUUID((string)reader["currentRegion"]); |
408 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); | 408 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); |
409 | LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); | 409 | LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); |
410 | } | 410 | } |
@@ -859,5 +859,53 @@ namespace OpenSim.Framework.Data.MySQL | |||
859 | 859 | ||
860 | return returnval; | 860 | return returnval; |
861 | } | 861 | } |
862 | |||
863 | /// <summary> | ||
864 | /// Creates a new agent and inserts it into the database | ||
865 | /// </summary> | ||
866 | /// <param name="agentdata">The agent data to be inserted</param> | ||
867 | /// <returns>Success?</returns> | ||
868 | public bool insertAgentRow(UserAgentData agentdata) | ||
869 | { | ||
870 | string sql = String.Empty; | ||
871 | sql += "REPLACE INTO "; | ||
872 | sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES "; | ||
873 | sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);"; | ||
874 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
875 | |||
876 | parameters["?UUID"] = agentdata.UUID.ToString(); | ||
877 | parameters["?sessionID"] = agentdata.sessionID.ToString(); | ||
878 | parameters["?secureSessionID"] = agentdata.secureSessionID.ToString(); | ||
879 | parameters["?agentIP"] = agentdata.agentIP.ToString(); | ||
880 | parameters["?agentPort"] = agentdata.agentPort.ToString(); | ||
881 | parameters["?agentOnline"] = (agentdata.agentOnline == true) ? "1" : "0"; | ||
882 | parameters["?loginTime"] = agentdata.loginTime.ToString(); | ||
883 | parameters["?logoutTime"] = agentdata.logoutTime.ToString(); | ||
884 | parameters["?currentRegion"] = agentdata.currentRegion.ToString(); | ||
885 | parameters["?currentHandle"] = agentdata.currentHandle.ToString(); | ||
886 | parameters["?currentPos"] = "<" + ((int)agentdata.currentPos.X).ToString() + "," + ((int)agentdata.currentPos.Y).ToString() + "," + ((int)agentdata.currentPos.Z).ToString() + ">"; | ||
887 | |||
888 | bool returnval = false; | ||
889 | |||
890 | try | ||
891 | { | ||
892 | IDbCommand result = Query(sql, parameters); | ||
893 | |||
894 | //Console.WriteLine(result.CommandText); | ||
895 | int x; | ||
896 | if ((x = result.ExecuteNonQuery()) > 0) | ||
897 | { | ||
898 | returnval = true; | ||
899 | } | ||
900 | result.Dispose(); | ||
901 | } | ||
902 | catch (Exception e) | ||
903 | { | ||
904 | m_log.Error(e.ToString()); | ||
905 | return false; | ||
906 | } | ||
907 | |||
908 | return returnval; | ||
909 | } | ||
862 | } | 910 | } |
863 | } | 911 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 2bba6ce..4c76461 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -585,7 +585,18 @@ namespace OpenSim.Framework.Data.MySQL | |||
585 | /// <param name="agent">The agent to create</param> | 585 | /// <param name="agent">The agent to create</param> |
586 | public void AddNewUserAgent(UserAgentData agent) | 586 | public void AddNewUserAgent(UserAgentData agent) |
587 | { | 587 | { |
588 | // Do nothing. | 588 | try |
589 | { | ||
590 | lock (database) | ||
591 | { | ||
592 | database.insertAgentRow(agent); | ||
593 | } | ||
594 | } | ||
595 | catch (Exception e) | ||
596 | { | ||
597 | database.Reconnect(); | ||
598 | m_log.Error(e.ToString()); | ||
599 | } | ||
589 | } | 600 | } |
590 | 601 | ||
591 | /// <summary> | 602 | /// <summary> |