diff options
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLPresenceData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLPresenceData.cs | 72 |
1 files changed, 3 insertions, 69 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs index 5a4ad3a..e7b3d9c 100644 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Data.MSSQL | |||
67 | using (SqlCommand cmd = new SqlCommand()) | 67 | using (SqlCommand cmd = new SqlCommand()) |
68 | { | 68 | { |
69 | 69 | ||
70 | cmd.CommandText = String.Format("UPDATE {0} SET Online='false' WHERE [RegionID]=@RegionID", m_Realm); | 70 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm); |
71 | 71 | ||
72 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 72 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); |
73 | cmd.Connection = conn; | 73 | cmd.Connection = conn; |
@@ -76,8 +76,7 @@ namespace OpenSim.Data.MSSQL | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | public bool ReportAgent(UUID sessionID, UUID regionID, string position, | 79 | public bool ReportAgent(UUID sessionID, UUID regionID) |
80 | string lookAt) | ||
81 | { | 80 | { |
82 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | 81 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); |
83 | if (pd.Length == 0) | 82 | if (pd.Length == 0) |
@@ -88,16 +87,11 @@ namespace OpenSim.Data.MSSQL | |||
88 | { | 87 | { |
89 | 88 | ||
90 | cmd.CommandText = String.Format(@"UPDATE {0} SET | 89 | cmd.CommandText = String.Format(@"UPDATE {0} SET |
91 | [RegionID] = @RegionID, | 90 | [RegionID] = @RegionID |
92 | [Position] = @Position, | ||
93 | [LookAt] = @LookAt, | ||
94 | [Online] = 'true' | ||
95 | WHERE [SessionID] = @SessionID", m_Realm); | 91 | WHERE [SessionID] = @SessionID", m_Realm); |
96 | 92 | ||
97 | cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); | 93 | cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); |
98 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 94 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); |
99 | cmd.Parameters.Add(m_database.CreateParameter("@Position", position.ToString())); | ||
100 | cmd.Parameters.Add(m_database.CreateParameter("@LookAt", lookAt.ToString())); | ||
101 | cmd.Connection = conn; | 95 | cmd.Connection = conn; |
102 | conn.Open(); | 96 | conn.Open(); |
103 | if (cmd.ExecuteNonQuery() == 0) | 97 | if (cmd.ExecuteNonQuery() == 0) |
@@ -106,65 +100,5 @@ namespace OpenSim.Data.MSSQL | |||
106 | return true; | 100 | return true; |
107 | } | 101 | } |
108 | 102 | ||
109 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
110 | { | ||
111 | PresenceData[] pd = Get("UserID", userID); | ||
112 | if (pd.Length == 0) | ||
113 | return false; | ||
114 | |||
115 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
116 | using (SqlCommand cmd = new SqlCommand()) | ||
117 | { | ||
118 | |||
119 | cmd.CommandText = String.Format(@"UPDATE {0} SET | ||
120 | [HomeRegionID] = @HomeRegionID, | ||
121 | [HomePosition] = @HomePosition, | ||
122 | [HomeLookAt] = @HomeLookAt | ||
123 | WHERE [UserID] = @UserID", m_Realm); | ||
124 | |||
125 | cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); | ||
126 | cmd.Parameters.Add(m_database.CreateParameter("@HomeRegionID", regionID.ToString())); | ||
127 | cmd.Parameters.Add(m_database.CreateParameter("@HomePosition", position)); | ||
128 | cmd.Parameters.Add(m_database.CreateParameter("@HomeLookAt", lookAt)); | ||
129 | cmd.Connection = conn; | ||
130 | conn.Open(); | ||
131 | if (cmd.ExecuteNonQuery() == 0) | ||
132 | return false; | ||
133 | } | ||
134 | return true; | ||
135 | } | ||
136 | |||
137 | public void Prune(string userID) | ||
138 | { | ||
139 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
140 | using (SqlCommand cmd = new SqlCommand()) | ||
141 | { | ||
142 | cmd.CommandText = String.Format("SELECT * from {0} WHERE [UserID] = @UserID", m_Realm); | ||
143 | |||
144 | cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); | ||
145 | cmd.Connection = conn; | ||
146 | conn.Open(); | ||
147 | |||
148 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
149 | { | ||
150 | List<UUID> deleteSessions = new List<UUID>(); | ||
151 | int online = 0; | ||
152 | |||
153 | while (reader.Read()) | ||
154 | { | ||
155 | if (bool.Parse(reader["Online"].ToString())) | ||
156 | online++; | ||
157 | else | ||
158 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
159 | } | ||
160 | |||
161 | if (online == 0 && deleteSessions.Count > 0) | ||
162 | deleteSessions.RemoveAt(0); | ||
163 | |||
164 | foreach (UUID s in deleteSessions) | ||
165 | Delete("SessionID", s.ToString()); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | 103 | } |
170 | } | 104 | } |