aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs182
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs165
-rw-r--r--OpenSim/Data/MySQL/MySQLAvatarData.cs17
-rw-r--r--OpenSim/Data/MySQL/MySQLFriendsData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs130
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs267
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs48
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs142
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs5
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs46
17 files changed, 598 insertions, 510 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index a22dc0a..20df234 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -163,54 +163,53 @@ namespace OpenSim.Data.MySQL
163 { 163 {
164 dbcon.Open(); 164 dbcon.Open();
165 165
166 MySqlCommand cmd = 166 using (MySqlCommand cmd =
167 new MySqlCommand( 167 new MySqlCommand(
168 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 168 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
169 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", 169 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
170 dbcon); 170 dbcon))
171
172 string assetName = asset.Name;
173 if (asset.Name.Length > 64)
174 {
175 assetName = asset.Name.Substring(0, 64);
176 m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
177 }
178
179 string assetDescription = asset.Description;
180 if (asset.Description.Length > 64)
181 {
182 assetDescription = asset.Description.Substring(0, 64);
183 m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
184 }
185
186 // need to ensure we dispose
187 try
188 { 171 {
189 using (cmd) 172 string assetName = asset.Name;
173 if (asset.Name.Length > 64)
190 { 174 {
191 // create unix epoch time 175 assetName = asset.Name.Substring(0, 64);
192 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 176 m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
193 cmd.Parameters.AddWithValue("?id", asset.ID); 177 }
194 cmd.Parameters.AddWithValue("?name", assetName); 178
195 cmd.Parameters.AddWithValue("?description", assetDescription); 179 string assetDescription = asset.Description;
196 cmd.Parameters.AddWithValue("?assetType", asset.Type); 180 if (asset.Description.Length > 64)
197 cmd.Parameters.AddWithValue("?local", asset.Local); 181 {
198 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 182 assetDescription = asset.Description.Substring(0, 64);
199 cmd.Parameters.AddWithValue("?create_time", now); 183 m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
200 cmd.Parameters.AddWithValue("?access_time", now); 184 }
201 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); 185
202 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 186 try
203 cmd.Parameters.AddWithValue("?data", asset.Data); 187 {
204 cmd.ExecuteNonQuery(); 188 using (cmd)
205 cmd.Dispose(); 189 {
206 return true; 190 // create unix epoch time
191 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
192 cmd.Parameters.AddWithValue("?id", asset.ID);
193 cmd.Parameters.AddWithValue("?name", assetName);
194 cmd.Parameters.AddWithValue("?description", assetDescription);
195 cmd.Parameters.AddWithValue("?assetType", asset.Type);
196 cmd.Parameters.AddWithValue("?local", asset.Local);
197 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
198 cmd.Parameters.AddWithValue("?create_time", now);
199 cmd.Parameters.AddWithValue("?access_time", now);
200 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
202 cmd.Parameters.AddWithValue("?data", asset.Data);
203 cmd.ExecuteNonQuery();
204 return true;
205 }
206 }
207 catch (Exception e)
208 {
209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
210 asset.FullID, asset.Name, e.Message);
211 return false;
207 } 212 }
208 }
209 catch (Exception e)
210 {
211 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
212 asset.FullID, asset.Name, e.Message);
213 return false;
214 } 213 }
215 } 214 }
216 } 215 }
@@ -223,33 +222,31 @@ namespace OpenSim.Data.MySQL
223 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 222 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
224 { 223 {
225 dbcon.Open(); 224 dbcon.Open();
226 MySqlCommand cmd =
227 new MySqlCommand("update assets set access_time=?access_time where id=?id",
228 dbcon);
229 225
230 // need to ensure we dispose 226 using (MySqlCommand cmd
231 try 227 = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon))
232 { 228 {
233 using (cmd) 229 try
234 { 230 {
235 // create unix epoch time 231 using (cmd)
236 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 232 {
237 cmd.Parameters.AddWithValue("?id", asset.ID); 233 // create unix epoch time
238 cmd.Parameters.AddWithValue("?access_time", now); 234 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
239 cmd.ExecuteNonQuery(); 235 cmd.Parameters.AddWithValue("?id", asset.ID);
240 cmd.Dispose(); 236 cmd.Parameters.AddWithValue("?access_time", now);
237 cmd.ExecuteNonQuery();
238 }
239 }
240 catch (Exception e)
241 {
242 m_log.ErrorFormat(
243 "[ASSETS DB]: " +
244 "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
245 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
241 } 246 }
242 }
243 catch (Exception e)
244 {
245 m_log.ErrorFormat(
246 "[ASSETS DB]: " +
247 "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
248 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
249 } 247 }
250 } 248 }
251 } 249 }
252
253 } 250 }
254 251
255 /// <summary> 252 /// <summary>
@@ -312,35 +309,41 @@ namespace OpenSim.Data.MySQL
312 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 309 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
313 { 310 {
314 dbcon.Open(); 311 dbcon.Open();
315 MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon);
316 cmd.Parameters.AddWithValue("?start", start);
317 cmd.Parameters.AddWithValue("?count", count);
318 312
319 try 313 using (MySqlCommand cmd
314 = new MySqlCommand(
315 "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
316 dbcon))
320 { 317 {
321 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 318 cmd.Parameters.AddWithValue("?start", start);
319 cmd.Parameters.AddWithValue("?count", count);
320
321 try
322 { 322 {
323 while (dbReader.Read()) 323 using (MySqlDataReader dbReader = cmd.ExecuteReader())
324 { 324 {
325 AssetMetadata metadata = new AssetMetadata(); 325 while (dbReader.Read())
326 metadata.Name = (string)dbReader["name"]; 326 {
327 metadata.Description = (string)dbReader["description"]; 327 AssetMetadata metadata = new AssetMetadata();
328 metadata.Type = (sbyte)dbReader["assetType"]; 328 metadata.Name = (string)dbReader["name"];
329 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. 329 metadata.Description = (string)dbReader["description"];
330 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 330 metadata.Type = (sbyte)dbReader["assetType"];
331 metadata.FullID = DBGuid.FromDB(dbReader["id"]); 331 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
332 metadata.CreatorID = dbReader["CreatorID"].ToString(); 332 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
333 333 metadata.FullID = DBGuid.FromDB(dbReader["id"]);
334 // Current SHA1s are not stored/computed. 334 metadata.CreatorID = dbReader["CreatorID"].ToString();
335 metadata.SHA1 = new byte[] { }; 335
336 336 // Current SHA1s are not stored/computed.
337 retList.Add(metadata); 337 metadata.SHA1 = new byte[] { };
338
339 retList.Add(metadata);
340 }
338 } 341 }
339 } 342 }
340 } 343 catch (Exception e)
341 catch (Exception e) 344 {
342 { 345 m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
343 m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 346 }
344 } 347 }
345 } 348 }
346 } 349 }
@@ -355,11 +358,12 @@ namespace OpenSim.Data.MySQL
355 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 358 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
356 { 359 {
357 dbcon.Open(); 360 dbcon.Open();
358 MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon);
359 cmd.Parameters.AddWithValue("?id", id);
360 cmd.ExecuteNonQuery();
361 361
362 cmd.Dispose(); 362 using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon))
363 {
364 cmd.Parameters.AddWithValue("?id", id);
365 cmd.ExecuteNonQuery();
366 }
363 } 367 }
364 } 368 }
365 369
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 664ce84..7627497 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -70,30 +70,34 @@ namespace OpenSim.Data.MySQL
70 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 70 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
71 { 71 {
72 dbcon.Open(); 72 dbcon.Open();
73 MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon);
74 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
75
76 IDataReader result = cmd.ExecuteReader();
77 73
78 if (result.Read()) 74 using (MySqlCommand cmd
75 = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon))
79 { 76 {
80 ret.PrincipalID = principalID; 77 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
81
82 CheckColumnNames(result);
83 78
84 foreach (string s in m_ColumnNames) 79 IDataReader result = cmd.ExecuteReader();
80
81 if (result.Read())
85 { 82 {
86 if (s == "UUID") 83 ret.PrincipalID = principalID;
87 continue; 84
88 85 CheckColumnNames(result);
89 ret.Data[s] = result[s].ToString(); 86
87 foreach (string s in m_ColumnNames)
88 {
89 if (s == "UUID")
90 continue;
91
92 ret.Data[s] = result[s].ToString();
93 }
94
95 return ret;
96 }
97 else
98 {
99 return null;
90 } 100 }
91
92 return ret;
93 }
94 else
95 {
96 return null;
97 } 101 }
98 } 102 }
99 } 103 }
@@ -119,57 +123,53 @@ namespace OpenSim.Data.MySQL
119 123
120 string[] fields = new List<string>(data.Data.Keys).ToArray(); 124 string[] fields = new List<string>(data.Data.Keys).ToArray();
121 125
122 MySqlCommand cmd = new MySqlCommand(); 126 using (MySqlCommand cmd = new MySqlCommand())
123
124 string update = "update `"+m_Realm+"` set ";
125 bool first = true;
126 foreach (string field in fields)
127 { 127 {
128 if (!first) 128 string update = "update `"+m_Realm+"` set ";
129 update += ", "; 129 bool first = true;
130 update += "`" + field + "` = ?"+field; 130 foreach (string field in fields)
131 131 {
132 first = false; 132 if (!first)
133 133 update += ", ";
134 cmd.Parameters.AddWithValue("?"+field, data.Data[field]); 134 update += "`" + field + "` = ?"+field;
135 } 135
136 136 first = false;
137 update += " where UUID = ?principalID"; 137
138 138 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
139 cmd.CommandText = update; 139 }
140 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); 140
141 141 update += " where UUID = ?principalID";
142 if (ExecuteNonQuery(cmd) < 1) 142
143 { 143 cmd.CommandText = update;
144 string insert = "insert into `" + m_Realm + "` (`UUID`, `" + 144 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
145 String.Join("`, `", fields) + 145
146 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")";
147
148 cmd.CommandText = insert;
149
150 if (ExecuteNonQuery(cmd) < 1) 146 if (ExecuteNonQuery(cmd) < 1)
151 { 147 {
152 cmd.Dispose(); 148 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
153 return false; 149 String.Join("`, `", fields) +
150 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")";
151
152 cmd.CommandText = insert;
153
154 if (ExecuteNonQuery(cmd) < 1)
155 return false;
154 } 156 }
155 } 157 }
156 158
157 cmd.Dispose();
158
159 return true; 159 return true;
160 } 160 }
161 161
162 public bool SetDataItem(UUID principalID, string item, string value) 162 public bool SetDataItem(UUID principalID, string item, string value)
163 { 163 {
164 MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + 164 using (MySqlCommand cmd
165 "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); 165 = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"))
166 166 {
167 167 cmd.Parameters.AddWithValue("?"+item, value);
168 cmd.Parameters.AddWithValue("?"+item, value); 168 cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
169 cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); 169
170 170 if (ExecuteNonQuery(cmd) > 0)
171 if (ExecuteNonQuery(cmd) > 0) 171 return true;
172 return true; 172 }
173 173
174 return false; 174 return false;
175 } 175 }
@@ -179,18 +179,18 @@ namespace OpenSim.Data.MySQL
179 if (System.Environment.TickCount - m_LastExpire > 30000) 179 if (System.Environment.TickCount - m_LastExpire > 30000)
180 DoExpire(); 180 DoExpire();
181 181
182 MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); 182 using (MySqlCommand cmd
183 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 183 = new MySqlCommand(
184 cmd.Parameters.AddWithValue("?token", token); 184 "insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"))
185 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
186
187 if (ExecuteNonQuery(cmd) > 0)
188 { 185 {
189 cmd.Dispose(); 186 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
190 return true; 187 cmd.Parameters.AddWithValue("?token", token);
188 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
189
190 if (ExecuteNonQuery(cmd) > 0)
191 return true;
191 } 192 }
192 193
193 cmd.Dispose();
194 return false; 194 return false;
195 } 195 }
196 196
@@ -199,30 +199,29 @@ namespace OpenSim.Data.MySQL
199 if (System.Environment.TickCount - m_LastExpire > 30000) 199 if (System.Environment.TickCount - m_LastExpire > 30000)
200 DoExpire(); 200 DoExpire();
201 201
202 MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); 202 using (MySqlCommand cmd
203 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 203 = new MySqlCommand(
204 cmd.Parameters.AddWithValue("?token", token); 204 "update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"))
205 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
206
207 if (ExecuteNonQuery(cmd) > 0)
208 { 205 {
209 cmd.Dispose(); 206 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
210 return true; 207 cmd.Parameters.AddWithValue("?token", token);
211 } 208 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
212 209
213 cmd.Dispose(); 210 if (ExecuteNonQuery(cmd) > 0)
211 return true;
212 }
214 213
215 return false; 214 return false;
216 } 215 }
217 216
218 private void DoExpire() 217 private void DoExpire()
219 { 218 {
220 MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); 219 using (MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"))
221 ExecuteNonQuery(cmd); 220 {
222 221 ExecuteNonQuery(cmd);
223 cmd.Dispose(); 222 }
224 223
225 m_LastExpire = System.Environment.TickCount; 224 m_LastExpire = System.Environment.TickCount;
226 } 225 }
227 } 226 }
228} 227} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs
index 8c841ab..6a2f5d8 100644
--- a/OpenSim/Data/MySQL/MySQLAvatarData.cs
+++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs
@@ -52,14 +52,15 @@ namespace OpenSim.Data.MySQL
52 52
53 public bool Delete(UUID principalID, string name) 53 public bool Delete(UUID principalID, string name)
54 { 54 {
55 MySqlCommand cmd = new MySqlCommand(); 55 using (MySqlCommand cmd = new MySqlCommand())
56 56 {
57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); 57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm);
58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
59 cmd.Parameters.AddWithValue("?Name", name); 59 cmd.Parameters.AddWithValue("?Name", name);
60 60
61 if (ExecuteNonQuery(cmd) > 0) 61 if (ExecuteNonQuery(cmd) > 0)
62 return true; 62 return true;
63 }
63 64
64 return false; 65 return false;
65 } 66 }
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs
index 130ba5e..3cd6b8f 100644
--- a/OpenSim/Data/MySQL/MySQLFriendsData.cs
+++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs
@@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL
49 49
50 public bool Delete(string principalID, string friend) 50 public bool Delete(string principalID, string friend)
51 { 51 {
52 MySqlCommand cmd = new MySqlCommand(); 52 using (MySqlCommand cmd = new MySqlCommand())
53 {
54 cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm);
55 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
56 cmd.Parameters.AddWithValue("?Friend", friend);
53 57
54 cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); 58 ExecuteNonQuery(cmd);
55 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 59 }
56 cmd.Parameters.AddWithValue("?Friend", friend);
57
58 ExecuteNonQuery(cmd);
59 60
60 return true; 61 return true;
61 } 62 }
62 63
63 public FriendsData[] GetFriends(UUID principalID) 64 public FriendsData[] GetFriends(UUID principalID)
64 { 65 {
65 MySqlCommand cmd = new MySqlCommand(); 66 using (MySqlCommand cmd = new MySqlCommand())
66 67 {
67 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); 68 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm);
68 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 69 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
69 70
70 return DoQuery(cmd); 71 return DoQuery(cmd);
72 }
71 } 73 }
72 74
73 public FriendsData[] GetFriends(string principalID) 75 public FriendsData[] GetFriends(string principalID)
74 { 76 {
75 MySqlCommand cmd = new MySqlCommand(); 77 using (MySqlCommand cmd = new MySqlCommand())
78 {
79 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm);
80 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%');
76 81
77 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); 82 return DoQuery(cmd);
78 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); 83 }
79 return DoQuery(cmd);
80 } 84 }
81 } 85 }
82} 86} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 1a634e5..e9b10f3 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -467,43 +467,43 @@ namespace OpenSim.Data.MySQL
467 { 467 {
468 dbcon.Open(); 468 dbcon.Open();
469 469
470 MySqlCommand result = new MySqlCommand(sql, dbcon); 470 using (MySqlCommand result = new MySqlCommand(sql, dbcon))
471 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
472 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
473 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
474 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
475 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
476 result.Parameters.AddWithValue("?inventoryName", itemName);
477 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
478 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
479 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
480 item.CurrentPermissions.ToString());
481 result.Parameters.AddWithValue("?invType", item.InvType);
482 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
483 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
484 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
485 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
486 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
487 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
488 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
489 result.Parameters.AddWithValue("?groupID", item.GroupID);
490 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
491 result.Parameters.AddWithValue("?flags", item.Flags);
492
493 lock (m_dbLock)
494 { 471 {
495 result.ExecuteNonQuery(); 472 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
473 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
474 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
475 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
476 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
477 result.Parameters.AddWithValue("?inventoryName", itemName);
478 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
479 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
480 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
481 item.CurrentPermissions.ToString());
482 result.Parameters.AddWithValue("?invType", item.InvType);
483 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
484 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
485 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
486 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
487 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
488 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
489 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
490 result.Parameters.AddWithValue("?groupID", item.GroupID);
491 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
492 result.Parameters.AddWithValue("?flags", item.Flags);
493
494 lock (m_dbLock)
495 result.ExecuteNonQuery();
496
497 result.Dispose();
496 } 498 }
497 499
498 result.Dispose(); 500 using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon))
499
500 result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon);
501 result.Parameters.AddWithValue("?folderID", item.Folder.ToString());
502 lock (m_dbLock)
503 { 501 {
504 result.ExecuteNonQuery(); 502 result.Parameters.AddWithValue("?folderID", item.Folder.ToString());
503
504 lock (m_dbLock)
505 result.ExecuteNonQuery();
505 } 506 }
506 result.Dispose();
507 } 507 }
508 } 508 }
509 catch (MySqlException e) 509 catch (MySqlException e)
@@ -533,12 +533,12 @@ namespace OpenSim.Data.MySQL
533 { 533 {
534 dbcon.Open(); 534 dbcon.Open();
535 535
536 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); 536 using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon))
537 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
538
539 lock (m_dbLock)
540 { 537 {
541 cmd.ExecuteNonQuery(); 538 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
539
540 lock (m_dbLock)
541 cmd.ExecuteNonQuery();
542 } 542 }
543 } 543 }
544 } 544 }
@@ -579,24 +579,26 @@ namespace OpenSim.Data.MySQL
579 { 579 {
580 dbcon.Open(); 580 dbcon.Open();
581 581
582 MySqlCommand cmd = new MySqlCommand(sql, dbcon); 582 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
583 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
584 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
585 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
586 cmd.Parameters.AddWithValue("?folderName", folderName);
587 cmd.Parameters.AddWithValue("?type", folder.Type);
588 cmd.Parameters.AddWithValue("?version", folder.Version);
589
590 try
591 { 583 {
592 lock (m_dbLock) 584 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
585 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
586 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
587 cmd.Parameters.AddWithValue("?folderName", folderName);
588 cmd.Parameters.AddWithValue("?type", folder.Type);
589 cmd.Parameters.AddWithValue("?version", folder.Version);
590
591 try
593 { 592 {
594 cmd.ExecuteNonQuery(); 593 lock (m_dbLock)
594 {
595 cmd.ExecuteNonQuery();
596 }
597 }
598 catch (Exception e)
599 {
600 m_log.Error(e.ToString());
595 } 601 }
596 }
597 catch (Exception e)
598 {
599 m_log.Error(e.ToString());
600 } 602 }
601 } 603 }
602 } 604 }
@@ -624,20 +626,22 @@ namespace OpenSim.Data.MySQL
624 { 626 {
625 dbcon.Open(); 627 dbcon.Open();
626 628
627 MySqlCommand cmd = new MySqlCommand(sql, dbcon); 629 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
628 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
629 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
630
631 try
632 { 630 {
633 lock (m_dbLock) 631 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
632 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
633
634 try
634 { 635 {
635 cmd.ExecuteNonQuery(); 636 lock (m_dbLock)
637 {
638 cmd.ExecuteNonQuery();
639 }
640 }
641 catch (Exception e)
642 {
643 m_log.Error(e.ToString());
636 } 644 }
637 }
638 catch (Exception e)
639 {
640 m_log.Error(e.ToString());
641 } 645 }
642 } 646 }
643 } 647 }
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index fc625f0..7808060 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -63,13 +63,14 @@ namespace OpenSim.Data.MySQL
63 63
64 public void LogoutRegionAgents(UUID regionID) 64 public void LogoutRegionAgents(UUID regionID)
65 { 65 {
66 MySqlCommand cmd = new MySqlCommand(); 66 using (MySqlCommand cmd = new MySqlCommand())
67 67 {
68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); 68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm);
69 69
70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
71 71
72 ExecuteNonQuery(cmd); 72 ExecuteNonQuery(cmd);
73 }
73 } 74 }
74 75
75 public bool ReportAgent(UUID sessionID, UUID regionID) 76 public bool ReportAgent(UUID sessionID, UUID regionID)
@@ -81,17 +82,18 @@ namespace OpenSim.Data.MySQL
81 if (regionID == UUID.Zero) 82 if (regionID == UUID.Zero)
82 return false; 83 return false;
83 84
84 MySqlCommand cmd = new MySqlCommand(); 85 using (MySqlCommand cmd = new MySqlCommand())
85 86 {
86 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); 87 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm);
87 88
88 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); 89 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
89 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 90 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
90 91
91 if (ExecuteNonQuery(cmd) == 0) 92 if (ExecuteNonQuery(cmd) == 0)
92 return false; 93 return false;
94 }
93 95
94 return true; 96 return true;
95 } 97 }
96 } 98 }
97} 99} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index d1f1932..0614879 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -329,11 +329,12 @@ namespace OpenSim.Data.MySQL
329 if (scopeID != UUID.Zero) 329 if (scopeID != UUID.Zero)
330 command += " and ScopeID = ?scopeID"; 330 command += " and ScopeID = ?scopeID";
331 331
332 MySqlCommand cmd = new MySqlCommand(command); 332 using (MySqlCommand cmd = new MySqlCommand(command))
333 333 {
334 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 334 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
335 335
336 return RunCommand(cmd); 336 return RunCommand(cmd);
337 }
337 } 338 }
338 } 339 }
339} 340} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 33c184f..89600db 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -129,119 +129,119 @@ namespace OpenSim.Data.MySQL
129 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 129 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
130 { 130 {
131 dbcon.Open(); 131 dbcon.Open();
132 MySqlCommand cmd = dbcon.CreateCommand();
133 132
134 foreach (SceneObjectPart prim in obj.Parts) 133 using (MySqlCommand cmd = dbcon.CreateCommand())
135 { 134 {
136 cmd.Parameters.Clear(); 135 foreach (SceneObjectPart prim in obj.Parts)
136 {
137 cmd.Parameters.Clear();
137 138
138 cmd.CommandText = "replace into prims (" + 139 cmd.CommandText = "replace into prims (" +
139 "UUID, CreationDate, " + 140 "UUID, CreationDate, " +
140 "Name, Text, Description, " + 141 "Name, Text, Description, " +
141 "SitName, TouchName, ObjectFlags, " + 142 "SitName, TouchName, ObjectFlags, " +
142 "OwnerMask, NextOwnerMask, GroupMask, " + 143 "OwnerMask, NextOwnerMask, GroupMask, " +
143 "EveryoneMask, BaseMask, PositionX, " + 144 "EveryoneMask, BaseMask, PositionX, " +
144 "PositionY, PositionZ, GroupPositionX, " + 145 "PositionY, PositionZ, GroupPositionX, " +
145 "GroupPositionY, GroupPositionZ, VelocityX, " + 146 "GroupPositionY, GroupPositionZ, VelocityX, " +
146 "VelocityY, VelocityZ, AngularVelocityX, " + 147 "VelocityY, VelocityZ, AngularVelocityX, " +
147 "AngularVelocityY, AngularVelocityZ, " + 148 "AngularVelocityY, AngularVelocityZ, " +
148 "AccelerationX, AccelerationY, " + 149 "AccelerationX, AccelerationY, " +
149 "AccelerationZ, RotationX, " + 150 "AccelerationZ, RotationX, " +
150 "RotationY, RotationZ, " + 151 "RotationY, RotationZ, " +
151 "RotationW, SitTargetOffsetX, " + 152 "RotationW, SitTargetOffsetX, " +
152 "SitTargetOffsetY, SitTargetOffsetZ, " + 153 "SitTargetOffsetY, SitTargetOffsetZ, " +
153 "SitTargetOrientW, SitTargetOrientX, " + 154 "SitTargetOrientW, SitTargetOrientX, " +
154 "SitTargetOrientY, SitTargetOrientZ, " + 155 "SitTargetOrientY, SitTargetOrientZ, " +
155 "RegionUUID, CreatorID, " + 156 "RegionUUID, CreatorID, " +
156 "OwnerID, GroupID, " + 157 "OwnerID, GroupID, " +
157 "LastOwnerID, SceneGroupID, " + 158 "LastOwnerID, SceneGroupID, " +
158 "PayPrice, PayButton1, " + 159 "PayPrice, PayButton1, " +
159 "PayButton2, PayButton3, " + 160 "PayButton2, PayButton3, " +
160 "PayButton4, LoopedSound, " + 161 "PayButton4, LoopedSound, " +
161 "LoopedSoundGain, TextureAnimation, " + 162 "LoopedSoundGain, TextureAnimation, " +
162 "OmegaX, OmegaY, OmegaZ, " + 163 "OmegaX, OmegaY, OmegaZ, " +
163 "CameraEyeOffsetX, CameraEyeOffsetY, " + 164 "CameraEyeOffsetX, CameraEyeOffsetY, " +
164 "CameraEyeOffsetZ, CameraAtOffsetX, " + 165 "CameraEyeOffsetZ, CameraAtOffsetX, " +
165 "CameraAtOffsetY, CameraAtOffsetZ, " + 166 "CameraAtOffsetY, CameraAtOffsetZ, " +
166 "ForceMouselook, ScriptAccessPin, " + 167 "ForceMouselook, ScriptAccessPin, " +
167 "AllowedDrop, DieAtEdge, " + 168 "AllowedDrop, DieAtEdge, " +
168 "SalePrice, SaleType, " + 169 "SalePrice, SaleType, " +
169 "ColorR, ColorG, ColorB, ColorA, " + 170 "ColorR, ColorG, ColorB, ColorA, " +
170 "ParticleSystem, ClickAction, Material, " + 171 "ParticleSystem, ClickAction, Material, " +
171 "CollisionSound, CollisionSoundVolume, " + 172 "CollisionSound, CollisionSoundVolume, " +
172 "PassTouches, " + 173 "PassTouches, " +
173 "LinkNumber, MediaURL, KeyframeMotion, " + 174 "LinkNumber, MediaURL, KeyframeMotion, " +
174 "PhysicsShapeType, Density, GravityModifier, " + 175 "PhysicsShapeType, Density, GravityModifier, " +
175 "Friction, Restitution) values (" + "?UUID, " + 176 "Friction, Restitution) values (" + "?UUID, " +
176 "?CreationDate, ?Name, ?Text, " + 177 "?CreationDate, ?Name, ?Text, " +
177 "?Description, ?SitName, ?TouchName, " + 178 "?Description, ?SitName, ?TouchName, " +
178 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + 179 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
179 "?GroupMask, ?EveryoneMask, ?BaseMask, " + 180 "?GroupMask, ?EveryoneMask, ?BaseMask, " +
180 "?PositionX, ?PositionY, ?PositionZ, " + 181 "?PositionX, ?PositionY, ?PositionZ, " +
181 "?GroupPositionX, ?GroupPositionY, " + 182 "?GroupPositionX, ?GroupPositionY, " +
182 "?GroupPositionZ, ?VelocityX, " + 183 "?GroupPositionZ, ?VelocityX, " +
183 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + 184 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " +
184 "?AngularVelocityY, ?AngularVelocityZ, " + 185 "?AngularVelocityY, ?AngularVelocityZ, " +
185 "?AccelerationX, ?AccelerationY, " + 186 "?AccelerationX, ?AccelerationY, " +
186 "?AccelerationZ, ?RotationX, " + 187 "?AccelerationZ, ?RotationX, " +
187 "?RotationY, ?RotationZ, " + 188 "?RotationY, ?RotationZ, " +
188 "?RotationW, ?SitTargetOffsetX, " + 189 "?RotationW, ?SitTargetOffsetX, " +
189 "?SitTargetOffsetY, ?SitTargetOffsetZ, " + 190 "?SitTargetOffsetY, ?SitTargetOffsetZ, " +
190 "?SitTargetOrientW, ?SitTargetOrientX, " + 191 "?SitTargetOrientW, ?SitTargetOrientX, " +
191 "?SitTargetOrientY, ?SitTargetOrientZ, " + 192 "?SitTargetOrientY, ?SitTargetOrientZ, " +
192 "?RegionUUID, ?CreatorID, ?OwnerID, " + 193 "?RegionUUID, ?CreatorID, ?OwnerID, " +
193 "?GroupID, ?LastOwnerID, ?SceneGroupID, " + 194 "?GroupID, ?LastOwnerID, ?SceneGroupID, " +
194 "?PayPrice, ?PayButton1, ?PayButton2, " + 195 "?PayPrice, ?PayButton1, ?PayButton2, " +
195 "?PayButton3, ?PayButton4, ?LoopedSound, " + 196 "?PayButton3, ?PayButton4, ?LoopedSound, " +
196 "?LoopedSoundGain, ?TextureAnimation, " + 197 "?LoopedSoundGain, ?TextureAnimation, " +
197 "?OmegaX, ?OmegaY, ?OmegaZ, " + 198 "?OmegaX, ?OmegaY, ?OmegaZ, " +
198 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + 199 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " +
199 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + 200 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " +
200 "?CameraAtOffsetY, ?CameraAtOffsetZ, " + 201 "?CameraAtOffsetY, ?CameraAtOffsetZ, " +
201 "?ForceMouselook, ?ScriptAccessPin, " + 202 "?ForceMouselook, ?ScriptAccessPin, " +
202 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + 203 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " +
203 "?SaleType, ?ColorR, ?ColorG, " + 204 "?SaleType, ?ColorR, ?ColorG, " +
204 "?ColorB, ?ColorA, ?ParticleSystem, " + 205 "?ColorB, ?ColorA, ?ParticleSystem, " +
205 "?ClickAction, ?Material, ?CollisionSound, " + 206 "?ClickAction, ?Material, ?CollisionSound, " +
206 "?CollisionSoundVolume, ?PassTouches, " + 207 "?CollisionSoundVolume, ?PassTouches, " +
207 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + 208 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
208 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 209 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
209 "?Friction, ?Restitution)"; 210 "?Friction, ?Restitution)";
210 211
211 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 212 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
212 213
213 ExecuteNonQuery(cmd); 214 ExecuteNonQuery(cmd);
214 215
215 cmd.Parameters.Clear(); 216 cmd.Parameters.Clear();
216 217
217 cmd.CommandText = "replace into primshapes (" + 218 cmd.CommandText = "replace into primshapes (" +
218 "UUID, Shape, ScaleX, ScaleY, " + 219 "UUID, Shape, ScaleX, ScaleY, " +
219 "ScaleZ, PCode, PathBegin, PathEnd, " + 220 "ScaleZ, PCode, PathBegin, PathEnd, " +
220 "PathScaleX, PathScaleY, PathShearX, " + 221 "PathScaleX, PathScaleY, PathShearX, " +
221 "PathShearY, PathSkew, PathCurve, " + 222 "PathShearY, PathSkew, PathCurve, " +
222 "PathRadiusOffset, PathRevolutions, " + 223 "PathRadiusOffset, PathRevolutions, " +
223 "PathTaperX, PathTaperY, PathTwist, " + 224 "PathTaperX, PathTaperY, PathTwist, " +
224 "PathTwistBegin, ProfileBegin, ProfileEnd, " + 225 "PathTwistBegin, ProfileBegin, ProfileEnd, " +
225 "ProfileCurve, ProfileHollow, Texture, " + 226 "ProfileCurve, ProfileHollow, Texture, " +
226 "ExtraParams, State, Media) values (?UUID, " + 227 "ExtraParams, State, Media) values (?UUID, " +
227 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + 228 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
228 "?PCode, ?PathBegin, ?PathEnd, " + 229 "?PCode, ?PathBegin, ?PathEnd, " +
229 "?PathScaleX, ?PathScaleY, " + 230 "?PathScaleX, ?PathScaleY, " +
230 "?PathShearX, ?PathShearY, " + 231 "?PathShearX, ?PathShearY, " +
231 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + 232 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " +
232 "?PathRevolutions, ?PathTaperX, " + 233 "?PathRevolutions, ?PathTaperX, " +
233 "?PathTaperY, ?PathTwist, " + 234 "?PathTaperY, ?PathTwist, " +
234 "?PathTwistBegin, ?ProfileBegin, " + 235 "?PathTwistBegin, ?ProfileBegin, " +
235 "?ProfileEnd, ?ProfileCurve, " + 236 "?ProfileEnd, ?ProfileCurve, " +
236 "?ProfileHollow, ?Texture, ?ExtraParams, " + 237 "?ProfileHollow, ?Texture, ?ExtraParams, " +
237 "?State, ?Media)"; 238 "?State, ?Media)";
238 239
239 FillShapeCommand(cmd, prim); 240 FillShapeCommand(cmd, prim);
240 241
241 ExecuteNonQuery(cmd); 242 ExecuteNonQuery(cmd);
243 }
242 } 244 }
243
244 cmd.Dispose();
245 } 245 }
246 } 246 }
247 } 247 }
@@ -1865,41 +1865,40 @@ namespace OpenSim.Data.MySQL
1865 { 1865 {
1866 RemoveItems(primID); 1866 RemoveItems(primID);
1867 1867
1868 if (items.Count == 0)
1869 return;
1870
1868 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1871 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1869 { 1872 {
1870 dbcon.Open(); 1873 dbcon.Open();
1871 1874
1872 MySqlCommand cmd = dbcon.CreateCommand(); 1875 using (MySqlCommand cmd = dbcon.CreateCommand())
1873
1874 if (items.Count == 0)
1875 return;
1876
1877 cmd.CommandText = "insert into primitems (" +
1878 "invType, assetType, name, " +
1879 "description, creationDate, nextPermissions, " +
1880 "currentPermissions, basePermissions, " +
1881 "everyonePermissions, groupPermissions, " +
1882 "flags, itemID, primID, assetID, " +
1883 "parentFolderID, creatorID, ownerID, " +
1884 "groupID, lastOwnerID) values (?invType, " +
1885 "?assetType, ?name, ?description, " +
1886 "?creationDate, ?nextPermissions, " +
1887 "?currentPermissions, ?basePermissions, " +
1888 "?everyonePermissions, ?groupPermissions, " +
1889 "?flags, ?itemID, ?primID, ?assetID, " +
1890 "?parentFolderID, ?creatorID, ?ownerID, " +
1891 "?groupID, ?lastOwnerID)";
1892
1893 foreach (TaskInventoryItem item in items)
1894 { 1876 {
1895 cmd.Parameters.Clear(); 1877 cmd.CommandText = "insert into primitems (" +
1896 1878 "invType, assetType, name, " +
1897 FillItemCommand(cmd, item); 1879 "description, creationDate, nextPermissions, " +
1898 1880 "currentPermissions, basePermissions, " +
1899 ExecuteNonQuery(cmd); 1881 "everyonePermissions, groupPermissions, " +
1882 "flags, itemID, primID, assetID, " +
1883 "parentFolderID, creatorID, ownerID, " +
1884 "groupID, lastOwnerID) values (?invType, " +
1885 "?assetType, ?name, ?description, " +
1886 "?creationDate, ?nextPermissions, " +
1887 "?currentPermissions, ?basePermissions, " +
1888 "?everyonePermissions, ?groupPermissions, " +
1889 "?flags, ?itemID, ?primID, ?assetID, " +
1890 "?parentFolderID, ?creatorID, ?ownerID, " +
1891 "?groupID, ?lastOwnerID)";
1892
1893 foreach (TaskInventoryItem item in items)
1894 {
1895 cmd.Parameters.Clear();
1896
1897 FillItemCommand(cmd, item);
1898
1899 ExecuteNonQuery(cmd);
1900 }
1900 } 1901 }
1901
1902 cmd.Dispose();
1903 } 1902 }
1904 } 1903 }
1905 } 1904 }
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index a18ac66..4ff3175 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -66,38 +66,40 @@ namespace OpenSim.Data.MySQL
66 if (words.Length > 2) 66 if (words.Length > 2)
67 return new UserAccountData[0]; 67 return new UserAccountData[0];
68 68
69 MySqlCommand cmd = new MySqlCommand(); 69 using (MySqlCommand cmd = new MySqlCommand())
70
71 if (words.Length == 1)
72 {
73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 { 70 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); 71 if (words.Length == 1)
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%"); 72 {
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%"); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
83 } 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%");
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%");
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
83 }
84 84
85 return DoQuery(cmd); 85 return DoQuery(cmd);
86 }
86 } 87 }
87 88
88 public UserAccountData[] GetUsersWhere(UUID scopeID, string where) 89 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
89 { 90 {
90 MySqlCommand cmd = new MySqlCommand(); 91 using (MySqlCommand cmd = new MySqlCommand())
91
92 if (scopeID != UUID.Zero)
93 { 92 {
94 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; 93 if (scopeID != UUID.Zero)
95 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 94 {
96 } 95 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
96 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
97 }
97 98
98 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); 99 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
99 100
100 return DoQuery(cmd); 101 return DoQuery(cmd);
102 }
101 } 103 }
102 } 104 }
103} 105}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1e717d9..3452f90 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1456,6 +1456,7 @@ namespace OpenSim.Region.Framework.Scenes
1456 PhysicsActor actor = PhysicsActor; 1456 PhysicsActor actor = PhysicsActor;
1457 if (actor == null) 1457 if (actor == null)
1458 { 1458 {
1459 SendControlsToScripts(flagsForScripts);
1459 return; 1460 return;
1460 } 1461 }
1461 1462
@@ -1632,15 +1633,7 @@ namespace OpenSim.Region.Framework.Scenes
1632 if (update_movementflag && ParentID == 0) 1633 if (update_movementflag && ParentID == 0)
1633 Animator.UpdateMovementAnimations(); 1634 Animator.UpdateMovementAnimations();
1634 1635
1635 lock (scriptedcontrols) 1636 SendControlsToScripts(flagsForScripts);
1636 {
1637 if (scriptedcontrols.Count > 0)
1638 {
1639 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
1640 // (e.g., a walking script) checks which animation is active it will be the correct animation.
1641 SendControlToScripts(flagsForScripts);
1642 }
1643 }
1644 } 1637 }
1645 1638
1646 m_scene.EventManager.TriggerOnClientMovement(this); 1639 m_scene.EventManager.TriggerOnClientMovement(this);
@@ -3830,77 +3823,92 @@ namespace OpenSim.Region.Framework.Scenes
3830 } 3823 }
3831 } 3824 }
3832 3825
3833 internal void SendControlToScripts(uint flags) 3826 private void SendControlsToScripts(uint flags)
3834 { 3827 {
3835 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3828 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3836 3829 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3837 if (MouseDown) 3830 lock (scriptedcontrols)
3838 { 3831 {
3839 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3832 if (scriptedcontrols.Count <= 0)
3840 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3833 return;
3834
3835 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3836
3837 if (MouseDown)
3841 { 3838 {
3842 allflags = ScriptControlled.CONTROL_ZERO; 3839 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3840 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3841 {
3842 allflags = ScriptControlled.CONTROL_ZERO;
3843 MouseDown = true;
3844 }
3845 }
3846
3847 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3848 {
3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3843 MouseDown = true; 3850 MouseDown = true;
3844 } 3851 }
3845 } 3852
3853 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3854 {
3855 allflags |= ScriptControlled.CONTROL_LBUTTON;
3856 MouseDown = true;
3857 }
3858
3859 // find all activated controls, whether the scripts are interested in them or not
3860 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3861 {
3862 allflags |= ScriptControlled.CONTROL_FWD;
3863 }
3864
3865 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3866 {
3867 allflags |= ScriptControlled.CONTROL_BACK;
3868 }
3869
3870 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3871 {
3872 allflags |= ScriptControlled.CONTROL_UP;
3873 }
3874
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_DOWN;
3878 }
3846 3879
3847 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3880 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3848 { 3881 {
3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3882 allflags |= ScriptControlled.CONTROL_LEFT;
3850 MouseDown = true; 3883 }
3851 } 3884
3852 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 3885 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3853 { 3886 {
3854 allflags |= ScriptControlled.CONTROL_LBUTTON; 3887 allflags |= ScriptControlled.CONTROL_RIGHT;
3855 MouseDown = true; 3888 }
3856 } 3889
3890 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3891 {
3892 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3893 }
3894
3895 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3896 {
3897 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3898 }
3857 3899
3858 // find all activated controls, whether the scripts are interested in them or not 3900 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3859 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 3901 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3860 {
3861 allflags |= ScriptControlled.CONTROL_FWD;
3862 }
3863 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3864 {
3865 allflags |= ScriptControlled.CONTROL_BACK;
3866 }
3867 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3868 {
3869 allflags |= ScriptControlled.CONTROL_UP;
3870 }
3871 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3872 {
3873 allflags |= ScriptControlled.CONTROL_DOWN;
3874 }
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_LEFT;
3878 }
3879 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3880 {
3881 allflags |= ScriptControlled.CONTROL_RIGHT;
3882 }
3883 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3884 {
3885 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3886 }
3887 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3888 {
3889 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3890 }
3891 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3892 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3893 {
3894 lock (scriptedcontrols)
3895 { 3902 {
3896 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 3903 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3897 { 3904 {
3898 UUID scriptUUID = kvp.Key; 3905 UUID scriptUUID = kvp.Key;
3899 ScriptControllers scriptControlData = kvp.Value; 3906 ScriptControllers scriptControlData = kvp.Value;
3900 3907
3901 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 3908 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3902 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 3909 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3903 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 3910 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
3911
3904 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3912 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3905 { 3913 {
3906 // only send if still pressed or just changed 3914 // only send if still pressed or just changed
@@ -3908,9 +3916,9 @@ namespace OpenSim.Region.Framework.Scenes
3908 } 3916 }
3909 } 3917 }
3910 } 3918 }
3919
3920 LastCommands = allflags;
3911 } 3921 }
3912
3913 LastCommands = allflags;
3914 } 3922 }
3915 3923
3916 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 3924 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
index ab6311b..4a21dc9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Text; 31using System.Text;
31using NUnit.Framework; 32using NUnit.Framework;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
68 Vector3 position = new Vector3(200,200,21); 69 Vector3 position = new Vector3(200,200,21);
69 70
70 foreach (Border b in testborders) 71 foreach (Border b in testborders)
71 {
72 Assert.That(!b.TestCross(position)); 72 Assert.That(!b.TestCross(position));
73 73
74 }
75
76 position = new Vector3(200,280,21); 74 position = new Vector3(200,280,21);
77 Assert.That(NorthBorder.TestCross(position)); 75 Assert.That(NorthBorder.TestCross(position));
78 76
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 1c33a5f..d23c965 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Reflection; 30using System.Reflection;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32using OpenSim.Framework; 34using OpenSim.Framework;
@@ -44,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
44 public void TestDuplicateObject() 46 public void TestDuplicateObject()
45 { 47 {
46 TestHelpers.InMethod(); 48 TestHelpers.InMethod();
49// TestHelpers.EnableLogging();
50
47 Scene scene = new SceneHelpers().SetupScene(); 51 Scene scene = new SceneHelpers().SetupScene();
48 52
49 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); 53 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
82 Assert.That(dupePart1.PhysActor, Is.Not.Null); 86 Assert.That(dupePart1.PhysActor, Is.Not.Null);
83 Assert.That(dupePart2.PhysActor, Is.Not.Null); 87 Assert.That(dupePart2.PhysActor, Is.Not.Null);
84 */ 88 */
89
90// TestHelpers.DisableLogging();
85 } 91 }
86 } 92 }
87} \ No newline at end of file 93} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index 19542ff..c750cc5 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -38,7 +38,8 @@ using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
39using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock; 40using OpenSim.Tests.Common.Mock;
41using System.Threading; 41using System.IO;
42using System.Text;
42 43
43namespace OpenSim.Region.Framework.Scenes.Tests 44namespace OpenSim.Region.Framework.Scenes.Tests
44{ 45{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3fe5780..a067868 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1922,6 +1922,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1922 rgb.y = texcolor.G; 1922 rgb.y = texcolor.G;
1923 rgb.z = texcolor.B; 1923 rgb.z = texcolor.B;
1924 return rgb; 1924 return rgb;
1925
1925 } 1926 }
1926 else 1927 else
1927 { 1928 {
@@ -3492,6 +3493,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3492 return m_host.UUID.ToString(); 3493 return m_host.UUID.ToString();
3493 } 3494 }
3494 3495
3496 public LSL_Key llGenerateKey()
3497 {
3498 m_host.AddScriptLPS(1);
3499 return UUID.Random().ToString();
3500 }
3501
3495 public void llSetBuoyancy(double buoyancy) 3502 public void llSetBuoyancy(double buoyancy)
3496 { 3503 {
3497 m_host.AddScriptLPS(1); 3504 m_host.AddScriptLPS(1);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index eab6851..2ecc455 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
105 LSL_Integer llFloor(double f); 105 LSL_Integer llFloor(double f);
106 void llForceMouselook(int mouselook); 106 void llForceMouselook(int mouselook);
107 LSL_Float llFrand(double mag); 107 LSL_Float llFrand(double mag);
108 LSL_Key llGenerateKey();
108 LSL_Vector llGetAccel(); 109 LSL_Vector llGetAccel();
109 LSL_Integer llGetAgentInfo(string id); 110 LSL_Integer llGetAgentInfo(string id);
110 LSL_String llGetAgentLanguage(string id); 111 LSL_String llGetAgentLanguage(string id);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 9446099..8db4006 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -376,6 +376,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
376 return m_LSL_Functions.llFrand(mag); 376 return m_LSL_Functions.llFrand(mag);
377 } 377 }
378 378
379 public LSL_Key llGenerateKey()
380 {
381 return m_LSL_Functions.llGenerateKey();
382 }
383
379 public LSL_Vector llGetAccel() 384 public LSL_Vector llGetAccel()
380 { 385 {
381 return m_LSL_Functions.llGetAccel(); 386 return m_LSL_Functions.llGetAccel();
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index ced06de..5030d4b 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Diagnostics; 29using System.Diagnostics;
30using System.IO;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32 34
@@ -34,6 +36,37 @@ namespace OpenSim.Tests.Common
34{ 36{
35 public class TestHelpers 37 public class TestHelpers
36 { 38 {
39 private static Stream EnableLoggingConfigStream
40 = new MemoryStream(
41 Encoding.UTF8.GetBytes(
42@"<log4net>
43 <!-- A1 is set to be a ConsoleAppender -->
44 <appender name=""A1"" type=""log4net.Appender.ConsoleAppender"">
45
46 <!-- A1 uses PatternLayout -->
47 <layout type=""log4net.Layout.PatternLayout"">
48 <!-- Print the date in ISO 8601 format -->
49 <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" />
50 </layout>
51 </appender>
52
53 <!-- Set root logger level to DEBUG and its only appender to A1 -->
54 <root>
55 <level value=""DEBUG"" />
56 <appender-ref ref=""A1"" />
57 </root>
58</log4net>"));
59
60 private static Stream DisableLoggingConfigStream
61 = new MemoryStream(
62 Encoding.UTF8.GetBytes(
63 // "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>")));
64 //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")));
65 //"<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")));
66 //"<configuration><log4net><root></root></log4net></configuration>")));
67 //"<configuration><log4net><root/></log4net></configuration>")));
68 "<log4net><root/></log4net>"));
69
37 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) 70 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d)
38 { 71 {
39 try 72 try
@@ -58,6 +91,19 @@ namespace OpenSim.Tests.Common
58 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); 91 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name);
59 } 92 }
60 93
94 public static void EnableLogging()
95 {
96 log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream);
97 }
98
99 /// <summary>
100 /// Disable logging whilst running the tests.
101 /// </summary>
102 public static void DisableLogging()
103 {
104 log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream);
105 }
106
61 /// <summary> 107 /// <summary>
62 /// Parse tail section into full UUID. 108 /// Parse tail section into full UUID.
63 /// </summary> 109 /// </summary>