aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLPresenceData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLPresenceData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs52
1 files changed, 52 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index 8ccad90..72b8a0c 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -93,5 +93,57 @@ namespace OpenSim.Data.MySQL
93 93
94 return true; 94 return true;
95 } 95 }
96
97 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
98 {
99 PresenceData[] pd = Get("UserID", userID);
100 if (pd.Length == 0)
101 return false;
102
103 MySqlCommand cmd = new MySqlCommand();
104
105 cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm);
106
107 cmd.Parameters.AddWithValue("?UserID", userID);
108 cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString());
109 cmd.Parameters.AddWithValue("?HomePosition", position);
110 cmd.Parameters.AddWithValue("?HomeLookAt", lookAt);
111
112 if (ExecuteNonQuery(cmd) == 0)
113 return false;
114
115 return true;
116 }
117
118 public void Prune(string userID)
119 {
120 MySqlCommand cmd = new MySqlCommand();
121
122 cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm);
123
124 cmd.Parameters.AddWithValue("?UserID", userID);
125
126 IDataReader reader = ExecuteReader(cmd);
127
128 List<UUID> deleteSessions = new List<UUID>();
129 int online = 0;
130
131 while(reader.Read())
132 {
133 if (bool.Parse(reader["Online"].ToString()))
134 online++;
135 else
136 deleteSessions.Add(new UUID(reader["SessionID"].ToString()));
137 }
138
139 if (online == 0 && deleteSessions.Count > 0)
140 deleteSessions.RemoveAt(0);
141
142 reader.Close();
143 CloseReaderCommand(cmd);
144
145 foreach (UUID s in deleteSessions)
146 Delete("SessionID", s.ToString());
147 }
96 } 148 }
97} 149}