diff options
63 files changed, 5604 insertions, 3471 deletions
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 821aea2..2098625 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
56 | private readonly Dictionary<UUID, Scene> m_scenes; | 56 | private readonly Dictionary<UUID, Scene> m_scenes; |
57 | private readonly Transmitter m_transmitter; | 57 | private readonly Transmitter m_transmitter; |
58 | 58 | ||
59 | private readonly Thread m_clientThread; | 59 | // private readonly Thread m_clientThread; |
60 | 60 | ||
61 | private readonly IList<Session> m_sessions = new List<Session>(); | 61 | private readonly IList<Session> m_sessions = new List<Session>(); |
62 | private readonly IList<Session> m_sessionsToClient = new List<Session>(); | 62 | private readonly IList<Session> m_sessionsToClient = new List<Session>(); |
diff --git a/OpenSim/ConsoleClient/ConsoleClient.cs b/OpenSim/ConsoleClient/ConsoleClient.cs index d195d25..8c616e0 100644 --- a/OpenSim/ConsoleClient/ConsoleClient.cs +++ b/OpenSim/ConsoleClient/ConsoleClient.cs | |||
@@ -82,9 +82,11 @@ namespace OpenSim.ConsoleClient | |||
82 | 82 | ||
83 | private static void SendCommand(string module, string[] cmd) | 83 | private static void SendCommand(string module, string[] cmd) |
84 | { | 84 | { |
85 | string sendCmd = cmd[0]; | 85 | string sendCmd = ""; |
86 | if (cmd.Length > 1) | 86 | if (cmd.Length > 1) |
87 | { | 87 | { |
88 | sendCmd = cmd[0]; | ||
89 | |||
88 | Array.Copy(cmd, 1, cmd, 0, cmd.Length-1); | 90 | Array.Copy(cmd, 1, cmd, 0, cmd.Length-1); |
89 | Array.Resize(ref cmd, cmd.Length-1); | 91 | Array.Resize(ref cmd, cmd.Length-1); |
90 | sendCmd += "\"" + String.Join("\" \"", cmd) + "\""; | 92 | sendCmd += "\"" + String.Join("\" \"", cmd) + "\""; |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 6a4ccd7..666c22f 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -43,10 +43,13 @@ namespace OpenSim.Data.MySQL | |||
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | private MySQLManager _dbConnection; | 46 | private string m_connectionString; |
47 | private object m_dbLock = new object(); | ||
47 | 48 | ||
48 | #region IPlugin Members | 49 | #region IPlugin Members |
49 | 50 | ||
51 | public override string Version { get { return "1.0.0.0"; } } | ||
52 | |||
50 | /// <summary> | 53 | /// <summary> |
51 | /// <para>Initialises Asset interface</para> | 54 | /// <para>Initialises Asset interface</para> |
52 | /// <para> | 55 | /// <para> |
@@ -58,63 +61,29 @@ namespace OpenSim.Data.MySQL | |||
58 | /// </para> | 61 | /// </para> |
59 | /// </summary> | 62 | /// </summary> |
60 | /// <param name="connect">connect string</param> | 63 | /// <param name="connect">connect string</param> |
61 | override public void Initialise(string connect) | 64 | public override void Initialise(string connect) |
62 | { | 65 | { |
63 | // TODO: This will let you pass in the connect string in | 66 | m_connectionString = connect; |
64 | // the config, though someone will need to write that. | ||
65 | if (connect == String.Empty) | ||
66 | { | ||
67 | // This is old seperate config file | ||
68 | m_log.Warn("no connect string, using old mysql_connection.ini instead"); | ||
69 | Initialise(); | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | _dbConnection = new MySQLManager(connect); | ||
74 | } | ||
75 | 67 | ||
76 | // This actually does the roll forward assembly stuff | 68 | // This actually does the roll forward assembly stuff |
77 | Assembly assem = GetType().Assembly; | 69 | Assembly assem = GetType().Assembly; |
78 | Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore"); | ||
79 | 70 | ||
80 | m.Update(); | 71 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
72 | { | ||
73 | dbcon.Open(); | ||
74 | Migration m = new Migration(dbcon, assem, "AssetStore"); | ||
75 | m.Update(); | ||
76 | } | ||
81 | } | 77 | } |
82 | 78 | ||
83 | /// <summary> | ||
84 | /// <para>Initialises Asset interface</para> | ||
85 | /// <para> | ||
86 | /// <list type="bullet"> | ||
87 | /// <item>Loads and initialises the MySQL storage plugin</item> | ||
88 | /// <item>uses the obsolete mysql_connection.ini</item> | ||
89 | /// </list> | ||
90 | /// </para> | ||
91 | /// </summary> | ||
92 | /// <remarks>DEPRECATED and shouldn't be used</remarks> | ||
93 | public override void Initialise() | 79 | public override void Initialise() |
94 | { | 80 | { |
95 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 81 | throw new NotImplementedException(); |
96 | string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
97 | string database = GridDataMySqlFile.ParseFileReadValue("database"); | ||
98 | string username = GridDataMySqlFile.ParseFileReadValue("username"); | ||
99 | string password = GridDataMySqlFile.ParseFileReadValue("password"); | ||
100 | string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
101 | string port = GridDataMySqlFile.ParseFileReadValue("port"); | ||
102 | |||
103 | _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); | ||
104 | |||
105 | } | 82 | } |
106 | 83 | ||
107 | public override void Dispose() { } | 84 | public override void Dispose() { } |
108 | 85 | ||
109 | /// <summary> | 86 | /// <summary> |
110 | /// Database provider version | ||
111 | /// </summary> | ||
112 | override public string Version | ||
113 | { | ||
114 | get { return _dbConnection.getVersion(); } | ||
115 | } | ||
116 | |||
117 | /// <summary> | ||
118 | /// The name of this DB provider | 87 | /// The name of this DB provider |
119 | /// </summary> | 88 | /// </summary> |
120 | override public string Name | 89 | override public string Name |
@@ -135,46 +104,43 @@ namespace OpenSim.Data.MySQL | |||
135 | override public AssetBase GetAsset(UUID assetID) | 104 | override public AssetBase GetAsset(UUID assetID) |
136 | { | 105 | { |
137 | AssetBase asset = null; | 106 | AssetBase asset = null; |
138 | lock (_dbConnection) | 107 | lock (m_dbLock) |
139 | { | 108 | { |
140 | _dbConnection.CheckConnection(); | 109 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
110 | { | ||
111 | dbcon.Open(); | ||
141 | 112 | ||
142 | MySqlCommand cmd = | 113 | using (MySqlCommand cmd = new MySqlCommand( |
143 | new MySqlCommand( | ||
144 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", | 114 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", |
145 | _dbConnection.Connection); | 115 | dbcon)) |
146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | ||
147 | |||
148 | try | ||
149 | { | ||
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
151 | { | 116 | { |
152 | if (dbReader.Read()) | 117 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
153 | { | ||
154 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); | ||
155 | asset.Data = (byte[]) dbReader["data"]; | ||
156 | asset.Description = (string) dbReader["description"]; | ||
157 | 118 | ||
158 | string local = dbReader["local"].ToString(); | 119 | try |
159 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 120 | { |
160 | asset.Local = true; | 121 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
161 | else | 122 | { |
162 | asset.Local = false; | 123 | if (dbReader.Read()) |
163 | 124 | { | |
164 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | 125 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); |
126 | asset.Data = (byte[])dbReader["data"]; | ||
127 | asset.Description = (string)dbReader["description"]; | ||
128 | |||
129 | string local = dbReader["local"].ToString(); | ||
130 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | ||
131 | asset.Local = true; | ||
132 | else | ||
133 | asset.Local = false; | ||
134 | |||
135 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | catch (Exception e) | ||
140 | { | ||
141 | m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); | ||
165 | } | 142 | } |
166 | dbReader.Close(); | ||
167 | cmd.Dispose(); | ||
168 | } | 143 | } |
169 | if (asset != null) | ||
170 | UpdateAccessTime(asset); | ||
171 | } | ||
172 | catch (Exception e) | ||
173 | { | ||
174 | m_log.ErrorFormat( | ||
175 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | ||
176 | + Environment.NewLine + "Reconnecting", assetID); | ||
177 | _dbConnection.Reconnect(); | ||
178 | } | 144 | } |
179 | } | 145 | } |
180 | return asset; | 146 | return asset; |
@@ -187,55 +153,57 @@ namespace OpenSim.Data.MySQL | |||
187 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 153 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
188 | override public void StoreAsset(AssetBase asset) | 154 | override public void StoreAsset(AssetBase asset) |
189 | { | 155 | { |
190 | lock (_dbConnection) | 156 | lock (m_dbLock) |
191 | { | 157 | { |
192 | _dbConnection.CheckConnection(); | 158 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
159 | { | ||
160 | dbcon.Open(); | ||
193 | 161 | ||
194 | MySqlCommand cmd = | 162 | MySqlCommand cmd = |
195 | new MySqlCommand( | 163 | new MySqlCommand( |
196 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + | 164 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + |
197 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", | 165 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", |
198 | _dbConnection.Connection); | 166 | dbcon); |
199 | 167 | ||
200 | string assetName = asset.Name; | 168 | string assetName = asset.Name; |
201 | if (asset.Name.Length > 64) | 169 | if (asset.Name.Length > 64) |
202 | { | ||
203 | assetName = asset.Name.Substring(0, 64); | ||
204 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | ||
205 | } | ||
206 | |||
207 | string assetDescription = asset.Description; | ||
208 | if (asset.Description.Length > 64) | ||
209 | { | ||
210 | assetDescription = asset.Description.Substring(0, 64); | ||
211 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
212 | } | ||
213 | |||
214 | // need to ensure we dispose | ||
215 | try | ||
216 | { | ||
217 | using (cmd) | ||
218 | { | 170 | { |
219 | // create unix epoch time | 171 | assetName = asset.Name.Substring(0, 64); |
220 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 172 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); |
221 | cmd.Parameters.AddWithValue("?id", asset.ID); | 173 | } |
222 | cmd.Parameters.AddWithValue("?name", assetName); | 174 | |
223 | cmd.Parameters.AddWithValue("?description", assetDescription); | 175 | string assetDescription = asset.Description; |
224 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | 176 | if (asset.Description.Length > 64) |
225 | cmd.Parameters.AddWithValue("?local", asset.Local); | 177 | { |
226 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | 178 | assetDescription = asset.Description.Substring(0, 64); |
227 | cmd.Parameters.AddWithValue("?create_time", now); | 179 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); |
228 | cmd.Parameters.AddWithValue("?access_time", now); | 180 | } |
229 | cmd.Parameters.AddWithValue("?data", asset.Data); | 181 | |
230 | cmd.ExecuteNonQuery(); | 182 | // need to ensure we dispose |
231 | cmd.Dispose(); | 183 | try |
184 | { | ||
185 | using (cmd) | ||
186 | { | ||
187 | // create unix epoch time | ||
188 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
189 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
190 | cmd.Parameters.AddWithValue("?name", assetName); | ||
191 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
192 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
193 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
194 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
195 | cmd.Parameters.AddWithValue("?create_time", now); | ||
196 | cmd.Parameters.AddWithValue("?access_time", now); | ||
197 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
198 | cmd.ExecuteNonQuery(); | ||
199 | cmd.Dispose(); | ||
200 | } | ||
201 | } | ||
202 | catch (Exception e) | ||
203 | { | ||
204 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | ||
205 | asset.FullID, asset.Name, e.Message); | ||
232 | } | 206 | } |
233 | } | ||
234 | catch (Exception e) | ||
235 | { | ||
236 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Attempting reconnect. Error: {2}", | ||
237 | asset.FullID, asset.Name, e.Message); | ||
238 | _dbConnection.Reconnect(); | ||
239 | } | 207 | } |
240 | } | 208 | } |
241 | } | 209 | } |
@@ -245,35 +213,36 @@ namespace OpenSim.Data.MySQL | |||
245 | // Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph | 213 | // Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph |
246 | return; | 214 | return; |
247 | 215 | ||
248 | lock (_dbConnection) | 216 | lock (m_dbLock) |
249 | { | 217 | { |
250 | _dbConnection.CheckConnection(); | 218 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
251 | |||
252 | MySqlCommand cmd = | ||
253 | new MySqlCommand("update assets set access_time=?access_time where id=?id", | ||
254 | _dbConnection.Connection); | ||
255 | |||
256 | // need to ensure we dispose | ||
257 | try | ||
258 | { | 219 | { |
259 | using (cmd) | 220 | dbcon.Open(); |
221 | MySqlCommand cmd = | ||
222 | new MySqlCommand("update assets set access_time=?access_time where id=?id", | ||
223 | dbcon); | ||
224 | |||
225 | // need to ensure we dispose | ||
226 | try | ||
227 | { | ||
228 | using (cmd) | ||
229 | { | ||
230 | // create unix epoch time | ||
231 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
232 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
233 | cmd.Parameters.AddWithValue("?access_time", now); | ||
234 | cmd.ExecuteNonQuery(); | ||
235 | cmd.Dispose(); | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
260 | { | 239 | { |
261 | // create unix epoch time | 240 | m_log.ErrorFormat( |
262 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 241 | "[ASSETS DB]: " + |
263 | cmd.Parameters.AddWithValue("?id", asset.ID); | 242 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() |
264 | cmd.Parameters.AddWithValue("?access_time", now); | 243 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); |
265 | cmd.ExecuteNonQuery(); | ||
266 | cmd.Dispose(); | ||
267 | } | 244 | } |
268 | } | 245 | } |
269 | catch (Exception e) | ||
270 | { | ||
271 | m_log.ErrorFormat( | ||
272 | "[ASSETS DB]: " + | ||
273 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
274 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
275 | _dbConnection.Reconnect(); | ||
276 | } | ||
277 | } | 246 | } |
278 | 247 | ||
279 | } | 248 | } |
@@ -287,37 +256,30 @@ namespace OpenSim.Data.MySQL | |||
287 | { | 256 | { |
288 | bool assetExists = false; | 257 | bool assetExists = false; |
289 | 258 | ||
290 | lock (_dbConnection) | 259 | lock (m_dbLock) |
291 | { | 260 | { |
292 | _dbConnection.CheckConnection(); | 261 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
293 | |||
294 | MySqlCommand cmd = | ||
295 | new MySqlCommand( | ||
296 | "SELECT id FROM assets WHERE id=?id", | ||
297 | _dbConnection.Connection); | ||
298 | |||
299 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | ||
300 | |||
301 | try | ||
302 | { | 262 | { |
303 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 263 | dbcon.Open(); |
264 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) | ||
304 | { | 265 | { |
305 | if (dbReader.Read()) | 266 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); |
267 | |||
268 | try | ||
306 | { | 269 | { |
307 | assetExists = true; | 270 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
271 | { | ||
272 | if (dbReader.Read()) | ||
273 | assetExists = true; | ||
274 | } | ||
275 | } | ||
276 | catch (Exception e) | ||
277 | { | ||
278 | m_log.ErrorFormat( | ||
279 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | ||
308 | } | 280 | } |
309 | |||
310 | dbReader.Close(); | ||
311 | cmd.Dispose(); | ||
312 | } | 281 | } |
313 | } | 282 | } |
314 | catch (Exception e) | ||
315 | { | ||
316 | m_log.ErrorFormat( | ||
317 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | ||
318 | + Environment.NewLine + "Attempting reconnection", uuid); | ||
319 | _dbConnection.Reconnect(); | ||
320 | } | ||
321 | } | 283 | } |
322 | 284 | ||
323 | return assetExists; | 285 | return assetExists; |
@@ -335,38 +297,39 @@ namespace OpenSim.Data.MySQL | |||
335 | { | 297 | { |
336 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 298 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
337 | 299 | ||
338 | lock (_dbConnection) | 300 | lock (m_dbLock) |
339 | { | 301 | { |
340 | _dbConnection.CheckConnection(); | 302 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
341 | |||
342 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection); | ||
343 | cmd.Parameters.AddWithValue("?start", start); | ||
344 | cmd.Parameters.AddWithValue("?count", count); | ||
345 | |||
346 | try | ||
347 | { | 303 | { |
348 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 304 | dbcon.Open(); |
305 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon); | ||
306 | cmd.Parameters.AddWithValue("?start", start); | ||
307 | cmd.Parameters.AddWithValue("?count", count); | ||
308 | |||
309 | try | ||
349 | { | 310 | { |
350 | while (dbReader.Read()) | 311 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
351 | { | 312 | { |
352 | AssetMetadata metadata = new AssetMetadata(); | 313 | while (dbReader.Read()) |
353 | metadata.Name = (string) dbReader["name"]; | 314 | { |
354 | metadata.Description = (string) dbReader["description"]; | 315 | AssetMetadata metadata = new AssetMetadata(); |
355 | metadata.Type = (sbyte) dbReader["assetType"]; | 316 | metadata.Name = (string)dbReader["name"]; |
356 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 317 | metadata.Description = (string)dbReader["description"]; |
357 | metadata.FullID = new UUID((string) dbReader["id"]); | 318 | metadata.Type = (sbyte)dbReader["assetType"]; |
358 | 319 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | |
359 | // Current SHA1s are not stored/computed. | 320 | metadata.FullID = new UUID((string)dbReader["id"]); |
360 | metadata.SHA1 = new byte[] {}; | 321 | |
361 | 322 | // Current SHA1s are not stored/computed. | |
362 | retList.Add(metadata); | 323 | metadata.SHA1 = new byte[] { }; |
324 | |||
325 | retList.Add(metadata); | ||
326 | } | ||
363 | } | 327 | } |
364 | } | 328 | } |
365 | } | 329 | catch (Exception e) |
366 | catch (Exception e) | 330 | { |
367 | { | 331 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
368 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection"); | 332 | } |
369 | _dbConnection.Reconnect(); | ||
370 | } | 333 | } |
371 | } | 334 | } |
372 | 335 | ||
@@ -374,7 +337,5 @@ namespace OpenSim.Data.MySQL | |||
374 | } | 337 | } |
375 | 338 | ||
376 | #endregion | 339 | #endregion |
377 | |||
378 | |||
379 | } | 340 | } |
380 | } | 341 | } |
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e508b52..5056aee 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -38,16 +38,22 @@ namespace OpenSim.Data.MySQL | |||
38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData | 38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData |
39 | { | 39 | { |
40 | private string m_Realm; | 40 | private string m_Realm; |
41 | private List<string> m_ColumnNames = null; | 41 | private List<string> m_ColumnNames; |
42 | private int m_LastExpire = 0; | 42 | private int m_LastExpire; |
43 | // private string m_connectionString; | ||
43 | 44 | ||
44 | public MySqlAuthenticationData(string connectionString, string realm) | 45 | public MySqlAuthenticationData(string connectionString, string realm) |
45 | : base(connectionString) | 46 | : base(connectionString) |
46 | { | 47 | { |
47 | m_Realm = realm; | 48 | m_Realm = realm; |
49 | m_connectionString = connectionString; | ||
48 | 50 | ||
49 | Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); | 51 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
50 | m.Update(); | 52 | { |
53 | dbcon.Open(); | ||
54 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); | ||
55 | m.Update(); | ||
56 | } | ||
51 | } | 57 | } |
52 | 58 | ||
53 | public AuthenticationData Get(UUID principalID) | 59 | public AuthenticationData Get(UUID principalID) |
@@ -55,45 +61,42 @@ namespace OpenSim.Data.MySQL | |||
55 | AuthenticationData ret = new AuthenticationData(); | 61 | AuthenticationData ret = new AuthenticationData(); |
56 | ret.Data = new Dictionary<string, object>(); | 62 | ret.Data = new Dictionary<string, object>(); |
57 | 63 | ||
58 | MySqlCommand cmd = new MySqlCommand( | 64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
59 | "select * from `"+m_Realm+"` where UUID = ?principalID" | ||
60 | ); | ||
61 | |||
62 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
63 | |||
64 | IDataReader result = ExecuteReader(cmd); | ||
65 | |||
66 | if (result.Read()) | ||
67 | { | 65 | { |
68 | ret.PrincipalID = principalID; | 66 | dbcon.Open(); |
67 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); | ||
68 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
69 | 69 | ||
70 | if (m_ColumnNames == null) | 70 | IDataReader result = cmd.ExecuteReader(); |
71 | { | ||
72 | m_ColumnNames = new List<string>(); | ||
73 | 71 | ||
74 | DataTable schemaTable = result.GetSchemaTable(); | 72 | if (result.Read()) |
75 | foreach (DataRow row in schemaTable.Rows) | ||
76 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
77 | } | ||
78 | |||
79 | foreach (string s in m_ColumnNames) | ||
80 | { | 73 | { |
81 | if (s == "UUID") | 74 | ret.PrincipalID = principalID; |
82 | continue; | ||
83 | 75 | ||
84 | ret.Data[s] = result[s].ToString(); | 76 | if (m_ColumnNames == null) |
85 | } | 77 | { |
78 | m_ColumnNames = new List<string>(); | ||
86 | 79 | ||
87 | result.Close(); | 80 | DataTable schemaTable = result.GetSchemaTable(); |
88 | CloseReaderCommand(cmd); | 81 | foreach (DataRow row in schemaTable.Rows) |
82 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
83 | } | ||
89 | 84 | ||
90 | return ret; | 85 | foreach (string s in m_ColumnNames) |
91 | } | 86 | { |
87 | if (s == "UUID") | ||
88 | continue; | ||
92 | 89 | ||
93 | result.Close(); | 90 | ret.Data[s] = result[s].ToString(); |
94 | CloseReaderCommand(cmd); | 91 | } |
95 | 92 | ||
96 | return null; | 93 | return ret; |
94 | } | ||
95 | else | ||
96 | { | ||
97 | return null; | ||
98 | } | ||
99 | } | ||
97 | } | 100 | } |
98 | 101 | ||
99 | public bool Store(AuthenticationData data) | 102 | public bool Store(AuthenticationData data) |
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e8694fc..2eae2d8 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -44,7 +44,6 @@ namespace OpenSim.Data.MySQL | |||
44 | 44 | ||
45 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | 45 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; |
46 | 46 | ||
47 | private MySqlConnection m_connection; | ||
48 | private string m_connectionString; | 47 | private string m_connectionString; |
49 | private long m_waitTimeout; | 48 | private long m_waitTimeout; |
50 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; | 49 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; |
@@ -67,24 +66,26 @@ namespace OpenSim.Data.MySQL | |||
67 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); | 66 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); |
68 | } | 67 | } |
69 | 68 | ||
70 | m_connection = new MySqlConnection(m_connectionString); | ||
71 | m_connection.Open(); | ||
72 | |||
73 | GetWaitTimeout(); | 69 | GetWaitTimeout(); |
74 | 70 | ||
75 | Assembly assem = GetType().Assembly; | 71 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
76 | Migration m = new Migration(m_connection, assem, "EstateStore"); | 72 | { |
77 | m.Update(); | 73 | dbcon.Open(); |
74 | |||
75 | Assembly assem = GetType().Assembly; | ||
76 | Migration m = new Migration(dbcon, assem, "EstateStore"); | ||
77 | m.Update(); | ||
78 | 78 | ||
79 | Type t = typeof(EstateSettings); | 79 | Type t = typeof(EstateSettings); |
80 | m_Fields = t.GetFields(BindingFlags.NonPublic | | 80 | m_Fields = t.GetFields(BindingFlags.NonPublic | |
81 | BindingFlags.Instance | | 81 | BindingFlags.Instance | |
82 | BindingFlags.DeclaredOnly); | 82 | BindingFlags.DeclaredOnly); |
83 | 83 | ||
84 | foreach (FieldInfo f in m_Fields) | 84 | foreach (FieldInfo f in m_Fields) |
85 | { | 85 | { |
86 | if (f.Name.Substring(0, 2) == "m_") | 86 | if (f.Name.Substring(0, 2) == "m_") |
87 | m_FieldMap[f.Name.Substring(2)] = f; | 87 | m_FieldMap[f.Name.Substring(2)] = f; |
88 | } | ||
88 | } | 89 | } |
89 | } | 90 | } |
90 | 91 | ||
@@ -95,47 +96,29 @@ namespace OpenSim.Data.MySQL | |||
95 | 96 | ||
96 | protected void GetWaitTimeout() | 97 | protected void GetWaitTimeout() |
97 | { | 98 | { |
98 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, | 99 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
99 | m_connection); | ||
100 | |||
101 | using (MySqlDataReader dbReader = | ||
102 | cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
103 | { | 100 | { |
104 | if (dbReader.Read()) | 101 | dbcon.Open(); |
102 | |||
103 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
105 | { | 104 | { |
106 | m_waitTimeout | 105 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
107 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | 106 | { |
108 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | 107 | if (dbReader.Read()) |
108 | { | ||
109 | m_waitTimeout | ||
110 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
111 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
112 | } | ||
113 | } | ||
109 | } | 114 | } |
110 | 115 | ||
111 | dbReader.Close(); | 116 | m_lastConnectionUse = DateTime.Now.Ticks; |
112 | cmd.Dispose(); | ||
113 | } | ||
114 | |||
115 | m_lastConnectionUse = DateTime.Now.Ticks; | ||
116 | |||
117 | m_log.DebugFormat( | ||
118 | "[REGION DB]: Connection wait timeout {0} seconds", | ||
119 | m_waitTimeout / TimeSpan.TicksPerSecond); | ||
120 | } | ||
121 | |||
122 | protected void CheckConnection() | ||
123 | { | ||
124 | long timeNow = DateTime.Now.Ticks; | ||
125 | if (timeNow - m_lastConnectionUse > m_waitTimeout || | ||
126 | m_connection.State != ConnectionState.Open) | ||
127 | { | ||
128 | m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); | ||
129 | 117 | ||
130 | lock (m_connection) | 118 | m_log.DebugFormat( |
131 | { | 119 | "[REGION DB]: Connection wait timeout {0} seconds", |
132 | m_connection.Close(); | 120 | m_waitTimeout / TimeSpan.TicksPerSecond); |
133 | m_connection = new MySqlConnection(m_connectionString); | ||
134 | m_connection.Open(); | ||
135 | } | ||
136 | } | 121 | } |
137 | |||
138 | m_lastConnectionUse = timeNow; | ||
139 | } | 122 | } |
140 | 123 | ||
141 | public EstateSettings LoadEstateSettings(UUID regionID) | 124 | public EstateSettings LoadEstateSettings(UUID regionID) |
@@ -143,114 +126,111 @@ namespace OpenSim.Data.MySQL | |||
143 | EstateSettings es = new EstateSettings(); | 126 | EstateSettings es = new EstateSettings(); |
144 | es.OnSave += StoreEstateSettings; | 127 | es.OnSave += StoreEstateSettings; |
145 | 128 | ||
146 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; | 129 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + |
130 | " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; | ||
147 | 131 | ||
148 | CheckConnection(); | 132 | bool migration = true; |
149 | 133 | ||
150 | MySqlCommand cmd = m_connection.CreateCommand(); | 134 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
151 | |||
152 | cmd.CommandText = sql; | ||
153 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
154 | |||
155 | IDataReader r = cmd.ExecuteReader(); | ||
156 | |||
157 | if (r.Read()) | ||
158 | { | 135 | { |
159 | foreach (string name in FieldList) | 136 | dbcon.Open(); |
137 | |||
138 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
160 | { | 139 | { |
161 | if (m_FieldMap[name].GetValue(es) is bool) | 140 | cmd.CommandText = sql; |
162 | { | 141 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
163 | int v = Convert.ToInt32(r[name]); | ||
164 | if (v != 0) | ||
165 | m_FieldMap[name].SetValue(es, true); | ||
166 | else | ||
167 | m_FieldMap[name].SetValue(es, false); | ||
168 | } | ||
169 | else if (m_FieldMap[name].GetValue(es) is UUID) | ||
170 | { | ||
171 | UUID uuid = UUID.Zero; | ||
172 | 142 | ||
173 | UUID.TryParse(r[name].ToString(), out uuid); | 143 | using (IDataReader r = cmd.ExecuteReader()) |
174 | m_FieldMap[name].SetValue(es, uuid); | ||
175 | } | ||
176 | else | ||
177 | { | 144 | { |
178 | m_FieldMap[name].SetValue(es, r[name]); | 145 | if (r.Read()) |
146 | { | ||
147 | migration = false; | ||
148 | |||
149 | foreach (string name in FieldList) | ||
150 | { | ||
151 | if (m_FieldMap[name].GetValue(es) is bool) | ||
152 | { | ||
153 | int v = Convert.ToInt32(r[name]); | ||
154 | if (v != 0) | ||
155 | m_FieldMap[name].SetValue(es, true); | ||
156 | else | ||
157 | m_FieldMap[name].SetValue(es, false); | ||
158 | } | ||
159 | else if (m_FieldMap[name].GetValue(es) is UUID) | ||
160 | { | ||
161 | UUID uuid = UUID.Zero; | ||
162 | |||
163 | UUID.TryParse(r[name].ToString(), out uuid); | ||
164 | m_FieldMap[name].SetValue(es, uuid); | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | m_FieldMap[name].SetValue(es, r[name]); | ||
169 | } | ||
170 | } | ||
171 | } | ||
179 | } | 172 | } |
180 | } | 173 | } |
181 | r.Close(); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | // Migration case | ||
186 | // | ||
187 | r.Close(); | ||
188 | |||
189 | List<string> names = new List<string>(FieldList); | ||
190 | 174 | ||
191 | names.Remove("EstateID"); | 175 | if (migration) |
176 | { | ||
177 | // Migration case | ||
178 | List<string> names = new List<string>(FieldList); | ||
192 | 179 | ||
193 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; | 180 | names.Remove("EstateID"); |
194 | 181 | ||
195 | cmd.CommandText = sql; | 182 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; |
196 | cmd.Parameters.Clear(); | ||
197 | 183 | ||
198 | foreach (string name in FieldList) | 184 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
199 | { | ||
200 | if (m_FieldMap[name].GetValue(es) is bool) | ||
201 | { | ||
202 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
203 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
204 | else | ||
205 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
206 | } | ||
207 | else | ||
208 | { | 185 | { |
209 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | 186 | cmd.CommandText = sql; |
187 | cmd.Parameters.Clear(); | ||
188 | |||
189 | foreach (string name in FieldList) | ||
190 | { | ||
191 | if (m_FieldMap[name].GetValue(es) is bool) | ||
192 | { | ||
193 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
194 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
195 | else | ||
196 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | cmd.ExecuteNonQuery(); | ||
205 | |||
206 | cmd.CommandText = "select LAST_INSERT_ID() as id"; | ||
207 | cmd.Parameters.Clear(); | ||
208 | |||
209 | using (IDataReader r = cmd.ExecuteReader()) | ||
210 | { | ||
211 | r.Read(); | ||
212 | es.EstateID = Convert.ToUInt32(r["id"]); | ||
213 | } | ||
214 | |||
215 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | ||
216 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
217 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
218 | |||
219 | // This will throw on dupe key | ||
220 | try { cmd.ExecuteNonQuery(); } | ||
221 | catch (Exception) { } | ||
222 | |||
223 | // Munge and transfer the ban list | ||
224 | cmd.Parameters.Clear(); | ||
225 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | ||
226 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
227 | |||
228 | try { cmd.ExecuteNonQuery(); } | ||
229 | catch (Exception) { } | ||
230 | |||
231 | es.Save(); | ||
210 | } | 232 | } |
211 | } | 233 | } |
212 | |||
213 | cmd.ExecuteNonQuery(); | ||
214 | |||
215 | cmd.CommandText = "select LAST_INSERT_ID() as id"; | ||
216 | cmd.Parameters.Clear(); | ||
217 | |||
218 | r = cmd.ExecuteReader(); | ||
219 | |||
220 | r.Read(); | ||
221 | |||
222 | es.EstateID = Convert.ToUInt32(r["id"]); | ||
223 | |||
224 | r.Close(); | ||
225 | |||
226 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | ||
227 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
228 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
229 | |||
230 | // This will throw on dupe key | ||
231 | try | ||
232 | { | ||
233 | cmd.ExecuteNonQuery(); | ||
234 | } | ||
235 | catch (Exception) | ||
236 | { | ||
237 | } | ||
238 | |||
239 | // Munge and transfer the ban list | ||
240 | // | ||
241 | cmd.Parameters.Clear(); | ||
242 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | ||
243 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
244 | |||
245 | try | ||
246 | { | ||
247 | cmd.ExecuteNonQuery(); | ||
248 | } | ||
249 | catch (Exception) | ||
250 | { | ||
251 | } | ||
252 | |||
253 | es.Save(); | ||
254 | } | 234 | } |
255 | 235 | ||
256 | LoadBanList(es); | 236 | LoadBanList(es); |
@@ -265,29 +245,33 @@ namespace OpenSim.Data.MySQL | |||
265 | { | 245 | { |
266 | string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")"; | 246 | string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")"; |
267 | 247 | ||
268 | CheckConnection(); | 248 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
249 | { | ||
250 | dbcon.Open(); | ||
269 | 251 | ||
270 | MySqlCommand cmd = m_connection.CreateCommand(); | 252 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
253 | { | ||
254 | cmd.CommandText = sql; | ||
271 | 255 | ||
272 | cmd.CommandText = sql; | 256 | foreach (string name in FieldList) |
257 | { | ||
258 | if (m_FieldMap[name].GetValue(es) is bool) | ||
259 | { | ||
260 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
261 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
262 | else | ||
263 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
268 | } | ||
269 | } | ||
273 | 270 | ||
274 | foreach (string name in FieldList) | 271 | cmd.ExecuteNonQuery(); |
275 | { | ||
276 | if (m_FieldMap[name].GetValue(es) is bool) | ||
277 | { | ||
278 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
279 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
280 | else | ||
281 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
286 | } | 272 | } |
287 | } | 273 | } |
288 | 274 | ||
289 | cmd.ExecuteNonQuery(); | ||
290 | |||
291 | SaveBanList(es); | 275 | SaveBanList(es); |
292 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); | 276 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); |
293 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); | 277 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); |
@@ -298,77 +282,89 @@ namespace OpenSim.Data.MySQL | |||
298 | { | 282 | { |
299 | es.ClearBans(); | 283 | es.ClearBans(); |
300 | 284 | ||
301 | CheckConnection(); | 285 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
302 | |||
303 | MySqlCommand cmd = m_connection.CreateCommand(); | ||
304 | |||
305 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; | ||
306 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); | ||
307 | |||
308 | IDataReader r = cmd.ExecuteReader(); | ||
309 | |||
310 | while (r.Read()) | ||
311 | { | 286 | { |
312 | EstateBan eb = new EstateBan(); | 287 | dbcon.Open(); |
313 | 288 | ||
314 | UUID uuid = new UUID(); | 289 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
315 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); | 290 | { |
291 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; | ||
292 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); | ||
316 | 293 | ||
317 | eb.BannedUserID = uuid; | 294 | using (IDataReader r = cmd.ExecuteReader()) |
318 | eb.BannedHostAddress = "0.0.0.0"; | 295 | { |
319 | eb.BannedHostIPMask = "0.0.0.0"; | 296 | while (r.Read()) |
320 | es.AddBan(eb); | 297 | { |
298 | EstateBan eb = new EstateBan(); | ||
299 | |||
300 | UUID uuid = new UUID(); | ||
301 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); | ||
302 | |||
303 | eb.BannedUserID = uuid; | ||
304 | eb.BannedHostAddress = "0.0.0.0"; | ||
305 | eb.BannedHostIPMask = "0.0.0.0"; | ||
306 | es.AddBan(eb); | ||
307 | } | ||
308 | } | ||
309 | } | ||
321 | } | 310 | } |
322 | r.Close(); | ||
323 | } | 311 | } |
324 | 312 | ||
325 | private void SaveBanList(EstateSettings es) | 313 | private void SaveBanList(EstateSettings es) |
326 | { | 314 | { |
327 | CheckConnection(); | 315 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
328 | 316 | { | |
329 | MySqlCommand cmd = m_connection.CreateCommand(); | 317 | dbcon.Open(); |
330 | 318 | ||
331 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; | 319 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
332 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | 320 | { |
321 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; | ||
322 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
333 | 323 | ||
334 | cmd.ExecuteNonQuery(); | 324 | cmd.ExecuteNonQuery(); |
335 | 325 | ||
336 | cmd.Parameters.Clear(); | 326 | cmd.Parameters.Clear(); |
337 | 327 | ||
338 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; | 328 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; |
339 | 329 | ||
340 | foreach (EstateBan b in es.EstateBans) | 330 | foreach (EstateBan b in es.EstateBans) |
341 | { | 331 | { |
342 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | 332 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); |
343 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); | 333 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); |
344 | 334 | ||
345 | cmd.ExecuteNonQuery(); | 335 | cmd.ExecuteNonQuery(); |
346 | cmd.Parameters.Clear(); | 336 | cmd.Parameters.Clear(); |
337 | } | ||
338 | } | ||
347 | } | 339 | } |
348 | } | 340 | } |
349 | 341 | ||
350 | void SaveUUIDList(uint EstateID, string table, UUID[] data) | 342 | void SaveUUIDList(uint EstateID, string table, UUID[] data) |
351 | { | 343 | { |
352 | CheckConnection(); | 344 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
353 | 345 | { | |
354 | MySqlCommand cmd = m_connection.CreateCommand(); | 346 | dbcon.Open(); |
355 | 347 | ||
356 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; | 348 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
357 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | 349 | { |
350 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; | ||
351 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
358 | 352 | ||
359 | cmd.ExecuteNonQuery(); | 353 | cmd.ExecuteNonQuery(); |
360 | 354 | ||
361 | cmd.Parameters.Clear(); | 355 | cmd.Parameters.Clear(); |
362 | 356 | ||
363 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; | 357 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; |
364 | 358 | ||
365 | foreach (UUID uuid in data) | 359 | foreach (UUID uuid in data) |
366 | { | 360 | { |
367 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | 361 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); |
368 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); | 362 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); |
369 | 363 | ||
370 | cmd.ExecuteNonQuery(); | 364 | cmd.ExecuteNonQuery(); |
371 | cmd.Parameters.Clear(); | 365 | cmd.Parameters.Clear(); |
366 | } | ||
367 | } | ||
372 | } | 368 | } |
373 | } | 369 | } |
374 | 370 | ||
@@ -376,25 +372,29 @@ namespace OpenSim.Data.MySQL | |||
376 | { | 372 | { |
377 | List<UUID> uuids = new List<UUID>(); | 373 | List<UUID> uuids = new List<UUID>(); |
378 | 374 | ||
379 | CheckConnection(); | 375 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
380 | 376 | { | |
381 | MySqlCommand cmd = m_connection.CreateCommand(); | 377 | dbcon.Open(); |
382 | |||
383 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; | ||
384 | cmd.Parameters.AddWithValue("?EstateID", EstateID); | ||
385 | 378 | ||
386 | IDataReader r = cmd.ExecuteReader(); | 379 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
380 | { | ||
381 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; | ||
382 | cmd.Parameters.AddWithValue("?EstateID", EstateID); | ||
387 | 383 | ||
388 | while (r.Read()) | 384 | using (IDataReader r = cmd.ExecuteReader()) |
389 | { | 385 | { |
390 | // EstateBan eb = new EstateBan(); | 386 | while (r.Read()) |
387 | { | ||
388 | // EstateBan eb = new EstateBan(); | ||
391 | 389 | ||
392 | UUID uuid = new UUID(); | 390 | UUID uuid = new UUID(); |
393 | UUID.TryParse(r["uuid"].ToString(), out uuid); | 391 | UUID.TryParse(r["uuid"].ToString(), out uuid); |
394 | 392 | ||
395 | uuids.Add(uuid); | 393 | uuids.Add(uuid); |
394 | } | ||
395 | } | ||
396 | } | ||
396 | } | 397 | } |
397 | r.Close(); | ||
398 | 398 | ||
399 | return uuids.ToArray(); | 399 | return uuids.ToArray(); |
400 | } | 400 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index fca0ca5..3fdcf1e 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -40,12 +40,16 @@ namespace OpenSim.Data.MySQL | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class MySqlFramework | 41 | public class MySqlFramework |
42 | { | 42 | { |
43 | protected MySqlConnection m_Connection; | 43 | private static readonly log4net.ILog m_log = |
44 | log4net.LogManager.GetLogger( | ||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected string m_connectionString; | ||
48 | protected object m_dbLock = new object(); | ||
44 | 49 | ||
45 | protected MySqlFramework(string connectionString) | 50 | protected MySqlFramework(string connectionString) |
46 | { | 51 | { |
47 | m_Connection = new MySqlConnection(connectionString); | 52 | m_connectionString = connectionString; |
48 | m_Connection.Open(); | ||
49 | } | 53 | } |
50 | 54 | ||
51 | ////////////////////////////////////////////////////////////// | 55 | ////////////////////////////////////////////////////////////// |
@@ -55,64 +59,24 @@ namespace OpenSim.Data.MySQL | |||
55 | // | 59 | // |
56 | protected int ExecuteNonQuery(MySqlCommand cmd) | 60 | protected int ExecuteNonQuery(MySqlCommand cmd) |
57 | { | 61 | { |
58 | lock (m_Connection) | 62 | lock (m_dbLock) |
59 | { | 63 | { |
60 | cmd.Connection = m_Connection; | 64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
61 | |||
62 | bool errorSeen = false; | ||
63 | |||
64 | while (true) | ||
65 | { | 65 | { |
66 | dbcon.Open(); | ||
67 | cmd.Connection = dbcon; | ||
68 | |||
66 | try | 69 | try |
67 | { | 70 | { |
68 | return cmd.ExecuteNonQuery(); | 71 | return cmd.ExecuteNonQuery(); |
69 | } | 72 | } |
70 | catch (MySqlException e) | ||
71 | { | ||
72 | if (errorSeen) | ||
73 | throw; | ||
74 | |||
75 | // This is "Server has gone away" and "Server lost" | ||
76 | // | ||
77 | if (e.Number == 2006 || e.Number == 2013) | ||
78 | { | ||
79 | errorSeen = true; | ||
80 | |||
81 | m_Connection.Close(); | ||
82 | MySqlConnection newConnection = | ||
83 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
84 | m_Connection.Dispose(); | ||
85 | m_Connection = newConnection; | ||
86 | m_Connection.Open(); | ||
87 | |||
88 | cmd.Connection = m_Connection; | ||
89 | } | ||
90 | else | ||
91 | throw; | ||
92 | } | ||
93 | catch (Exception e) | 73 | catch (Exception e) |
94 | { | 74 | { |
75 | m_log.Error(e.Message, e); | ||
95 | return 0; | 76 | return 0; |
96 | } | 77 | } |
97 | } | 78 | } |
98 | } | 79 | } |
99 | } | 80 | } |
100 | |||
101 | protected IDataReader ExecuteReader(MySqlCommand cmd) | ||
102 | { | ||
103 | MySqlConnection newConnection = | ||
104 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
105 | newConnection.Open(); | ||
106 | |||
107 | cmd.Connection = newConnection; | ||
108 | return cmd.ExecuteReader(); | ||
109 | } | ||
110 | |||
111 | protected void CloseReaderCommand(MySqlCommand cmd) | ||
112 | { | ||
113 | cmd.Connection.Close(); | ||
114 | cmd.Connection.Dispose(); | ||
115 | cmd.Dispose(); | ||
116 | } | ||
117 | } | 81 | } |
118 | } | 82 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 2269d20..6ad59f6 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -54,12 +54,16 @@ namespace OpenSim.Data.MySQL | |||
54 | string realm, string storeName) : base(connectionString) | 54 | string realm, string storeName) : base(connectionString) |
55 | { | 55 | { |
56 | m_Realm = realm; | 56 | m_Realm = realm; |
57 | m_connectionString = connectionString; | ||
58 | |||
57 | if (storeName != String.Empty) | 59 | if (storeName != String.Empty) |
58 | { | 60 | { |
59 | Assembly assem = GetType().Assembly; | 61 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
60 | 62 | { | |
61 | Migration m = new Migration(m_Connection, assem, storeName); | 63 | dbcon.Open(); |
62 | m.Update(); | 64 | Migration m = new Migration(dbcon, GetType().Assembly, storeName); |
65 | m.Update(); | ||
66 | } | ||
63 | } | 67 | } |
64 | 68 | ||
65 | Type t = typeof(T); | 69 | Type t = typeof(T); |
@@ -107,149 +111,160 @@ namespace OpenSim.Data.MySQL | |||
107 | 111 | ||
108 | List<string> terms = new List<string>(); | 112 | List<string> terms = new List<string>(); |
109 | 113 | ||
110 | MySqlCommand cmd = new MySqlCommand(); | 114 | using (MySqlCommand cmd = new MySqlCommand()) |
111 | |||
112 | for (int i = 0 ; i < fields.Length ; i++) | ||
113 | { | 115 | { |
114 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | 116 | for (int i = 0 ; i < fields.Length ; i++) |
115 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | 117 | { |
116 | } | 118 | cmd.Parameters.AddWithValue(fields[i], keys[i]); |
117 | 119 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | |
118 | string where = String.Join(" and ", terms.ToArray()); | 120 | } |
119 | 121 | ||
120 | string query = String.Format("select * from {0} where {1}", | 122 | string where = String.Join(" and ", terms.ToArray()); |
121 | m_Realm, where); | ||
122 | 123 | ||
123 | cmd.CommandText = query; | 124 | string query = String.Format("select * from {0} where {1}", |
125 | m_Realm, where); | ||
124 | 126 | ||
125 | return DoQuery(cmd); | 127 | cmd.CommandText = query; |
128 | |||
129 | return DoQuery(cmd); | ||
130 | } | ||
126 | } | 131 | } |
127 | 132 | ||
128 | protected T[] DoQuery(MySqlCommand cmd) | 133 | protected T[] DoQuery(MySqlCommand cmd) |
129 | { | 134 | { |
130 | IDataReader reader = ExecuteReader(cmd); | ||
131 | if (reader == null) | ||
132 | return new T[0]; | ||
133 | |||
134 | CheckColumnNames(reader); | ||
135 | |||
136 | List<T> result = new List<T>(); | 135 | List<T> result = new List<T>(); |
137 | 136 | ||
138 | while (reader.Read()) | 137 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
139 | { | 138 | { |
140 | T row = new T(); | 139 | dbcon.Open(); |
140 | cmd.Connection = dbcon; | ||
141 | 141 | ||
142 | foreach (string name in m_Fields.Keys) | 142 | using (IDataReader reader = cmd.ExecuteReader()) |
143 | { | 143 | { |
144 | if (m_Fields[name].GetValue(row) is bool) | 144 | if (reader == null) |
145 | { | 145 | return new T[0]; |
146 | int v = Convert.ToInt32(reader[name]); | ||
147 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
148 | } | ||
149 | else if (m_Fields[name].GetValue(row) is UUID) | ||
150 | { | ||
151 | UUID uuid = UUID.Zero; | ||
152 | 146 | ||
153 | UUID.TryParse(reader[name].ToString(), out uuid); | 147 | CheckColumnNames(reader); |
154 | m_Fields[name].SetValue(row, uuid); | ||
155 | } | ||
156 | else if (m_Fields[name].GetValue(row) is int) | ||
157 | { | ||
158 | int v = Convert.ToInt32(reader[name]); | ||
159 | m_Fields[name].SetValue(row, v); | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | m_Fields[name].SetValue(row, reader[name]); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | if (m_DataField != null) | ||
168 | { | ||
169 | Dictionary<string, string> data = | ||
170 | new Dictionary<string, string>(); | ||
171 | 148 | ||
172 | foreach (string col in m_ColumnNames) | 149 | while (reader.Read()) |
173 | { | 150 | { |
174 | data[col] = reader[col].ToString(); | 151 | T row = new T(); |
175 | if (data[col] == null) | 152 | |
176 | data[col] = String.Empty; | 153 | foreach (string name in m_Fields.Keys) |
154 | { | ||
155 | if (m_Fields[name].GetValue(row) is bool) | ||
156 | { | ||
157 | int v = Convert.ToInt32(reader[name]); | ||
158 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
159 | } | ||
160 | else if (m_Fields[name].GetValue(row) is UUID) | ||
161 | { | ||
162 | UUID uuid = UUID.Zero; | ||
163 | |||
164 | UUID.TryParse(reader[name].ToString(), out uuid); | ||
165 | m_Fields[name].SetValue(row, uuid); | ||
166 | } | ||
167 | else if (m_Fields[name].GetValue(row) is int) | ||
168 | { | ||
169 | int v = Convert.ToInt32(reader[name]); | ||
170 | m_Fields[name].SetValue(row, v); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | m_Fields[name].SetValue(row, reader[name]); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | if (m_DataField != null) | ||
179 | { | ||
180 | Dictionary<string, string> data = | ||
181 | new Dictionary<string, string>(); | ||
182 | |||
183 | foreach (string col in m_ColumnNames) | ||
184 | { | ||
185 | data[col] = reader[col].ToString(); | ||
186 | if (data[col] == null) | ||
187 | data[col] = String.Empty; | ||
188 | } | ||
189 | |||
190 | m_DataField.SetValue(row, data); | ||
191 | } | ||
192 | |||
193 | result.Add(row); | ||
177 | } | 194 | } |
178 | |||
179 | m_DataField.SetValue(row, data); | ||
180 | } | 195 | } |
181 | |||
182 | result.Add(row); | ||
183 | } | 196 | } |
184 | 197 | ||
185 | reader.Close(); | ||
186 | |||
187 | CloseReaderCommand(cmd); | ||
188 | |||
189 | return result.ToArray(); | 198 | return result.ToArray(); |
190 | } | 199 | } |
191 | 200 | ||
192 | public virtual T[] Get(string where) | 201 | public virtual T[] Get(string where) |
193 | { | 202 | { |
194 | MySqlCommand cmd = new MySqlCommand(); | 203 | using (MySqlCommand cmd = new MySqlCommand()) |
195 | 204 | { | |
196 | string query = String.Format("select * from {0} where {1}", | 205 | |
197 | m_Realm, where); | 206 | string query = String.Format("select * from {0} where {1}", |
198 | 207 | m_Realm, where); | |
199 | cmd.CommandText = query; | 208 | |
200 | 209 | cmd.CommandText = query; | |
201 | return DoQuery(cmd); | 210 | |
211 | return DoQuery(cmd); | ||
212 | } | ||
202 | } | 213 | } |
203 | 214 | ||
204 | public virtual bool Store(T row) | 215 | public virtual bool Store(T row) |
205 | { | 216 | { |
206 | MySqlCommand cmd = new MySqlCommand(); | 217 | using (MySqlCommand cmd = new MySqlCommand()) |
218 | { | ||
207 | 219 | ||
208 | string query = ""; | 220 | string query = ""; |
209 | List<String> names = new List<String>(); | 221 | List<String> names = new List<String>(); |
210 | List<String> values = new List<String>(); | 222 | List<String> values = new List<String>(); |
211 | 223 | ||
212 | foreach (FieldInfo fi in m_Fields.Values) | 224 | foreach (FieldInfo fi in m_Fields.Values) |
213 | { | 225 | { |
214 | names.Add(fi.Name); | 226 | names.Add(fi.Name); |
215 | values.Add("?" + fi.Name); | 227 | values.Add("?" + fi.Name); |
216 | cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); | 228 | cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); |
217 | } | 229 | } |
218 | 230 | ||
219 | if (m_DataField != null) | 231 | if (m_DataField != null) |
220 | { | 232 | { |
221 | Dictionary<string, string> data = | 233 | Dictionary<string, string> data = |
222 | (Dictionary<string, string>)m_DataField.GetValue(row); | 234 | (Dictionary<string, string>)m_DataField.GetValue(row); |
223 | 235 | ||
224 | foreach (KeyValuePair<string, string> kvp in data) | 236 | foreach (KeyValuePair<string, string> kvp in data) |
225 | { | 237 | { |
226 | names.Add(kvp.Key); | 238 | names.Add(kvp.Key); |
227 | values.Add("?" + kvp.Key); | 239 | values.Add("?" + kvp.Key); |
228 | cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value); | 240 | cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value); |
241 | } | ||
229 | } | 242 | } |
230 | } | ||
231 | 243 | ||
232 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; | 244 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; |
233 | 245 | ||
234 | cmd.CommandText = query; | 246 | cmd.CommandText = query; |
235 | 247 | ||
236 | if (ExecuteNonQuery(cmd) > 0) | 248 | if (ExecuteNonQuery(cmd) > 0) |
237 | return true; | 249 | return true; |
238 | 250 | ||
239 | return false; | 251 | return false; |
252 | } | ||
240 | } | 253 | } |
241 | 254 | ||
242 | public virtual bool Delete(string field, string val) | 255 | public virtual bool Delete(string field, string val) |
243 | { | 256 | { |
244 | MySqlCommand cmd = new MySqlCommand(); | 257 | using (MySqlCommand cmd = new MySqlCommand()) |
258 | { | ||
245 | 259 | ||
246 | cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); | 260 | cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); |
247 | cmd.Parameters.AddWithValue(field, val); | 261 | cmd.Parameters.AddWithValue(field, val); |
248 | 262 | ||
249 | if (ExecuteNonQuery(cmd) > 0) | 263 | if (ExecuteNonQuery(cmd) > 0) |
250 | return true; | 264 | return true; |
251 | 265 | ||
252 | return false; | 266 | return false; |
267 | } | ||
253 | } | 268 | } |
254 | } | 269 | } |
255 | } | 270 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1ec2609..f4e7b85 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -31,6 +31,7 @@ using System.Data; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using log4net; | 33 | using log4net; |
34 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | 37 | ||
@@ -43,49 +44,9 @@ namespace OpenSim.Data.MySQL | |||
43 | { | 44 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 46 | ||
46 | /// <summary> | 47 | private MySQLManager m_database; |
47 | /// MySQL Database Manager | 48 | private object m_dbLock = new object(); |
48 | /// </summary> | 49 | private string m_connectionString; |
49 | private MySQLManager database; | ||
50 | |||
51 | |||
52 | /// <summary> | ||
53 | /// Better DB manager. Swap-in replacement too. | ||
54 | /// </summary> | ||
55 | public Dictionary<int, MySQLSuperManager> m_dbconnections = new Dictionary<int, MySQLSuperManager>(); | ||
56 | |||
57 | public int m_maxConnections = 10; | ||
58 | public int m_lastConnect; | ||
59 | |||
60 | public MySQLSuperManager GetLockedConnection() | ||
61 | { | ||
62 | int lockedCons = 0; | ||
63 | while (true) | ||
64 | { | ||
65 | m_lastConnect++; | ||
66 | |||
67 | // Overflow protection | ||
68 | if (m_lastConnect == int.MaxValue) | ||
69 | m_lastConnect = 0; | ||
70 | |||
71 | MySQLSuperManager x = m_dbconnections[m_lastConnect % m_maxConnections]; | ||
72 | if (!x.Locked) | ||
73 | { | ||
74 | x.GetLock(); | ||
75 | return x; | ||
76 | } | ||
77 | |||
78 | lockedCons++; | ||
79 | if (lockedCons > m_maxConnections) | ||
80 | { | ||
81 | lockedCons = 0; | ||
82 | Thread.Sleep(1000); // Wait some time before searching them again. | ||
83 | m_log.Debug( | ||
84 | "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | 50 | ||
90 | override public void Initialise() | 51 | override public void Initialise() |
91 | { | 52 | { |
@@ -106,49 +67,17 @@ namespace OpenSim.Data.MySQL | |||
106 | /// <param name="connect">connect string.</param> | 67 | /// <param name="connect">connect string.</param> |
107 | override public void Initialise(string connect) | 68 | override public void Initialise(string connect) |
108 | { | 69 | { |
109 | if (connect != String.Empty) | 70 | m_connectionString = connect; |
110 | { | 71 | m_database = new MySQLManager(connect); |
111 | database = new MySQLManager(connect); | ||
112 | 72 | ||
113 | m_log.Info("Creating " + m_maxConnections + " DB connections..."); | 73 | // This actually does the roll forward assembly stuff |
114 | for (int i = 0; i < m_maxConnections; i++) | 74 | Assembly assem = GetType().Assembly; |
115 | { | ||
116 | m_log.Info("Connecting to DB... [" + i + "]"); | ||
117 | MySQLSuperManager msm = new MySQLSuperManager(); | ||
118 | msm.Manager = new MySQLManager(connect); | ||
119 | m_dbconnections.Add(i, msm); | ||
120 | } | ||
121 | 75 | ||
122 | } | 76 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
123 | else | ||
124 | { | 77 | { |
125 | m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); | 78 | Migration m = new Migration(dbcon, assem, "GridStore"); |
126 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 79 | m.Update(); |
127 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
128 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | ||
129 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | ||
130 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | ||
131 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
132 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | ||
133 | |||
134 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, | ||
135 | settingPooling, settingPort); | ||
136 | |||
137 | m_log.Info("Creating " + m_maxConnections + " DB connections..."); | ||
138 | for (int i = 0; i < m_maxConnections; i++) | ||
139 | { | ||
140 | m_log.Info("Connecting to DB... [" + i + "]"); | ||
141 | MySQLSuperManager msm = new MySQLSuperManager(); | ||
142 | msm.Manager = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, | ||
143 | settingPooling, settingPort); | ||
144 | m_dbconnections.Add(i, msm); | ||
145 | } | ||
146 | } | 80 | } |
147 | |||
148 | // This actually does the roll forward assembly stuff | ||
149 | Assembly assem = GetType().Assembly; | ||
150 | Migration m = new Migration(database.Connection, assem, "GridStore"); | ||
151 | m.Update(); | ||
152 | } | 81 | } |
153 | 82 | ||
154 | /// <summary> | 83 | /// <summary> |
@@ -156,7 +85,6 @@ namespace OpenSim.Data.MySQL | |||
156 | /// </summary> | 85 | /// </summary> |
157 | override public void Dispose() | 86 | override public void Dispose() |
158 | { | 87 | { |
159 | database.Close(); | ||
160 | } | 88 | } |
161 | 89 | ||
162 | /// <summary> | 90 | /// <summary> |
@@ -187,8 +115,6 @@ namespace OpenSim.Data.MySQL | |||
187 | /// <returns>Array of sim profiles</returns> | 115 | /// <returns>Array of sim profiles</returns> |
188 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | 116 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) |
189 | { | 117 | { |
190 | MySQLSuperManager dbm = GetLockedConnection(); | ||
191 | |||
192 | try | 118 | try |
193 | { | 119 | { |
194 | Dictionary<string, object> param = new Dictionary<string, object>(); | 120 | Dictionary<string, object> param = new Dictionary<string, object>(); |
@@ -197,35 +123,33 @@ namespace OpenSim.Data.MySQL | |||
197 | param["?xmax"] = xmax.ToString(); | 123 | param["?xmax"] = xmax.ToString(); |
198 | param["?ymax"] = ymax.ToString(); | 124 | param["?ymax"] = ymax.ToString(); |
199 | 125 | ||
200 | IDbCommand result = | 126 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
201 | dbm.Manager.Query( | 127 | { |
202 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | 128 | dbcon.Open(); |
203 | param); | 129 | |
204 | IDataReader reader = result.ExecuteReader(); | 130 | using (IDbCommand result = m_database.Query(dbcon, |
131 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | ||
132 | param)) | ||
133 | { | ||
134 | using (IDataReader reader = result.ExecuteReader()) | ||
135 | { | ||
136 | RegionProfileData row; | ||
205 | 137 | ||
206 | RegionProfileData row; | 138 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
207 | 139 | ||
208 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 140 | while ((row = m_database.readSimRow(reader)) != null) |
141 | rows.Add(row); | ||
209 | 142 | ||
210 | while ((row = dbm.Manager.readSimRow(reader)) != null) | 143 | return rows.ToArray(); |
211 | { | 144 | } |
212 | rows.Add(row); | 145 | } |
213 | } | 146 | } |
214 | reader.Close(); | ||
215 | result.Dispose(); | ||
216 | |||
217 | return rows.ToArray(); | ||
218 | } | 147 | } |
219 | catch (Exception e) | 148 | catch (Exception e) |
220 | { | 149 | { |
221 | dbm.Manager.Reconnect(); | 150 | m_log.Error(e.Message, e); |
222 | m_log.Error(e.ToString()); | ||
223 | return null; | 151 | return null; |
224 | } | 152 | } |
225 | finally | ||
226 | { | ||
227 | dbm.Release(); | ||
228 | } | ||
229 | } | 153 | } |
230 | 154 | ||
231 | /// <summary> | 155 | /// <summary> |
@@ -236,42 +160,38 @@ namespace OpenSim.Data.MySQL | |||
236 | /// <returns>A list of sim profiles</returns> | 160 | /// <returns>A list of sim profiles</returns> |
237 | override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum) | 161 | override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum) |
238 | { | 162 | { |
239 | MySQLSuperManager dbm = GetLockedConnection(); | ||
240 | |||
241 | try | 163 | try |
242 | { | 164 | { |
243 | Dictionary<string, object> param = new Dictionary<string, object>(); | 165 | Dictionary<string, object> param = new Dictionary<string, object>(); |
244 | param["?name"] = namePrefix + "%"; | 166 | param["?name"] = namePrefix + "%"; |
245 | 167 | ||
246 | IDbCommand result = | 168 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
247 | dbm.Manager.Query( | 169 | { |
170 | dbcon.Open(); | ||
171 | |||
172 | using (IDbCommand result = m_database.Query(dbcon, | ||
248 | "SELECT * FROM regions WHERE regionName LIKE ?name", | 173 | "SELECT * FROM regions WHERE regionName LIKE ?name", |
249 | param); | 174 | param)) |
250 | IDataReader reader = result.ExecuteReader(); | 175 | { |
176 | using (IDataReader reader = result.ExecuteReader()) | ||
177 | { | ||
178 | RegionProfileData row; | ||
251 | 179 | ||
252 | RegionProfileData row; | 180 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
253 | 181 | ||
254 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 182 | while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null) |
183 | rows.Add(row); | ||
255 | 184 | ||
256 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) | 185 | return rows; |
257 | { | 186 | } |
258 | rows.Add(row); | 187 | } |
259 | } | 188 | } |
260 | reader.Close(); | ||
261 | result.Dispose(); | ||
262 | |||
263 | return rows; | ||
264 | } | 189 | } |
265 | catch (Exception e) | 190 | catch (Exception e) |
266 | { | 191 | { |
267 | dbm.Manager.Reconnect(); | 192 | m_log.Error(e.Message, e); |
268 | m_log.Error(e.ToString()); | ||
269 | return null; | 193 | return null; |
270 | } | 194 | } |
271 | finally | ||
272 | { | ||
273 | dbm.Release(); | ||
274 | } | ||
275 | } | 195 | } |
276 | 196 | ||
277 | /// <summary> | 197 | /// <summary> |
@@ -281,32 +201,30 @@ namespace OpenSim.Data.MySQL | |||
281 | /// <returns>Sim profile</returns> | 201 | /// <returns>Sim profile</returns> |
282 | override public RegionProfileData GetProfileByHandle(ulong handle) | 202 | override public RegionProfileData GetProfileByHandle(ulong handle) |
283 | { | 203 | { |
284 | MySQLSuperManager dbm = GetLockedConnection(); | ||
285 | |||
286 | try | 204 | try |
287 | { | 205 | { |
288 | Dictionary<string, object> param = new Dictionary<string, object>(); | 206 | Dictionary<string, object> param = new Dictionary<string, object>(); |
289 | param["?handle"] = handle.ToString(); | 207 | param["?handle"] = handle.ToString(); |
290 | |||
291 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); | ||
292 | IDataReader reader = result.ExecuteReader(); | ||
293 | 208 | ||
294 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 209 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
295 | reader.Close(); | 210 | { |
296 | result.Dispose(); | 211 | dbcon.Open(); |
297 | 212 | ||
298 | return row; | 213 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param)) |
214 | { | ||
215 | using (IDataReader reader = result.ExecuteReader()) | ||
216 | { | ||
217 | RegionProfileData row = m_database.readSimRow(reader); | ||
218 | return row; | ||
219 | } | ||
220 | } | ||
299 | } | 221 | } |
222 | } | ||
300 | catch (Exception e) | 223 | catch (Exception e) |
301 | { | 224 | { |
302 | dbm.Manager.Reconnect(); | 225 | m_log.Error(e.Message, e); |
303 | m_log.Error(e.ToString()); | ||
304 | return null; | 226 | return null; |
305 | } | 227 | } |
306 | finally | ||
307 | { | ||
308 | dbm.Release(); | ||
309 | } | ||
310 | } | 228 | } |
311 | 229 | ||
312 | /// <summary> | 230 | /// <summary> |
@@ -316,30 +234,29 @@ namespace OpenSim.Data.MySQL | |||
316 | /// <returns>The sim profile</returns> | 234 | /// <returns>The sim profile</returns> |
317 | override public RegionProfileData GetProfileByUUID(UUID uuid) | 235 | override public RegionProfileData GetProfileByUUID(UUID uuid) |
318 | { | 236 | { |
319 | MySQLSuperManager dbm = GetLockedConnection(); | ||
320 | |||
321 | try | 237 | try |
322 | { | 238 | { |
323 | Dictionary<string, object> param = new Dictionary<string, object>(); | 239 | Dictionary<string, object> param = new Dictionary<string, object>(); |
324 | param["?uuid"] = uuid.ToString(); | 240 | param["?uuid"] = uuid.ToString(); |
325 | 241 | ||
326 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); | 242 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
327 | IDataReader reader = result.ExecuteReader(); | 243 | { |
328 | 244 | dbcon.Open(); | |
329 | RegionProfileData row = dbm.Manager.readSimRow(reader); | ||
330 | reader.Close(); | ||
331 | result.Dispose(); | ||
332 | 245 | ||
333 | return row; | 246 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param)) |
247 | { | ||
248 | using (IDataReader reader = result.ExecuteReader()) | ||
249 | { | ||
250 | RegionProfileData row = m_database.readSimRow(reader); | ||
251 | return row; | ||
252 | } | ||
253 | } | ||
334 | } | 254 | } |
255 | } | ||
335 | catch (Exception e) | 256 | catch (Exception e) |
336 | { | 257 | { |
337 | dbm.Manager.Reconnect(); | 258 | m_log.Error(e.Message, e); |
338 | m_log.Error(e.ToString()); | ||
339 | return null; | 259 | return null; |
340 | } finally | ||
341 | { | ||
342 | dbm.Release(); | ||
343 | } | 260 | } |
344 | } | 261 | } |
345 | 262 | ||
@@ -351,37 +268,36 @@ namespace OpenSim.Data.MySQL | |||
351 | { | 268 | { |
352 | if (regionName.Length > 2) | 269 | if (regionName.Length > 2) |
353 | { | 270 | { |
354 | MySQLSuperManager dbm = GetLockedConnection(); | ||
355 | |||
356 | try | 271 | try |
357 | { | 272 | { |
358 | Dictionary<string, object> param = new Dictionary<string, object>(); | 273 | Dictionary<string, object> param = new Dictionary<string, object>(); |
359 | // Add % because this is a like query. | 274 | // Add % because this is a like query. |
360 | param["?regionName"] = regionName + "%"; | 275 | param["?regionName"] = regionName + "%"; |
361 | // Order by statement will return shorter matches first. Only returns one record or no record. | ||
362 | IDbCommand result = | ||
363 | dbm.Manager.Query( | ||
364 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | ||
365 | param); | ||
366 | IDataReader reader = result.ExecuteReader(); | ||
367 | 276 | ||
368 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 277 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
369 | reader.Close(); | 278 | { |
370 | result.Dispose(); | 279 | dbcon.Open(); |
371 | 280 | ||
372 | return row; | 281 | // Order by statement will return shorter matches first. Only returns one record or no record. |
282 | using (IDbCommand result = m_database.Query(dbcon, | ||
283 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | ||
284 | param)) | ||
285 | { | ||
286 | using (IDataReader reader = result.ExecuteReader()) | ||
287 | { | ||
288 | RegionProfileData row = m_database.readSimRow(reader); | ||
289 | return row; | ||
290 | } | ||
291 | } | ||
292 | } | ||
373 | } | 293 | } |
374 | catch (Exception e) | 294 | catch (Exception e) |
375 | { | 295 | { |
376 | dbm.Manager.Reconnect(); | 296 | m_log.Error(e.Message, e); |
377 | m_log.Error(e.ToString()); | ||
378 | return null; | 297 | return null; |
379 | } | 298 | } |
380 | finally | ||
381 | { | ||
382 | dbm.Release(); | ||
383 | } | ||
384 | } | 299 | } |
300 | |||
385 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | 301 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); |
386 | return null; | 302 | return null; |
387 | } | 303 | } |
@@ -393,17 +309,16 @@ namespace OpenSim.Data.MySQL | |||
393 | /// <returns>Successful?</returns> | 309 | /// <returns>Successful?</returns> |
394 | override public DataResponse StoreProfile(RegionProfileData profile) | 310 | override public DataResponse StoreProfile(RegionProfileData profile) |
395 | { | 311 | { |
396 | MySQLSuperManager dbm = GetLockedConnection(); | 312 | try |
397 | try { | 313 | { |
398 | if (dbm.Manager.insertRegion(profile)) | 314 | if (m_database.insertRegion(profile)) |
399 | { | ||
400 | return DataResponse.RESPONSE_OK; | 315 | return DataResponse.RESPONSE_OK; |
401 | } | 316 | else |
402 | return DataResponse.RESPONSE_ERROR; | 317 | return DataResponse.RESPONSE_ERROR; |
403 | } | 318 | } |
404 | finally | 319 | catch |
405 | { | 320 | { |
406 | dbm.Release(); | 321 | return DataResponse.RESPONSE_ERROR; |
407 | } | 322 | } |
408 | } | 323 | } |
409 | 324 | ||
@@ -415,18 +330,16 @@ namespace OpenSim.Data.MySQL | |||
415 | //public DataResponse DeleteProfile(RegionProfileData profile) | 330 | //public DataResponse DeleteProfile(RegionProfileData profile) |
416 | override public DataResponse DeleteProfile(string uuid) | 331 | override public DataResponse DeleteProfile(string uuid) |
417 | { | 332 | { |
418 | MySQLSuperManager dbm = GetLockedConnection(); | 333 | try |
419 | 334 | { | |
420 | 335 | if (m_database.deleteRegion(uuid)) | |
421 | try { | ||
422 | if (dbm.Manager.deleteRegion(uuid)) | ||
423 | { | ||
424 | return DataResponse.RESPONSE_OK; | 336 | return DataResponse.RESPONSE_OK; |
425 | } | 337 | else |
426 | return DataResponse.RESPONSE_ERROR; | 338 | return DataResponse.RESPONSE_ERROR; |
427 | } finally | 339 | } |
340 | catch | ||
428 | { | 341 | { |
429 | dbm.Release(); | 342 | return DataResponse.RESPONSE_ERROR; |
430 | } | 343 | } |
431 | } | 344 | } |
432 | 345 | ||
@@ -477,33 +390,32 @@ namespace OpenSim.Data.MySQL | |||
477 | /// <returns></returns> | 390 | /// <returns></returns> |
478 | override public ReservationData GetReservationAtPoint(uint x, uint y) | 391 | override public ReservationData GetReservationAtPoint(uint x, uint y) |
479 | { | 392 | { |
480 | MySQLSuperManager dbm = GetLockedConnection(); | ||
481 | |||
482 | try | 393 | try |
483 | { | 394 | { |
484 | Dictionary<string, object> param = new Dictionary<string, object>(); | 395 | Dictionary<string, object> param = new Dictionary<string, object>(); |
485 | param["?x"] = x.ToString(); | 396 | param["?x"] = x.ToString(); |
486 | param["?y"] = y.ToString(); | 397 | param["?y"] = y.ToString(); |
487 | IDbCommand result = | 398 | |
488 | dbm.Manager.Query( | 399 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
489 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | 400 | { |
490 | param); | 401 | dbcon.Open(); |
491 | IDataReader reader = result.ExecuteReader(); | 402 | |
492 | 403 | using (IDbCommand result = m_database.Query(dbcon, | |
493 | ReservationData row = dbm.Manager.readReservationRow(reader); | 404 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", |
494 | reader.Close(); | 405 | param)) |
495 | result.Dispose(); | 406 | { |
496 | 407 | using (IDataReader reader = result.ExecuteReader()) | |
497 | return row; | 408 | { |
409 | ReservationData row = m_database.readReservationRow(reader); | ||
410 | return row; | ||
411 | } | ||
412 | } | ||
413 | } | ||
498 | } | 414 | } |
499 | catch (Exception e) | 415 | catch (Exception e) |
500 | { | 416 | { |
501 | dbm.Manager.Reconnect(); | 417 | m_log.Error(e.Message, e); |
502 | m_log.Error(e.ToString()); | ||
503 | return null; | 418 | return null; |
504 | } finally | ||
505 | { | ||
506 | dbm.Release(); | ||
507 | } | 419 | } |
508 | } | 420 | } |
509 | } | 421 | } |
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 4b71e39..192deb2 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
30 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
31 | using System.Reflection; | 30 | using System.Reflection; |
32 | using log4net; | 31 | using log4net; |
@@ -44,14 +43,10 @@ namespace OpenSim.Data.MySQL | |||
44 | private static readonly ILog m_log | 43 | private static readonly ILog m_log |
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 45 | ||
47 | /// <summary> | 46 | private string m_connectionString; |
48 | /// The database manager | 47 | private object m_dbLock = new object(); |
49 | /// </summary> | ||
50 | private MySQLManager database; | ||
51 | 48 | ||
52 | private bool rollbackStore = false; | 49 | public string Version { get { return "1.0.0.0"; } } |
53 | private bool opengridmode = false; | ||
54 | private string rollbackDir = ""; | ||
55 | 50 | ||
56 | public void Initialise() | 51 | public void Initialise() |
57 | { | 52 | { |
@@ -72,37 +67,17 @@ namespace OpenSim.Data.MySQL | |||
72 | /// <param name="connect">connect string</param> | 67 | /// <param name="connect">connect string</param> |
73 | public void Initialise(string connect) | 68 | public void Initialise(string connect) |
74 | { | 69 | { |
75 | if (connect != String.Empty) | 70 | m_connectionString = connect; |
76 | { | ||
77 | database = new MySQLManager(connect); | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | m_log.Warn("Reverting to deprecated mysql_connection.ini file for connection info"); | ||
82 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | ||
83 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
84 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | ||
85 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | ||
86 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | ||
87 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
88 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | ||
89 | |||
90 | rollbackDir = GridDataMySqlFile.ParseFileReadValue("rollbackdir"); | ||
91 | rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true"; | ||
92 | opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true"; | ||
93 | |||
94 | if (rollbackStore) | ||
95 | m_log.Warn("[MysqlInventory] Enabling rollback mode in: " + rollbackDir); | ||
96 | |||
97 | database = | ||
98 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | ||
99 | settingPort); | ||
100 | } | ||
101 | 71 | ||
102 | // This actually does the roll forward assembly stuff | 72 | // This actually does the roll forward assembly stuff |
103 | Assembly assem = GetType().Assembly; | 73 | Assembly assem = GetType().Assembly; |
104 | Migration m = new Migration(database.Connection, assem, "InventoryStore"); | 74 | |
105 | m.Update(); | 75 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
76 | { | ||
77 | dbcon.Open(); | ||
78 | Migration m = new Migration(dbcon, assem, "InventoryStore"); | ||
79 | m.Update(); | ||
80 | } | ||
106 | } | 81 | } |
107 | 82 | ||
108 | /// <summary> | 83 | /// <summary> |
@@ -124,15 +99,6 @@ namespace OpenSim.Data.MySQL | |||
124 | } | 99 | } |
125 | 100 | ||
126 | /// <summary> | 101 | /// <summary> |
127 | /// Returns the version of this DB provider | ||
128 | /// </summary> | ||
129 | /// <returns>A string containing the DB provider version</returns> | ||
130 | public string Version | ||
131 | { | ||
132 | get { return database.getVersion(); } | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Returns a list of items in a specified folder | 102 | /// Returns a list of items in a specified folder |
137 | /// </summary> | 103 | /// </summary> |
138 | /// <param name="folderID">The folder to search</param> | 104 | /// <param name="folderID">The folder to search</param> |
@@ -141,36 +107,37 @@ namespace OpenSim.Data.MySQL | |||
141 | { | 107 | { |
142 | try | 108 | try |
143 | { | 109 | { |
144 | lock (database) | 110 | lock (m_dbLock) |
145 | { | 111 | { |
146 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 112 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
147 | 113 | ||
148 | database.CheckConnection(); | 114 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
149 | |||
150 | MySqlCommand result = | ||
151 | new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", | ||
152 | database.Connection); | ||
153 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | ||
154 | MySqlDataReader reader = result.ExecuteReader(); | ||
155 | |||
156 | while (reader.Read()) | ||
157 | { | 115 | { |
158 | // A null item (because something went wrong) breaks everything in the folder | 116 | dbcon.Open(); |
159 | InventoryItemBase item = readInventoryItem(reader); | ||
160 | if (item != null) | ||
161 | items.Add(item); | ||
162 | } | ||
163 | 117 | ||
164 | reader.Close(); | 118 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", dbcon)) |
165 | result.Dispose(); | 119 | { |
120 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | ||
121 | |||
122 | using (MySqlDataReader reader = result.ExecuteReader()) | ||
123 | { | ||
124 | while (reader.Read()) | ||
125 | { | ||
126 | // A null item (because something went wrong) breaks everything in the folder | ||
127 | InventoryItemBase item = readInventoryItem(reader); | ||
128 | if (item != null) | ||
129 | items.Add(item); | ||
130 | } | ||
166 | 131 | ||
167 | return items; | 132 | return items; |
133 | } | ||
134 | } | ||
135 | } | ||
168 | } | 136 | } |
169 | } | 137 | } |
170 | catch (Exception e) | 138 | catch (Exception e) |
171 | { | 139 | { |
172 | database.Reconnect(); | 140 | m_log.Error(e.Message, e); |
173 | m_log.Error(e.ToString()); | ||
174 | return null; | 141 | return null; |
175 | } | 142 | } |
176 | } | 143 | } |
@@ -184,33 +151,33 @@ namespace OpenSim.Data.MySQL | |||
184 | { | 151 | { |
185 | try | 152 | try |
186 | { | 153 | { |
187 | lock (database) | 154 | lock (m_dbLock) |
188 | { | 155 | { |
189 | database.CheckConnection(); | 156 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
190 | 157 | { | |
191 | MySqlCommand result = | 158 | dbcon.Open(); |
192 | new MySqlCommand( | ||
193 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | ||
194 | database.Connection); | ||
195 | result.Parameters.AddWithValue("?uuid", user.ToString()); | ||
196 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | ||
197 | MySqlDataReader reader = result.ExecuteReader(); | ||
198 | |||
199 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
200 | while (reader.Read()) | ||
201 | items.Add(readInventoryFolder(reader)); | ||
202 | 159 | ||
160 | using (MySqlCommand result = new MySqlCommand( | ||
161 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon)) | ||
162 | { | ||
163 | result.Parameters.AddWithValue("?uuid", user.ToString()); | ||
164 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | ||
203 | 165 | ||
204 | reader.Close(); | 166 | using (MySqlDataReader reader = result.ExecuteReader()) |
205 | result.Dispose(); | 167 | { |
168 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
169 | while (reader.Read()) | ||
170 | items.Add(readInventoryFolder(reader)); | ||
206 | 171 | ||
207 | return items; | 172 | return items; |
173 | } | ||
174 | } | ||
175 | } | ||
208 | } | 176 | } |
209 | } | 177 | } |
210 | catch (Exception e) | 178 | catch (Exception e) |
211 | { | 179 | { |
212 | database.Reconnect(); | 180 | m_log.Error(e.Message, e); |
213 | m_log.Error(e.ToString()); | ||
214 | return null; | 181 | return null; |
215 | } | 182 | } |
216 | } | 183 | } |
@@ -225,46 +192,44 @@ namespace OpenSim.Data.MySQL | |||
225 | { | 192 | { |
226 | try | 193 | try |
227 | { | 194 | { |
228 | lock (database) | 195 | lock (m_dbLock) |
229 | { | 196 | { |
230 | database.CheckConnection(); | 197 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
198 | { | ||
199 | dbcon.Open(); | ||
231 | 200 | ||
232 | MySqlCommand result = | 201 | using (MySqlCommand result = new MySqlCommand( |
233 | new MySqlCommand( | 202 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon)) |
234 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | 203 | { |
235 | database.Connection); | 204 | result.Parameters.AddWithValue("?uuid", user.ToString()); |
236 | result.Parameters.AddWithValue("?uuid", user.ToString()); | 205 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); |
237 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | ||
238 | 206 | ||
239 | MySqlDataReader reader = result.ExecuteReader(); | 207 | using (MySqlDataReader reader = result.ExecuteReader()) |
208 | { | ||
209 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
210 | while (reader.Read()) | ||
211 | items.Add(readInventoryFolder(reader)); | ||
240 | 212 | ||
241 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 213 | InventoryFolderBase rootFolder = null; |
242 | while (reader.Read()) | ||
243 | items.Add(readInventoryFolder(reader)); | ||
244 | 214 | ||
245 | InventoryFolderBase rootFolder = null; | 215 | // There should only ever be one root folder for a user. However, if there's more |
216 | // than one we'll simply use the first one rather than failing. It would be even | ||
217 | // nicer to print some message to this effect, but this feels like it's too low a | ||
218 | // to put such a message out, and it's too minor right now to spare the time to | ||
219 | // suitably refactor. | ||
220 | if (items.Count > 0) | ||
221 | rootFolder = items[0]; | ||
246 | 222 | ||
247 | // There should only ever be one root folder for a user. However, if there's more | 223 | return rootFolder; |
248 | // than one we'll simply use the first one rather than failing. It would be even | 224 | } |
249 | // nicer to print some message to this effect, but this feels like it's too low a | 225 | } |
250 | // to put such a message out, and it's too minor right now to spare the time to | ||
251 | // suitably refactor. | ||
252 | if (items.Count > 0) | ||
253 | { | ||
254 | rootFolder = items[0]; | ||
255 | } | 226 | } |
256 | |||
257 | reader.Close(); | ||
258 | result.Dispose(); | ||
259 | |||
260 | return rootFolder; | ||
261 | } | 227 | } |
262 | } | 228 | } |
263 | catch (Exception e) | 229 | catch (Exception e) |
264 | { | 230 | { |
265 | database.Reconnect(); | 231 | m_log.Error(e.Message, e); |
266 | m_log.Error(e.ToString()); | 232 | return null; |
267 | throw; | ||
268 | } | 233 | } |
269 | } | 234 | } |
270 | 235 | ||
@@ -279,31 +244,31 @@ namespace OpenSim.Data.MySQL | |||
279 | { | 244 | { |
280 | try | 245 | try |
281 | { | 246 | { |
282 | lock (database) | 247 | lock (m_dbLock) |
283 | { | 248 | { |
284 | database.CheckConnection(); | 249 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
285 | 250 | { | |
286 | MySqlCommand result = | 251 | dbcon.Open(); |
287 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", | ||
288 | database.Connection); | ||
289 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | ||
290 | MySqlDataReader reader = result.ExecuteReader(); | ||
291 | 252 | ||
292 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 253 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", dbcon)) |
254 | { | ||
255 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | ||
256 | using (MySqlDataReader reader = result.ExecuteReader()) | ||
257 | { | ||
258 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
293 | 259 | ||
294 | while (reader.Read()) | 260 | while (reader.Read()) |
295 | items.Add(readInventoryFolder(reader)); | 261 | items.Add(readInventoryFolder(reader)); |
296 | 262 | ||
297 | reader.Close(); | 263 | return items; |
298 | result.Dispose(); | 264 | } |
299 | 265 | } | |
300 | return items; | 266 | } |
301 | } | 267 | } |
302 | } | 268 | } |
303 | catch (Exception e) | 269 | catch (Exception e) |
304 | { | 270 | { |
305 | database.Reconnect(); | 271 | m_log.Error(e.Message, e); |
306 | m_log.Error(e.ToString()); | ||
307 | return null; | 272 | return null; |
308 | } | 273 | } |
309 | } | 274 | } |
@@ -378,29 +343,31 @@ namespace OpenSim.Data.MySQL | |||
378 | { | 343 | { |
379 | try | 344 | try |
380 | { | 345 | { |
381 | lock (database) | 346 | lock (m_dbLock) |
382 | { | 347 | { |
383 | database.CheckConnection(); | 348 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
384 | 349 | { | |
385 | MySqlCommand result = | 350 | dbcon.Open(); |
386 | new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); | ||
387 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); | ||
388 | MySqlDataReader reader = result.ExecuteReader(); | ||
389 | 351 | ||
390 | InventoryItemBase item = null; | 352 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", dbcon)) |
391 | if (reader.Read()) | 353 | { |
392 | item = readInventoryItem(reader); | 354 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); |
393 | 355 | ||
394 | reader.Close(); | 356 | using (MySqlDataReader reader = result.ExecuteReader()) |
395 | result.Dispose(); | 357 | { |
358 | InventoryItemBase item = null; | ||
359 | if (reader.Read()) | ||
360 | item = readInventoryItem(reader); | ||
396 | 361 | ||
397 | return item; | 362 | return item; |
363 | } | ||
364 | } | ||
365 | } | ||
398 | } | 366 | } |
399 | } | 367 | } |
400 | catch (Exception e) | 368 | catch (Exception e) |
401 | { | 369 | { |
402 | database.Reconnect(); | 370 | m_log.Error(e.Message, e); |
403 | m_log.Error(e.ToString()); | ||
404 | } | 371 | } |
405 | return null; | 372 | return null; |
406 | } | 373 | } |
@@ -425,7 +392,7 @@ namespace OpenSim.Data.MySQL | |||
425 | } | 392 | } |
426 | catch (Exception e) | 393 | catch (Exception e) |
427 | { | 394 | { |
428 | m_log.Error(e.ToString()); | 395 | m_log.Error(e.Message, e); |
429 | } | 396 | } |
430 | 397 | ||
431 | return null; | 398 | return null; |
@@ -441,151 +408,35 @@ namespace OpenSim.Data.MySQL | |||
441 | { | 408 | { |
442 | try | 409 | try |
443 | { | 410 | { |
444 | lock (database) | 411 | lock (m_dbLock) |
445 | { | 412 | { |
446 | database.CheckConnection(); | 413 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
414 | { | ||
415 | dbcon.Open(); | ||
447 | 416 | ||
448 | MySqlCommand result = | 417 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon)) |
449 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); | 418 | { |
450 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | 419 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); |
451 | MySqlDataReader reader = result.ExecuteReader(); | ||
452 | 420 | ||
453 | InventoryFolderBase folder = null; | 421 | using (MySqlDataReader reader = result.ExecuteReader()) |
454 | if (reader.Read()) | 422 | { |
455 | folder = readInventoryFolder(reader); | 423 | InventoryFolderBase folder = null; |
456 | reader.Close(); | 424 | if (reader.Read()) |
457 | result.Dispose(); | 425 | folder = readInventoryFolder(reader); |
458 | 426 | ||
459 | return folder; | 427 | return folder; |
428 | } | ||
429 | } | ||
430 | } | ||
460 | } | 431 | } |
461 | } | 432 | } |
462 | catch (Exception e) | 433 | catch (Exception e) |
463 | { | 434 | { |
464 | database.Reconnect(); | 435 | m_log.Error(e.Message, e); |
465 | m_log.Error(e.ToString()); | ||
466 | return null; | 436 | return null; |
467 | } | 437 | } |
468 | } | 438 | } |
469 | 439 | ||
470 | #region Inventory Rollback-via-.sql Support | ||
471 | /// <summary> | ||
472 | /// Not a good SQL escape function, but it'll do the job (if mutilate the data.) | ||
473 | /// Someone may want to write something better here. | ||
474 | /// </summary> | ||
475 | /// <param name="str"></param> | ||
476 | /// <returns></returns> | ||
477 | private static string cheapSQLescape(string str) | ||
478 | { | ||
479 | str = str.Replace("\\", ""); | ||
480 | str = str.Replace("'", ""); | ||
481 | str = str.Replace("\"", ""); | ||
482 | return "'" + str + "'"; | ||
483 | } | ||
484 | |||
485 | private static string InventoryItemToSql(InventoryItemBase item) | ||
486 | { | ||
487 | string sql = | ||
488 | "REPLACE /*! INVITEM AT ***$SUBS$*** */ INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" | ||
489 | + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" | ||
490 | + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType" | ||
491 | + ", creationDate, groupID, groupOwned, flags) VALUES "; | ||
492 | sql += | ||
493 | "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" | ||
494 | + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" | ||
495 | + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" | ||
496 | + ", ?groupID, ?groupOwned, ?flags);\r\n"; | ||
497 | |||
498 | string itemName = item.Name; | ||
499 | string itemDesc = item.Description; | ||
500 | |||
501 | sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); | ||
502 | |||
503 | sql = sql.Replace("?inventoryID", cheapSQLescape(item.ID.ToString())); | ||
504 | sql = sql.Replace("?assetID", cheapSQLescape(item.AssetID.ToString())); | ||
505 | sql = sql.Replace("?assetType", cheapSQLescape(item.AssetType.ToString())); | ||
506 | sql = sql.Replace("?parentFolderID", cheapSQLescape(item.Folder.ToString())); | ||
507 | sql = sql.Replace("?avatarID", cheapSQLescape(item.Owner.ToString())); | ||
508 | sql = sql.Replace("?inventoryName", cheapSQLescape(itemName)); | ||
509 | sql = sql.Replace("?inventoryDescription", cheapSQLescape(itemDesc)); | ||
510 | sql = sql.Replace("?inventoryNextPermissions", cheapSQLescape(item.NextPermissions.ToString())); | ||
511 | sql = sql.Replace("?inventoryCurrentPermissions", cheapSQLescape(item.CurrentPermissions.ToString())); | ||
512 | sql = sql.Replace("?invType", cheapSQLescape(item.InvType.ToString())); | ||
513 | sql = sql.Replace("?creatorID", cheapSQLescape(item.CreatorId)); | ||
514 | sql = sql.Replace("?inventoryBasePermissions", cheapSQLescape(item.BasePermissions.ToString())); | ||
515 | sql = sql.Replace("?inventoryEveryOnePermissions", cheapSQLescape(item.EveryOnePermissions.ToString())); | ||
516 | sql = sql.Replace("?inventoryGroupPermissions", cheapSQLescape(item.GroupPermissions.ToString())); | ||
517 | sql = sql.Replace("?salePrice", cheapSQLescape(item.SalePrice.ToString())); | ||
518 | sql = sql.Replace("?saleType", cheapSQLescape(unchecked((sbyte)item.SaleType).ToString())); | ||
519 | sql = sql.Replace("?creationDate", cheapSQLescape(item.CreationDate.ToString())); | ||
520 | sql = sql.Replace("?groupID", cheapSQLescape(item.GroupID.ToString())); | ||
521 | sql = sql.Replace("?groupOwned", cheapSQLescape(item.GroupOwned.ToString())); | ||
522 | sql = sql.Replace("?flags", cheapSQLescape(item.Flags.ToString())); | ||
523 | |||
524 | return sql; | ||
525 | } | ||
526 | |||
527 | private static string InventoryFolderToSql(InventoryFolderBase folder) | ||
528 | { | ||
529 | string sql = | ||
530 | "REPLACE /*! INVFOLDER AT ***$SUBS$*** */ INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; | ||
531 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version);\r\n"; | ||
532 | |||
533 | string folderName = folder.Name; | ||
534 | |||
535 | sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); | ||
536 | |||
537 | sql = sql.Replace("?folderID", cheapSQLescape(folder.ID.ToString())); | ||
538 | sql = sql.Replace("?agentID", cheapSQLescape(folder.Owner.ToString())); | ||
539 | sql = sql.Replace("?parentFolderID", cheapSQLescape(folder.ParentID.ToString())); | ||
540 | sql = sql.Replace("?folderName", cheapSQLescape(folderName)); | ||
541 | sql = sql.Replace("?type", cheapSQLescape(folder.Type.ToString())); | ||
542 | sql = sql.Replace("?version", cheapSQLescape(folder.Version.ToString())); | ||
543 | |||
544 | return sql; | ||
545 | } | ||
546 | |||
547 | private static string getRollbackFolderDate() | ||
548 | { | ||
549 | return DateTime.UtcNow.Year.ToString() + "-" + DateTime.UtcNow.Month.ToString() + "-" + | ||
550 | DateTime.UtcNow.Day.ToString(); | ||
551 | } | ||
552 | |||
553 | private void StoreRollbackItem(UUID ItemID) | ||
554 | { | ||
555 | if (rollbackStore == true) | ||
556 | { | ||
557 | string todaysPath = RollbackGetTodaysPath(); | ||
558 | |||
559 | InventoryItemBase imb = getInventoryItem(ItemID); | ||
560 | string sql = InventoryItemToSql(imb); | ||
561 | File.AppendAllText(Path.Combine(todaysPath, imb.Owner.ToString()), sql); | ||
562 | } | ||
563 | } | ||
564 | |||
565 | private void StoreRollbackFolder(UUID FolderID) | ||
566 | { | ||
567 | if (rollbackStore == true) | ||
568 | { | ||
569 | string todaysPath = RollbackGetTodaysPath(); | ||
570 | |||
571 | InventoryFolderBase ifb = getInventoryFolder(FolderID); | ||
572 | string sql = InventoryFolderToSql(ifb); | ||
573 | File.AppendAllText(Path.Combine(todaysPath, ifb.Owner.ToString()), sql); | ||
574 | } | ||
575 | } | ||
576 | |||
577 | private string RollbackGetTodaysPath() | ||
578 | { | ||
579 | if (!Directory.Exists(rollbackDir)) | ||
580 | Directory.CreateDirectory(rollbackDir); | ||
581 | |||
582 | string todaysPath = Path.Combine(rollbackDir, getRollbackFolderDate()); | ||
583 | if (!Directory.Exists(todaysPath)) | ||
584 | Directory.CreateDirectory(todaysPath); | ||
585 | return todaysPath; | ||
586 | } | ||
587 | #endregion | ||
588 | |||
589 | /// <summary> | 440 | /// <summary> |
590 | /// Adds a specified item to the database | 441 | /// Adds a specified item to the database |
591 | /// </summary> | 442 | /// </summary> |
@@ -619,46 +470,48 @@ namespace OpenSim.Data.MySQL | |||
619 | 470 | ||
620 | try | 471 | try |
621 | { | 472 | { |
622 | database.CheckConnection(); | 473 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
623 | |||
624 | MySqlCommand result = new MySqlCommand(sql, database.Connection); | ||
625 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); | ||
626 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
627 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
628 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
629 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
630 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
631 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
632 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
633 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
634 | item.CurrentPermissions.ToString()); | ||
635 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
636 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
637 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
638 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
639 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
640 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
641 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
642 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
643 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
644 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
645 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
646 | |||
647 | lock (database) | ||
648 | { | 474 | { |
649 | result.ExecuteNonQuery(); | 475 | dbcon.Open(); |
650 | } | 476 | |
477 | MySqlCommand result = new MySqlCommand(sql, dbcon); | ||
478 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); | ||
479 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
480 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
481 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
482 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
483 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
484 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
485 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
486 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
487 | item.CurrentPermissions.ToString()); | ||
488 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
489 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
490 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
491 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
492 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
493 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
494 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
495 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
496 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
497 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
498 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
499 | |||
500 | lock (m_dbLock) | ||
501 | { | ||
502 | result.ExecuteNonQuery(); | ||
503 | } | ||
651 | 504 | ||
652 | result.Dispose(); | 505 | result.Dispose(); |
653 | 506 | ||
654 | result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", database.Connection); | 507 | result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon); |
655 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString | 508 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); |
656 | ()); | 509 | lock (m_dbLock) |
657 | lock (database) | 510 | { |
658 | { | 511 | result.ExecuteNonQuery(); |
659 | result.ExecuteNonQuery(); | 512 | } |
513 | result.Dispose(); | ||
660 | } | 514 | } |
661 | result.Dispose(); | ||
662 | } | 515 | } |
663 | catch (MySqlException e) | 516 | catch (MySqlException e) |
664 | { | 517 | { |
@@ -672,8 +525,6 @@ namespace OpenSim.Data.MySQL | |||
672 | /// <param name="item">Inventory item to update</param> | 525 | /// <param name="item">Inventory item to update</param> |
673 | public void updateInventoryItem(InventoryItemBase item) | 526 | public void updateInventoryItem(InventoryItemBase item) |
674 | { | 527 | { |
675 | StoreRollbackItem(item.ID); | ||
676 | |||
677 | addInventoryItem(item); | 528 | addInventoryItem(item); |
678 | } | 529 | } |
679 | 530 | ||
@@ -683,25 +534,24 @@ namespace OpenSim.Data.MySQL | |||
683 | /// <param name="item">The inventory item UUID to delete</param> | 534 | /// <param name="item">The inventory item UUID to delete</param> |
684 | public void deleteInventoryItem(UUID itemID) | 535 | public void deleteInventoryItem(UUID itemID) |
685 | { | 536 | { |
686 | StoreRollbackItem(itemID); | ||
687 | |||
688 | try | 537 | try |
689 | { | 538 | { |
690 | database.CheckConnection(); | 539 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
540 | { | ||
541 | dbcon.Open(); | ||
691 | 542 | ||
692 | MySqlCommand cmd = | 543 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); |
693 | new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); | 544 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); |
694 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); | ||
695 | 545 | ||
696 | lock (database) | 546 | lock (m_dbLock) |
697 | { | 547 | { |
698 | cmd.ExecuteNonQuery(); | 548 | cmd.ExecuteNonQuery(); |
549 | } | ||
699 | } | 550 | } |
700 | } | 551 | } |
701 | catch (MySqlException e) | 552 | catch (MySqlException e) |
702 | { | 553 | { |
703 | database.Reconnect(); | 554 | m_log.Error(e.Message, e); |
704 | m_log.Error(e.ToString()); | ||
705 | } | 555 | } |
706 | } | 556 | } |
707 | 557 | ||
@@ -732,26 +582,29 @@ namespace OpenSim.Data.MySQL | |||
732 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); | 582 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); |
733 | } | 583 | } |
734 | 584 | ||
735 | database.CheckConnection(); | 585 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
586 | { | ||
587 | dbcon.Open(); | ||
736 | 588 | ||
737 | MySqlCommand cmd = new MySqlCommand(sql, database.Connection); | 589 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); |
738 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | 590 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
739 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); | 591 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); |
740 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | 592 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); |
741 | cmd.Parameters.AddWithValue("?folderName", folderName); | 593 | cmd.Parameters.AddWithValue("?folderName", folderName); |
742 | cmd.Parameters.AddWithValue("?type", folder.Type); | 594 | cmd.Parameters.AddWithValue("?type", folder.Type); |
743 | cmd.Parameters.AddWithValue("?version", folder.Version); | 595 | cmd.Parameters.AddWithValue("?version", folder.Version); |
744 | 596 | ||
745 | try | 597 | try |
746 | { | ||
747 | lock (database) | ||
748 | { | 598 | { |
749 | cmd.ExecuteNonQuery(); | 599 | lock (m_dbLock) |
600 | { | ||
601 | cmd.ExecuteNonQuery(); | ||
602 | } | ||
603 | } | ||
604 | catch (Exception e) | ||
605 | { | ||
606 | m_log.Error(e.ToString()); | ||
750 | } | 607 | } |
751 | } | ||
752 | catch (Exception e) | ||
753 | { | ||
754 | m_log.Error(e.ToString()); | ||
755 | } | 608 | } |
756 | } | 609 | } |
757 | 610 | ||
@@ -761,7 +614,6 @@ namespace OpenSim.Data.MySQL | |||
761 | /// <param name="folder">Folder to update</param> | 614 | /// <param name="folder">Folder to update</param> |
762 | public void updateInventoryFolder(InventoryFolderBase folder) | 615 | public void updateInventoryFolder(InventoryFolderBase folder) |
763 | { | 616 | { |
764 | StoreRollbackFolder(folder.ID); | ||
765 | addInventoryFolder(folder); | 617 | addInventoryFolder(folder); |
766 | } | 618 | } |
767 | 619 | ||
@@ -772,27 +624,28 @@ namespace OpenSim.Data.MySQL | |||
772 | /// <remarks>UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID</remarks> | 624 | /// <remarks>UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID</remarks> |
773 | public void moveInventoryFolder(InventoryFolderBase folder) | 625 | public void moveInventoryFolder(InventoryFolderBase folder) |
774 | { | 626 | { |
775 | StoreRollbackFolder(folder.ID); | ||
776 | |||
777 | string sql = | 627 | string sql = |
778 | "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; | 628 | "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; |
779 | 629 | ||
780 | database.CheckConnection(); | 630 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
631 | { | ||
632 | dbcon.Open(); | ||
781 | 633 | ||
782 | MySqlCommand cmd = new MySqlCommand(sql, database.Connection); | 634 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); |
783 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | 635 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
784 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | 636 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); |
785 | 637 | ||
786 | try | 638 | try |
787 | { | ||
788 | lock (database) | ||
789 | { | 639 | { |
790 | cmd.ExecuteNonQuery(); | 640 | lock (m_dbLock) |
641 | { | ||
642 | cmd.ExecuteNonQuery(); | ||
643 | } | ||
644 | } | ||
645 | catch (Exception e) | ||
646 | { | ||
647 | m_log.Error(e.ToString()); | ||
791 | } | 648 | } |
792 | } | ||
793 | catch (Exception e) | ||
794 | { | ||
795 | m_log.Error(e.ToString()); | ||
796 | } | 649 | } |
797 | } | 650 | } |
798 | 651 | ||
@@ -836,95 +689,102 @@ namespace OpenSim.Data.MySQL | |||
836 | try | 689 | try |
837 | { | 690 | { |
838 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 691 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
839 | Dictionary<UUID, List<InventoryFolderBase>> hashtable | 692 | Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ; |
840 | = new Dictionary<UUID, List<InventoryFolderBase>>(); ; | ||
841 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); | 693 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); |
842 | lock (database) | 694 | bool buildResultsFromHashTable = false; |
843 | { | ||
844 | MySqlCommand result; | ||
845 | MySqlDataReader reader; | ||
846 | bool buildResultsFromHashTable = false; | ||
847 | |||
848 | database.CheckConnection(); | ||
849 | |||
850 | /* Fetch the parent folder from the database to determine the agent ID, and if | ||
851 | * we're querying the root of the inventory folder tree */ | ||
852 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", | ||
853 | database.Connection); | ||
854 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | ||
855 | reader = result.ExecuteReader(); | ||
856 | while (reader.Read()) // Should be at most 1 result | ||
857 | parentFolder.Add(readInventoryFolder(reader)); | ||
858 | reader.Close(); | ||
859 | result.Dispose(); | ||
860 | 695 | ||
861 | if (parentFolder.Count >= 1) // No result means parent folder does not exist | 696 | lock (m_dbLock) |
697 | { | ||
698 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
862 | { | 699 | { |
863 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder | 700 | dbcon.Open(); |
701 | |||
702 | /* Fetch the parent folder from the database to determine the agent ID, and if | ||
703 | * we're querying the root of the inventory folder tree */ | ||
704 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon)) | ||
864 | { | 705 | { |
865 | /* Get all of the agent's folders from the database, put them in a list and return it */ | 706 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); |
866 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", | 707 | |
867 | database.Connection); | 708 | using (MySqlDataReader reader = result.ExecuteReader()) |
868 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
869 | reader = result.ExecuteReader(); | ||
870 | while (reader.Read()) | ||
871 | { | 709 | { |
872 | InventoryFolderBase curFolder = readInventoryFolder(reader); | 710 | // Should be at most 1 result |
873 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | 711 | while (reader.Read()) |
874 | folders.Add(curFolder); | 712 | parentFolder.Add(readInventoryFolder(reader)); |
875 | } | 713 | } |
876 | reader.Close(); | 714 | } |
877 | result.Dispose(); | 715 | |
878 | } // if we are querying the root folder | 716 | if (parentFolder.Count >= 1) // No result means parent folder does not exist |
879 | else // else we are querying a subtree of the inventory folder tree | ||
880 | { | 717 | { |
881 | /* Get all of the agent's folders from the database, put them all in a hash table | 718 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder |
882 | * indexed by their parent ID */ | ||
883 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", | ||
884 | database.Connection); | ||
885 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
886 | reader = result.ExecuteReader(); | ||
887 | while (reader.Read()) | ||
888 | { | 719 | { |
889 | InventoryFolderBase curFolder = readInventoryFolder(reader); | 720 | /* Get all of the agent's folders from the database, put them in a list and return it */ |
890 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | 721 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon)) |
891 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list | ||
892 | else // else current folder has no known (yet) siblings | ||
893 | { | 722 | { |
894 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); | 723 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); |
895 | siblingList.Add(curFolder); | 724 | |
896 | // Current folder has no known (yet) siblings | 725 | using (MySqlDataReader reader = result.ExecuteReader()) |
897 | hashtable.Add(curFolder.ParentID, siblingList); | 726 | { |
727 | while (reader.Read()) | ||
728 | { | ||
729 | InventoryFolderBase curFolder = readInventoryFolder(reader); | ||
730 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | ||
731 | folders.Add(curFolder); | ||
732 | } | ||
733 | } | ||
734 | } | ||
735 | } // if we are querying the root folder | ||
736 | else // else we are querying a subtree of the inventory folder tree | ||
737 | { | ||
738 | /* Get all of the agent's folders from the database, put them all in a hash table | ||
739 | * indexed by their parent ID */ | ||
740 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon)) | ||
741 | { | ||
742 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
743 | |||
744 | using (MySqlDataReader reader = result.ExecuteReader()) | ||
745 | { | ||
746 | while (reader.Read()) | ||
747 | { | ||
748 | InventoryFolderBase curFolder = readInventoryFolder(reader); | ||
749 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | ||
750 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list | ||
751 | else // else current folder has no known (yet) siblings | ||
752 | { | ||
753 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); | ||
754 | siblingList.Add(curFolder); | ||
755 | // Current folder has no known (yet) siblings | ||
756 | hashtable.Add(curFolder.ParentID, siblingList); | ||
757 | } | ||
758 | } // while more items to read from the database | ||
759 | } | ||
898 | } | 760 | } |
899 | } // while more items to read from the database | ||
900 | reader.Close(); | ||
901 | result.Dispose(); | ||
902 | 761 | ||
903 | // Set flag so we know we need to build the results from the hash table after | 762 | // Set flag so we know we need to build the results from the hash table after |
904 | // we unlock the database | 763 | // we unlock the database |
905 | buildResultsFromHashTable = true; | 764 | buildResultsFromHashTable = true; |
906 | 765 | ||
907 | } // else we are querying a subtree of the inventory folder tree | 766 | } // else we are querying a subtree of the inventory folder tree |
908 | } // if folder parentID exists | 767 | } // if folder parentID exists |
909 | 768 | ||
910 | if (buildResultsFromHashTable) | 769 | if (buildResultsFromHashTable) |
911 | { | 770 | { |
912 | /* We have all of the user's folders stored in a hash table indexed by their parent ID | 771 | /* We have all of the user's folders stored in a hash table indexed by their parent ID |
913 | * and we need to return the requested subtree. We will build the requested subtree | 772 | * and we need to return the requested subtree. We will build the requested subtree |
914 | * by performing a breadth-first-search on the hash table */ | 773 | * by performing a breadth-first-search on the hash table */ |
915 | if (hashtable.ContainsKey(parentID)) | 774 | if (hashtable.ContainsKey(parentID)) |
916 | folders.AddRange(hashtable[parentID]); | 775 | folders.AddRange(hashtable[parentID]); |
917 | for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static | 776 | for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static |
918 | if (hashtable.ContainsKey(folders[i].ID)) | 777 | if (hashtable.ContainsKey(folders[i].ID)) |
919 | folders.AddRange(hashtable[folders[i].ID]); | 778 | folders.AddRange(hashtable[folders[i].ID]); |
779 | } | ||
920 | } | 780 | } |
921 | } // lock (database) | 781 | } // lock (database) |
782 | |||
922 | return folders; | 783 | return folders; |
923 | } | 784 | } |
924 | catch (Exception e) | 785 | catch (Exception e) |
925 | { | 786 | { |
926 | database.Reconnect(); | 787 | m_log.Error(e.Message, e); |
927 | m_log.Error(e.ToString()); | ||
928 | return null; | 788 | return null; |
929 | } | 789 | } |
930 | } | 790 | } |
@@ -935,25 +795,24 @@ namespace OpenSim.Data.MySQL | |||
935 | /// <param name="folderID">the folder UUID</param> | 795 | /// <param name="folderID">the folder UUID</param> |
936 | protected void deleteOneFolder(UUID folderID) | 796 | protected void deleteOneFolder(UUID folderID) |
937 | { | 797 | { |
938 | StoreRollbackFolder(folderID); | ||
939 | |||
940 | try | 798 | try |
941 | { | 799 | { |
942 | database.CheckConnection(); | 800 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
801 | { | ||
802 | dbcon.Open(); | ||
943 | 803 | ||
944 | MySqlCommand cmd = | 804 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", dbcon)) |
945 | new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); | 805 | { |
946 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 806 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
947 | 807 | ||
948 | lock (database) | 808 | lock (m_dbLock) |
949 | { | 809 | cmd.ExecuteNonQuery(); |
950 | cmd.ExecuteNonQuery(); | 810 | } |
951 | } | 811 | } |
952 | } | 812 | } |
953 | catch (MySqlException e) | 813 | catch (MySqlException e) |
954 | { | 814 | { |
955 | database.Reconnect(); | 815 | m_log.Error(e.Message, e); |
956 | m_log.Error(e.ToString()); | ||
957 | } | 816 | } |
958 | } | 817 | } |
959 | 818 | ||
@@ -963,30 +822,23 @@ namespace OpenSim.Data.MySQL | |||
963 | /// <param name="folderID">the folder UUID</param> | 822 | /// <param name="folderID">the folder UUID</param> |
964 | protected void deleteItemsInFolder(UUID folderID) | 823 | protected void deleteItemsInFolder(UUID folderID) |
965 | { | 824 | { |
966 | if (rollbackStore) | ||
967 | { | ||
968 | foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) | ||
969 | { | ||
970 | StoreRollbackItem(itemBase.ID); | ||
971 | } | ||
972 | } | ||
973 | |||
974 | try | 825 | try |
975 | { | 826 | { |
976 | database.CheckConnection(); | 827 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
828 | { | ||
829 | dbcon.Open(); | ||
977 | 830 | ||
978 | MySqlCommand cmd = | 831 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", dbcon)) |
979 | new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); | 832 | { |
980 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 833 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
981 | 834 | ||
982 | lock (database) | 835 | lock (m_dbLock) |
983 | { | 836 | cmd.ExecuteNonQuery(); |
984 | cmd.ExecuteNonQuery(); | 837 | } |
985 | } | 838 | } |
986 | } | 839 | } |
987 | catch (MySqlException e) | 840 | catch (MySqlException e) |
988 | { | 841 | { |
989 | database.Reconnect(); | ||
990 | m_log.Error(e.ToString()); | 842 | m_log.Error(e.ToString()); |
991 | } | 843 | } |
992 | } | 844 | } |
@@ -999,80 +851,53 @@ namespace OpenSim.Data.MySQL | |||
999 | { | 851 | { |
1000 | List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); | 852 | List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); |
1001 | 853 | ||
1002 | // Dont delete in OGM - makes for easier restores if someone sends a malcious command. (just restore the folder entry) | 854 | //Delete all sub-folders |
1003 | if (opengridmode == false) | 855 | foreach (InventoryFolderBase f in subFolders) |
1004 | { | 856 | { |
1005 | //Delete all sub-folders | 857 | deleteOneFolder(f.ID); |
1006 | foreach (InventoryFolderBase f in subFolders) | 858 | deleteItemsInFolder(f.ID); |
1007 | { | ||
1008 | StoreRollbackFolder(f.ID); | ||
1009 | deleteOneFolder(f.ID); | ||
1010 | |||
1011 | if (rollbackStore) | ||
1012 | { | ||
1013 | foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID)) | ||
1014 | { | ||
1015 | StoreRollbackItem(itemBase.ID); | ||
1016 | } | ||
1017 | } | ||
1018 | deleteItemsInFolder(f.ID); | ||
1019 | } | ||
1020 | } | 859 | } |
1021 | 860 | ||
1022 | StoreRollbackFolder(folderID); | ||
1023 | //Delete the actual row | 861 | //Delete the actual row |
1024 | deleteOneFolder(folderID); | 862 | deleteOneFolder(folderID); |
1025 | 863 | deleteItemsInFolder(folderID); | |
1026 | // Just delete the folder context in OGM | ||
1027 | if (opengridmode == false) | ||
1028 | { | ||
1029 | if (rollbackStore) | ||
1030 | { | ||
1031 | foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) | ||
1032 | { | ||
1033 | StoreRollbackItem(itemBase.ID); | ||
1034 | } | ||
1035 | } | ||
1036 | deleteItemsInFolder(folderID); | ||
1037 | } | ||
1038 | } | 864 | } |
1039 | 865 | ||
1040 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | 866 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) |
1041 | { | 867 | { |
1042 | MySqlDataReader result = null; | 868 | lock (m_dbLock) |
1043 | MySqlCommand sqlCmd = null; | ||
1044 | lock (database) | ||
1045 | { | 869 | { |
1046 | try | 870 | try |
1047 | { | 871 | { |
1048 | database.CheckConnection(); | 872 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1049 | sqlCmd = new MySqlCommand( | ||
1050 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", | ||
1051 | database.Connection); | ||
1052 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); | ||
1053 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | ||
1054 | result = sqlCmd.ExecuteReader(); | ||
1055 | |||
1056 | List<InventoryItemBase> list = new List<InventoryItemBase>(); | ||
1057 | while (result.Read()) | ||
1058 | { | 873 | { |
1059 | InventoryItemBase item = readInventoryItem(result); | 874 | dbcon.Open(); |
1060 | if (item != null) | 875 | |
1061 | list.Add(item); | 876 | using (MySqlCommand sqlCmd = new MySqlCommand( |
877 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", dbcon)) | ||
878 | { | ||
879 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); | ||
880 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | ||
881 | |||
882 | using (MySqlDataReader result = sqlCmd.ExecuteReader()) | ||
883 | { | ||
884 | List<InventoryItemBase> list = new List<InventoryItemBase>(); | ||
885 | while (result.Read()) | ||
886 | { | ||
887 | InventoryItemBase item = readInventoryItem(result); | ||
888 | if (item != null) | ||
889 | list.Add(item); | ||
890 | } | ||
891 | return list; | ||
892 | } | ||
893 | } | ||
1062 | } | 894 | } |
1063 | return list; | ||
1064 | } | 895 | } |
1065 | catch (Exception e) | 896 | catch (Exception e) |
1066 | { | 897 | { |
1067 | database.Reconnect(); | 898 | m_log.Error(e.Message, e); |
1068 | m_log.Error(e.ToString()); | ||
1069 | return null; | 899 | return null; |
1070 | } | 900 | } |
1071 | finally | ||
1072 | { | ||
1073 | if (result != null) result.Close(); | ||
1074 | if (sqlCmd != null) sqlCmd.Dispose(); | ||
1075 | } | ||
1076 | } | 901 | } |
1077 | } | 902 | } |
1078 | } | 903 | } |
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 9a4a4bb..a06eec3 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -48,75 +48,54 @@ namespace OpenSim.Data.MySQL | |||
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private string m_ConnectionString; | 51 | private string m_connectionString; |
52 | 52 | private object m_dbLock = new object(); | |
53 | private MySqlConnection m_Connection = null; | ||
54 | 53 | ||
55 | public void Initialise(string connectionString) | 54 | public void Initialise(string connectionString) |
56 | { | 55 | { |
57 | m_ConnectionString = connectionString; | 56 | m_connectionString = connectionString; |
58 | 57 | ||
59 | m_Connection = new MySqlConnection(m_ConnectionString); | 58 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
59 | { | ||
60 | dbcon.Open(); | ||
60 | 61 | ||
61 | m_Connection.Open(); | 62 | // Apply new Migrations |
63 | // | ||
64 | Assembly assem = GetType().Assembly; | ||
65 | Migration m = new Migration(dbcon, assem, "RegionStore"); | ||
66 | m.Update(); | ||
62 | 67 | ||
63 | // Apply new Migrations | 68 | // Clean dropped attachments |
64 | // | 69 | // |
65 | Assembly assem = GetType().Assembly; | 70 | try |
66 | Migration m = new Migration(m_Connection, assem, "RegionStore"); | 71 | { |
67 | m.Update(); | 72 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
68 | 73 | { | |
69 | // NOTE: This is a very slow query that times out on regions with a lot of prims. | 74 | cmd.CommandText = "delete from prims, primshapes using prims " + |
70 | // I'm told that it is no longer relevant so it's commented out now, but if it | 75 | "left join primshapes on prims.uuid = primshapes.uuid " + |
71 | // is relevant it should be added as a console command instead of part of the | 76 | "where PCode = 9 and State <> 0"; |
72 | // startup phase | 77 | ExecuteNonQuery(cmd); |
73 | // Clean dropped attachments | 78 | } |
74 | // | 79 | } |
75 | //try | 80 | catch (MySqlException ex) |
76 | //{ | 81 | { |
77 | // using (MySqlCommand cmd = m_Connection.CreateCommand()) | 82 | m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); |
78 | // { | 83 | } |
79 | // cmd.CommandText = "delete from prims, primshapes using prims " + | 84 | } |
80 | // "left join primshapes on prims.uuid = primshapes.uuid " + | ||
81 | // "where PCode = 9 and State <> 0"; | ||
82 | // ExecuteNonQuery(cmd); | ||
83 | // } | ||
84 | //} | ||
85 | //catch (MySqlException ex) | ||
86 | //{ | ||
87 | // m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); | ||
88 | //} | ||
89 | } | 85 | } |
90 | 86 | ||
91 | private IDataReader ExecuteReader(MySqlCommand c) | 87 | private IDataReader ExecuteReader(MySqlCommand c) |
92 | { | 88 | { |
93 | IDataReader r = null; | 89 | IDataReader r = null; |
94 | bool errorSeen = false; | ||
95 | 90 | ||
96 | while (true) | 91 | try |
97 | { | 92 | { |
98 | try | 93 | r = c.ExecuteReader(); |
99 | { | 94 | } |
100 | r = c.ExecuteReader(); | 95 | catch (Exception e) |
101 | } | 96 | { |
102 | catch (Exception) | 97 | m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); |
103 | { | 98 | throw; |
104 | Thread.Sleep(500); | ||
105 | |||
106 | m_Connection.Close(); | ||
107 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
108 | m_Connection.Open(); | ||
109 | c.Connection = m_Connection; | ||
110 | |||
111 | if (!errorSeen) | ||
112 | { | ||
113 | errorSeen = true; | ||
114 | continue; | ||
115 | } | ||
116 | throw; | ||
117 | } | ||
118 | |||
119 | break; | ||
120 | } | 99 | } |
121 | 100 | ||
122 | return r; | 101 | return r; |
@@ -124,32 +103,14 @@ namespace OpenSim.Data.MySQL | |||
124 | 103 | ||
125 | private void ExecuteNonQuery(MySqlCommand c) | 104 | private void ExecuteNonQuery(MySqlCommand c) |
126 | { | 105 | { |
127 | bool errorSeen = false; | 106 | try |
128 | |||
129 | while (true) | ||
130 | { | 107 | { |
131 | try | 108 | c.ExecuteNonQuery(); |
132 | { | 109 | } |
133 | c.ExecuteNonQuery(); | 110 | catch (Exception e) |
134 | } | 111 | { |
135 | catch (Exception) | 112 | m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message); |
136 | { | 113 | throw; |
137 | Thread.Sleep(500); | ||
138 | |||
139 | m_Connection.Close(); | ||
140 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
141 | m_Connection.Open(); | ||
142 | c.Connection = m_Connection; | ||
143 | |||
144 | if (!errorSeen) | ||
145 | { | ||
146 | errorSeen = true; | ||
147 | continue; | ||
148 | } | ||
149 | throw; | ||
150 | } | ||
151 | |||
152 | break; | ||
153 | } | 114 | } |
154 | } | 115 | } |
155 | 116 | ||
@@ -166,115 +127,119 @@ namespace OpenSim.Data.MySQL | |||
166 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 127 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
167 | return; | 128 | return; |
168 | 129 | ||
169 | lock (m_Connection) | 130 | lock (m_dbLock) |
170 | { | 131 | { |
171 | MySqlCommand cmd = m_Connection.CreateCommand(); | 132 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
172 | |||
173 | foreach (SceneObjectPart prim in obj.Children.Values) | ||
174 | { | 133 | { |
175 | cmd.Parameters.Clear(); | 134 | dbcon.Open(); |
176 | 135 | MySqlCommand cmd = dbcon.CreateCommand(); | |
177 | cmd.CommandText = "replace into prims ("+ | 136 | |
178 | "UUID, CreationDate, "+ | 137 | foreach (SceneObjectPart prim in obj.Children.Values) |
179 | "Name, Text, Description, "+ | 138 | { |
180 | "SitName, TouchName, ObjectFlags, "+ | 139 | cmd.Parameters.Clear(); |
181 | "OwnerMask, NextOwnerMask, GroupMask, "+ | 140 | |
182 | "EveryoneMask, BaseMask, PositionX, "+ | 141 | cmd.CommandText = "replace into prims (" + |
183 | "PositionY, PositionZ, GroupPositionX, "+ | 142 | "UUID, CreationDate, " + |
184 | "GroupPositionY, GroupPositionZ, VelocityX, "+ | 143 | "Name, Text, Description, " + |
185 | "VelocityY, VelocityZ, AngularVelocityX, "+ | 144 | "SitName, TouchName, ObjectFlags, " + |
186 | "AngularVelocityY, AngularVelocityZ, "+ | 145 | "OwnerMask, NextOwnerMask, GroupMask, " + |
187 | "AccelerationX, AccelerationY, "+ | 146 | "EveryoneMask, BaseMask, PositionX, " + |
188 | "AccelerationZ, RotationX, "+ | 147 | "PositionY, PositionZ, GroupPositionX, " + |
189 | "RotationY, RotationZ, "+ | 148 | "GroupPositionY, GroupPositionZ, VelocityX, " + |
190 | "RotationW, SitTargetOffsetX, "+ | 149 | "VelocityY, VelocityZ, AngularVelocityX, " + |
191 | "SitTargetOffsetY, SitTargetOffsetZ, "+ | 150 | "AngularVelocityY, AngularVelocityZ, " + |
192 | "SitTargetOrientW, SitTargetOrientX, "+ | 151 | "AccelerationX, AccelerationY, " + |
193 | "SitTargetOrientY, SitTargetOrientZ, "+ | 152 | "AccelerationZ, RotationX, " + |
194 | "RegionUUID, CreatorID, "+ | 153 | "RotationY, RotationZ, " + |
195 | "OwnerID, GroupID, "+ | 154 | "RotationW, SitTargetOffsetX, " + |
196 | "LastOwnerID, SceneGroupID, "+ | 155 | "SitTargetOffsetY, SitTargetOffsetZ, " + |
197 | "PayPrice, PayButton1, "+ | 156 | "SitTargetOrientW, SitTargetOrientX, " + |
198 | "PayButton2, PayButton3, "+ | 157 | "SitTargetOrientY, SitTargetOrientZ, " + |
199 | "PayButton4, LoopedSound, "+ | 158 | "RegionUUID, CreatorID, " + |
200 | "LoopedSoundGain, TextureAnimation, "+ | 159 | "OwnerID, GroupID, " + |
201 | "OmegaX, OmegaY, OmegaZ, "+ | 160 | "LastOwnerID, SceneGroupID, " + |
202 | "CameraEyeOffsetX, CameraEyeOffsetY, "+ | 161 | "PayPrice, PayButton1, " + |
203 | "CameraEyeOffsetZ, CameraAtOffsetX, "+ | 162 | "PayButton2, PayButton3, " + |
204 | "CameraAtOffsetY, CameraAtOffsetZ, "+ | 163 | "PayButton4, LoopedSound, " + |
205 | "ForceMouselook, ScriptAccessPin, "+ | 164 | "LoopedSoundGain, TextureAnimation, " + |
206 | "AllowedDrop, DieAtEdge, "+ | 165 | "OmegaX, OmegaY, OmegaZ, " + |
207 | "SalePrice, SaleType, "+ | 166 | "CameraEyeOffsetX, CameraEyeOffsetY, " + |
208 | "ColorR, ColorG, ColorB, ColorA, "+ | 167 | "CameraEyeOffsetZ, CameraAtOffsetX, " + |
209 | "ParticleSystem, ClickAction, Material, "+ | 168 | "CameraAtOffsetY, CameraAtOffsetZ, " + |
210 | "CollisionSound, CollisionSoundVolume, "+ | 169 | "ForceMouselook, ScriptAccessPin, " + |
211 | "PassTouches, "+ | 170 | "AllowedDrop, DieAtEdge, " + |
212 | "LinkNumber) values (" + "?UUID, "+ | 171 | "SalePrice, SaleType, " + |
213 | "?CreationDate, ?Name, ?Text, "+ | 172 | "ColorR, ColorG, ColorB, ColorA, " + |
214 | "?Description, ?SitName, ?TouchName, "+ | 173 | "ParticleSystem, ClickAction, Material, " + |
215 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ | 174 | "CollisionSound, CollisionSoundVolume, " + |
216 | "?GroupMask, ?EveryoneMask, ?BaseMask, "+ | 175 | "PassTouches, " + |
217 | "?PositionX, ?PositionY, ?PositionZ, "+ | 176 | "LinkNumber) values (" + "?UUID, " + |
218 | "?GroupPositionX, ?GroupPositionY, "+ | 177 | "?CreationDate, ?Name, ?Text, " + |
219 | "?GroupPositionZ, ?VelocityX, "+ | 178 | "?Description, ?SitName, ?TouchName, " + |
220 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ | 179 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
221 | "?AngularVelocityY, ?AngularVelocityZ, "+ | 180 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + |
222 | "?AccelerationX, ?AccelerationY, "+ | 181 | "?PositionX, ?PositionY, ?PositionZ, " + |
223 | "?AccelerationZ, ?RotationX, "+ | 182 | "?GroupPositionX, ?GroupPositionY, " + |
224 | "?RotationY, ?RotationZ, "+ | 183 | "?GroupPositionZ, ?VelocityX, " + |
225 | "?RotationW, ?SitTargetOffsetX, "+ | 184 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + |
226 | "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ | 185 | "?AngularVelocityY, ?AngularVelocityZ, " + |
227 | "?SitTargetOrientW, ?SitTargetOrientX, "+ | 186 | "?AccelerationX, ?AccelerationY, " + |
228 | "?SitTargetOrientY, ?SitTargetOrientZ, "+ | 187 | "?AccelerationZ, ?RotationX, " + |
229 | "?RegionUUID, ?CreatorID, ?OwnerID, "+ | 188 | "?RotationY, ?RotationZ, " + |
230 | "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ | 189 | "?RotationW, ?SitTargetOffsetX, " + |
231 | "?PayPrice, ?PayButton1, ?PayButton2, "+ | 190 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + |
232 | "?PayButton3, ?PayButton4, ?LoopedSound, "+ | 191 | "?SitTargetOrientW, ?SitTargetOrientX, " + |
233 | "?LoopedSoundGain, ?TextureAnimation, "+ | 192 | "?SitTargetOrientY, ?SitTargetOrientZ, " + |
234 | "?OmegaX, ?OmegaY, ?OmegaZ, "+ | 193 | "?RegionUUID, ?CreatorID, ?OwnerID, " + |
235 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ | 194 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + |
236 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ | 195 | "?PayPrice, ?PayButton1, ?PayButton2, " + |
237 | "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ | 196 | "?PayButton3, ?PayButton4, ?LoopedSound, " + |
238 | "?ForceMouselook, ?ScriptAccessPin, "+ | 197 | "?LoopedSoundGain, ?TextureAnimation, " + |
239 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ | 198 | "?OmegaX, ?OmegaY, ?OmegaZ, " + |
240 | "?SaleType, ?ColorR, ?ColorG, "+ | 199 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + |
241 | "?ColorB, ?ColorA, ?ParticleSystem, "+ | 200 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + |
242 | "?ClickAction, ?Material, ?CollisionSound, "+ | 201 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + |
243 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; | 202 | "?ForceMouselook, ?ScriptAccessPin, " + |
244 | 203 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + | |
245 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 204 | "?SaleType, ?ColorR, ?ColorG, " + |
246 | 205 | "?ColorB, ?ColorA, ?ParticleSystem, " + | |
247 | ExecuteNonQuery(cmd); | 206 | "?ClickAction, ?Material, ?CollisionSound, " + |
248 | 207 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; | |
249 | cmd.Parameters.Clear(); | 208 | |
250 | 209 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | |
251 | cmd.CommandText = "replace into primshapes ("+ | 210 | |
252 | "UUID, Shape, ScaleX, ScaleY, "+ | 211 | ExecuteNonQuery(cmd); |
253 | "ScaleZ, PCode, PathBegin, PathEnd, "+ | 212 | |
254 | "PathScaleX, PathScaleY, PathShearX, "+ | 213 | cmd.Parameters.Clear(); |
255 | "PathShearY, PathSkew, PathCurve, "+ | 214 | |
256 | "PathRadiusOffset, PathRevolutions, "+ | 215 | cmd.CommandText = "replace into primshapes (" + |
257 | "PathTaperX, PathTaperY, PathTwist, "+ | 216 | "UUID, Shape, ScaleX, ScaleY, " + |
258 | "PathTwistBegin, ProfileBegin, ProfileEnd, "+ | 217 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
259 | "ProfileCurve, ProfileHollow, Texture, "+ | 218 | "PathScaleX, PathScaleY, PathShearX, " + |
260 | "ExtraParams, State) values (?UUID, "+ | 219 | "PathShearY, PathSkew, PathCurve, " + |
261 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ | 220 | "PathRadiusOffset, PathRevolutions, " + |
262 | "?PCode, ?PathBegin, ?PathEnd, "+ | 221 | "PathTaperX, PathTaperY, PathTwist, " + |
263 | "?PathScaleX, ?PathScaleY, "+ | 222 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
264 | "?PathShearX, ?PathShearY, "+ | 223 | "ProfileCurve, ProfileHollow, Texture, " + |
265 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ | 224 | "ExtraParams, State) values (?UUID, " + |
266 | "?PathRevolutions, ?PathTaperX, "+ | 225 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
267 | "?PathTaperY, ?PathTwist, "+ | 226 | "?PCode, ?PathBegin, ?PathEnd, " + |
268 | "?PathTwistBegin, ?ProfileBegin, "+ | 227 | "?PathScaleX, ?PathScaleY, " + |
269 | "?ProfileEnd, ?ProfileCurve, "+ | 228 | "?PathShearX, ?PathShearY, " + |
270 | "?ProfileHollow, ?Texture, ?ExtraParams, "+ | 229 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + |
271 | "?State)"; | 230 | "?PathRevolutions, ?PathTaperX, " + |
272 | 231 | "?PathTaperY, ?PathTwist, " + | |
273 | FillShapeCommand(cmd, prim); | 232 | "?PathTwistBegin, ?ProfileBegin, " + |
274 | 233 | "?ProfileEnd, ?ProfileCurve, " + | |
275 | ExecuteNonQuery(cmd); | 234 | "?ProfileHollow, ?Texture, ?ExtraParams, " + |
235 | "?State)"; | ||
236 | |||
237 | FillShapeCommand(cmd, prim); | ||
238 | |||
239 | ExecuteNonQuery(cmd); | ||
240 | } | ||
241 | cmd.Dispose(); | ||
276 | } | 242 | } |
277 | cmd.Dispose(); | ||
278 | } | 243 | } |
279 | } | 244 | } |
280 | 245 | ||
@@ -290,22 +255,27 @@ namespace OpenSim.Data.MySQL | |||
290 | // cause the loss of a prim, but is cleaner. | 255 | // cause the loss of a prim, but is cleaner. |
291 | // It's also faster because it uses the primary key. | 256 | // It's also faster because it uses the primary key. |
292 | // | 257 | // |
293 | lock (m_Connection) | 258 | lock (m_dbLock) |
294 | { | 259 | { |
295 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 260 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
296 | { | 261 | { |
297 | cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; | 262 | dbcon.Open(); |
298 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); | ||
299 | 263 | ||
300 | using (IDataReader reader = ExecuteReader(cmd)) | 264 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
301 | { | 265 | { |
302 | while (reader.Read()) | 266 | cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; |
303 | uuids.Add(new UUID(reader["UUID"].ToString())); | 267 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); |
304 | } | 268 | |
269 | using (IDataReader reader = ExecuteReader(cmd)) | ||
270 | { | ||
271 | while (reader.Read()) | ||
272 | uuids.Add(new UUID(reader["UUID"].ToString())); | ||
273 | } | ||
305 | 274 | ||
306 | // delete the main prims | 275 | // delete the main prims |
307 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; | 276 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; |
308 | ExecuteNonQuery(cmd); | 277 | ExecuteNonQuery(cmd); |
278 | } | ||
309 | } | 279 | } |
310 | } | 280 | } |
311 | 281 | ||
@@ -326,14 +296,19 @@ namespace OpenSim.Data.MySQL | |||
326 | /// <param name="uuid">the Item UUID</param> | 296 | /// <param name="uuid">the Item UUID</param> |
327 | private void RemoveItems(UUID uuid) | 297 | private void RemoveItems(UUID uuid) |
328 | { | 298 | { |
329 | lock (m_Connection) | 299 | lock (m_dbLock) |
330 | { | 300 | { |
331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 301 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
332 | { | 302 | { |
333 | cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; | 303 | dbcon.Open(); |
334 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); | 304 | |
305 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
306 | { | ||
307 | cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; | ||
308 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); | ||
335 | 309 | ||
336 | ExecuteNonQuery(cmd); | 310 | ExecuteNonQuery(cmd); |
311 | } | ||
337 | } | 312 | } |
338 | } | 313 | } |
339 | } | 314 | } |
@@ -345,29 +320,33 @@ namespace OpenSim.Data.MySQL | |||
345 | /// <param name="uuids">the list of UUIDs</param> | 320 | /// <param name="uuids">the list of UUIDs</param> |
346 | private void RemoveShapes(List<UUID> uuids) | 321 | private void RemoveShapes(List<UUID> uuids) |
347 | { | 322 | { |
348 | lock (m_Connection) | 323 | lock (m_dbLock) |
349 | { | 324 | { |
350 | string sql = "delete from primshapes where "; | 325 | string sql = "delete from primshapes where "; |
351 | 326 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | |
352 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
353 | { | 327 | { |
354 | for (int i = 0; i < uuids.Count; i++) | 328 | dbcon.Open(); |
329 | |||
330 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
355 | { | 331 | { |
356 | if ((i + 1) == uuids.Count) | 332 | for (int i = 0; i < uuids.Count; i++) |
357 | {// end of the list | ||
358 | sql += "(UUID = ?UUID" + i + ")"; | ||
359 | } | ||
360 | else | ||
361 | { | 333 | { |
362 | sql += "(UUID = ?UUID" + i + ") or "; | 334 | if ((i + 1) == uuids.Count) |
335 | {// end of the list | ||
336 | sql += "(UUID = ?UUID" + i + ")"; | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | sql += "(UUID = ?UUID" + i + ") or "; | ||
341 | } | ||
363 | } | 342 | } |
364 | } | 343 | cmd.CommandText = sql; |
365 | cmd.CommandText = sql; | ||
366 | 344 | ||
367 | for (int i = 0; i < uuids.Count; i++) | 345 | for (int i = 0; i < uuids.Count; i++) |
368 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); | 346 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); |
369 | 347 | ||
370 | ExecuteNonQuery(cmd); | 348 | ExecuteNonQuery(cmd); |
349 | } | ||
371 | } | 350 | } |
372 | } | 351 | } |
373 | } | 352 | } |
@@ -379,30 +358,34 @@ namespace OpenSim.Data.MySQL | |||
379 | /// <param name="uuids">the list of UUIDs</param> | 358 | /// <param name="uuids">the list of UUIDs</param> |
380 | private void RemoveItems(List<UUID> uuids) | 359 | private void RemoveItems(List<UUID> uuids) |
381 | { | 360 | { |
382 | lock (m_Connection) | 361 | lock (m_dbLock) |
383 | { | 362 | { |
384 | string sql = "delete from primitems where "; | 363 | string sql = "delete from primitems where "; |
385 | 364 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | |
386 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
387 | { | 365 | { |
388 | for (int i = 0; i < uuids.Count; i++) | 366 | dbcon.Open(); |
367 | |||
368 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
389 | { | 369 | { |
390 | if ((i + 1) == uuids.Count) | 370 | for (int i = 0; i < uuids.Count; i++) |
391 | { | 371 | { |
392 | // end of the list | 372 | if ((i + 1) == uuids.Count) |
393 | sql += "(PrimID = ?PrimID" + i + ")"; | 373 | { |
394 | } | 374 | // end of the list |
395 | else | 375 | sql += "(PrimID = ?PrimID" + i + ")"; |
396 | { | 376 | } |
397 | sql += "(PrimID = ?PrimID" + i + ") or "; | 377 | else |
378 | { | ||
379 | sql += "(PrimID = ?PrimID" + i + ") or "; | ||
380 | } | ||
398 | } | 381 | } |
399 | } | 382 | cmd.CommandText = sql; |
400 | cmd.CommandText = sql; | ||
401 | 383 | ||
402 | for (int i = 0; i < uuids.Count; i++) | 384 | for (int i = 0; i < uuids.Count; i++) |
403 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); | 385 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); |
404 | 386 | ||
405 | ExecuteNonQuery(cmd); | 387 | ExecuteNonQuery(cmd); |
388 | } | ||
406 | } | 389 | } |
407 | } | 390 | } |
408 | } | 391 | } |
@@ -417,33 +400,38 @@ namespace OpenSim.Data.MySQL | |||
417 | 400 | ||
418 | #region Prim Loading | 401 | #region Prim Loading |
419 | 402 | ||
420 | lock (m_Connection) | 403 | lock (m_dbLock) |
421 | { | 404 | { |
422 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
423 | { | 406 | { |
424 | cmd.CommandText = | 407 | dbcon.Open(); |
425 | "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; | ||
426 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
427 | 408 | ||
428 | using (IDataReader reader = ExecuteReader(cmd)) | 409 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
429 | { | 410 | { |
430 | while (reader.Read()) | 411 | cmd.CommandText = |
412 | "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; | ||
413 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
414 | |||
415 | using (IDataReader reader = ExecuteReader(cmd)) | ||
431 | { | 416 | { |
432 | SceneObjectPart prim = BuildPrim(reader); | 417 | while (reader.Read()) |
433 | if (reader["Shape"] is DBNull) | 418 | { |
434 | prim.Shape = PrimitiveBaseShape.Default; | 419 | SceneObjectPart prim = BuildPrim(reader); |
435 | else | 420 | if (reader["Shape"] is DBNull) |
436 | prim.Shape = BuildShape(reader); | 421 | prim.Shape = PrimitiveBaseShape.Default; |
422 | else | ||
423 | prim.Shape = BuildShape(reader); | ||
437 | 424 | ||
438 | UUID parentID = new UUID(reader["SceneGroupID"].ToString()); | 425 | UUID parentID = new UUID(reader["SceneGroupID"].ToString()); |
439 | if (parentID != prim.UUID) | 426 | if (parentID != prim.UUID) |
440 | prim.ParentUUID = parentID; | 427 | prim.ParentUUID = parentID; |
441 | 428 | ||
442 | prims[prim.UUID] = prim; | 429 | prims[prim.UUID] = prim; |
443 | 430 | ||
444 | ++count; | 431 | ++count; |
445 | if (count % ROWS_PER_QUERY == 0) | 432 | if (count % ROWS_PER_QUERY == 0) |
446 | m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); | 433 | m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); |
434 | } | ||
447 | } | 435 | } |
448 | } | 436 | } |
449 | } | 437 | } |
@@ -497,20 +485,25 @@ namespace OpenSim.Data.MySQL | |||
497 | // list from DB of all prims which have items and | 485 | // list from DB of all prims which have items and |
498 | // LoadItems only on those | 486 | // LoadItems only on those |
499 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | 487 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); |
500 | lock (m_Connection) | 488 | lock (m_dbLock) |
501 | { | 489 | { |
502 | using (MySqlCommand itemCmd = m_Connection.CreateCommand()) | 490 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
503 | { | 491 | { |
504 | itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; | 492 | dbcon.Open(); |
505 | using (IDataReader itemReader = ExecuteReader(itemCmd)) | 493 | |
494 | using (MySqlCommand itemCmd = dbcon.CreateCommand()) | ||
506 | { | 495 | { |
507 | while (itemReader.Read()) | 496 | itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; |
497 | using (IDataReader itemReader = ExecuteReader(itemCmd)) | ||
508 | { | 498 | { |
509 | if (!(itemReader["primID"] is DBNull)) | 499 | while (itemReader.Read()) |
510 | { | 500 | { |
511 | UUID primID = new UUID(itemReader["primID"].ToString()); | 501 | if (!(itemReader["primID"] is DBNull)) |
512 | if (prims.ContainsKey(primID)) | 502 | { |
513 | primsWithInventory.Add(prims[primID]); | 503 | UUID primID = new UUID(itemReader["primID"].ToString()); |
504 | if (prims.ContainsKey(primID)) | ||
505 | primsWithInventory.Add(prims[primID]); | ||
506 | } | ||
514 | } | 507 | } |
515 | } | 508 | } |
516 | } | 509 | } |
@@ -535,23 +528,28 @@ namespace OpenSim.Data.MySQL | |||
535 | /// <param name="prim">The prim</param> | 528 | /// <param name="prim">The prim</param> |
536 | private void LoadItems(SceneObjectPart prim) | 529 | private void LoadItems(SceneObjectPart prim) |
537 | { | 530 | { |
538 | lock (m_Connection) | 531 | lock (m_dbLock) |
539 | { | 532 | { |
540 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 533 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
541 | 534 | ||
542 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 535 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
543 | { | 536 | { |
544 | cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; | 537 | dbcon.Open(); |
545 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | ||
546 | 538 | ||
547 | using (IDataReader reader = ExecuteReader(cmd)) | 539 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
548 | { | 540 | { |
549 | while (reader.Read()) | 541 | cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; |
542 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | ||
543 | |||
544 | using (IDataReader reader = ExecuteReader(cmd)) | ||
550 | { | 545 | { |
551 | TaskInventoryItem item = BuildItem(reader); | 546 | while (reader.Read()) |
547 | { | ||
548 | TaskInventoryItem item = BuildItem(reader); | ||
552 | 549 | ||
553 | item.ParentID = prim.UUID; // Values in database are often wrong | 550 | item.ParentID = prim.UUID; // Values in database are often wrong |
554 | inventory.Add(item); | 551 | inventory.Add(item); |
552 | } | ||
555 | } | 553 | } |
556 | } | 554 | } |
557 | } | 555 | } |
@@ -564,22 +562,27 @@ namespace OpenSim.Data.MySQL | |||
564 | { | 562 | { |
565 | m_log.Info("[REGION DB]: Storing terrain"); | 563 | m_log.Info("[REGION DB]: Storing terrain"); |
566 | 564 | ||
567 | lock (m_Connection) | 565 | lock (m_dbLock) |
568 | { | 566 | { |
569 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 567 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
570 | { | 568 | { |
571 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | 569 | dbcon.Open(); |
572 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
573 | 570 | ||
574 | ExecuteNonQuery(cmd); | 571 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
572 | { | ||
573 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | ||
574 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
575 | 575 | ||
576 | cmd.CommandText = "insert into terrain (RegionUUID, " + | 576 | ExecuteNonQuery(cmd); |
577 | "Revision, Heightfield) values (?RegionUUID, " + | ||
578 | "1, ?Heightfield)"; | ||
579 | 577 | ||
580 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 578 | cmd.CommandText = "insert into terrain (RegionUUID, " + |
579 | "Revision, Heightfield) values (?RegionUUID, " + | ||
580 | "1, ?Heightfield)"; | ||
581 | 581 | ||
582 | ExecuteNonQuery(cmd); | 582 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); |
583 | |||
584 | ExecuteNonQuery(cmd); | ||
585 | } | ||
583 | } | 586 | } |
584 | } | 587 | } |
585 | } | 588 | } |
@@ -588,38 +591,43 @@ namespace OpenSim.Data.MySQL | |||
588 | { | 591 | { |
589 | double[,] terrain = null; | 592 | double[,] terrain = null; |
590 | 593 | ||
591 | lock (m_Connection) | 594 | lock (m_dbLock) |
592 | { | 595 | { |
593 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 596 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
594 | { | 597 | { |
595 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + | 598 | dbcon.Open(); |
596 | "from terrain where RegionUUID = ?RegionUUID " + | ||
597 | "order by Revision desc limit 1"; | ||
598 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
599 | 599 | ||
600 | using (IDataReader reader = ExecuteReader(cmd)) | 600 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
601 | { | 601 | { |
602 | while (reader.Read()) | 602 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + |
603 | "from terrain where RegionUUID = ?RegionUUID " + | ||
604 | "order by Revision desc limit 1"; | ||
605 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
606 | |||
607 | using (IDataReader reader = ExecuteReader(cmd)) | ||
603 | { | 608 | { |
604 | int rev = Convert.ToInt32(reader["Revision"]); | 609 | while (reader.Read()) |
610 | { | ||
611 | int rev = Convert.ToInt32(reader["Revision"]); | ||
605 | 612 | ||
606 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 613 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; |
607 | terrain.Initialize(); | 614 | terrain.Initialize(); |
608 | 615 | ||
609 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) | 616 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) |
610 | { | ||
611 | using (BinaryReader br = new BinaryReader(mstr)) | ||
612 | { | 617 | { |
613 | for (int x = 0; x < (int)Constants.RegionSize; x++) | 618 | using (BinaryReader br = new BinaryReader(mstr)) |
614 | { | 619 | { |
615 | for (int y = 0; y < (int)Constants.RegionSize; y++) | 620 | for (int x = 0; x < (int)Constants.RegionSize; x++) |
616 | { | 621 | { |
617 | terrain[x, y] = br.ReadDouble(); | 622 | for (int y = 0; y < (int)Constants.RegionSize; y++) |
623 | { | ||
624 | terrain[x, y] = br.ReadDouble(); | ||
625 | } | ||
618 | } | 626 | } |
619 | } | 627 | } |
620 | } | ||
621 | 628 | ||
622 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); | 629 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); |
630 | } | ||
623 | } | 631 | } |
624 | } | 632 | } |
625 | } | 633 | } |
@@ -631,63 +639,73 @@ namespace OpenSim.Data.MySQL | |||
631 | 639 | ||
632 | public void RemoveLandObject(UUID globalID) | 640 | public void RemoveLandObject(UUID globalID) |
633 | { | 641 | { |
634 | lock (m_Connection) | 642 | lock (m_dbLock) |
635 | { | 643 | { |
636 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 644 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
637 | { | 645 | { |
638 | cmd.CommandText = "delete from land where UUID = ?UUID"; | 646 | dbcon.Open(); |
639 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | 647 | |
648 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
649 | { | ||
650 | cmd.CommandText = "delete from land where UUID = ?UUID"; | ||
651 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | ||
640 | 652 | ||
641 | ExecuteNonQuery(cmd); | 653 | ExecuteNonQuery(cmd); |
654 | } | ||
642 | } | 655 | } |
643 | } | 656 | } |
644 | } | 657 | } |
645 | 658 | ||
646 | public void StoreLandObject(ILandObject parcel) | 659 | public void StoreLandObject(ILandObject parcel) |
647 | { | 660 | { |
648 | lock (m_Connection) | 661 | lock (m_dbLock) |
649 | { | 662 | { |
650 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 663 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
651 | { | 664 | { |
652 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + | 665 | dbcon.Open(); |
653 | "LocalLandID, Bitmap, Name, Description, " + | 666 | |
654 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + | 667 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
655 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + | ||
656 | "SalePrice, LandStatus, LandFlags, LandingType, " + | ||
657 | "MediaAutoScale, MediaTextureUUID, MediaURL, " + | ||
658 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | ||
659 | "UserLocationX, UserLocationY, UserLocationZ, " + | ||
660 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | ||
661 | "AuthbuyerID, OtherCleanTime, Dwell) values (" + | ||
662 | "?UUID, ?RegionUUID, " + | ||
663 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | ||
664 | "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + | ||
665 | "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + | ||
666 | "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + | ||
667 | "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + | ||
668 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | ||
669 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | ||
670 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | ||
671 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; | ||
672 | |||
673 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | ||
674 | |||
675 | ExecuteNonQuery(cmd); | ||
676 | |||
677 | cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; | ||
678 | |||
679 | ExecuteNonQuery(cmd); | ||
680 | |||
681 | cmd.Parameters.Clear(); | ||
682 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
683 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
684 | "?Flags)"; | ||
685 | |||
686 | foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) | ||
687 | { | 668 | { |
688 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | 669 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + |
670 | "LocalLandID, Bitmap, Name, Description, " + | ||
671 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + | ||
672 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + | ||
673 | "SalePrice, LandStatus, LandFlags, LandingType, " + | ||
674 | "MediaAutoScale, MediaTextureUUID, MediaURL, " + | ||
675 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | ||
676 | "UserLocationX, UserLocationY, UserLocationZ, " + | ||
677 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | ||
678 | "AuthbuyerID, OtherCleanTime, Dwell) values (" + | ||
679 | "?UUID, ?RegionUUID, " + | ||
680 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | ||
681 | "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + | ||
682 | "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + | ||
683 | "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + | ||
684 | "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + | ||
685 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | ||
686 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | ||
687 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | ||
688 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; | ||
689 | |||
690 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | ||
691 | |||
689 | ExecuteNonQuery(cmd); | 692 | ExecuteNonQuery(cmd); |
693 | |||
694 | cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; | ||
695 | |||
696 | ExecuteNonQuery(cmd); | ||
697 | |||
690 | cmd.Parameters.Clear(); | 698 | cmd.Parameters.Clear(); |
699 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
700 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
701 | "?Flags)"; | ||
702 | |||
703 | foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) | ||
704 | { | ||
705 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | ||
706 | ExecuteNonQuery(cmd); | ||
707 | cmd.Parameters.Clear(); | ||
708 | } | ||
691 | } | 709 | } |
692 | } | 710 | } |
693 | } | 711 | } |
@@ -697,27 +715,32 @@ namespace OpenSim.Data.MySQL | |||
697 | { | 715 | { |
698 | RegionSettings rs = null; | 716 | RegionSettings rs = null; |
699 | 717 | ||
700 | lock (m_Connection) | 718 | lock (m_dbLock) |
701 | { | 719 | { |
702 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 720 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
703 | { | 721 | { |
704 | cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; | 722 | dbcon.Open(); |
705 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); | ||
706 | 723 | ||
707 | using (IDataReader reader = ExecuteReader(cmd)) | 724 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
708 | { | 725 | { |
709 | if (reader.Read()) | 726 | cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; |
710 | { | 727 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); |
711 | rs = BuildRegionSettings(reader); | 728 | |
712 | rs.OnSave += StoreRegionSettings; | 729 | using (IDataReader reader = ExecuteReader(cmd)) |
713 | } | ||
714 | else | ||
715 | { | 730 | { |
716 | rs = new RegionSettings(); | 731 | if (reader.Read()) |
717 | rs.RegionUUID = regionUUID; | 732 | { |
718 | rs.OnSave += StoreRegionSettings; | 733 | rs = BuildRegionSettings(reader); |
734 | rs.OnSave += StoreRegionSettings; | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | rs = new RegionSettings(); | ||
739 | rs.RegionUUID = regionUUID; | ||
740 | rs.OnSave += StoreRegionSettings; | ||
719 | 741 | ||
720 | StoreRegionSettings(rs); | 742 | StoreRegionSettings(rs); |
743 | } | ||
721 | } | 744 | } |
722 | } | 745 | } |
723 | } | 746 | } |
@@ -728,46 +751,51 @@ namespace OpenSim.Data.MySQL | |||
728 | 751 | ||
729 | public void StoreRegionSettings(RegionSettings rs) | 752 | public void StoreRegionSettings(RegionSettings rs) |
730 | { | 753 | { |
731 | lock (m_Connection) | 754 | lock (m_dbLock) |
732 | { | 755 | { |
733 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 756 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
734 | { | 757 | { |
735 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | 758 | dbcon.Open(); |
736 | "block_terraform, block_fly, allow_damage, " + | 759 | |
737 | "restrict_pushing, allow_land_resell, " + | 760 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
738 | "allow_land_join_divide, block_show_in_search, " + | 761 | { |
739 | "agent_limit, object_bonus, maturity, " + | 762 | cmd.CommandText = "replace into regionsettings (regionUUID, " + |
740 | "disable_scripts, disable_collisions, " + | 763 | "block_terraform, block_fly, allow_damage, " + |
741 | "disable_physics, terrain_texture_1, " + | 764 | "restrict_pushing, allow_land_resell, " + |
742 | "terrain_texture_2, terrain_texture_3, " + | 765 | "allow_land_join_divide, block_show_in_search, " + |
743 | "terrain_texture_4, elevation_1_nw, " + | 766 | "agent_limit, object_bonus, maturity, " + |
744 | "elevation_2_nw, elevation_1_ne, " + | 767 | "disable_scripts, disable_collisions, " + |
745 | "elevation_2_ne, elevation_1_se, " + | 768 | "disable_physics, terrain_texture_1, " + |
746 | "elevation_2_se, elevation_1_sw, " + | 769 | "terrain_texture_2, terrain_texture_3, " + |
747 | "elevation_2_sw, water_height, " + | 770 | "terrain_texture_4, elevation_1_nw, " + |
748 | "terrain_raise_limit, terrain_lower_limit, " + | 771 | "elevation_2_nw, elevation_1_ne, " + |
749 | "use_estate_sun, fixed_sun, sun_position, " + | 772 | "elevation_2_ne, elevation_1_se, " + |
750 | "covenant, Sandbox, sunvectorx, sunvectory, " + | 773 | "elevation_2_se, elevation_1_sw, " + |
751 | "sunvectorz, loaded_creation_datetime, " + | 774 | "elevation_2_sw, water_height, " + |
752 | "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + | 775 | "terrain_raise_limit, terrain_lower_limit, " + |
753 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | 776 | "use_estate_sun, fixed_sun, sun_position, " + |
754 | "?AllowLandResell, ?AllowLandJoinDivide, " + | 777 | "covenant, Sandbox, sunvectorx, sunvectory, " + |
755 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | 778 | "sunvectorz, loaded_creation_datetime, " + |
756 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | 779 | "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + |
757 | "?DisablePhysics, ?TerrainTexture1, " + | 780 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + |
758 | "?TerrainTexture2, ?TerrainTexture3, " + | 781 | "?AllowLandResell, ?AllowLandJoinDivide, " + |
759 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | 782 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + |
760 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | 783 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + |
761 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | 784 | "?DisablePhysics, ?TerrainTexture1, " + |
762 | "?WaterHeight, ?TerrainRaiseLimit, " + | 785 | "?TerrainTexture2, ?TerrainTexture3, " + |
763 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | 786 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + |
764 | "?SunPosition, ?Covenant, ?Sandbox, " + | 787 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + |
765 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | 788 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + |
766 | "?LoadedCreationDateTime, ?LoadedCreationID)"; | 789 | "?WaterHeight, ?TerrainRaiseLimit, " + |
767 | 790 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | |
768 | FillRegionSettingsCommand(cmd, rs); | 791 | "?SunPosition, ?Covenant, ?Sandbox, " + |
769 | 792 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | |
770 | ExecuteNonQuery(cmd); | 793 | "?LoadedCreationDateTime, ?LoadedCreationID)"; |
794 | |||
795 | FillRegionSettingsCommand(cmd, rs); | ||
796 | |||
797 | ExecuteNonQuery(cmd); | ||
798 | } | ||
771 | } | 799 | } |
772 | } | 800 | } |
773 | } | 801 | } |
@@ -776,36 +804,41 @@ namespace OpenSim.Data.MySQL | |||
776 | { | 804 | { |
777 | List<LandData> landData = new List<LandData>(); | 805 | List<LandData> landData = new List<LandData>(); |
778 | 806 | ||
779 | lock (m_Connection) | 807 | lock (m_dbLock) |
780 | { | 808 | { |
781 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 809 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
782 | { | 810 | { |
783 | cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; | 811 | dbcon.Open(); |
784 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
785 | 812 | ||
786 | using (IDataReader reader = ExecuteReader(cmd)) | 813 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
787 | { | 814 | { |
788 | while (reader.Read()) | 815 | cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; |
816 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
817 | |||
818 | using (IDataReader reader = ExecuteReader(cmd)) | ||
789 | { | 819 | { |
790 | LandData newLand = BuildLandData(reader); | 820 | while (reader.Read()) |
791 | landData.Add(newLand); | 821 | { |
822 | LandData newLand = BuildLandData(reader); | ||
823 | landData.Add(newLand); | ||
824 | } | ||
792 | } | 825 | } |
793 | } | 826 | } |
794 | } | ||
795 | 827 | ||
796 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 828 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
797 | { | ||
798 | foreach (LandData land in landData) | ||
799 | { | 829 | { |
800 | cmd.Parameters.Clear(); | 830 | foreach (LandData land in landData) |
801 | cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; | ||
802 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
803 | |||
804 | using (IDataReader reader = ExecuteReader(cmd)) | ||
805 | { | 831 | { |
806 | while (reader.Read()) | 832 | cmd.Parameters.Clear(); |
833 | cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; | ||
834 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
835 | |||
836 | using (IDataReader reader = ExecuteReader(cmd)) | ||
807 | { | 837 | { |
808 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | 838 | while (reader.Read()) |
839 | { | ||
840 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | ||
841 | } | ||
809 | } | 842 | } |
810 | } | 843 | } |
811 | } | 844 | } |
@@ -1513,41 +1546,46 @@ namespace OpenSim.Data.MySQL | |||
1513 | 1546 | ||
1514 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | 1547 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
1515 | { | 1548 | { |
1516 | lock (m_Connection) | 1549 | lock (m_dbLock) |
1517 | { | 1550 | { |
1518 | RemoveItems(primID); | 1551 | RemoveItems(primID); |
1519 | 1552 | ||
1520 | MySqlCommand cmd = m_Connection.CreateCommand(); | 1553 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1521 | |||
1522 | if (items.Count == 0) | ||
1523 | return; | ||
1524 | |||
1525 | cmd.CommandText = "insert into primitems ("+ | ||
1526 | "invType, assetType, name, "+ | ||
1527 | "description, creationDate, nextPermissions, "+ | ||
1528 | "currentPermissions, basePermissions, "+ | ||
1529 | "everyonePermissions, groupPermissions, "+ | ||
1530 | "flags, itemID, primID, assetID, "+ | ||
1531 | "parentFolderID, creatorID, ownerID, "+ | ||
1532 | "groupID, lastOwnerID) values (?invType, "+ | ||
1533 | "?assetType, ?name, ?description, "+ | ||
1534 | "?creationDate, ?nextPermissions, "+ | ||
1535 | "?currentPermissions, ?basePermissions, "+ | ||
1536 | "?everyonePermissions, ?groupPermissions, "+ | ||
1537 | "?flags, ?itemID, ?primID, ?assetID, "+ | ||
1538 | "?parentFolderID, ?creatorID, ?ownerID, "+ | ||
1539 | "?groupID, ?lastOwnerID)"; | ||
1540 | |||
1541 | foreach (TaskInventoryItem item in items) | ||
1542 | { | 1554 | { |
1543 | cmd.Parameters.Clear(); | 1555 | dbcon.Open(); |
1556 | |||
1557 | MySqlCommand cmd = dbcon.CreateCommand(); | ||
1558 | |||
1559 | if (items.Count == 0) | ||
1560 | return; | ||
1561 | |||
1562 | cmd.CommandText = "insert into primitems (" + | ||
1563 | "invType, assetType, name, " + | ||
1564 | "description, creationDate, nextPermissions, " + | ||
1565 | "currentPermissions, basePermissions, " + | ||
1566 | "everyonePermissions, groupPermissions, " + | ||
1567 | "flags, itemID, primID, assetID, " + | ||
1568 | "parentFolderID, creatorID, ownerID, " + | ||
1569 | "groupID, lastOwnerID) values (?invType, " + | ||
1570 | "?assetType, ?name, ?description, " + | ||
1571 | "?creationDate, ?nextPermissions, " + | ||
1572 | "?currentPermissions, ?basePermissions, " + | ||
1573 | "?everyonePermissions, ?groupPermissions, " + | ||
1574 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1575 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1576 | "?groupID, ?lastOwnerID)"; | ||
1577 | |||
1578 | foreach (TaskInventoryItem item in items) | ||
1579 | { | ||
1580 | cmd.Parameters.Clear(); | ||
1581 | |||
1582 | FillItemCommand(cmd, item); | ||
1544 | 1583 | ||
1545 | FillItemCommand(cmd, item); | 1584 | ExecuteNonQuery(cmd); |
1585 | } | ||
1546 | 1586 | ||
1547 | ExecuteNonQuery(cmd); | 1587 | cmd.Dispose(); |
1548 | } | 1588 | } |
1549 | |||
1550 | cmd.Dispose(); | ||
1551 | } | 1589 | } |
1552 | } | 1590 | } |
1553 | } | 1591 | } |
diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 8f67eeb..304883c 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs | |||
@@ -79,14 +79,19 @@ namespace OpenSim.Data.MySQL | |||
79 | 79 | ||
80 | // This actually does the roll forward assembly stuff | 80 | // This actually does the roll forward assembly stuff |
81 | Assembly assem = GetType().Assembly; | 81 | Assembly assem = GetType().Assembly; |
82 | Migration m = new Migration(database.Connection, assem, "LogStore"); | ||
83 | 82 | ||
84 | // TODO: After rev 6000, remove this. People should have | 83 | using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect)) |
85 | // been rolled onto the new migration code by then. | 84 | { |
86 | TestTables(m); | 85 | dbcon.Open(); |
86 | |||
87 | Migration m = new Migration(dbcon, assem, "LogStore"); | ||
87 | 88 | ||
88 | m.Update(); | 89 | // TODO: After rev 6000, remove this. People should have |
90 | // been rolled onto the new migration code by then. | ||
91 | TestTables(m); | ||
89 | 92 | ||
93 | m.Update(); | ||
94 | } | ||
90 | } | 95 | } |
91 | 96 | ||
92 | /// <summary></summary> | 97 | /// <summary></summary> |
@@ -128,7 +133,6 @@ namespace OpenSim.Data.MySQL | |||
128 | } | 133 | } |
129 | catch | 134 | catch |
130 | { | 135 | { |
131 | database.Reconnect(); | ||
132 | } | 136 | } |
133 | } | 137 | } |
134 | 138 | ||
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 243394e..ace2027 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -46,15 +46,12 @@ namespace OpenSim.Data.MySQL | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
49 | /// The database connection object | ||
50 | /// </summary> | ||
51 | private MySqlConnection dbcon; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Connection string for ADO.net | 49 | /// Connection string for ADO.net |
55 | /// </summary> | 50 | /// </summary> |
56 | private string connectionString; | 51 | private string connectionString; |
57 | 52 | ||
53 | private object m_dbLock = new object(); | ||
54 | |||
58 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | 55 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; |
59 | 56 | ||
60 | /// <summary> | 57 | /// <summary> |
@@ -109,11 +106,11 @@ namespace OpenSim.Data.MySQL | |||
109 | try | 106 | try |
110 | { | 107 | { |
111 | connectionString = connect; | 108 | connectionString = connect; |
112 | dbcon = new MySqlConnection(connectionString); | 109 | //dbcon = new MySqlConnection(connectionString); |
113 | 110 | ||
114 | try | 111 | try |
115 | { | 112 | { |
116 | dbcon.Open(); | 113 | //dbcon.Open(); |
117 | } | 114 | } |
118 | catch(Exception e) | 115 | catch(Exception e) |
119 | { | 116 | { |
@@ -134,18 +131,21 @@ namespace OpenSim.Data.MySQL | |||
134 | /// </summary> | 131 | /// </summary> |
135 | protected void GetWaitTimeout() | 132 | protected void GetWaitTimeout() |
136 | { | 133 | { |
137 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); | 134 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
138 | |||
139 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
140 | { | 135 | { |
141 | if (dbReader.Read()) | 136 | dbcon.Open(); |
137 | |||
138 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
142 | { | 139 | { |
143 | m_waitTimeout | 140 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
144 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | 141 | { |
142 | if (dbReader.Read()) | ||
143 | { | ||
144 | m_waitTimeout | ||
145 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
146 | } | ||
147 | } | ||
145 | } | 148 | } |
146 | |||
147 | dbReader.Close(); | ||
148 | cmd.Dispose(); | ||
149 | } | 149 | } |
150 | 150 | ||
151 | m_lastConnectionUse = DateTime.Now.Ticks; | 151 | m_lastConnectionUse = DateTime.Now.Ticks; |
@@ -154,66 +154,9 @@ namespace OpenSim.Data.MySQL | |||
154 | "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); | 154 | "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); |
155 | } | 155 | } |
156 | 156 | ||
157 | /// <summary> | 157 | public string ConnectionString |
158 | /// Should be called before any db operation. This checks to see if the connection has not timed out | ||
159 | /// </summary> | ||
160 | public void CheckConnection() | ||
161 | { | 158 | { |
162 | //m_log.Debug("[REGION DB]: Checking connection"); | 159 | get { return connectionString; } |
163 | |||
164 | long timeNow = DateTime.Now.Ticks; | ||
165 | if (timeNow - m_lastConnectionUse > m_waitTimeout || dbcon.State != ConnectionState.Open) | ||
166 | { | ||
167 | m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); | ||
168 | Reconnect(); | ||
169 | } | ||
170 | |||
171 | // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather | ||
172 | // than require the code to call another method - the timeout leeway should be large enough to cover the | ||
173 | // inaccuracy. | ||
174 | m_lastConnectionUse = timeNow; | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Get the connection being used | ||
179 | /// </summary> | ||
180 | /// <returns>MySqlConnection Object</returns> | ||
181 | public MySqlConnection Connection | ||
182 | { | ||
183 | get { return dbcon; } | ||
184 | } | ||
185 | |||
186 | /// <summary> | ||
187 | /// Shuts down the database connection | ||
188 | /// </summary> | ||
189 | public void Close() | ||
190 | { | ||
191 | dbcon.Close(); | ||
192 | dbcon = null; | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Reconnects to the database | ||
197 | /// </summary> | ||
198 | public void Reconnect() | ||
199 | { | ||
200 | m_log.Info("[REGION DB] Reconnecting database"); | ||
201 | |||
202 | lock (dbcon) | ||
203 | { | ||
204 | try | ||
205 | { | ||
206 | // Close the DB connection | ||
207 | dbcon.Close(); | ||
208 | // Try reopen it | ||
209 | dbcon = new MySqlConnection(connectionString); | ||
210 | dbcon.Open(); | ||
211 | } | ||
212 | catch (Exception e) | ||
213 | { | ||
214 | m_log.Error("Unable to reconnect to database " + e.ToString()); | ||
215 | } | ||
216 | } | ||
217 | } | 160 | } |
218 | 161 | ||
219 | /// <summary> | 162 | /// <summary> |
@@ -264,9 +207,13 @@ namespace OpenSim.Data.MySQL | |||
264 | /// <param name="name">name of embedded resource</param> | 207 | /// <param name="name">name of embedded resource</param> |
265 | public void ExecuteResourceSql(string name) | 208 | public void ExecuteResourceSql(string name) |
266 | { | 209 | { |
267 | CheckConnection(); | 210 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
268 | MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); | 211 | { |
269 | cmd.ExecuteNonQuery(); | 212 | dbcon.Open(); |
213 | |||
214 | MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); | ||
215 | cmd.ExecuteNonQuery(); | ||
216 | } | ||
270 | } | 217 | } |
271 | 218 | ||
272 | /// <summary> | 219 | /// <summary> |
@@ -275,22 +222,29 @@ namespace OpenSim.Data.MySQL | |||
275 | /// <param name="sql">sql string to execute</param> | 222 | /// <param name="sql">sql string to execute</param> |
276 | public void ExecuteSql(string sql) | 223 | public void ExecuteSql(string sql) |
277 | { | 224 | { |
278 | CheckConnection(); | 225 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
279 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | 226 | { |
280 | cmd.ExecuteNonQuery(); | 227 | dbcon.Open(); |
228 | |||
229 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | ||
230 | cmd.ExecuteNonQuery(); | ||
231 | } | ||
281 | } | 232 | } |
282 | 233 | ||
283 | public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters) | 234 | public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters) |
284 | { | 235 | { |
285 | CheckConnection(); | 236 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
286 | |||
287 | MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
288 | cmd.CommandText = sql; | ||
289 | foreach (KeyValuePair<string, string> param in parameters) | ||
290 | { | 237 | { |
291 | cmd.Parameters.AddWithValue(param.Key, param.Value); | 238 | dbcon.Open(); |
239 | |||
240 | MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
241 | cmd.CommandText = sql; | ||
242 | foreach (KeyValuePair<string, string> param in parameters) | ||
243 | { | ||
244 | cmd.Parameters.AddWithValue(param.Key, param.Value); | ||
245 | } | ||
246 | cmd.ExecuteNonQuery(); | ||
292 | } | 247 | } |
293 | cmd.ExecuteNonQuery(); | ||
294 | } | 248 | } |
295 | 249 | ||
296 | /// <summary> | 250 | /// <summary> |
@@ -299,35 +253,37 @@ namespace OpenSim.Data.MySQL | |||
299 | /// <param name="tableList"></param> | 253 | /// <param name="tableList"></param> |
300 | public void GetTableVersion(Dictionary<string, string> tableList) | 254 | public void GetTableVersion(Dictionary<string, string> tableList) |
301 | { | 255 | { |
302 | lock (dbcon) | 256 | lock (m_dbLock) |
303 | { | 257 | { |
304 | CheckConnection(); | 258 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
305 | |||
306 | MySqlCommand tablesCmd = | ||
307 | new MySqlCommand( | ||
308 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", | ||
309 | dbcon); | ||
310 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); | ||
311 | |||
312 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | ||
313 | { | 259 | { |
314 | while (tables.Read()) | 260 | dbcon.Open(); |
261 | |||
262 | using (MySqlCommand tablesCmd = new MySqlCommand( | ||
263 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon)) | ||
315 | { | 264 | { |
316 | try | 265 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); |
266 | |||
267 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | ||
317 | { | 268 | { |
318 | string tableName = (string) tables["TABLE_NAME"]; | 269 | while (tables.Read()) |
319 | string comment = (string) tables["TABLE_COMMENT"]; | ||
320 | if (tableList.ContainsKey(tableName)) | ||
321 | { | 270 | { |
322 | tableList[tableName] = comment; | 271 | try |
272 | { | ||
273 | string tableName = (string)tables["TABLE_NAME"]; | ||
274 | string comment = (string)tables["TABLE_COMMENT"]; | ||
275 | if (tableList.ContainsKey(tableName)) | ||
276 | { | ||
277 | tableList[tableName] = comment; | ||
278 | } | ||
279 | } | ||
280 | catch (Exception e) | ||
281 | { | ||
282 | m_log.Error(e.Message, e); | ||
283 | } | ||
323 | } | 284 | } |
324 | } | 285 | } |
325 | catch (Exception e) | ||
326 | { | ||
327 | m_log.Error(e.ToString()); | ||
328 | } | ||
329 | } | 286 | } |
330 | tables.Close(); | ||
331 | } | 287 | } |
332 | } | 288 | } |
333 | } | 289 | } |
@@ -337,28 +293,27 @@ namespace OpenSim.Data.MySQL | |||
337 | /// <summary> | 293 | /// <summary> |
338 | /// Runs a query with protection against SQL Injection by using parameterised input. | 294 | /// Runs a query with protection against SQL Injection by using parameterised input. |
339 | /// </summary> | 295 | /// </summary> |
296 | /// <param name="dbcon">Database connection</param> | ||
340 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | 297 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> |
341 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | 298 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> |
342 | /// <returns>A MySQL DB Command</returns> | 299 | /// <returns>A MySQL DB Command</returns> |
343 | public IDbCommand Query(string sql, Dictionary<string, object> parameters) | 300 | public IDbCommand Query(MySqlConnection dbcon, string sql, Dictionary<string, object> parameters) |
344 | { | 301 | { |
345 | try | 302 | try |
346 | { | 303 | { |
347 | CheckConnection(); // Not sure if this one is necessary | 304 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); |
348 | |||
349 | MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); | ||
350 | dbcommand.CommandText = sql; | 305 | dbcommand.CommandText = sql; |
351 | foreach (KeyValuePair<string, object> param in parameters) | 306 | foreach (KeyValuePair<string, object> param in parameters) |
352 | { | 307 | { |
353 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | 308 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); |
354 | } | 309 | } |
355 | 310 | ||
356 | return (IDbCommand) dbcommand; | 311 | return (IDbCommand)dbcommand; |
357 | } | 312 | } |
358 | catch (Exception e) | 313 | catch (Exception e) |
359 | { | 314 | { |
360 | // Return null if it fails. | 315 | // Return null if it fails. |
361 | m_log.Error("Failed during Query generation: " + e.ToString()); | 316 | m_log.Error("Failed during Query generation: " + e.Message, e); |
362 | return null; | 317 | return null; |
363 | } | 318 | } |
364 | } | 319 | } |
@@ -694,8 +649,6 @@ namespace OpenSim.Data.MySQL | |||
694 | ret.Add(attachpoint, item); | 649 | ret.Add(attachpoint, item); |
695 | } | 650 | } |
696 | 651 | ||
697 | r.Close(); | ||
698 | |||
699 | return ret; | 652 | return ret; |
700 | } | 653 | } |
701 | 654 | ||
@@ -727,12 +680,17 @@ namespace OpenSim.Data.MySQL | |||
727 | 680 | ||
728 | try | 681 | try |
729 | { | 682 | { |
730 | IDbCommand result = Query(sql, parameters); | 683 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
684 | { | ||
685 | dbcon.Open(); | ||
686 | |||
687 | IDbCommand result = Query(dbcon, sql, parameters); | ||
731 | 688 | ||
732 | if (result.ExecuteNonQuery() == 1) | 689 | if (result.ExecuteNonQuery() == 1) |
733 | returnval = true; | 690 | returnval = true; |
734 | 691 | ||
735 | result.Dispose(); | 692 | result.Dispose(); |
693 | } | ||
736 | } | 694 | } |
737 | catch (Exception e) | 695 | catch (Exception e) |
738 | { | 696 | { |
@@ -828,12 +786,17 @@ namespace OpenSim.Data.MySQL | |||
828 | 786 | ||
829 | try | 787 | try |
830 | { | 788 | { |
831 | IDbCommand result = Query(sql, parameters); | 789 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
790 | { | ||
791 | dbcon.Open(); | ||
832 | 792 | ||
833 | if (result.ExecuteNonQuery() == 1) | 793 | IDbCommand result = Query(dbcon, sql, parameters); |
834 | returnval = true; | ||
835 | 794 | ||
836 | result.Dispose(); | 795 | if (result.ExecuteNonQuery() == 1) |
796 | returnval = true; | ||
797 | |||
798 | result.Dispose(); | ||
799 | } | ||
837 | } | 800 | } |
838 | catch (Exception e) | 801 | catch (Exception e) |
839 | { | 802 | { |
@@ -927,12 +890,17 @@ namespace OpenSim.Data.MySQL | |||
927 | bool returnval = false; | 890 | bool returnval = false; |
928 | try | 891 | try |
929 | { | 892 | { |
930 | IDbCommand result = Query(sql, parameters); | 893 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
894 | { | ||
895 | dbcon.Open(); | ||
931 | 896 | ||
932 | if (result.ExecuteNonQuery() == 1) | 897 | IDbCommand result = Query(dbcon, sql, parameters); |
933 | returnval = true; | ||
934 | 898 | ||
935 | result.Dispose(); | 899 | if (result.ExecuteNonQuery() == 1) |
900 | returnval = true; | ||
901 | |||
902 | result.Dispose(); | ||
903 | } | ||
936 | } | 904 | } |
937 | catch (Exception e) | 905 | catch (Exception e) |
938 | { | 906 | { |
@@ -1030,18 +998,23 @@ namespace OpenSim.Data.MySQL | |||
1030 | 998 | ||
1031 | try | 999 | try |
1032 | { | 1000 | { |
1033 | IDbCommand result = Query(sql, parameters); | 1001 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
1034 | |||
1035 | // int x; | ||
1036 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1037 | // { | ||
1038 | // returnval = true; | ||
1039 | // } | ||
1040 | if (result.ExecuteNonQuery() > 0) | ||
1041 | { | 1002 | { |
1042 | returnval = true; | 1003 | dbcon.Open(); |
1004 | |||
1005 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1006 | |||
1007 | // int x; | ||
1008 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1009 | // { | ||
1010 | // returnval = true; | ||
1011 | // } | ||
1012 | if (result.ExecuteNonQuery() > 0) | ||
1013 | { | ||
1014 | returnval = true; | ||
1015 | } | ||
1016 | result.Dispose(); | ||
1043 | } | 1017 | } |
1044 | result.Dispose(); | ||
1045 | } | 1018 | } |
1046 | catch (Exception e) | 1019 | catch (Exception e) |
1047 | { | 1020 | { |
@@ -1070,18 +1043,23 @@ namespace OpenSim.Data.MySQL | |||
1070 | { | 1043 | { |
1071 | parameters["?uuid"] = uuid; | 1044 | parameters["?uuid"] = uuid; |
1072 | 1045 | ||
1073 | IDbCommand result = Query(sql, parameters); | 1046 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
1074 | |||
1075 | // int x; | ||
1076 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1077 | // { | ||
1078 | // returnval = true; | ||
1079 | // } | ||
1080 | if (result.ExecuteNonQuery() > 0) | ||
1081 | { | 1047 | { |
1082 | returnval = true; | 1048 | dbcon.Open(); |
1049 | |||
1050 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1051 | |||
1052 | // int x; | ||
1053 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1054 | // { | ||
1055 | // returnval = true; | ||
1056 | // } | ||
1057 | if (result.ExecuteNonQuery() > 0) | ||
1058 | { | ||
1059 | returnval = true; | ||
1060 | } | ||
1061 | result.Dispose(); | ||
1083 | } | 1062 | } |
1084 | result.Dispose(); | ||
1085 | } | 1063 | } |
1086 | catch (Exception e) | 1064 | catch (Exception e) |
1087 | { | 1065 | { |
@@ -1122,18 +1100,23 @@ namespace OpenSim.Data.MySQL | |||
1122 | 1100 | ||
1123 | try | 1101 | try |
1124 | { | 1102 | { |
1125 | IDbCommand result = Query(sql, parameters); | 1103 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
1126 | |||
1127 | // int x; | ||
1128 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1129 | // { | ||
1130 | // returnval = true; | ||
1131 | // } | ||
1132 | if (result.ExecuteNonQuery() > 0) | ||
1133 | { | 1104 | { |
1134 | returnval = true; | 1105 | dbcon.Open(); |
1106 | |||
1107 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1108 | |||
1109 | // int x; | ||
1110 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1111 | // { | ||
1112 | // returnval = true; | ||
1113 | // } | ||
1114 | if (result.ExecuteNonQuery() > 0) | ||
1115 | { | ||
1116 | returnval = true; | ||
1117 | } | ||
1118 | result.Dispose(); | ||
1135 | } | 1119 | } |
1136 | result.Dispose(); | ||
1137 | } | 1120 | } |
1138 | catch (Exception e) | 1121 | catch (Exception e) |
1139 | { | 1122 | { |
@@ -1167,45 +1150,51 @@ namespace OpenSim.Data.MySQL | |||
1167 | bool returnval = false; | 1150 | bool returnval = false; |
1168 | 1151 | ||
1169 | // we want to send in byte data, which means we can't just pass down strings | 1152 | // we want to send in byte data, which means we can't just pass down strings |
1170 | try { | 1153 | try |
1171 | MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); | 1154 | { |
1172 | cmd.CommandText = sql; | 1155 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
1173 | cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); | 1156 | { |
1174 | cmd.Parameters.AddWithValue("?serial", appearance.Serial); | 1157 | dbcon.Open(); |
1175 | cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); | 1158 | |
1176 | cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); | 1159 | using (MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand()) |
1177 | cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); | 1160 | { |
1178 | cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); | 1161 | cmd.CommandText = sql; |
1179 | cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); | 1162 | cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); |
1180 | cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); | 1163 | cmd.Parameters.AddWithValue("?serial", appearance.Serial); |
1181 | cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); | 1164 | cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); |
1182 | cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); | 1165 | cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); |
1183 | cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); | 1166 | cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); |
1184 | cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); | 1167 | cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); |
1185 | cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); | 1168 | cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); |
1186 | cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); | 1169 | cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); |
1187 | cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); | 1170 | cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); |
1188 | cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); | 1171 | cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); |
1189 | cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); | 1172 | cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); |
1190 | cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); | 1173 | cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); |
1191 | cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); | 1174 | cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); |
1192 | cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); | 1175 | cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); |
1193 | cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); | 1176 | cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); |
1194 | cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); | 1177 | cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); |
1195 | cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); | 1178 | cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); |
1196 | cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); | 1179 | cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); |
1197 | cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); | 1180 | cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); |
1198 | cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); | 1181 | cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); |
1199 | cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); | 1182 | cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); |
1200 | cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); | 1183 | cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); |
1201 | cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); | 1184 | cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); |
1202 | cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); | 1185 | cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); |
1203 | cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); | 1186 | cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); |
1204 | 1187 | cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); | |
1205 | if (cmd.ExecuteNonQuery() > 0) | 1188 | cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); |
1206 | returnval = true; | 1189 | cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); |
1207 | 1190 | cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); | |
1208 | cmd.Dispose(); | 1191 | cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); |
1192 | cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); | ||
1193 | |||
1194 | if (cmd.ExecuteNonQuery() > 0) | ||
1195 | returnval = true; | ||
1196 | } | ||
1197 | } | ||
1209 | } | 1198 | } |
1210 | catch (Exception e) | 1199 | catch (Exception e) |
1211 | { | 1200 | { |
@@ -1221,33 +1210,38 @@ namespace OpenSim.Data.MySQL | |||
1221 | { | 1210 | { |
1222 | string sql = "delete from avatarattachments where UUID = ?uuid"; | 1211 | string sql = "delete from avatarattachments where UUID = ?uuid"; |
1223 | 1212 | ||
1224 | MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); | 1213 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) |
1225 | cmd.CommandText = sql; | 1214 | { |
1226 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | 1215 | dbcon.Open(); |
1216 | |||
1217 | MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
1218 | cmd.CommandText = sql; | ||
1219 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
1227 | 1220 | ||
1228 | cmd.ExecuteNonQuery(); | 1221 | cmd.ExecuteNonQuery(); |
1229 | 1222 | ||
1230 | if (data == null) | 1223 | if (data == null) |
1231 | return; | 1224 | return; |
1232 | 1225 | ||
1233 | sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; | 1226 | sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; |
1234 | 1227 | ||
1235 | cmd = (MySqlCommand) dbcon.CreateCommand(); | 1228 | cmd = (MySqlCommand)dbcon.CreateCommand(); |
1236 | cmd.CommandText = sql; | 1229 | cmd.CommandText = sql; |
1237 | 1230 | ||
1238 | foreach (DictionaryEntry e in data) | 1231 | foreach (DictionaryEntry e in data) |
1239 | { | 1232 | { |
1240 | int attachpoint = Convert.ToInt32(e.Key); | 1233 | int attachpoint = Convert.ToInt32(e.Key); |
1241 | 1234 | ||
1242 | Hashtable item = (Hashtable)e.Value; | 1235 | Hashtable item = (Hashtable)e.Value; |
1243 | 1236 | ||
1244 | cmd.Parameters.Clear(); | 1237 | cmd.Parameters.Clear(); |
1245 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | 1238 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); |
1246 | cmd.Parameters.AddWithValue("?attachpoint", attachpoint); | 1239 | cmd.Parameters.AddWithValue("?attachpoint", attachpoint); |
1247 | cmd.Parameters.AddWithValue("?item", item["item"]); | 1240 | cmd.Parameters.AddWithValue("?item", item["item"]); |
1248 | cmd.Parameters.AddWithValue("?asset", item["asset"]); | 1241 | cmd.Parameters.AddWithValue("?asset", item["asset"]); |
1249 | 1242 | ||
1250 | cmd.ExecuteNonQuery(); | 1243 | cmd.ExecuteNonQuery(); |
1244 | } | ||
1251 | } | 1245 | } |
1252 | } | 1246 | } |
1253 | } | 1247 | } |
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index e5dd0e5..4950f7f 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -123,27 +123,26 @@ namespace OpenSim.Data.MySQL | |||
123 | 123 | ||
124 | cmd.Parameters.AddWithValue("?UserID", userID); | 124 | cmd.Parameters.AddWithValue("?UserID", userID); |
125 | 125 | ||
126 | IDataReader reader = ExecuteReader(cmd); | 126 | using (IDataReader reader = cmd.ExecuteReader()) |
127 | |||
128 | List<UUID> deleteSessions = new List<UUID>(); | ||
129 | int online = 0; | ||
130 | |||
131 | while(reader.Read()) | ||
132 | { | 127 | { |
133 | if (bool.Parse(reader["Online"].ToString())) | ||
134 | online++; | ||
135 | else | ||
136 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
137 | } | ||
138 | 128 | ||
139 | if (online == 0 && deleteSessions.Count > 0) | 129 | List<UUID> deleteSessions = new List<UUID>(); |
140 | deleteSessions.RemoveAt(0); | 130 | int online = 0; |
141 | 131 | ||
142 | reader.Close(); | 132 | while(reader.Read()) |
143 | CloseReaderCommand(cmd); | 133 | { |
134 | if (bool.Parse(reader["Online"].ToString())) | ||
135 | online++; | ||
136 | else | ||
137 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
138 | } | ||
144 | 139 | ||
145 | foreach (UUID s in deleteSessions) | 140 | if (online == 0 && deleteSessions.Count > 0) |
146 | Delete("SessionID", s.ToString()); | 141 | deleteSessions.RemoveAt(0); |
142 | |||
143 | foreach (UUID s in deleteSessions) | ||
144 | Delete("SessionID", s.ToString()); | ||
145 | } | ||
147 | } | 146 | } |
148 | } | 147 | } |
149 | } | 148 | } |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index d045f61..aa9a104 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -38,16 +38,21 @@ namespace OpenSim.Data.MySQL | |||
38 | public class MySqlRegionData : MySqlFramework, IRegionData | 38 | public class MySqlRegionData : MySqlFramework, IRegionData |
39 | { | 39 | { |
40 | private string m_Realm; | 40 | private string m_Realm; |
41 | private List<string> m_ColumnNames = null; | 41 | private List<string> m_ColumnNames; |
42 | // private int m_LastExpire = 0; | 42 | //private string m_connectionString; |
43 | 43 | ||
44 | public MySqlRegionData(string connectionString, string realm) | 44 | public MySqlRegionData(string connectionString, string realm) |
45 | : base(connectionString) | 45 | : base(connectionString) |
46 | { | 46 | { |
47 | m_Realm = realm; | 47 | m_Realm = realm; |
48 | m_connectionString = connectionString; | ||
48 | 49 | ||
49 | Migration m = new Migration(m_Connection, GetType().Assembly, "GridStore"); | 50 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
50 | m.Update(); | 51 | { |
52 | dbcon.Open(); | ||
53 | Migration m = new Migration(dbcon, GetType().Assembly, "GridStore"); | ||
54 | m.Update(); | ||
55 | } | ||
51 | } | 56 | } |
52 | 57 | ||
53 | public List<RegionData> Get(string regionName, UUID scopeID) | 58 | public List<RegionData> Get(string regionName, UUID scopeID) |
@@ -56,12 +61,13 @@ namespace OpenSim.Data.MySQL | |||
56 | if (scopeID != UUID.Zero) | 61 | if (scopeID != UUID.Zero) |
57 | command += " and ScopeID = ?scopeID"; | 62 | command += " and ScopeID = ?scopeID"; |
58 | 63 | ||
59 | MySqlCommand cmd = new MySqlCommand(command); | 64 | using (MySqlCommand cmd = new MySqlCommand(command)) |
60 | 65 | { | |
61 | cmd.Parameters.AddWithValue("?regionName", regionName); | 66 | cmd.Parameters.AddWithValue("?regionName", regionName); |
62 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 67 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
63 | 68 | ||
64 | return RunCommand(cmd); | 69 | return RunCommand(cmd); |
70 | } | ||
65 | } | 71 | } |
66 | 72 | ||
67 | public RegionData Get(int posX, int posY, UUID scopeID) | 73 | public RegionData Get(int posX, int posY, UUID scopeID) |
@@ -70,17 +76,18 @@ namespace OpenSim.Data.MySQL | |||
70 | if (scopeID != UUID.Zero) | 76 | if (scopeID != UUID.Zero) |
71 | command += " and ScopeID = ?scopeID"; | 77 | command += " and ScopeID = ?scopeID"; |
72 | 78 | ||
73 | MySqlCommand cmd = new MySqlCommand(command); | 79 | using (MySqlCommand cmd = new MySqlCommand(command)) |
74 | 80 | { | |
75 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); | 81 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); |
76 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); | 82 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); |
77 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 83 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
78 | 84 | ||
79 | List<RegionData> ret = RunCommand(cmd); | 85 | List<RegionData> ret = RunCommand(cmd); |
80 | if (ret.Count == 0) | 86 | if (ret.Count == 0) |
81 | return null; | 87 | return null; |
82 | 88 | ||
83 | return ret[0]; | 89 | return ret[0]; |
90 | } | ||
84 | } | 91 | } |
85 | 92 | ||
86 | public RegionData Get(UUID regionID, UUID scopeID) | 93 | public RegionData Get(UUID regionID, UUID scopeID) |
@@ -89,16 +96,17 @@ namespace OpenSim.Data.MySQL | |||
89 | if (scopeID != UUID.Zero) | 96 | if (scopeID != UUID.Zero) |
90 | command += " and ScopeID = ?scopeID"; | 97 | command += " and ScopeID = ?scopeID"; |
91 | 98 | ||
92 | MySqlCommand cmd = new MySqlCommand(command); | 99 | using (MySqlCommand cmd = new MySqlCommand(command)) |
93 | 100 | { | |
94 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | 101 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); |
95 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 102 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
96 | 103 | ||
97 | List<RegionData> ret = RunCommand(cmd); | 104 | List<RegionData> ret = RunCommand(cmd); |
98 | if (ret.Count == 0) | 105 | if (ret.Count == 0) |
99 | return null; | 106 | return null; |
100 | 107 | ||
101 | return ret[0]; | 108 | return ret[0]; |
109 | } | ||
102 | } | 110 | } |
103 | 111 | ||
104 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 112 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
@@ -107,74 +115,79 @@ namespace OpenSim.Data.MySQL | |||
107 | if (scopeID != UUID.Zero) | 115 | if (scopeID != UUID.Zero) |
108 | command += " and ScopeID = ?scopeID"; | 116 | command += " and ScopeID = ?scopeID"; |
109 | 117 | ||
110 | MySqlCommand cmd = new MySqlCommand(command); | 118 | using (MySqlCommand cmd = new MySqlCommand(command)) |
111 | 119 | { | |
112 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); | 120 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); |
113 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); | 121 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); |
114 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | 122 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); |
115 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | 123 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); |
116 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 124 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
117 | 125 | ||
118 | return RunCommand(cmd); | 126 | return RunCommand(cmd); |
127 | } | ||
119 | } | 128 | } |
120 | 129 | ||
121 | public List<RegionData> RunCommand(MySqlCommand cmd) | 130 | public List<RegionData> RunCommand(MySqlCommand cmd) |
122 | { | 131 | { |
123 | List<RegionData> retList = new List<RegionData>(); | 132 | List<RegionData> retList = new List<RegionData>(); |
124 | 133 | ||
125 | IDataReader result = ExecuteReader(cmd); | 134 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
126 | |||
127 | while (result.Read()) | ||
128 | { | 135 | { |
129 | RegionData ret = new RegionData(); | 136 | dbcon.Open(); |
130 | ret.Data = new Dictionary<string, object>(); | 137 | cmd.Connection = dbcon; |
131 | 138 | ||
132 | UUID regionID; | 139 | using (IDataReader result = cmd.ExecuteReader()) |
133 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
134 | ret.RegionID = regionID; | ||
135 | UUID scope; | ||
136 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
137 | ret.ScopeID = scope; | ||
138 | ret.RegionName = result["regionName"].ToString(); | ||
139 | ret.posX = Convert.ToInt32(result["locX"]); | ||
140 | ret.posY = Convert.ToInt32(result["locY"]); | ||
141 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
142 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
143 | |||
144 | if (m_ColumnNames == null) | ||
145 | { | 140 | { |
146 | m_ColumnNames = new List<string>(); | 141 | while (result.Read()) |
142 | { | ||
143 | RegionData ret = new RegionData(); | ||
144 | ret.Data = new Dictionary<string, object>(); | ||
145 | |||
146 | UUID regionID; | ||
147 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
148 | ret.RegionID = regionID; | ||
149 | UUID scope; | ||
150 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
151 | ret.ScopeID = scope; | ||
152 | ret.RegionName = result["regionName"].ToString(); | ||
153 | ret.posX = Convert.ToInt32(result["locX"]); | ||
154 | ret.posY = Convert.ToInt32(result["locY"]); | ||
155 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
156 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
157 | |||
158 | if (m_ColumnNames == null) | ||
159 | { | ||
160 | m_ColumnNames = new List<string>(); | ||
161 | |||
162 | DataTable schemaTable = result.GetSchemaTable(); | ||
163 | foreach (DataRow row in schemaTable.Rows) | ||
164 | { | ||
165 | if (row["ColumnName"] != null) | ||
166 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
167 | } | ||
168 | } | ||
147 | 169 | ||
148 | DataTable schemaTable = result.GetSchemaTable(); | 170 | foreach (string s in m_ColumnNames) |
149 | foreach (DataRow row in schemaTable.Rows) | ||
150 | { | 171 | { |
151 | if (row["ColumnName"] != null) | 172 | if (s == "uuid") |
152 | m_ColumnNames.Add(row["ColumnName"].ToString()); | 173 | continue; |
174 | if (s == "ScopeID") | ||
175 | continue; | ||
176 | if (s == "regionName") | ||
177 | continue; | ||
178 | if (s == "locX") | ||
179 | continue; | ||
180 | if (s == "locY") | ||
181 | continue; | ||
182 | |||
183 | ret.Data[s] = result[s].ToString(); | ||
153 | } | 184 | } |
154 | } | ||
155 | 185 | ||
156 | foreach (string s in m_ColumnNames) | 186 | retList.Add(ret); |
157 | { | 187 | } |
158 | if (s == "uuid") | ||
159 | continue; | ||
160 | if (s == "ScopeID") | ||
161 | continue; | ||
162 | if (s == "regionName") | ||
163 | continue; | ||
164 | if (s == "locX") | ||
165 | continue; | ||
166 | if (s == "locY") | ||
167 | continue; | ||
168 | |||
169 | ret.Data[s] = result[s].ToString(); | ||
170 | } | 188 | } |
171 | |||
172 | retList.Add(ret); | ||
173 | } | 189 | } |
174 | 190 | ||
175 | result.Close(); | ||
176 | CloseReaderCommand(cmd); | ||
177 | |||
178 | return retList; | 191 | return retList; |
179 | } | 192 | } |
180 | 193 | ||
@@ -201,76 +214,72 @@ namespace OpenSim.Data.MySQL | |||
201 | 214 | ||
202 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 215 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
203 | 216 | ||
204 | MySqlCommand cmd = new MySqlCommand(); | 217 | using (MySqlCommand cmd = new MySqlCommand()) |
205 | |||
206 | string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; | ||
207 | foreach (string field in fields) | ||
208 | { | 218 | { |
209 | update += ", "; | 219 | string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; |
210 | update += "`" + field + "` = ?"+field; | 220 | foreach (string field in fields) |
211 | 221 | { | |
212 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | 222 | update += ", "; |
213 | } | 223 | update += "`" + field + "` = ?" + field; |
214 | |||
215 | update += " where uuid = ?regionID"; | ||
216 | 224 | ||
217 | if (data.ScopeID != UUID.Zero) | 225 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); |
218 | update += " and ScopeID = ?scopeID"; | 226 | } |
219 | 227 | ||
220 | cmd.CommandText = update; | 228 | update += " where uuid = ?regionID"; |
221 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | ||
222 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); | ||
223 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | ||
224 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | ||
225 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | ||
226 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | ||
228 | 229 | ||
229 | if (ExecuteNonQuery(cmd) < 1) | 230 | if (data.ScopeID != UUID.Zero) |
230 | { | 231 | update += " and ScopeID = ?scopeID"; |
231 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + | ||
232 | String.Join("`, `", fields) + | ||
233 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; | ||
234 | 232 | ||
235 | cmd.CommandText = insert; | 233 | cmd.CommandText = update; |
234 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | ||
235 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); | ||
236 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | ||
237 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | ||
238 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | ||
239 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | ||
240 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | ||
236 | 241 | ||
237 | if (ExecuteNonQuery(cmd) < 1) | 242 | if (ExecuteNonQuery(cmd) < 1) |
238 | { | 243 | { |
239 | cmd.Dispose(); | 244 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + |
240 | return false; | 245 | String.Join("`, `", fields) + |
246 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; | ||
247 | |||
248 | cmd.CommandText = insert; | ||
249 | |||
250 | if (ExecuteNonQuery(cmd) < 1) | ||
251 | { | ||
252 | return false; | ||
253 | } | ||
241 | } | 254 | } |
242 | } | 255 | } |
243 | 256 | ||
244 | cmd.Dispose(); | ||
245 | |||
246 | return true; | 257 | return true; |
247 | } | 258 | } |
248 | 259 | ||
249 | public bool SetDataItem(UUID regionID, string item, string value) | 260 | public bool SetDataItem(UUID regionID, string item, string value) |
250 | { | 261 | { |
251 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + | 262 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) |
252 | "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); | 263 | { |
253 | 264 | cmd.Parameters.AddWithValue("?" + item, value); | |
254 | 265 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | |
255 | cmd.Parameters.AddWithValue("?"+item, value); | ||
256 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
257 | 266 | ||
258 | if (ExecuteNonQuery(cmd) > 0) | 267 | if (ExecuteNonQuery(cmd) > 0) |
259 | return true; | 268 | return true; |
269 | } | ||
260 | 270 | ||
261 | return false; | 271 | return false; |
262 | } | 272 | } |
263 | 273 | ||
264 | public bool Delete(UUID regionID) | 274 | public bool Delete(UUID regionID) |
265 | { | 275 | { |
266 | MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + | 276 | using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) |
267 | "` where uuid = ?UUID"); | 277 | { |
268 | 278 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | |
269 | |||
270 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
271 | 279 | ||
272 | if (ExecuteNonQuery(cmd) > 0) | 280 | if (ExecuteNonQuery(cmd) > 0) |
273 | return true; | 281 | return true; |
282 | } | ||
274 | 283 | ||
275 | return false; | 284 | return false; |
276 | } | 285 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 04f872f..2cf88b8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using log4net; | 35 | using log4net; |
36 | using MySql.Data.MySqlClient; | ||
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | 39 | ||
@@ -45,15 +46,9 @@ namespace OpenSim.Data.MySQL | |||
45 | { | 46 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
48 | /// <summary> | 49 | private MySQLManager m_database; |
49 | /// Database manager for MySQL | 50 | private string m_connectionString; |
50 | /// </summary> | 51 | private object m_dbLock = new object(); |
51 | public MySQLManager database; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Better DB manager. Swap-in replacement too. | ||
55 | /// </summary> | ||
56 | public Dictionary<int, MySQLSuperManager> m_dbconnections = new Dictionary<int, MySQLSuperManager>(); | ||
57 | 52 | ||
58 | public int m_maxConnections = 10; | 53 | public int m_maxConnections = 10; |
59 | public int m_lastConnect; | 54 | public int m_lastConnect; |
@@ -63,7 +58,6 @@ namespace OpenSim.Data.MySQL | |||
63 | private string m_userFriendsTableName = "userfriends"; | 58 | private string m_userFriendsTableName = "userfriends"; |
64 | private string m_appearanceTableName = "avatarappearance"; | 59 | private string m_appearanceTableName = "avatarappearance"; |
65 | private string m_attachmentsTableName = "avatarattachments"; | 60 | private string m_attachmentsTableName = "avatarattachments"; |
66 | private string m_connectString; | ||
67 | 61 | ||
68 | public override void Initialise() | 62 | public override void Initialise() |
69 | { | 63 | { |
@@ -71,41 +65,6 @@ namespace OpenSim.Data.MySQL | |||
71 | throw new PluginNotInitialisedException(Name); | 65 | throw new PluginNotInitialisedException(Name); |
72 | } | 66 | } |
73 | 67 | ||
74 | public MySQLSuperManager GetLockedConnection(string why) | ||
75 | { | ||
76 | int lockedCons = 0; | ||
77 | while (true) | ||
78 | { | ||
79 | m_lastConnect++; | ||
80 | |||
81 | // Overflow protection | ||
82 | if (m_lastConnect == int.MaxValue) | ||
83 | m_lastConnect = 0; | ||
84 | |||
85 | MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; | ||
86 | if (!x.Locked) | ||
87 | { | ||
88 | x.GetLock(); | ||
89 | x.Running = why; | ||
90 | return x; | ||
91 | } | ||
92 | |||
93 | lockedCons++; | ||
94 | if (lockedCons > m_maxConnections) | ||
95 | { | ||
96 | lockedCons = 0; | ||
97 | Thread.Sleep(1000); // Wait some time before searching them again. | ||
98 | m_log.Debug( | ||
99 | "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); | ||
100 | m_log.Debug("Current connections-in-use dump:"); | ||
101 | foreach (KeyValuePair<int, MySQLSuperManager> kvp in m_dbconnections) | ||
102 | { | ||
103 | m_log.Debug(kvp.Value.Running); | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | |||
109 | /// <summary> | 68 | /// <summary> |
110 | /// Initialise User Interface | 69 | /// Initialise User Interface |
111 | /// Loads and initialises the MySQL storage plugin | 70 | /// Loads and initialises the MySQL storage plugin |
@@ -115,55 +74,18 @@ namespace OpenSim.Data.MySQL | |||
115 | /// <param name="connect">connect string.</param> | 74 | /// <param name="connect">connect string.</param> |
116 | public override void Initialise(string connect) | 75 | public override void Initialise(string connect) |
117 | { | 76 | { |
118 | if (connect == String.Empty) | 77 | m_connectionString = connect; |
119 | { | 78 | m_database = new MySQLManager(connect); |
120 | // TODO: actually do something with our connect string | ||
121 | // instead of loading the second config | ||
122 | |||
123 | m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead"); | ||
124 | IniFile iniFile = new IniFile("mysql_connection.ini"); | ||
125 | string settingHostname = iniFile.ParseFileReadValue("hostname"); | ||
126 | string settingDatabase = iniFile.ParseFileReadValue("database"); | ||
127 | string settingUsername = iniFile.ParseFileReadValue("username"); | ||
128 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
129 | string settingPooling = iniFile.ParseFileReadValue("pooling"); | ||
130 | string settingPort = iniFile.ParseFileReadValue("port"); | ||
131 | |||
132 | m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + | ||
133 | ";User ID=" + | ||
134 | settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; | ||
135 | |||
136 | m_log.Info("Creating " + m_maxConnections + " DB connections..."); | ||
137 | for (int i = 0; i < m_maxConnections; i++) | ||
138 | { | ||
139 | m_log.Info("Connecting to DB... [" + i + "]"); | ||
140 | MySQLSuperManager msm = new MySQLSuperManager(); | ||
141 | msm.Manager = new MySQLManager(m_connectString); | ||
142 | m_dbconnections.Add(i, msm); | ||
143 | } | ||
144 | |||
145 | database = new MySQLManager(m_connectString); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | m_connectString = connect; | ||
150 | database = new MySQLManager(m_connectString); | ||
151 | |||
152 | m_log.Info("Creating " + m_maxConnections + " DB connections..."); | ||
153 | for (int i = 0; i < m_maxConnections; i++) | ||
154 | { | ||
155 | m_log.Info("Connecting to DB... [" + i + "]"); | ||
156 | MySQLSuperManager msm = new MySQLSuperManager(); | ||
157 | msm.Manager = new MySQLManager(m_connectString); | ||
158 | m_dbconnections.Add(i, msm); | ||
159 | } | ||
160 | } | ||
161 | 79 | ||
162 | // This actually does the roll forward assembly stuff | 80 | // This actually does the roll forward assembly stuff |
163 | Assembly assem = GetType().Assembly; | 81 | Assembly assem = GetType().Assembly; |
164 | Migration m = new Migration(database.Connection, assem, "UserStore"); | ||
165 | 82 | ||
166 | m.Update(); | 83 | using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString)) |
84 | { | ||
85 | dbcon.Open(); | ||
86 | Migration m = new Migration(dbcon, assem, "UserStore"); | ||
87 | m.Update(); | ||
88 | } | ||
167 | } | 89 | } |
168 | 90 | ||
169 | public override void Dispose() | 91 | public override void Dispose() |
@@ -173,35 +95,32 @@ namespace OpenSim.Data.MySQL | |||
173 | // see IUserDataPlugin | 95 | // see IUserDataPlugin |
174 | public override UserProfileData GetUserByName(string user, string last) | 96 | public override UserProfileData GetUserByName(string user, string last) |
175 | { | 97 | { |
176 | MySQLSuperManager dbm = GetLockedConnection("GetUserByName"); | ||
177 | |||
178 | try | 98 | try |
179 | { | 99 | { |
180 | Dictionary<string, object> param = new Dictionary<string, object>(); | 100 | Dictionary<string, object> param = new Dictionary<string, object>(); |
181 | param["?first"] = user; | 101 | param["?first"] = user; |
182 | param["?second"] = last; | 102 | param["?second"] = last; |
183 | 103 | ||
184 | IDbCommand result = | 104 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
185 | dbm.Manager.Query( | 105 | { |
186 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); | 106 | dbcon.Open(); |
187 | IDataReader reader = result.ExecuteReader(); | ||
188 | |||
189 | UserProfileData row = dbm.Manager.readUserRow(reader); | ||
190 | 107 | ||
191 | reader.Dispose(); | 108 | using (IDbCommand result = m_database.Query(dbcon, |
192 | result.Dispose(); | 109 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) |
193 | return row; | 110 | { |
111 | using (IDataReader reader = result.ExecuteReader()) | ||
112 | { | ||
113 | UserProfileData row = m_database.readUserRow(reader); | ||
114 | return row; | ||
115 | } | ||
116 | } | ||
117 | } | ||
194 | } | 118 | } |
195 | catch (Exception e) | 119 | catch (Exception e) |
196 | { | 120 | { |
197 | dbm.Manager.Reconnect(); | 121 | m_log.Error(e.Message, e); |
198 | m_log.Error(e.ToString()); | ||
199 | return null; | 122 | return null; |
200 | } | 123 | } |
201 | finally | ||
202 | { | ||
203 | dbm.Release(); | ||
204 | } | ||
205 | } | 124 | } |
206 | 125 | ||
207 | #region User Friends List Data | 126 | #region User Friends List Data |
@@ -216,38 +135,38 @@ namespace OpenSim.Data.MySQL | |||
216 | param["?friendPerms"] = perms.ToString(); | 135 | param["?friendPerms"] = perms.ToString(); |
217 | param["?datetimestamp"] = dtvalue.ToString(); | 136 | param["?datetimestamp"] = dtvalue.ToString(); |
218 | 137 | ||
219 | MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend"); | ||
220 | |||
221 | try | 138 | try |
222 | { | 139 | { |
223 | IDbCommand adder = | 140 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
224 | dbm.Manager.Query( | 141 | { |
142 | dbcon.Open(); | ||
143 | |||
144 | using (IDbCommand adder = m_database.Query(dbcon, | ||
225 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 145 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
226 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 146 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
227 | "VALUES " + | 147 | "VALUES " + |
228 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", | 148 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", |
229 | param); | 149 | param)) |
230 | adder.ExecuteNonQuery(); | 150 | { |
151 | adder.ExecuteNonQuery(); | ||
152 | } | ||
231 | 153 | ||
232 | adder = | 154 | using (IDbCommand adder = m_database.Query(dbcon, |
233 | dbm.Manager.Query( | ||
234 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 155 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
235 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 156 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
236 | "VALUES " + | 157 | "VALUES " + |
237 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | 158 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", |
238 | param); | 159 | param)) |
239 | adder.ExecuteNonQuery(); | 160 | { |
161 | adder.ExecuteNonQuery(); | ||
162 | } | ||
163 | } | ||
240 | } | 164 | } |
241 | catch (Exception e) | 165 | catch (Exception e) |
242 | { | 166 | { |
243 | dbm.Manager.Reconnect(); | 167 | m_log.Error(e.Message, e); |
244 | m_log.Error(e.ToString()); | ||
245 | return; | 168 | return; |
246 | } | 169 | } |
247 | finally | ||
248 | { | ||
249 | dbm.Release(); | ||
250 | } | ||
251 | } | 170 | } |
252 | 171 | ||
253 | public override void RemoveUserFriend(UUID friendlistowner, UUID friend) | 172 | public override void RemoveUserFriend(UUID friendlistowner, UUID friend) |
@@ -256,32 +175,32 @@ namespace OpenSim.Data.MySQL | |||
256 | param["?ownerID"] = friendlistowner.ToString(); | 175 | param["?ownerID"] = friendlistowner.ToString(); |
257 | param["?friendID"] = friend.ToString(); | 176 | param["?friendID"] = friend.ToString(); |
258 | 177 | ||
259 | MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend"); | ||
260 | |||
261 | try | 178 | try |
262 | { | 179 | { |
263 | IDbCommand updater = | 180 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
264 | dbm.Manager.Query( | 181 | { |
265 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", | 182 | dbcon.Open(); |
266 | param); | ||
267 | updater.ExecuteNonQuery(); | ||
268 | 183 | ||
269 | updater = | 184 | using (IDbCommand updater = m_database.Query(dbcon, |
270 | dbm.Manager.Query( | 185 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", |
271 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | 186 | param)) |
272 | param); | 187 | { |
273 | updater.ExecuteNonQuery(); | 188 | updater.ExecuteNonQuery(); |
189 | } | ||
190 | |||
191 | using (IDbCommand updater = m_database.Query(dbcon, | ||
192 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | ||
193 | param)) | ||
194 | { | ||
195 | updater.ExecuteNonQuery(); | ||
196 | } | ||
197 | } | ||
274 | } | 198 | } |
275 | catch (Exception e) | 199 | catch (Exception e) |
276 | { | 200 | { |
277 | dbm.Manager.Reconnect(); | 201 | m_log.Error(e.Message, e); |
278 | m_log.Error(e.ToString()); | ||
279 | return; | 202 | return; |
280 | } | 203 | } |
281 | finally | ||
282 | { | ||
283 | dbm.Release(); | ||
284 | } | ||
285 | } | 204 | } |
286 | 205 | ||
287 | public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | 206 | public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) |
@@ -291,28 +210,27 @@ namespace OpenSim.Data.MySQL | |||
291 | param["?friendID"] = friend.ToString(); | 210 | param["?friendID"] = friend.ToString(); |
292 | param["?friendPerms"] = perms.ToString(); | 211 | param["?friendPerms"] = perms.ToString(); |
293 | 212 | ||
294 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms"); | ||
295 | |||
296 | try | 213 | try |
297 | { | 214 | { |
298 | IDbCommand updater = | 215 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
299 | dbm.Manager.Query( | 216 | { |
300 | "update " + m_userFriendsTableName + | 217 | dbcon.Open(); |
301 | " SET friendPerms = ?friendPerms " + | 218 | |
302 | "where ownerID = ?ownerID and friendID = ?friendID", | 219 | using (IDbCommand updater = m_database.Query(dbcon, |
303 | param); | 220 | "update " + m_userFriendsTableName + |
304 | updater.ExecuteNonQuery(); | 221 | " SET friendPerms = ?friendPerms " + |
222 | "where ownerID = ?ownerID and friendID = ?friendID", | ||
223 | param)) | ||
224 | { | ||
225 | updater.ExecuteNonQuery(); | ||
226 | } | ||
227 | } | ||
305 | } | 228 | } |
306 | catch (Exception e) | 229 | catch (Exception e) |
307 | { | 230 | { |
308 | dbm.Manager.Reconnect(); | 231 | m_log.Error(e.Message, e); |
309 | m_log.Error(e.ToString()); | ||
310 | return; | 232 | return; |
311 | } | 233 | } |
312 | finally | ||
313 | { | ||
314 | dbm.Release(); | ||
315 | } | ||
316 | } | 234 | } |
317 | 235 | ||
318 | public override List<FriendListItem> GetUserFriendList(UUID friendlistowner) | 236 | public override List<FriendListItem> GetUserFriendList(UUID friendlistowner) |
@@ -322,87 +240,83 @@ namespace OpenSim.Data.MySQL | |||
322 | Dictionary<string, object> param = new Dictionary<string, object>(); | 240 | Dictionary<string, object> param = new Dictionary<string, object>(); |
323 | param["?ownerID"] = friendlistowner.ToString(); | 241 | param["?ownerID"] = friendlistowner.ToString(); |
324 | 242 | ||
325 | MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); | ||
326 | |||
327 | try | 243 | try |
328 | { | 244 | { |
329 | //Left Join userfriends to itself | 245 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
330 | IDbCommand result = | 246 | { |
331 | dbm.Manager.Query( | 247 | dbcon.Open(); |
248 | |||
249 | //Left Join userfriends to itself | ||
250 | using (IDbCommand result = m_database.Query(dbcon, | ||
332 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + | 251 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + |
333 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | 252 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + |
334 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | 253 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", |
335 | param); | 254 | param)) |
336 | IDataReader reader = result.ExecuteReader(); | 255 | { |
337 | 256 | using (IDataReader reader = result.ExecuteReader()) | |
338 | while (reader.Read()) | 257 | { |
339 | { | 258 | while (reader.Read()) |
340 | FriendListItem fli = new FriendListItem(); | 259 | { |
341 | fli.FriendListOwner = new UUID((string) reader["ownerID"]); | 260 | FriendListItem fli = new FriendListItem(); |
342 | fli.Friend = new UUID((string) reader["friendID"]); | 261 | fli.FriendListOwner = new UUID((string)reader["ownerID"]); |
343 | fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); | 262 | fli.Friend = new UUID((string)reader["friendID"]); |
344 | 263 | fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); | |
345 | // This is not a real column in the database table, it's a joined column from the opposite record | 264 | |
346 | fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); | 265 | // This is not a real column in the database table, it's a joined column from the opposite record |
347 | 266 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | |
348 | Lfli.Add(fli); | 267 | |
268 | Lfli.Add(fli); | ||
269 | } | ||
270 | } | ||
271 | } | ||
349 | } | 272 | } |
350 | |||
351 | reader.Dispose(); | ||
352 | result.Dispose(); | ||
353 | } | 273 | } |
354 | catch (Exception e) | 274 | catch (Exception e) |
355 | { | 275 | { |
356 | dbm.Manager.Reconnect(); | 276 | m_log.Error(e.Message, e); |
357 | m_log.Error(e.ToString()); | ||
358 | return Lfli; | 277 | return Lfli; |
359 | } | 278 | } |
360 | finally | ||
361 | { | ||
362 | dbm.Release(); | ||
363 | } | ||
364 | 279 | ||
365 | return Lfli; | 280 | return Lfli; |
366 | } | 281 | } |
367 | 282 | ||
368 | override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | 283 | override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) |
369 | { | 284 | { |
370 | MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos"); | ||
371 | Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); | 285 | Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); |
372 | 286 | ||
373 | try | 287 | try |
374 | { | 288 | { |
375 | foreach (UUID uuid in uuids) | 289 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
376 | { | 290 | { |
377 | Dictionary<string, object> param = new Dictionary<string, object>(); | 291 | dbcon.Open(); |
378 | param["?uuid"] = uuid.ToString(); | ||
379 | IDbCommand result = | ||
380 | dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + | ||
381 | " where UUID = ?uuid", param); | ||
382 | 292 | ||
383 | IDataReader reader = result.ExecuteReader(); | 293 | foreach (UUID uuid in uuids) |
384 | while (reader.Read()) | ||
385 | { | 294 | { |
386 | FriendRegionInfo fri = new FriendRegionInfo(); | 295 | Dictionary<string, object> param = new Dictionary<string, object>(); |
387 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; | 296 | param["?uuid"] = uuid.ToString(); |
388 | fri.regionHandle = (ulong)reader["currentHandle"]; | 297 | |
389 | 298 | using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName + | |
390 | infos[uuid] = fri; | 299 | " where UUID = ?uuid", param)) |
300 | { | ||
301 | using (IDataReader reader = result.ExecuteReader()) | ||
302 | { | ||
303 | while (reader.Read()) | ||
304 | { | ||
305 | FriendRegionInfo fri = new FriendRegionInfo(); | ||
306 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; | ||
307 | fri.regionHandle = (ulong)reader["currentHandle"]; | ||
308 | |||
309 | infos[uuid] = fri; | ||
310 | } | ||
311 | } | ||
312 | } | ||
391 | } | 313 | } |
392 | |||
393 | reader.Dispose(); | ||
394 | result.Dispose(); | ||
395 | } | 314 | } |
396 | } | 315 | } |
397 | catch (Exception e) | 316 | catch (Exception e) |
398 | { | 317 | { |
399 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); | 318 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); |
400 | dbm.Manager.Reconnect(); | 319 | m_log.Error(e.Message, e); |
401 | m_log.Error(e.ToString()); | ||
402 | } | ||
403 | finally | ||
404 | { | ||
405 | dbm.Release(); | ||
406 | } | 320 | } |
407 | 321 | ||
408 | return infos; | 322 | return infos; |
@@ -423,76 +337,73 @@ namespace OpenSim.Data.MySQL | |||
423 | Dictionary<string, object> param = new Dictionary<string, object>(); | 337 | Dictionary<string, object> param = new Dictionary<string, object>(); |
424 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | 338 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; |
425 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; | 339 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; |
426 | MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); | ||
427 | 340 | ||
428 | try | 341 | try |
429 | { | 342 | { |
430 | IDbCommand result = | 343 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
431 | dbm.Manager.Query( | 344 | { |
345 | dbcon.Open(); | ||
346 | |||
347 | using (IDbCommand result = m_database.Query(dbcon, | ||
432 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 348 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
433 | " WHERE username like ?first AND lastname like ?second LIMIT 100", | 349 | " WHERE username like ?first AND lastname like ?second LIMIT 100", |
434 | param); | 350 | param)) |
435 | IDataReader reader = result.ExecuteReader(); | 351 | { |
436 | 352 | using (IDataReader reader = result.ExecuteReader()) | |
437 | while (reader.Read()) | 353 | { |
438 | { | 354 | while (reader.Read()) |
439 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 355 | { |
440 | user.AvatarID = new UUID((string) reader["UUID"]); | 356 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
441 | user.firstName = (string) reader["username"]; | 357 | user.AvatarID = new UUID((string)reader["UUID"]); |
442 | user.lastName = (string) reader["lastname"]; | 358 | user.firstName = (string)reader["username"]; |
443 | returnlist.Add(user); | 359 | user.lastName = (string)reader["lastname"]; |
360 | returnlist.Add(user); | ||
361 | } | ||
362 | } | ||
363 | } | ||
444 | } | 364 | } |
445 | reader.Dispose(); | ||
446 | result.Dispose(); | ||
447 | } | 365 | } |
448 | catch (Exception e) | 366 | catch (Exception e) |
449 | { | 367 | { |
450 | dbm.Manager.Reconnect(); | 368 | m_log.Error(e.Message, e); |
451 | m_log.Error(e.ToString()); | ||
452 | return returnlist; | 369 | return returnlist; |
453 | } | 370 | } |
454 | finally | ||
455 | { | ||
456 | dbm.Release(); | ||
457 | } | ||
458 | } | 371 | } |
459 | else | 372 | else |
460 | { | 373 | { |
461 | MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); | ||
462 | |||
463 | try | 374 | try |
464 | { | 375 | { |
465 | Dictionary<string, object> param = new Dictionary<string, object>(); | 376 | Dictionary<string, object> param = new Dictionary<string, object>(); |
466 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | 377 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; |
467 | 378 | ||
468 | IDbCommand result = | 379 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
469 | dbm.Manager.Query( | 380 | { |
381 | dbcon.Open(); | ||
382 | |||
383 | using (IDbCommand result = m_database.Query(dbcon, | ||
470 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 384 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
471 | " WHERE username like ?first OR lastname like ?first LIMIT 100", | 385 | " WHERE username like ?first OR lastname like ?first LIMIT 100", |
472 | param); | 386 | param)) |
473 | IDataReader reader = result.ExecuteReader(); | 387 | { |
474 | 388 | using (IDataReader reader = result.ExecuteReader()) | |
475 | while (reader.Read()) | 389 | { |
476 | { | 390 | while (reader.Read()) |
477 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 391 | { |
478 | user.AvatarID = new UUID((string) reader["UUID"]); | 392 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
479 | user.firstName = (string) reader["username"]; | 393 | user.AvatarID = new UUID((string)reader["UUID"]); |
480 | user.lastName = (string) reader["lastname"]; | 394 | user.firstName = (string)reader["username"]; |
481 | returnlist.Add(user); | 395 | user.lastName = (string)reader["lastname"]; |
396 | returnlist.Add(user); | ||
397 | } | ||
398 | } | ||
399 | } | ||
482 | } | 400 | } |
483 | reader.Dispose(); | ||
484 | result.Dispose(); | ||
485 | } | 401 | } |
486 | catch (Exception e) | 402 | catch (Exception e) |
487 | { | 403 | { |
488 | dbm.Manager.Reconnect(); | 404 | m_log.Error(e.Message, e); |
489 | m_log.Error(e.ToString()); | ||
490 | return returnlist; | 405 | return returnlist; |
491 | } | 406 | } |
492 | finally | ||
493 | { | ||
494 | dbm.Release(); | ||
495 | } | ||
496 | } | 407 | } |
497 | return returnlist; | 408 | return returnlist; |
498 | } | 409 | } |
@@ -504,32 +415,30 @@ namespace OpenSim.Data.MySQL | |||
504 | /// <returns>User profile data</returns> | 415 | /// <returns>User profile data</returns> |
505 | public override UserProfileData GetUserByUUID(UUID uuid) | 416 | public override UserProfileData GetUserByUUID(UUID uuid) |
506 | { | 417 | { |
507 | MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); | ||
508 | try | 418 | try |
509 | { | 419 | { |
510 | Dictionary<string, object> param = new Dictionary<string, object>(); | 420 | Dictionary<string, object> param = new Dictionary<string, object>(); |
511 | param["?uuid"] = uuid.ToString(); | 421 | param["?uuid"] = uuid.ToString(); |
512 | 422 | ||
513 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); | 423 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
514 | IDataReader reader = result.ExecuteReader(); | 424 | { |
515 | 425 | dbcon.Open(); | |
516 | UserProfileData row = dbm.Manager.readUserRow(reader); | ||
517 | |||
518 | reader.Dispose(); | ||
519 | result.Dispose(); | ||
520 | 426 | ||
521 | return row; | 427 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) |
428 | { | ||
429 | using (IDataReader reader = result.ExecuteReader()) | ||
430 | { | ||
431 | UserProfileData row = m_database.readUserRow(reader); | ||
432 | return row; | ||
433 | } | ||
434 | } | ||
435 | } | ||
522 | } | 436 | } |
523 | catch (Exception e) | 437 | catch (Exception e) |
524 | { | 438 | { |
525 | dbm.Manager.Reconnect(); | 439 | m_log.Error(e.Message, e); |
526 | m_log.Error(e.ToString()); | ||
527 | return null; | 440 | return null; |
528 | } | 441 | } |
529 | finally | ||
530 | { | ||
531 | dbm.Release(); | ||
532 | } | ||
533 | } | 442 | } |
534 | 443 | ||
535 | /// <summary> | 444 | /// <summary> |
@@ -565,25 +474,18 @@ namespace OpenSim.Data.MySQL | |||
565 | param["?UUID"] = AgentID.ToString(); | 474 | param["?UUID"] = AgentID.ToString(); |
566 | param["?webLoginKey"] = WebLoginKey.ToString(); | 475 | param["?webLoginKey"] = WebLoginKey.ToString(); |
567 | 476 | ||
568 | MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey"); | ||
569 | |||
570 | try | 477 | try |
571 | { | 478 | { |
572 | dbm.Manager.ExecuteParameterizedSql( | 479 | m_database.ExecuteParameterizedSql( |
573 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + | 480 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + |
574 | "where UUID = ?UUID", | 481 | "where UUID = ?UUID", |
575 | param); | 482 | param); |
576 | } | 483 | } |
577 | catch (Exception e) | 484 | catch (Exception e) |
578 | { | 485 | { |
579 | dbm.Manager.Reconnect(); | 486 | m_log.Error(e.Message, e); |
580 | m_log.Error(e.ToString()); | ||
581 | return; | 487 | return; |
582 | } | 488 | } |
583 | finally | ||
584 | { | ||
585 | dbm.Release(); | ||
586 | } | ||
587 | } | 489 | } |
588 | 490 | ||
589 | /// <summary> | 491 | /// <summary> |
@@ -593,34 +495,30 @@ namespace OpenSim.Data.MySQL | |||
593 | /// <returns>The users session</returns> | 495 | /// <returns>The users session</returns> |
594 | public override UserAgentData GetAgentByUUID(UUID uuid) | 496 | public override UserAgentData GetAgentByUUID(UUID uuid) |
595 | { | 497 | { |
596 | MySQLSuperManager dbm = GetLockedConnection("GetAgentByUUID"); | ||
597 | |||
598 | try | 498 | try |
599 | { | 499 | { |
600 | Dictionary<string, object> param = new Dictionary<string, object>(); | 500 | Dictionary<string, object> param = new Dictionary<string, object>(); |
601 | param["?uuid"] = uuid.ToString(); | 501 | param["?uuid"] = uuid.ToString(); |
602 | 502 | ||
603 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", | 503 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
604 | param); | 504 | { |
605 | IDataReader reader = result.ExecuteReader(); | 505 | dbcon.Open(); |
606 | |||
607 | UserAgentData row = dbm.Manager.readAgentRow(reader); | ||
608 | |||
609 | reader.Dispose(); | ||
610 | result.Dispose(); | ||
611 | 506 | ||
612 | return row; | 507 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) |
508 | { | ||
509 | using (IDataReader reader = result.ExecuteReader()) | ||
510 | { | ||
511 | UserAgentData row = m_database.readAgentRow(reader); | ||
512 | return row; | ||
513 | } | ||
514 | } | ||
515 | } | ||
613 | } | 516 | } |
614 | catch (Exception e) | 517 | catch (Exception e) |
615 | { | 518 | { |
616 | dbm.Manager.Reconnect(); | 519 | m_log.Error(e.Message, e); |
617 | m_log.Error(e.ToString()); | ||
618 | return null; | 520 | return null; |
619 | } | 521 | } |
620 | finally | ||
621 | { | ||
622 | dbm.Release(); | ||
623 | } | ||
624 | } | 522 | } |
625 | 523 | ||
626 | /// <summary> | 524 | /// <summary> |
@@ -634,27 +532,22 @@ namespace OpenSim.Data.MySQL | |||
634 | { | 532 | { |
635 | return; | 533 | return; |
636 | } | 534 | } |
637 | MySQLSuperManager dbm = GetLockedConnection("AddNewUserProfile"); | ||
638 | 535 | ||
639 | try | 536 | try |
640 | { | 537 | { |
641 | dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 538 | m_database.insertUserRow( |
642 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 539 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
643 | user.HomeLocation.Z, | 540 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
644 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | 541 | user.HomeLocation.Z, |
645 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | 542 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, |
646 | user.CanDoMask, user.WantDoMask, | 543 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, |
647 | user.AboutText, user.FirstLifeAboutText, user.Image, | 544 | user.CanDoMask, user.WantDoMask, |
648 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | 545 | user.AboutText, user.FirstLifeAboutText, user.Image, |
546 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
649 | } | 547 | } |
650 | catch (Exception e) | 548 | catch (Exception e) |
651 | { | 549 | { |
652 | dbm.Manager.Reconnect(); | 550 | m_log.Error(e.Message, e); |
653 | m_log.Error(e.ToString()); | ||
654 | } | ||
655 | finally | ||
656 | { | ||
657 | dbm.Release(); | ||
658 | } | 551 | } |
659 | } | 552 | } |
660 | 553 | ||
@@ -668,19 +561,13 @@ namespace OpenSim.Data.MySQL | |||
668 | if (agent.ProfileID == zero || agent.SessionID == zero) | 561 | if (agent.ProfileID == zero || agent.SessionID == zero) |
669 | return; | 562 | return; |
670 | 563 | ||
671 | MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent"); | ||
672 | try | 564 | try |
673 | { | 565 | { |
674 | dbm.Manager.insertAgentRow(agent); | 566 | m_database.insertAgentRow(agent); |
675 | } | 567 | } |
676 | catch (Exception e) | 568 | catch (Exception e) |
677 | { | 569 | { |
678 | dbm.Manager.Reconnect(); | 570 | m_log.Error(e.Message, e); |
679 | m_log.Error(e.ToString()); | ||
680 | } | ||
681 | finally | ||
682 | { | ||
683 | dbm.Release(); | ||
684 | } | 571 | } |
685 | } | 572 | } |
686 | 573 | ||
@@ -690,24 +577,24 @@ namespace OpenSim.Data.MySQL | |||
690 | /// <param name="user">The profile data to use to update the DB</param> | 577 | /// <param name="user">The profile data to use to update the DB</param> |
691 | public override bool UpdateUserProfile(UserProfileData user) | 578 | public override bool UpdateUserProfile(UserProfileData user) |
692 | { | 579 | { |
693 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); | ||
694 | try | 580 | try |
695 | { | 581 | { |
696 | dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 582 | m_database.updateUserRow( |
697 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 583 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
698 | user.HomeLocation.Z, user.HomeLookAt.X, | 584 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
699 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, | 585 | user.HomeLocation.Z, user.HomeLookAt.X, |
700 | user.UserInventoryURI, | 586 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, |
701 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, | 587 | user.UserInventoryURI, |
702 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, | 588 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, |
703 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | 589 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, |
590 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
591 | |||
592 | return true; | ||
704 | } | 593 | } |
705 | finally | 594 | catch |
706 | { | 595 | { |
707 | dbm.Release(); | 596 | return false; |
708 | } | 597 | } |
709 | |||
710 | return true; | ||
711 | } | 598 | } |
712 | 599 | ||
713 | /// <summary> | 600 | /// <summary> |
@@ -742,41 +629,40 @@ namespace OpenSim.Data.MySQL | |||
742 | /// </summary> | 629 | /// </summary> |
743 | public override AvatarAppearance GetUserAppearance(UUID user) | 630 | public override AvatarAppearance GetUserAppearance(UUID user) |
744 | { | 631 | { |
745 | MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); | ||
746 | try | 632 | try |
747 | { | 633 | { |
748 | Dictionary<string, object> param = new Dictionary<string, object>(); | 634 | Dictionary<string, object> param = new Dictionary<string, object>(); |
749 | param["?owner"] = user.ToString(); | 635 | param["?owner"] = user.ToString(); |
750 | 636 | ||
751 | IDbCommand result = dbm.Manager.Query( | 637 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
752 | "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); | ||
753 | IDataReader reader = result.ExecuteReader(); | ||
754 | |||
755 | AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); | ||
756 | |||
757 | reader.Dispose(); | ||
758 | result.Dispose(); | ||
759 | |||
760 | if (null == appearance) | ||
761 | { | 638 | { |
762 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | 639 | dbcon.Open(); |
763 | return null; | ||
764 | } | ||
765 | |||
766 | appearance.SetAttachments(GetUserAttachments(user)); | ||
767 | 640 | ||
768 | return appearance; | 641 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) |
642 | { | ||
643 | using (IDataReader reader = result.ExecuteReader()) | ||
644 | { | ||
645 | AvatarAppearance appearance = m_database.readAppearanceRow(reader); | ||
646 | |||
647 | if (appearance == null) | ||
648 | { | ||
649 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | ||
650 | return null; | ||
651 | } | ||
652 | else | ||
653 | { | ||
654 | appearance.SetAttachments(GetUserAttachments(user)); | ||
655 | return appearance; | ||
656 | } | ||
657 | } | ||
658 | } | ||
659 | } | ||
769 | } | 660 | } |
770 | catch (Exception e) | 661 | catch (Exception e) |
771 | { | 662 | { |
772 | dbm.Manager.Reconnect(); | 663 | m_log.Error(e.Message, e); |
773 | m_log.Error(e.ToString()); | ||
774 | return null; | 664 | return null; |
775 | } | 665 | } |
776 | finally | ||
777 | { | ||
778 | dbm.Release(); | ||
779 | } | ||
780 | } | 666 | } |
781 | 667 | ||
782 | /// <summary> | 668 | /// <summary> |
@@ -787,22 +673,16 @@ namespace OpenSim.Data.MySQL | |||
787 | // override | 673 | // override |
788 | public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | 674 | public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) |
789 | { | 675 | { |
790 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserAppearance"); | ||
791 | try | 676 | try |
792 | { | 677 | { |
793 | appearance.Owner = user; | 678 | appearance.Owner = user; |
794 | dbm.Manager.insertAppearanceRow(appearance); | 679 | m_database.insertAppearanceRow(appearance); |
795 | 680 | ||
796 | UpdateUserAttachments(user, appearance.GetAttachments()); | 681 | UpdateUserAttachments(user, appearance.GetAttachments()); |
797 | } | 682 | } |
798 | catch (Exception e) | 683 | catch (Exception e) |
799 | { | 684 | { |
800 | dbm.Manager.Reconnect(); | 685 | m_log.Error(e.Message, e); |
801 | m_log.Error(e.ToString()); | ||
802 | } | ||
803 | finally | ||
804 | { | ||
805 | dbm.Release(); | ||
806 | } | 686 | } |
807 | } | 687 | } |
808 | 688 | ||
@@ -829,43 +709,33 @@ namespace OpenSim.Data.MySQL | |||
829 | Dictionary<string, object> param = new Dictionary<string, object>(); | 709 | Dictionary<string, object> param = new Dictionary<string, object>(); |
830 | param["?uuid"] = agentID.ToString(); | 710 | param["?uuid"] = agentID.ToString(); |
831 | 711 | ||
832 | MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); | ||
833 | |||
834 | try | 712 | try |
835 | { | 713 | { |
836 | IDbCommand result = dbm.Manager.Query( | 714 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
837 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); | 715 | { |
838 | IDataReader reader = result.ExecuteReader(); | 716 | dbcon.Open(); |
839 | |||
840 | Hashtable ret = dbm.Manager.readAttachments(reader); | ||
841 | 717 | ||
842 | reader.Dispose(); | 718 | using (IDbCommand result = m_database.Query(dbcon, |
843 | result.Dispose(); | 719 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) |
844 | return ret; | 720 | { |
721 | using (IDataReader reader = result.ExecuteReader()) | ||
722 | { | ||
723 | Hashtable ret = m_database.readAttachments(reader); | ||
724 | return ret; | ||
725 | } | ||
726 | } | ||
727 | } | ||
845 | } | 728 | } |
846 | catch (Exception e) | 729 | catch (Exception e) |
847 | { | 730 | { |
848 | dbm.Manager.Reconnect(); | 731 | m_log.Error(e.Message, e); |
849 | m_log.Error(e.ToString()); | ||
850 | return null; | 732 | return null; |
851 | } | 733 | } |
852 | finally | ||
853 | { | ||
854 | dbm.Release(); | ||
855 | } | ||
856 | } | 734 | } |
857 | 735 | ||
858 | public void UpdateUserAttachments(UUID agentID, Hashtable data) | 736 | public void UpdateUserAttachments(UUID agentID, Hashtable data) |
859 | { | 737 | { |
860 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserAttachments"); | 738 | m_database.writeAttachments(agentID, data); |
861 | try | ||
862 | { | ||
863 | dbm.Manager.writeAttachments(agentID, data); | ||
864 | } | ||
865 | finally | ||
866 | { | ||
867 | dbm.Release(); | ||
868 | } | ||
869 | } | 739 | } |
870 | 740 | ||
871 | public override void ResetAttachments(UUID userID) | 741 | public override void ResetAttachments(UUID userID) |
@@ -873,19 +743,10 @@ namespace OpenSim.Data.MySQL | |||
873 | Dictionary<string, string> param = new Dictionary<string, string>(); | 743 | Dictionary<string, string> param = new Dictionary<string, string>(); |
874 | param["?uuid"] = userID.ToString(); | 744 | param["?uuid"] = userID.ToString(); |
875 | 745 | ||
876 | MySQLSuperManager dbm = GetLockedConnection("ResetAttachments"); | 746 | m_database.ExecuteParameterizedSql( |
877 | 747 | "UPDATE " + m_attachmentsTableName + | |
878 | try | 748 | " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", |
879 | { | 749 | param); |
880 | dbm.Manager.ExecuteParameterizedSql( | ||
881 | "UPDATE " + m_attachmentsTableName + | ||
882 | " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", | ||
883 | param); | ||
884 | } | ||
885 | finally | ||
886 | { | ||
887 | dbm.Release(); | ||
888 | } | ||
889 | } | 750 | } |
890 | 751 | ||
891 | public override void LogoutUsers(UUID regionID) | 752 | public override void LogoutUsers(UUID regionID) |
@@ -893,25 +754,18 @@ namespace OpenSim.Data.MySQL | |||
893 | Dictionary<string, string> param = new Dictionary<string, string>(); | 754 | Dictionary<string, string> param = new Dictionary<string, string>(); |
894 | param["?regionID"] = regionID.ToString(); | 755 | param["?regionID"] = regionID.ToString(); |
895 | 756 | ||
896 | MySQLSuperManager dbm = GetLockedConnection("LogoutUsers"); | ||
897 | |||
898 | try | 757 | try |
899 | { | 758 | { |
900 | dbm.Manager.ExecuteParameterizedSql( | 759 | m_database.ExecuteParameterizedSql( |
901 | "update " + m_agentsTableName + " SET agentOnline = 0 " + | 760 | "update " + m_agentsTableName + " SET agentOnline = 0 " + |
902 | "where currentRegion = ?regionID", | 761 | "where currentRegion = ?regionID", |
903 | param); | 762 | param); |
904 | } | 763 | } |
905 | catch (Exception e) | 764 | catch (Exception e) |
906 | { | 765 | { |
907 | dbm.Manager.Reconnect(); | 766 | m_log.Error(e.Message, e); |
908 | m_log.Error(e.ToString()); | ||
909 | return; | 767 | return; |
910 | } | 768 | } |
911 | finally | ||
912 | { | ||
913 | dbm.Release(); | ||
914 | } | ||
915 | } | 769 | } |
916 | } | 770 | } |
917 | } | 771 | } |
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 0eebc9c..b5866cb 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs | |||
@@ -110,47 +110,58 @@ namespace OpenSim.Data.MySQL | |||
110 | 110 | ||
111 | public bool MoveItem(string id, string newParent) | 111 | public bool MoveItem(string id, string newParent) |
112 | { | 112 | { |
113 | MySqlCommand cmd = new MySqlCommand(); | 113 | using (MySqlCommand cmd = new MySqlCommand()) |
114 | { | ||
114 | 115 | ||
115 | cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); | 116 | cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); |
116 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); | 117 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); |
117 | cmd.Parameters.AddWithValue("?InventoryID", id); | 118 | cmd.Parameters.AddWithValue("?InventoryID", id); |
118 | 119 | ||
119 | return ExecuteNonQuery(cmd) == 0 ? false : true; | 120 | return ExecuteNonQuery(cmd) == 0 ? false : true; |
121 | } | ||
120 | } | 122 | } |
121 | 123 | ||
122 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 124 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
123 | { | 125 | { |
124 | MySqlCommand cmd = new MySqlCommand(); | 126 | using (MySqlCommand cmd = new MySqlCommand()) |
125 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); | 127 | { |
128 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); | ||
126 | 129 | ||
127 | cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); | 130 | cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); |
128 | cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | 131 | cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); |
129 | 132 | ||
130 | return DoQuery(cmd); | 133 | return DoQuery(cmd); |
134 | } | ||
131 | } | 135 | } |
132 | 136 | ||
133 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 137 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
134 | { | 138 | { |
135 | MySqlCommand cmd = new MySqlCommand(); | 139 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
136 | |||
137 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); | ||
138 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
139 | cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); | ||
140 | |||
141 | IDataReader reader = ExecuteReader(cmd); | ||
142 | |||
143 | int perms = 0; | ||
144 | |||
145 | if (reader.Read()) | ||
146 | { | 140 | { |
147 | perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); | 141 | dbcon.Open(); |
142 | |||
143 | using (MySqlCommand cmd = new MySqlCommand()) | ||
144 | { | ||
145 | cmd.Connection = dbcon; | ||
146 | |||
147 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); | ||
148 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
149 | cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); | ||
150 | |||
151 | using (IDataReader reader = cmd.ExecuteReader()) | ||
152 | { | ||
153 | |||
154 | int perms = 0; | ||
155 | |||
156 | if (reader.Read()) | ||
157 | { | ||
158 | perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); | ||
159 | } | ||
160 | |||
161 | return perms; | ||
162 | } | ||
163 | } | ||
148 | } | 164 | } |
149 | |||
150 | reader.Close(); | ||
151 | CloseReaderCommand(cmd); | ||
152 | |||
153 | return perms; | ||
154 | } | 165 | } |
155 | } | 166 | } |
156 | } | 167 | } |
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index d1d5c2a..8272316 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | |||
@@ -31,6 +31,7 @@ using OpenSim.Data.Tests; | |||
31 | using log4net; | 31 | using log4net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Tests.Common; |
34 | using MySql.Data.MySqlClient; | ||
34 | 35 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 36 | namespace OpenSim.Data.MySQL.Tests |
36 | { | 37 | { |
@@ -65,9 +66,13 @@ namespace OpenSim.Data.MySQL.Tests | |||
65 | 66 | ||
66 | // This actually does the roll forward assembly stuff | 67 | // This actually does the roll forward assembly stuff |
67 | Assembly assem = GetType().Assembly; | 68 | Assembly assem = GetType().Assembly; |
68 | Migration m = new Migration(database.Connection, assem, "GridStore"); | ||
69 | 69 | ||
70 | m.Update(); | 70 | using (MySqlConnection dbcon = new MySqlConnection(connect)) |
71 | { | ||
72 | dbcon.Open(); | ||
73 | Migration m = new Migration(dbcon, assem, "AssetStore"); | ||
74 | m.Update(); | ||
75 | } | ||
71 | } | 76 | } |
72 | 77 | ||
73 | [TestFixtureTearDown] | 78 | [TestFixtureTearDown] |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 23642b3..c52f60b 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Data.SQLite | |||
41 | /// </summary> | 41 | /// </summary> |
42 | public class SQLiteAssetData : AssetDataBase | 42 | public class SQLiteAssetData : AssetDataBase |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; | 46 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; |
47 | private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; | 47 | private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 6b67ec6..8e91693 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -39,9 +39,7 @@ namespace OpenSim.Data.SQLite | |||
39 | { | 39 | { |
40 | public class SQLiteGenericTableHandler<T> : SQLiteFramework where T: class, new() | 40 | public class SQLiteGenericTableHandler<T> : SQLiteFramework where T: class, new() |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | 43 | ||
46 | protected Dictionary<string, FieldInfo> m_Fields = | 44 | protected Dictionary<string, FieldInfo> m_Fields = |
47 | new Dictionary<string, FieldInfo>(); | 45 | new Dictionary<string, FieldInfo>(); |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 97625a7..5c93f88 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -41,8 +41,7 @@ namespace OpenSim.Data.SQLite | |||
41 | /// </summary> | 41 | /// </summary> |
42 | public class SQLiteXInventoryData : IXInventoryData | 42 | public class SQLiteXInventoryData : IXInventoryData |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger( | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | 45 | ||
47 | private SQLiteGenericTableHandler<XInventoryFolder> m_Folders; | 46 | private SQLiteGenericTableHandler<XInventoryFolder> m_Folders; |
48 | private SqliteItemHandler m_Items; | 47 | private SqliteItemHandler m_Items; |
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs new file mode 100644 index 0000000..ee7dec8 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs | |||
@@ -0,0 +1,755 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | |||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | |||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Framework.Communications.Clients | ||
43 | { | ||
44 | public class RegionClient | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) | ||
49 | { | ||
50 | reason = String.Empty; | ||
51 | |||
52 | // Eventually, we want to use a caps url instead of the agentID | ||
53 | string uri = string.Empty; | ||
54 | try | ||
55 | { | ||
56 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | ||
57 | } | ||
58 | catch (Exception e) | ||
59 | { | ||
60 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); | ||
61 | reason = e.Message; | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | ||
66 | |||
67 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
68 | AgentCreateRequest.Method = "POST"; | ||
69 | AgentCreateRequest.ContentType = "application/json"; | ||
70 | AgentCreateRequest.Timeout = 10000; | ||
71 | //AgentCreateRequest.KeepAlive = false; | ||
72 | AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
73 | |||
74 | // Fill it in | ||
75 | OSDMap args = null; | ||
76 | try | ||
77 | { | ||
78 | args = aCircuit.PackAgentCircuitData(); | ||
79 | } | ||
80 | catch (Exception e) | ||
81 | { | ||
82 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); | ||
83 | } | ||
84 | // Add the regionhandle of the destination region | ||
85 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
86 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
87 | args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); | ||
88 | |||
89 | string strBuffer = ""; | ||
90 | byte[] buffer = new byte[1]; | ||
91 | try | ||
92 | { | ||
93 | strBuffer = OSDParser.SerializeJsonString(args); | ||
94 | Encoding str = Util.UTF8; | ||
95 | buffer = str.GetBytes(strBuffer); | ||
96 | |||
97 | } | ||
98 | catch (Exception e) | ||
99 | { | ||
100 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
101 | // ignore. buffer will be empty, caller should check. | ||
102 | } | ||
103 | |||
104 | Stream os = null; | ||
105 | try | ||
106 | { // send the Post | ||
107 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
108 | os = AgentCreateRequest.GetRequestStream(); | ||
109 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
110 | //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); | ||
111 | } | ||
112 | //catch (WebException ex) | ||
113 | catch | ||
114 | { | ||
115 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
116 | reason = "cannot contact remote region"; | ||
117 | return false; | ||
118 | } | ||
119 | finally | ||
120 | { | ||
121 | if (os != null) | ||
122 | os.Close(); | ||
123 | } | ||
124 | |||
125 | // Let's wait for the response | ||
126 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
127 | |||
128 | WebResponse webResponse = null; | ||
129 | StreamReader sr = null; | ||
130 | try | ||
131 | { | ||
132 | webResponse = AgentCreateRequest.GetResponse(); | ||
133 | if (webResponse == null) | ||
134 | { | ||
135 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | |||
140 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
141 | string response = sr.ReadToEnd().Trim(); | ||
142 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); | ||
143 | |||
144 | if (!String.IsNullOrEmpty(response)) | ||
145 | { | ||
146 | try | ||
147 | { | ||
148 | // we assume we got an OSDMap back | ||
149 | OSDMap r = GetOSDMap(response); | ||
150 | bool success = r["success"].AsBoolean(); | ||
151 | reason = r["reason"].AsString(); | ||
152 | return success; | ||
153 | } | ||
154 | catch (NullReferenceException e) | ||
155 | { | ||
156 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
157 | |||
158 | // check for old style response | ||
159 | if (response.ToLower().StartsWith("true")) | ||
160 | return true; | ||
161 | |||
162 | return false; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | catch (WebException ex) | ||
168 | { | ||
169 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
170 | // ignore, really | ||
171 | } | ||
172 | finally | ||
173 | { | ||
174 | if (sr != null) | ||
175 | sr.Close(); | ||
176 | } | ||
177 | |||
178 | return true; | ||
179 | |||
180 | } | ||
181 | |||
182 | public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) | ||
183 | { | ||
184 | // Eventually, we want to use a caps url instead of the agentID | ||
185 | string uri = string.Empty; | ||
186 | try | ||
187 | { | ||
188 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); | ||
193 | return false; | ||
194 | } | ||
195 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | ||
196 | |||
197 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
198 | ChildUpdateRequest.Method = "PUT"; | ||
199 | ChildUpdateRequest.ContentType = "application/json"; | ||
200 | ChildUpdateRequest.Timeout = 10000; | ||
201 | //ChildUpdateRequest.KeepAlive = false; | ||
202 | |||
203 | // Fill it in | ||
204 | OSDMap args = null; | ||
205 | try | ||
206 | { | ||
207 | args = cAgentData.Pack(); | ||
208 | } | ||
209 | catch (Exception e) | ||
210 | { | ||
211 | m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); | ||
212 | } | ||
213 | // Add the regionhandle of the destination region | ||
214 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
215 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
216 | |||
217 | string strBuffer = ""; | ||
218 | byte[] buffer = new byte[1]; | ||
219 | try | ||
220 | { | ||
221 | strBuffer = OSDParser.SerializeJsonString(args); | ||
222 | Encoding str = Util.UTF8; | ||
223 | buffer = str.GetBytes(strBuffer); | ||
224 | |||
225 | } | ||
226 | catch (Exception e) | ||
227 | { | ||
228 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | ||
229 | // ignore. buffer will be empty, caller should check. | ||
230 | } | ||
231 | |||
232 | Stream os = null; | ||
233 | try | ||
234 | { // send the Post | ||
235 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
236 | os = ChildUpdateRequest.GetRequestStream(); | ||
237 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
238 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
239 | } | ||
240 | //catch (WebException ex) | ||
241 | catch | ||
242 | { | ||
243 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
244 | |||
245 | return false; | ||
246 | } | ||
247 | finally | ||
248 | { | ||
249 | if (os != null) | ||
250 | os.Close(); | ||
251 | } | ||
252 | |||
253 | // Let's wait for the response | ||
254 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); | ||
255 | |||
256 | WebResponse webResponse = null; | ||
257 | StreamReader sr = null; | ||
258 | try | ||
259 | { | ||
260 | webResponse = ChildUpdateRequest.GetResponse(); | ||
261 | if (webResponse == null) | ||
262 | { | ||
263 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); | ||
264 | } | ||
265 | |||
266 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
267 | //reply = sr.ReadToEnd().Trim(); | ||
268 | sr.ReadToEnd().Trim(); | ||
269 | sr.Close(); | ||
270 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
271 | |||
272 | } | ||
273 | catch (WebException ex) | ||
274 | { | ||
275 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); | ||
276 | // ignore, really | ||
277 | } | ||
278 | finally | ||
279 | { | ||
280 | if (sr != null) | ||
281 | sr.Close(); | ||
282 | } | ||
283 | |||
284 | return true; | ||
285 | } | ||
286 | |||
287 | public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) | ||
288 | { | ||
289 | agent = null; | ||
290 | // Eventually, we want to use a caps url instead of the agentID | ||
291 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
292 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
293 | |||
294 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
295 | request.Method = "GET"; | ||
296 | request.Timeout = 10000; | ||
297 | //request.Headers.Add("authorization", ""); // coming soon | ||
298 | |||
299 | HttpWebResponse webResponse = null; | ||
300 | string reply = string.Empty; | ||
301 | StreamReader sr = null; | ||
302 | try | ||
303 | { | ||
304 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
305 | if (webResponse == null) | ||
306 | { | ||
307 | m_log.Info("[REST COMMS]: Null reply on agent get "); | ||
308 | } | ||
309 | |||
310 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
311 | reply = sr.ReadToEnd().Trim(); | ||
312 | |||
313 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | ||
314 | |||
315 | } | ||
316 | catch (WebException ex) | ||
317 | { | ||
318 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | ||
319 | // ignore, really | ||
320 | return false; | ||
321 | } | ||
322 | finally | ||
323 | { | ||
324 | if (sr != null) | ||
325 | sr.Close(); | ||
326 | } | ||
327 | |||
328 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
329 | { | ||
330 | // we know it's jason | ||
331 | OSDMap args = GetOSDMap(reply); | ||
332 | if (args == null) | ||
333 | { | ||
334 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); | ||
335 | return false; | ||
336 | } | ||
337 | |||
338 | agent = new CompleteAgentData(); | ||
339 | agent.Unpack(args); | ||
340 | return true; | ||
341 | } | ||
342 | |||
343 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
344 | return false; | ||
345 | } | ||
346 | |||
347 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) | ||
348 | { | ||
349 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); | ||
350 | |||
351 | WebRequest request = WebRequest.Create(uri); | ||
352 | request.Method = "DELETE"; | ||
353 | request.Timeout = 10000; | ||
354 | |||
355 | StreamReader sr = null; | ||
356 | try | ||
357 | { | ||
358 | WebResponse webResponse = request.GetResponse(); | ||
359 | if (webResponse == null) | ||
360 | { | ||
361 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
362 | } | ||
363 | |||
364 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
365 | //reply = sr.ReadToEnd().Trim(); | ||
366 | sr.ReadToEnd().Trim(); | ||
367 | sr.Close(); | ||
368 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
369 | |||
370 | } | ||
371 | catch (WebException ex) | ||
372 | { | ||
373 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
374 | // ignore, really | ||
375 | } | ||
376 | finally | ||
377 | { | ||
378 | if (sr != null) | ||
379 | sr.Close(); | ||
380 | } | ||
381 | |||
382 | return true; | ||
383 | } | ||
384 | |||
385 | |||
386 | public bool DoCloseAgentCall(GridRegion region, UUID id) | ||
387 | { | ||
388 | string uri = string.Empty; | ||
389 | try | ||
390 | { | ||
391 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
392 | } | ||
393 | catch (Exception e) | ||
394 | { | ||
395 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); | ||
396 | return false; | ||
397 | } | ||
398 | |||
399 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); | ||
400 | |||
401 | WebRequest request = WebRequest.Create(uri); | ||
402 | request.Method = "DELETE"; | ||
403 | request.Timeout = 10000; | ||
404 | |||
405 | StreamReader sr = null; | ||
406 | try | ||
407 | { | ||
408 | WebResponse webResponse = request.GetResponse(); | ||
409 | if (webResponse == null) | ||
410 | { | ||
411 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
412 | } | ||
413 | |||
414 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
415 | //reply = sr.ReadToEnd().Trim(); | ||
416 | sr.ReadToEnd().Trim(); | ||
417 | sr.Close(); | ||
418 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
419 | |||
420 | } | ||
421 | catch (WebException ex) | ||
422 | { | ||
423 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
424 | // ignore, really | ||
425 | } | ||
426 | finally | ||
427 | { | ||
428 | if (sr != null) | ||
429 | sr.Close(); | ||
430 | } | ||
431 | |||
432 | return true; | ||
433 | } | ||
434 | |||
435 | public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) | ||
436 | { | ||
437 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
438 | string uri | ||
439 | = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort | ||
440 | + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; | ||
441 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
442 | |||
443 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
444 | ObjectCreateRequest.Method = "POST"; | ||
445 | ObjectCreateRequest.ContentType = "application/json"; | ||
446 | ObjectCreateRequest.Timeout = 10000; | ||
447 | |||
448 | OSDMap args = new OSDMap(2); | ||
449 | args["sog"] = OSD.FromString(sogXml2); | ||
450 | args["extra"] = OSD.FromString(sog.ExtraToXmlString()); | ||
451 | if (allowScriptCrossing) | ||
452 | { | ||
453 | string state = sog.GetStateSnapshot(); | ||
454 | if (state.Length > 0) | ||
455 | args["state"] = OSD.FromString(state); | ||
456 | } | ||
457 | |||
458 | string strBuffer = ""; | ||
459 | byte[] buffer = new byte[1]; | ||
460 | try | ||
461 | { | ||
462 | strBuffer = OSDParser.SerializeJsonString(args); | ||
463 | Encoding str = Util.UTF8; | ||
464 | buffer = str.GetBytes(strBuffer); | ||
465 | |||
466 | } | ||
467 | catch (Exception e) | ||
468 | { | ||
469 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
470 | // ignore. buffer will be empty, caller should check. | ||
471 | } | ||
472 | |||
473 | Stream os = null; | ||
474 | try | ||
475 | { // send the Post | ||
476 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
477 | os = ObjectCreateRequest.GetRequestStream(); | ||
478 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
479 | m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
480 | } | ||
481 | //catch (WebException ex) | ||
482 | catch | ||
483 | { | ||
484 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
485 | |||
486 | return false; | ||
487 | } | ||
488 | finally | ||
489 | { | ||
490 | if (os != null) | ||
491 | os.Close(); | ||
492 | } | ||
493 | |||
494 | // Let's wait for the response | ||
495 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
496 | |||
497 | StreamReader sr = null; | ||
498 | try | ||
499 | { | ||
500 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
501 | if (webResponse == null) | ||
502 | { | ||
503 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
504 | } | ||
505 | |||
506 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
507 | //reply = sr.ReadToEnd().Trim(); | ||
508 | sr.ReadToEnd().Trim(); | ||
509 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
510 | |||
511 | } | ||
512 | catch (WebException ex) | ||
513 | { | ||
514 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
515 | // ignore, really | ||
516 | } | ||
517 | finally | ||
518 | { | ||
519 | if (sr != null) | ||
520 | sr.Close(); | ||
521 | } | ||
522 | |||
523 | return true; | ||
524 | |||
525 | } | ||
526 | |||
527 | public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) | ||
528 | { | ||
529 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
530 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; | ||
531 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
532 | |||
533 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
534 | ObjectCreateRequest.Method = "PUT"; | ||
535 | ObjectCreateRequest.ContentType = "application/json"; | ||
536 | ObjectCreateRequest.Timeout = 10000; | ||
537 | |||
538 | OSDMap args = new OSDMap(2); | ||
539 | args["userid"] = OSD.FromUUID(userID); | ||
540 | args["itemid"] = OSD.FromUUID(itemID); | ||
541 | |||
542 | string strBuffer = ""; | ||
543 | byte[] buffer = new byte[1]; | ||
544 | try | ||
545 | { | ||
546 | strBuffer = OSDParser.SerializeJsonString(args); | ||
547 | Encoding str = Util.UTF8; | ||
548 | buffer = str.GetBytes(strBuffer); | ||
549 | |||
550 | } | ||
551 | catch (Exception e) | ||
552 | { | ||
553 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
554 | // ignore. buffer will be empty, caller should check. | ||
555 | } | ||
556 | |||
557 | Stream os = null; | ||
558 | try | ||
559 | { // send the Post | ||
560 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
561 | os = ObjectCreateRequest.GetRequestStream(); | ||
562 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
563 | //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); | ||
564 | } | ||
565 | //catch (WebException ex) | ||
566 | catch | ||
567 | { | ||
568 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
569 | |||
570 | return false; | ||
571 | } | ||
572 | finally | ||
573 | { | ||
574 | if (os != null) | ||
575 | os.Close(); | ||
576 | } | ||
577 | |||
578 | // Let's wait for the response | ||
579 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
580 | |||
581 | StreamReader sr = null; | ||
582 | try | ||
583 | { | ||
584 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
585 | if (webResponse == null) | ||
586 | { | ||
587 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
588 | } | ||
589 | |||
590 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
591 | sr.ReadToEnd().Trim(); | ||
592 | sr.ReadToEnd().Trim(); | ||
593 | |||
594 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
595 | |||
596 | } | ||
597 | catch (WebException ex) | ||
598 | { | ||
599 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
600 | // ignore, really | ||
601 | } | ||
602 | finally | ||
603 | { | ||
604 | if (sr != null) | ||
605 | sr.Close(); | ||
606 | } | ||
607 | |||
608 | return true; | ||
609 | |||
610 | } | ||
611 | |||
612 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) | ||
613 | { | ||
614 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | ||
615 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | ||
616 | |||
617 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); | ||
618 | HelloNeighbourRequest.Method = "POST"; | ||
619 | HelloNeighbourRequest.ContentType = "application/json"; | ||
620 | HelloNeighbourRequest.Timeout = 10000; | ||
621 | |||
622 | // Fill it in | ||
623 | OSDMap args = null; | ||
624 | try | ||
625 | { | ||
626 | args = thisRegion.PackRegionInfoData(); | ||
627 | } | ||
628 | catch (Exception e) | ||
629 | { | ||
630 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); | ||
631 | } | ||
632 | // Add the regionhandle of the destination region | ||
633 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
634 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
635 | |||
636 | string strBuffer = ""; | ||
637 | byte[] buffer = new byte[1]; | ||
638 | try | ||
639 | { | ||
640 | strBuffer = OSDParser.SerializeJsonString(args); | ||
641 | Encoding str = Util.UTF8; | ||
642 | buffer = str.GetBytes(strBuffer); | ||
643 | |||
644 | } | ||
645 | catch (Exception e) | ||
646 | { | ||
647 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); | ||
648 | // ignore. buffer will be empty, caller should check. | ||
649 | } | ||
650 | |||
651 | Stream os = null; | ||
652 | try | ||
653 | { // send the Post | ||
654 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send | ||
655 | os = HelloNeighbourRequest.GetRequestStream(); | ||
656 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
657 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); | ||
658 | } | ||
659 | //catch (WebException ex) | ||
660 | catch | ||
661 | { | ||
662 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); | ||
663 | |||
664 | return false; | ||
665 | } | ||
666 | finally | ||
667 | { | ||
668 | if (os != null) | ||
669 | os.Close(); | ||
670 | } | ||
671 | // Let's wait for the response | ||
672 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | ||
673 | |||
674 | StreamReader sr = null; | ||
675 | try | ||
676 | { | ||
677 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | ||
678 | if (webResponse == null) | ||
679 | { | ||
680 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | ||
681 | } | ||
682 | |||
683 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
684 | //reply = sr.ReadToEnd().Trim(); | ||
685 | sr.ReadToEnd().Trim(); | ||
686 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | ||
687 | |||
688 | } | ||
689 | catch (WebException ex) | ||
690 | { | ||
691 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | ||
692 | // ignore, really | ||
693 | } | ||
694 | finally | ||
695 | { | ||
696 | if (sr != null) | ||
697 | sr.Close(); | ||
698 | } | ||
699 | |||
700 | return true; | ||
701 | |||
702 | } | ||
703 | |||
704 | #region Hyperlinks | ||
705 | |||
706 | public virtual ulong GetRegionHandle(ulong handle) | ||
707 | { | ||
708 | return handle; | ||
709 | } | ||
710 | |||
711 | public virtual bool IsHyperlink(ulong handle) | ||
712 | { | ||
713 | return false; | ||
714 | } | ||
715 | |||
716 | public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
717 | { | ||
718 | } | ||
719 | |||
720 | public virtual void AdjustUserInformation(AgentCircuitData aCircuit) | ||
721 | { | ||
722 | } | ||
723 | |||
724 | #endregion /* Hyperlinks */ | ||
725 | |||
726 | public static OSDMap GetOSDMap(string data) | ||
727 | { | ||
728 | OSDMap args = null; | ||
729 | try | ||
730 | { | ||
731 | OSD buffer; | ||
732 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
733 | buffer = OSDParser.DeserializeJson(data); | ||
734 | if (buffer.Type == OSDType.Map) | ||
735 | { | ||
736 | args = (OSDMap)buffer; | ||
737 | return args; | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | // uh? | ||
742 | System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); | ||
743 | return null; | ||
744 | } | ||
745 | } | ||
746 | catch (Exception ex) | ||
747 | { | ||
748 | System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); | ||
749 | return null; | ||
750 | } | ||
751 | } | ||
752 | |||
753 | |||
754 | } | ||
755 | } | ||
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 0a51266..b70d1db 100644..100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Framework.Console | |||
73 | 73 | ||
74 | public virtual void Output(string text) | 74 | public virtual void Output(string text) |
75 | { | 75 | { |
76 | System.Console.Write(text); | 76 | System.Console.WriteLine(text); |
77 | } | 77 | } |
78 | 78 | ||
79 | public string CmdPrompt(string p) | 79 | public string CmdPrompt(string p) |
diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs index a2f31ea..f4d3687 100644..100755 --- a/OpenSim/Framework/Console/ConsolePluginCommand.cs +++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs | |||
@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Console | |||
124 | /// </summary> | 124 | /// </summary> |
125 | public void ShowHelp(ConsoleBase console) | 125 | public void ShowHelp(ConsoleBase console) |
126 | { | 126 | { |
127 | console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText); | 127 | console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText + "\n"); |
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index c27072c..9fdd1b8 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -302,6 +302,12 @@ namespace OpenSim.Framework.Console | |||
302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) | 302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) |
303 | return reply; | 303 | return reply; |
304 | 304 | ||
305 | lock(m_Connections) | ||
306 | { | ||
307 | if(!m_Connections.ContainsKey(id)) | ||
308 | return reply; | ||
309 | } | ||
310 | |||
305 | if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty) | 311 | if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty) |
306 | return reply; | 312 | return reply; |
307 | 313 | ||
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 10ff57d..693aedc 100644..100755 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -409,7 +409,7 @@ namespace OpenSim | |||
409 | if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && | 409 | if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && |
410 | presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) | 410 | presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) |
411 | { | 411 | { |
412 | m_log.Info( | 412 | MainConsole.Instance.Output( |
413 | String.Format( | 413 | String.Format( |
414 | "Kicking user: {0,-16}{1,-16}{2,-37} in region: {3,-16}", | 414 | "Kicking user: {0,-16}{1,-16}{2,-37} in region: {3,-16}", |
415 | presence.Firstname, presence.Lastname, presence.UUID, regionInfo.RegionName)); | 415 | presence.Firstname, presence.Lastname, presence.UUID, regionInfo.RegionName)); |
@@ -424,7 +424,7 @@ namespace OpenSim | |||
424 | presence.Scene.IncomingCloseAgent(presence.UUID); | 424 | presence.Scene.IncomingCloseAgent(presence.UUID); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | m_log.Info(""); | 427 | MainConsole.Instance.Output(""); |
428 | } | 428 | } |
429 | 429 | ||
430 | /// <summary> | 430 | /// <summary> |
@@ -471,7 +471,7 @@ namespace OpenSim | |||
471 | 471 | ||
472 | private void HandleClearAssets(string module, string[] args) | 472 | private void HandleClearAssets(string module, string[] args) |
473 | { | 473 | { |
474 | m_log.Info("Not implemented."); | 474 | MainConsole.Instance.Output("Not implemented."); |
475 | } | 475 | } |
476 | 476 | ||
477 | /// <summary> | 477 | /// <summary> |
@@ -481,7 +481,7 @@ namespace OpenSim | |||
481 | /// <param name="args"></param> | 481 | /// <param name="args"></param> |
482 | private void HandleForceUpdate(string module, string[] args) | 482 | private void HandleForceUpdate(string module, string[] args) |
483 | { | 483 | { |
484 | m_log.Info("Updating all clients"); | 484 | MainConsole.Instance.Output("Updating all clients"); |
485 | m_sceneManager.ForceCurrentSceneClientUpdate(); | 485 | m_sceneManager.ForceCurrentSceneClientUpdate(); |
486 | } | 486 | } |
487 | 487 | ||
@@ -498,7 +498,7 @@ namespace OpenSim | |||
498 | } | 498 | } |
499 | else | 499 | else |
500 | { | 500 | { |
501 | m_log.Info("Argument error: edit scale <prim name> <x> <y> <z>"); | 501 | MainConsole.Instance.Output("Argument error: edit scale <prim name> <x> <y> <z>"); |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
@@ -511,7 +511,7 @@ namespace OpenSim | |||
511 | { | 511 | { |
512 | if (cmd.Length < 4) | 512 | if (cmd.Length < 4) |
513 | { | 513 | { |
514 | m_log.Error("Usage: create region <region name> <region_file.ini>"); | 514 | MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); |
515 | return; | 515 | return; |
516 | } | 516 | } |
517 | if (cmd[3].EndsWith(".xml")) | 517 | if (cmd[3].EndsWith(".xml")) |
@@ -538,7 +538,7 @@ namespace OpenSim | |||
538 | } | 538 | } |
539 | else | 539 | else |
540 | { | 540 | { |
541 | m_log.Error("Usage: create region <region name> <region_file.ini>"); | 541 | MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | } | 544 | } |
@@ -562,8 +562,8 @@ namespace OpenSim | |||
562 | case "set": | 562 | case "set": |
563 | if (cmdparams.Length < 4) | 563 | if (cmdparams.Length < 4) |
564 | { | 564 | { |
565 | m_log.Error("SYNTAX: " + n + " SET SECTION KEY VALUE"); | 565 | MainConsole.Instance.Output(String.Format("SYNTAX: {0} SET SECTION KEY VALUE",n)); |
566 | m_log.Error("EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); | 566 | MainConsole.Instance.Output(String.Format("EXAMPLE: {0} SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5",n)); |
567 | } | 567 | } |
568 | else | 568 | else |
569 | { | 569 | { |
@@ -576,8 +576,7 @@ namespace OpenSim | |||
576 | c.Set(cmdparams[2], _value); | 576 | c.Set(cmdparams[2], _value); |
577 | m_config.Source.Merge(source); | 577 | m_config.Source.Merge(source); |
578 | 578 | ||
579 | m_log.Error(n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + | 579 | MainConsole.Instance.Output(String.Format("{0} {0} {1} {2} {3}",n,cmdparams[1],cmdparams[2],_value)); |
580 | _value); | ||
581 | } | 580 | } |
582 | } | 581 | } |
583 | break; | 582 | break; |
@@ -585,21 +584,21 @@ namespace OpenSim | |||
585 | case "get": | 584 | case "get": |
586 | if (cmdparams.Length < 3) | 585 | if (cmdparams.Length < 3) |
587 | { | 586 | { |
588 | m_log.Error("SYNTAX: " + n + " GET SECTION KEY"); | 587 | MainConsole.Instance.Output(String.Format("SYNTAX: {0} GET SECTION KEY",n)); |
589 | m_log.Error("EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); | 588 | MainConsole.Instance.Output(String.Format("EXAMPLE: {0} GET ScriptEngine.DotNetEngine NumberOfScriptThreads",n)); |
590 | } | 589 | } |
591 | else | 590 | else |
592 | { | 591 | { |
593 | IConfig c = m_config.Source.Configs[cmdparams[1]]; | 592 | IConfig c = m_config.Source.Configs[cmdparams[1]]; |
594 | if (c == null) | 593 | if (c == null) |
595 | { | 594 | { |
596 | m_log.Info("Section \"" + cmdparams[1] + "\" does not exist."); | 595 | MainConsole.Instance.Output(String.Format("Section \"{0}\" does not exist.",cmdparams[1])); |
597 | break; | 596 | break; |
598 | } | 597 | } |
599 | else | 598 | else |
600 | { | 599 | { |
601 | m_log.Info(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + | 600 | MainConsole.Instance.Output(String.Format("{0} GET {1} {2} : {3}",n,cmdparams[1],cmdparams[2], |
602 | c.GetString(cmdparams[2])); | 601 | c.GetString(cmdparams[2]))); |
603 | } | 602 | } |
604 | } | 603 | } |
605 | 604 | ||
@@ -608,17 +607,17 @@ namespace OpenSim | |||
608 | case "save": | 607 | case "save": |
609 | if (cmdparams.Length < 2) | 608 | if (cmdparams.Length < 2) |
610 | { | 609 | { |
611 | m_log.Error("SYNTAX: " + n + " SAVE FILE"); | 610 | MainConsole.Instance.Output("SYNTAX: " + n + " SAVE FILE"); |
612 | return; | 611 | return; |
613 | } | 612 | } |
614 | 613 | ||
615 | if (Application.iniFilePath == cmdparams[1]) | 614 | if (Application.iniFilePath == cmdparams[1]) |
616 | { | 615 | { |
617 | m_log.Error("FILE can not be "+Application.iniFilePath); | 616 | MainConsole.Instance.Output("FILE can not be " + Application.iniFilePath); |
618 | return; | 617 | return; |
619 | } | 618 | } |
620 | 619 | ||
621 | m_log.Info("Saving configuration file: " + cmdparams[1]); | 620 | MainConsole.Instance.Output("Saving configuration file: " + cmdparams[1]); |
622 | m_config.Save(cmdparams[1]); | 621 | m_config.Save(cmdparams[1]); |
623 | break; | 622 | break; |
624 | } | 623 | } |
@@ -644,7 +643,7 @@ namespace OpenSim | |||
644 | case "list": | 643 | case "list": |
645 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) | 644 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) |
646 | { | 645 | { |
647 | m_log.Info("Shared region module: " + irm.Name); | 646 | MainConsole.Instance.Output(String.Format("Shared region module: {0}", irm.Name)); |
648 | } | 647 | } |
649 | break; | 648 | break; |
650 | case "unload": | 649 | case "unload": |
@@ -654,7 +653,7 @@ namespace OpenSim | |||
654 | { | 653 | { |
655 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) | 654 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) |
656 | { | 655 | { |
657 | m_log.Info("Unloading module: " + rm.Name); | 656 | MainConsole.Instance.Output(String.Format("Unloading module: {0}", rm.Name)); |
658 | m_moduleLoader.UnloadModule(rm); | 657 | m_moduleLoader.UnloadModule(rm); |
659 | } | 658 | } |
660 | } | 659 | } |
@@ -665,7 +664,7 @@ namespace OpenSim | |||
665 | { | 664 | { |
666 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) | 665 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) |
667 | { | 666 | { |
668 | m_log.Info("Loading module: " + cmdparams[1]); | 667 | MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1])); |
669 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); | 668 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); |
670 | } | 669 | } |
671 | } | 670 | } |
@@ -710,7 +709,7 @@ namespace OpenSim | |||
710 | if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) | 709 | if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) |
711 | RemoveRegion(removeScene, false); | 710 | RemoveRegion(removeScene, false); |
712 | else | 711 | else |
713 | m_log.Error("no region with that name"); | 712 | MainConsole.Instance.Output("no region with that name"); |
714 | break; | 713 | break; |
715 | 714 | ||
716 | case "delete-region": | 715 | case "delete-region": |
@@ -720,7 +719,7 @@ namespace OpenSim | |||
720 | if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) | 719 | if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) |
721 | RemoveRegion(killScene, true); | 720 | RemoveRegion(killScene, true); |
722 | else | 721 | else |
723 | m_log.Error("no region with that name"); | 722 | MainConsole.Instance.Output("no region with that name"); |
724 | break; | 723 | break; |
725 | 724 | ||
726 | case "restart": | 725 | case "restart": |
@@ -730,7 +729,7 @@ namespace OpenSim | |||
730 | case "Add-InventoryHost": | 729 | case "Add-InventoryHost": |
731 | if (cmdparams.Length > 0) | 730 | if (cmdparams.Length > 0) |
732 | { | 731 | { |
733 | m_log.Info("Not implemented."); | 732 | MainConsole.Instance.Output("Not implemented."); |
734 | } | 733 | } |
735 | break; | 734 | break; |
736 | 735 | ||
@@ -748,20 +747,19 @@ namespace OpenSim | |||
748 | string newRegionName = CombineParams(cmdparams, 2); | 747 | string newRegionName = CombineParams(cmdparams, 2); |
749 | 748 | ||
750 | if (!m_sceneManager.TrySetCurrentScene(newRegionName)) | 749 | if (!m_sceneManager.TrySetCurrentScene(newRegionName)) |
751 | m_log.Error("Couldn't select region " + newRegionName); | 750 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); |
752 | } | 751 | } |
753 | else | 752 | else |
754 | { | 753 | { |
755 | m_log.Error("Usage: change region <region name>"); | 754 | MainConsole.Instance.Output("Usage: change region <region name>"); |
756 | } | 755 | } |
757 | 756 | ||
758 | string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); | 757 | string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); |
759 | m_log.Info(String.Format("Currently selected region is {0}", regionName)); | 758 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); |
760 | m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName); | 759 | m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName); |
761 | m_console.ConsoleScene = m_sceneManager.CurrentScene; | 760 | m_console.ConsoleScene = m_sceneManager.CurrentScene; |
762 | } | 761 | } |
763 | 762 | ||
764 | |||
765 | /// <summary> | 763 | /// <summary> |
766 | /// Turn on some debugging values for OpenSim. | 764 | /// Turn on some debugging values for OpenSim. |
767 | /// </summary> | 765 | /// </summary> |
@@ -783,9 +781,9 @@ namespace OpenSim | |||
783 | } | 781 | } |
784 | else | 782 | else |
785 | { | 783 | { |
786 | m_log.Error("packet debug should be 0..255"); | 784 | MainConsole.Instance.Output("packet debug should be 0..255"); |
787 | } | 785 | } |
788 | m_log.Info("New packet debug: " + newDebug.ToString()); | 786 | MainConsole.Instance.Output(String.Format("New packet debug: {0}", newDebug)); |
789 | } | 787 | } |
790 | 788 | ||
791 | break; | 789 | break; |
@@ -795,7 +793,7 @@ namespace OpenSim | |||
795 | { | 793 | { |
796 | if (m_sceneManager.CurrentScene == null) | 794 | if (m_sceneManager.CurrentScene == null) |
797 | { | 795 | { |
798 | m_log.Info("Please use 'change region <regioname>' first"); | 796 | MainConsole.Instance.Output("Please use 'change region <regioname>' first"); |
799 | } | 797 | } |
800 | else | 798 | else |
801 | { | 799 | { |
@@ -804,7 +802,7 @@ namespace OpenSim | |||
804 | bool physicsOn = !Convert.ToBoolean(args[4]); | 802 | bool physicsOn = !Convert.ToBoolean(args[4]); |
805 | m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); | 803 | m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); |
806 | 804 | ||
807 | m_log.Info( | 805 | MainConsole.Instance.Output( |
808 | String.Format( | 806 | String.Format( |
809 | "Set debug scene scripting = {0}, collisions = {1}, physics = {2}", | 807 | "Set debug scene scripting = {0}, collisions = {1}, physics = {2}", |
810 | !scriptingOn, !collisionsOn, !physicsOn)); | 808 | !scriptingOn, !collisionsOn, !physicsOn)); |
@@ -812,13 +810,13 @@ namespace OpenSim | |||
812 | } | 810 | } |
813 | else | 811 | else |
814 | { | 812 | { |
815 | m_log.Error("debug scene <scripting> <collisions> <physics> (where inside <> is true/false)"); | 813 | MainConsole.Instance.Output("debug scene <scripting> <collisions> <physics> (where inside <> is true/false)"); |
816 | } | 814 | } |
817 | 815 | ||
818 | break; | 816 | break; |
819 | 817 | ||
820 | default: | 818 | default: |
821 | m_log.Error("Unknown debug"); | 819 | MainConsole.Instance.Output("Unknown debug"); |
822 | break; | 820 | break; |
823 | } | 821 | } |
824 | } | 822 | } |
@@ -840,7 +838,7 @@ namespace OpenSim | |||
840 | switch (showParams[0]) | 838 | switch (showParams[0]) |
841 | { | 839 | { |
842 | case "assets": | 840 | case "assets": |
843 | m_log.Info("Not implemented."); | 841 | MainConsole.Instance.Output("Not implemented."); |
844 | break; | 842 | break; |
845 | 843 | ||
846 | case "users": | 844 | case "users": |
@@ -854,9 +852,9 @@ namespace OpenSim | |||
854 | agents = m_sceneManager.GetCurrentSceneAvatars(); | 852 | agents = m_sceneManager.GetCurrentSceneAvatars(); |
855 | } | 853 | } |
856 | 854 | ||
857 | m_log.Info(String.Format("\nAgents connected: {0}\n", agents.Count)); | 855 | MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count)); |
858 | 856 | ||
859 | m_log.Info( | 857 | MainConsole.Instance.Output( |
860 | String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", "Firstname", "Lastname", | 858 | String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", "Firstname", "Lastname", |
861 | "Agent ID", "Root/Child", "Region", "Position")); | 859 | "Agent ID", "Root/Child", "Region", "Position")); |
862 | 860 | ||
@@ -874,7 +872,7 @@ namespace OpenSim | |||
874 | regionName = regionInfo.RegionName; | 872 | regionName = regionInfo.RegionName; |
875 | } | 873 | } |
876 | 874 | ||
877 | m_log.Info( | 875 | MainConsole.Instance.Output( |
878 | String.Format( | 876 | String.Format( |
879 | "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", | 877 | "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", |
880 | presence.Firstname, | 878 | presence.Firstname, |
@@ -885,7 +883,7 @@ namespace OpenSim | |||
885 | presence.AbsolutePosition.ToString())); | 883 | presence.AbsolutePosition.ToString())); |
886 | } | 884 | } |
887 | 885 | ||
888 | m_log.Info(String.Empty); | 886 | MainConsole.Instance.Output(String.Empty); |
889 | break; | 887 | break; |
890 | 888 | ||
891 | case "connections": | 889 | case "connections": |
@@ -903,25 +901,30 @@ namespace OpenSim | |||
903 | } | 901 | } |
904 | ); | 902 | ); |
905 | 903 | ||
906 | m_log.Info(connections.ToString()); | 904 | MainConsole.Instance.Output(connections.ToString()); |
907 | break; | 905 | break; |
908 | 906 | ||
909 | case "modules": | 907 | case "modules": |
910 | m_log.Info("The currently loaded shared modules are:"); | 908 | MainConsole.Instance.Output("The currently loaded shared modules are:"); |
911 | foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) | 909 | foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) |
912 | { | 910 | { |
913 | m_log.Info("Shared Module: " + module.Name); | 911 | MainConsole.Instance.Output("Shared Module: " + module.Name); |
914 | } | 912 | } |
913 | |||
914 | MainConsole.Instance.Output(""); | ||
915 | break; | 915 | break; |
916 | 916 | ||
917 | case "regions": | 917 | case "regions": |
918 | m_sceneManager.ForEachScene( | 918 | m_sceneManager.ForEachScene( |
919 | delegate(Scene scene) | 919 | delegate(Scene scene) |
920 | { | 920 | { |
921 | m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + | 921 | MainConsole.Instance.Output(String.Format( |
922 | scene.RegionInfo.RegionLocX + " , Region YLoc: " + | 922 | "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}", |
923 | scene.RegionInfo.RegionLocY + " , Region Port: " + | 923 | scene.RegionInfo.RegionName, |
924 | scene.RegionInfo.InternalEndPoint.Port.ToString()); | 924 | scene.RegionInfo.RegionLocX, |
925 | scene.RegionInfo.RegionLocY, | ||
926 | scene.RegionInfo.InternalEndPoint.Port)); | ||
927 | |||
925 | }); | 928 | }); |
926 | break; | 929 | break; |
927 | 930 | ||
@@ -946,8 +949,10 @@ namespace OpenSim | |||
946 | { | 949 | { |
947 | rating = "PG"; | 950 | rating = "PG"; |
948 | } | 951 | } |
949 | m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region Rating: " + | 952 | MainConsole.Instance.Output(String.Format( |
950 | rating); | 953 | "Region Name: {0}, Region Rating {1}", |
954 | scene.RegionInfo.RegionName, | ||
955 | rating)); | ||
951 | }); | 956 | }); |
952 | break; | 957 | break; |
953 | } | 958 | } |
@@ -968,7 +973,7 @@ namespace OpenSim | |||
968 | if (client is IStatsCollector) | 973 | if (client is IStatsCollector) |
969 | { | 974 | { |
970 | report = report + client.FirstName + | 975 | report = report + client.FirstName + |
971 | " " + client.LastName + "\n"; | 976 | " " + client.LastName; |
972 | 977 | ||
973 | IStatsCollector stats = | 978 | IStatsCollector stats = |
974 | (IStatsCollector) client; | 979 | (IStatsCollector) client; |
@@ -985,7 +990,7 @@ namespace OpenSim | |||
985 | "Texture", | 990 | "Texture", |
986 | "Asset"); | 991 | "Asset"); |
987 | report = report + stats.Report() + | 992 | report = report + stats.Report() + |
988 | "\n\n"; | 993 | "\n"; |
989 | } | 994 | } |
990 | }); | 995 | }); |
991 | }); | 996 | }); |
@@ -1017,7 +1022,7 @@ namespace OpenSim | |||
1017 | /// <param name="cmdparams"></param> | 1022 | /// <param name="cmdparams"></param> |
1018 | protected void SaveXml(string module, string[] cmdparams) | 1023 | protected void SaveXml(string module, string[] cmdparams) |
1019 | { | 1024 | { |
1020 | m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); | 1025 | MainConsole.Instance.Output("PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); |
1021 | 1026 | ||
1022 | if (cmdparams.Length > 0) | 1027 | if (cmdparams.Length > 0) |
1023 | { | 1028 | { |
@@ -1036,7 +1041,7 @@ namespace OpenSim | |||
1036 | /// <param name="cmdparams"></param> | 1041 | /// <param name="cmdparams"></param> |
1037 | protected void LoadXml(string module, string[] cmdparams) | 1042 | protected void LoadXml(string module, string[] cmdparams) |
1038 | { | 1043 | { |
1039 | m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); | 1044 | MainConsole.Instance.Output("PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); |
1040 | 1045 | ||
1041 | Vector3 loadOffset = new Vector3(0, 0, 0); | 1046 | Vector3 loadOffset = new Vector3(0, 0, 0); |
1042 | if (cmdparams.Length > 2) | 1047 | if (cmdparams.Length > 2) |
@@ -1059,8 +1064,7 @@ namespace OpenSim | |||
1059 | { | 1064 | { |
1060 | loadOffset.Z = (float) Convert.ToDecimal(cmdparams[6]); | 1065 | loadOffset.Z = (float) Convert.ToDecimal(cmdparams[6]); |
1061 | } | 1066 | } |
1062 | m_log.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + | 1067 | MainConsole.Instance.Output(String.Format("loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z)); |
1063 | loadOffset.Z + ">"); | ||
1064 | } | 1068 | } |
1065 | } | 1069 | } |
1066 | m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); | 1070 | m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); |
@@ -1073,7 +1077,7 @@ namespace OpenSim | |||
1073 | } | 1077 | } |
1074 | catch (FileNotFoundException) | 1078 | catch (FileNotFoundException) |
1075 | { | 1079 | { |
1076 | m_log.Error("Default xml not found. Usage: load-xml <filename>"); | 1080 | MainConsole.Instance.Output("Default xml not found. Usage: load-xml <filename>"); |
1077 | } | 1081 | } |
1078 | } | 1082 | } |
1079 | } | 1083 | } |
@@ -1109,7 +1113,7 @@ namespace OpenSim | |||
1109 | } | 1113 | } |
1110 | catch (FileNotFoundException) | 1114 | catch (FileNotFoundException) |
1111 | { | 1115 | { |
1112 | m_log.Error("Specified xml not found. Usage: load xml2 <filename>"); | 1116 | MainConsole.Instance.Output("Specified xml not found. Usage: load xml2 <filename>"); |
1113 | } | 1117 | } |
1114 | } | 1118 | } |
1115 | else | 1119 | else |
@@ -1120,7 +1124,7 @@ namespace OpenSim | |||
1120 | } | 1124 | } |
1121 | catch (FileNotFoundException) | 1125 | catch (FileNotFoundException) |
1122 | { | 1126 | { |
1123 | m_log.Error("Default xml not found. Usage: load xml2 <filename>"); | 1127 | MainConsole.Instance.Output("Default xml not found. Usage: load xml2 <filename>"); |
1124 | } | 1128 | } |
1125 | } | 1129 | } |
1126 | } | 1130 | } |
@@ -1137,7 +1141,7 @@ namespace OpenSim | |||
1137 | } | 1141 | } |
1138 | catch (Exception e) | 1142 | catch (Exception e) |
1139 | { | 1143 | { |
1140 | m_log.Error(e.Message); | 1144 | MainConsole.Instance.Output(e.Message); |
1141 | } | 1145 | } |
1142 | } | 1146 | } |
1143 | 1147 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b888017..4e2a0b7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -1471,6 +1471,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1471 | 1471 | ||
1472 | public void SendKillObject(ulong regionHandle, uint localID) | 1472 | public void SendKillObject(ulong regionHandle, uint localID) |
1473 | { | 1473 | { |
1474 | // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle); | ||
1475 | |||
1474 | KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject); | 1476 | KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject); |
1475 | // TODO: don't create new blocks if recycling an old packet | 1477 | // TODO: don't create new blocks if recycling an old packet |
1476 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 1478 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
@@ -3478,6 +3480,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3478 | 3480 | ||
3479 | public void SendPrimitiveToClient(SendPrimitiveData data) | 3481 | public void SendPrimitiveToClient(SendPrimitiveData data) |
3480 | { | 3482 | { |
3483 | // string text = data.text; | ||
3484 | // if (text.IndexOf("\n") >= 0) | ||
3485 | // text = text.Remove(text.IndexOf("\n")); | ||
3486 | // m_log.DebugFormat( | ||
3487 | // "[CLIENT]: Placing request to send full info about prim {0} text {1} to client {2}", | ||
3488 | // data.localID, text, Name); | ||
3489 | |||
3481 | if (data.priority == double.NaN) | 3490 | if (data.priority == double.NaN) |
3482 | { | 3491 | { |
3483 | m_log.Error("[LLClientView] SendPrimitiveToClient received a NaN priority, dropping update"); | 3492 | m_log.Error("[LLClientView] SendPrimitiveToClient received a NaN priority, dropping update"); |
@@ -3515,7 +3524,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3515 | 3524 | ||
3516 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; | 3525 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; |
3517 | for (int i = 0; i < count; i++) | 3526 | for (int i = 0; i < count; i++) |
3527 | { | ||
3518 | outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); | 3528 | outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); |
3529 | |||
3530 | // string text = Util.FieldToString(outPacket.ObjectData[i].Text); | ||
3531 | // if (text.IndexOf("\n") >= 0) | ||
3532 | // text = text.Remove(text.IndexOf("\n")); | ||
3533 | // m_log.DebugFormat( | ||
3534 | // "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", | ||
3535 | // outPacket.ObjectData[i].ID, text, Name); | ||
3536 | } | ||
3519 | } | 3537 | } |
3520 | 3538 | ||
3521 | OutPacket(outPacket, ThrottleOutPacketType.State); | 3539 | OutPacket(outPacket, ThrottleOutPacketType.State); |
@@ -5173,6 +5191,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5173 | { | 5191 | { |
5174 | ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; | 5192 | ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; |
5175 | 5193 | ||
5194 | //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID); | ||
5195 | |||
5176 | #region Packet Session and User Check | 5196 | #region Packet Session and User Check |
5177 | if (m_checkPackets) | 5197 | if (m_checkPackets) |
5178 | { | 5198 | { |
@@ -5193,7 +5213,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5193 | args.Type = ChatTypeEnum.Shout; | 5213 | args.Type = ChatTypeEnum.Shout; |
5194 | args.Position = new Vector3(); | 5214 | args.Position = new Vector3(); |
5195 | args.Scene = Scene; | 5215 | args.Scene = Scene; |
5196 | args.Sender = this; | 5216 | args.Sender = this; |
5197 | ChatMessage handlerChatFromClient2 = OnChatFromClient; | 5217 | ChatMessage handlerChatFromClient2 = OnChatFromClient; |
5198 | if (handlerChatFromClient2 != null) | 5218 | if (handlerChatFromClient2 != null) |
5199 | handlerChatFromClient2(this, args); | 5219 | handlerChatFromClient2(this, args); |
@@ -9095,8 +9115,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9095 | 9115 | ||
9096 | private bool HandleSendPostcard(IClientAPI client, Packet packet) | 9116 | private bool HandleSendPostcard(IClientAPI client, Packet packet) |
9097 | { | 9117 | { |
9098 | SendPostcardPacket SendPostcard = | 9118 | // SendPostcardPacket SendPostcard = |
9099 | (SendPostcardPacket)packet; | 9119 | // (SendPostcardPacket)packet; |
9100 | SendPostcard handlerSendPostcard = OnSendPostcard; | 9120 | SendPostcard handlerSendPostcard = OnSendPostcard; |
9101 | if (handlerSendPostcard != null) | 9121 | if (handlerSendPostcard != null) |
9102 | { | 9122 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index adcf6bd..9216e0b 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -762,7 +762,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
762 | case "expire": | 762 | case "expire": |
763 | 763 | ||
764 | 764 | ||
765 | if (cmdparams.Length >= 3) | 765 | if (cmdparams.Length < 3) |
766 | { | 766 | { |
767 | m_log.InfoFormat("[FLOTSAM ASSET CACHE] Invalid parameters for Expire, please specify a valid date & time", cmd); | 767 | m_log.InfoFormat("[FLOTSAM ASSET CACHE] Invalid parameters for Expire, please specify a valid date & time", cmd); |
768 | break; | 768 | break; |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index e48b078..fdfcd10 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -172,24 +172,27 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
172 | 172 | ||
173 | private void RetrieveInstantMessages(IClientAPI client) | 173 | private void RetrieveInstantMessages(IClientAPI client) |
174 | { | 174 | { |
175 | m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); | 175 | if (m_RestURL != "") |
176 | { | ||
177 | m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); | ||
176 | 178 | ||
177 | List<GridInstantMessage>msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( | 179 | List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( |
178 | "POST", m_RestURL+"/RetrieveMessages/", client.AgentId); | 180 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); |
179 | 181 | ||
180 | foreach (GridInstantMessage im in msglist) | 182 | foreach (GridInstantMessage im in msglist) |
181 | { | 183 | { |
182 | // client.SendInstantMessage(im); | 184 | // client.SendInstantMessage(im); |
183 | 185 | ||
184 | // Send through scene event manager so all modules get a chance | 186 | // Send through scene event manager so all modules get a chance |
185 | // to look at this message before it gets delivered. | 187 | // to look at this message before it gets delivered. |
186 | // | 188 | // |
187 | // Needed for proper state management for stored group | 189 | // Needed for proper state management for stored group |
188 | // invitations | 190 | // invitations |
189 | // | 191 | // |
190 | Scene s = FindScene(client.AgentId); | 192 | Scene s = FindScene(client.AgentId); |
191 | if (s != null) | 193 | if (s != null) |
192 | s.EventManager.TriggerIncomingInstantMessage(im); | 194 | s.EventManager.TriggerIncomingInstantMessage(im); |
195 | } | ||
193 | } | 196 | } |
194 | } | 197 | } |
195 | 198 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index e53290c..e37da9f 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -191,7 +191,6 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
191 | { | 191 | { |
192 | m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message); | 192 | m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message); |
193 | } | 193 | } |
194 | |||
195 | } | 194 | } |
196 | 195 | ||
197 | } | 196 | } |
@@ -203,6 +202,14 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
203 | m_log.DebugFormat(" - folder {0}", lib.Name); | 202 | m_log.DebugFormat(" - folder {0}", lib.Name); |
204 | DumpFolder(lib); | 203 | DumpFolder(lib); |
205 | } | 204 | } |
205 | // | ||
206 | // private void DumpLibrary() | ||
207 | // { | ||
208 | // InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; | ||
209 | // | ||
210 | // m_log.DebugFormat(" - folder {0}", lib.Name); | ||
211 | // DumpFolder(lib); | ||
212 | // } | ||
206 | 213 | ||
207 | private void DumpFolder(InventoryFolderImpl folder) | 214 | private void DumpFolder(InventoryFolderImpl folder) |
208 | { | 215 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 96d65d7..f15f8f6 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -87,7 +87,10 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
87 | 87 | ||
88 | foreach (IMonitor monitor in m_monitors) | 88 | foreach (IMonitor monitor in m_monitors) |
89 | { | 89 | { |
90 | if (monitor.ToString() == monID) | 90 | string elemName = monitor.ToString(); |
91 | if (elemName.StartsWith(monitor.GetType().Namespace)) | ||
92 | elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); | ||
93 | if (elemName == monID || monitor.ToString() == monID) | ||
91 | { | 94 | { |
92 | Hashtable ereply3 = new Hashtable(); | 95 | Hashtable ereply3 = new Hashtable(); |
93 | 96 | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index f51d0c2..e3c7bbf 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -362,7 +362,14 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
362 | 362 | ||
363 | if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) | 363 | if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) |
364 | { | 364 | { |
365 | scene.AssetService.Delete(oldID.ToString()); | 365 | if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString()); |
366 | if (oldAsset != null) | ||
367 | { | ||
368 | if (oldAsset.Temporary == true) | ||
369 | { | ||
370 | scene.AssetService.Delete(oldID.ToString()); | ||
371 | } | ||
372 | } | ||
366 | } | 373 | } |
367 | } | 374 | } |
368 | 375 | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index d57a8e5..3291be4 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -342,6 +342,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
342 | m_log.Error( | 342 | m_log.Error( |
343 | "[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); | 343 | "[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); |
344 | } | 344 | } |
345 | |||
345 | m_textureManager.ReturnData(id, imageJ2000); | 346 | m_textureManager.ReturnData(id, imageJ2000); |
346 | } | 347 | } |
347 | 348 | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 60df2e7..d647e71 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -262,44 +262,34 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
262 | { | 262 | { |
263 | case ChatTypeEnum.Whisper: | 263 | case ChatTypeEnum.Whisper: |
264 | if (dis < m_whisperdistance) | 264 | if (dis < m_whisperdistance) |
265 | { | 265 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
266 | lock (m_pending.SyncRoot) | ||
267 | { | ||
268 | m_pending.Enqueue(new ListenerInfo(li,name,id,msg)); | ||
269 | } | ||
270 | } | ||
271 | break; | 266 | break; |
272 | 267 | ||
273 | case ChatTypeEnum.Say: | 268 | case ChatTypeEnum.Say: |
274 | if (dis < m_saydistance) | 269 | if (dis < m_saydistance) |
275 | { | 270 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
276 | lock (m_pending.SyncRoot) | ||
277 | { | ||
278 | m_pending.Enqueue(new ListenerInfo(li,name,id,msg)); | ||
279 | } | ||
280 | } | ||
281 | break; | 271 | break; |
282 | 272 | ||
283 | case ChatTypeEnum.Shout: | 273 | case ChatTypeEnum.Shout: |
284 | if (dis < m_shoutdistance) | 274 | if (dis < m_shoutdistance) |
285 | { | 275 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
286 | lock (m_pending.SyncRoot) | ||
287 | { | ||
288 | m_pending.Enqueue(new ListenerInfo(li,name,id,msg)); | ||
289 | } | ||
290 | } | ||
291 | break; | 276 | break; |
292 | 277 | ||
293 | case ChatTypeEnum.Region: | 278 | case ChatTypeEnum.Region: |
294 | lock (m_pending.SyncRoot) | 279 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
295 | { | ||
296 | m_pending.Enqueue(new ListenerInfo(li,name,id,msg)); | ||
297 | } | ||
298 | break; | 280 | break; |
299 | } | 281 | } |
300 | } | 282 | } |
301 | } | 283 | } |
302 | 284 | ||
285 | protected void QueueMessage(ListenerInfo li) | ||
286 | { | ||
287 | lock (m_pending.SyncRoot) | ||
288 | { | ||
289 | m_pending.Enqueue(li); | ||
290 | } | ||
291 | } | ||
292 | |||
303 | /// <summary> | 293 | /// <summary> |
304 | /// Are there any listen events ready to be dispatched? | 294 | /// Are there any listen events ready to be dispatched? |
305 | /// </summary> | 295 | /// </summary> |
@@ -319,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
319 | 309 | ||
320 | lock (m_pending.SyncRoot) | 310 | lock (m_pending.SyncRoot) |
321 | { | 311 | { |
322 | li = (ListenerInfo) m_pending.Dequeue(); | 312 | li = (ListenerInfo)m_pending.Dequeue(); |
323 | } | 313 | } |
324 | 314 | ||
325 | return li; | 315 | return li; |
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index 8b5a413..127469e 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs | |||
@@ -41,9 +41,7 @@ namespace OpenSim.Region.CoreModules.World | |||
41 | { | 41 | { |
42 | public class AccessModule : ISharedRegionModule | 42 | public class AccessModule : ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log = | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | 45 | ||
48 | private List<Scene> m_SceneList = new List<Scene>(); | 46 | private List<Scene> m_SceneList = new List<Scene>(); |
49 | 47 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index bb9c6fe..59a1b8f 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -420,9 +420,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
420 | currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; | 420 | currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; |
421 | currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; | 421 | currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; |
422 | currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; | 422 | currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; |
423 | 423 | ||
424 | IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); | 424 | IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); |
425 | estateModule.sendRegionHandshakeToAll(); | 425 | |
426 | if (estateModule != null) | ||
427 | estateModule.sendRegionHandshakeToAll(); | ||
426 | 428 | ||
427 | return true; | 429 | return true; |
428 | } | 430 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 8c1e1c2..d986274 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -36,11 +36,13 @@ using OpenMetaverse; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | 37 | ||
38 | using OpenSim.Framework.Serialization; | 38 | using OpenSim.Framework.Serialization; |
39 | using OpenSim.Framework.Serialization.External; | ||
39 | using OpenSim.Region.CoreModules.World.Serialiser; | 40 | using OpenSim.Region.CoreModules.World.Serialiser; |
40 | using OpenSim.Region.CoreModules.World.Terrain; | 41 | using OpenSim.Region.CoreModules.World.Terrain; |
41 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Serialization; | 43 | using OpenSim.Region.Framework.Scenes.Serialization; |
43 | using OpenSim.Tests.Common; | 44 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common.Mock; | ||
44 | using OpenSim.Tests.Common.Setup; | 46 | using OpenSim.Tests.Common.Setup; |
45 | 47 | ||
46 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests | 48 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests |
@@ -50,6 +52,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
50 | { | 52 | { |
51 | private Guid m_lastRequestId; | 53 | private Guid m_lastRequestId; |
52 | private string m_lastErrorMessage; | 54 | private string m_lastErrorMessage; |
55 | |||
56 | protected TestScene m_scene; | ||
57 | protected ArchiverModule m_archiverModule; | ||
58 | |||
59 | [SetUp] | ||
60 | public void SetUp() | ||
61 | { | ||
62 | m_archiverModule = new ArchiverModule(); | ||
63 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
64 | TerrainModule terrainModule = new TerrainModule(); | ||
65 | |||
66 | m_scene = SceneSetupHelpers.SetupScene("scene1"); | ||
67 | SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | ||
68 | } | ||
53 | 69 | ||
54 | private void LoadCompleted(Guid requestId, string errorMessage) | 70 | private void LoadCompleted(Guid requestId, string errorMessage) |
55 | { | 71 | { |
@@ -74,6 +90,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
74 | } | 90 | } |
75 | } | 91 | } |
76 | 92 | ||
93 | protected SceneObjectPart CreateSceneObjectPart1() | ||
94 | { | ||
95 | string partName = "My Little Pony"; | ||
96 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015"); | ||
97 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
98 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
99 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
100 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
101 | |||
102 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | ||
103 | } | ||
104 | |||
105 | protected SceneObjectPart CreateSceneObjectPart2() | ||
106 | { | ||
107 | string partName = "Action Man"; | ||
108 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000016"); | ||
109 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder(); | ||
110 | Vector3 groupPosition = new Vector3(90, 80, 70); | ||
111 | Quaternion rotationOffset = new Quaternion(60, 70, 80, 90); | ||
112 | Vector3 offsetPosition = new Vector3(20, 25, 30); | ||
113 | |||
114 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | ||
115 | } | ||
116 | |||
77 | /// <summary> | 117 | /// <summary> |
78 | /// Test saving a V0.2 OpenSim Region Archive. | 118 | /// Test saving a V0.2 OpenSim Region Archive. |
79 | /// </summary> | 119 | /// </summary> |
@@ -83,59 +123,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
83 | TestHelper.InMethod(); | 123 | TestHelper.InMethod(); |
84 | //log4net.Config.XmlConfigurator.Configure(); | 124 | //log4net.Config.XmlConfigurator.Configure(); |
85 | 125 | ||
86 | ArchiverModule archiverModule = new ArchiverModule(); | 126 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
87 | SerialiserModule serialiserModule = new SerialiserModule(); | 127 | m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); |
88 | TerrainModule terrainModule = new TerrainModule(); | ||
89 | |||
90 | Scene scene = SceneSetupHelpers.SetupScene("asset"); | ||
91 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | ||
92 | 128 | ||
93 | SceneObjectPart part1; | 129 | SceneObjectPart part2 = CreateSceneObjectPart2(); |
94 | 130 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | |
95 | // Create and add prim 1 | ||
96 | { | ||
97 | string partName = "My Little Pony"; | ||
98 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015"); | ||
99 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
100 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
101 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
102 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
103 | |||
104 | part1 | ||
105 | = new SceneObjectPart( | ||
106 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
107 | part1.Name = partName; | ||
108 | |||
109 | scene.AddNewSceneObject(new SceneObjectGroup(part1), false); | ||
110 | } | ||
111 | |||
112 | SceneObjectPart part2; | ||
113 | |||
114 | // Create and add prim 2 | ||
115 | { | ||
116 | string partName = "Action Man"; | ||
117 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000016"); | ||
118 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder(); | ||
119 | Vector3 groupPosition = new Vector3(90, 80, 70); | ||
120 | Quaternion rotationOffset = new Quaternion(60, 70, 80, 90); | ||
121 | Vector3 offsetPosition = new Vector3(20, 25, 30); | ||
122 | |||
123 | part2 | ||
124 | = new SceneObjectPart( | ||
125 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
126 | part2.Name = partName; | ||
127 | |||
128 | scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | ||
129 | } | ||
130 | 131 | ||
131 | MemoryStream archiveWriteStream = new MemoryStream(); | 132 | MemoryStream archiveWriteStream = new MemoryStream(); |
132 | scene.EventManager.OnOarFileSaved += SaveCompleted; | 133 | m_scene.EventManager.OnOarFileSaved += SaveCompleted; |
133 | 134 | ||
134 | Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); | 135 | Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); |
135 | 136 | ||
136 | lock (this) | 137 | lock (this) |
137 | { | 138 | { |
138 | archiverModule.ArchiveRegion(archiveWriteStream, requestId); | 139 | m_archiverModule.ArchiveRegion(archiveWriteStream, requestId); |
139 | //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; | 140 | //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; |
140 | //while (assetServer.HasWaitingRequests()) | 141 | //while (assetServer.HasWaitingRequests()) |
141 | // assetServer.ProcessNextRequest(); | 142 | // assetServer.ProcessNextRequest(); |
@@ -214,32 +215,58 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
214 | // Also check that direct entries which will also have a file entry containing that directory doesn't | 215 | // Also check that direct entries which will also have a file entry containing that directory doesn't |
215 | // upset load | 216 | // upset load |
216 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 217 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
217 | 218 | ||
218 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); | 219 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); |
219 | 220 | ||
220 | string part1Name = "object1"; | 221 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
221 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder(); | 222 | SceneObjectGroup object1 = new SceneObjectGroup(part1); |
222 | Vector3 groupPosition = new Vector3(90, 80, 70); | ||
223 | Quaternion rotationOffset = new Quaternion(60, 70, 80, 90); | ||
224 | Vector3 offsetPosition = new Vector3(20, 25, 30); | ||
225 | |||
226 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
227 | ArchiverModule archiverModule = new ArchiverModule(); | ||
228 | 223 | ||
229 | Scene scene = SceneSetupHelpers.SetupScene(); | 224 | // Let's put some inventory items into our object |
230 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 225 | string soundItemName = "sound-item1"; |
226 | UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||
227 | Type type = GetType(); | ||
228 | Assembly assembly = type.Assembly; | ||
229 | string soundDataResourceName = null; | ||
230 | string[] names = assembly.GetManifestResourceNames(); | ||
231 | foreach (string name in names) | ||
232 | { | ||
233 | if (name.EndsWith(".Resources.test-sound.wav")) | ||
234 | soundDataResourceName = name; | ||
235 | } | ||
236 | Assert.That(soundDataResourceName, Is.Not.Null); | ||
231 | 237 | ||
232 | SceneObjectPart part1 | 238 | byte[] soundData; |
233 | = new SceneObjectPart( | 239 | Console.WriteLine("Loading " + soundDataResourceName); |
234 | UUID.Zero, shape, groupPosition, rotationOffset, offsetPosition); | 240 | using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName)) |
235 | part1.Name = part1Name; | 241 | { |
236 | SceneObjectGroup object1 = new SceneObjectGroup(part1); | 242 | using (BinaryReader br = new BinaryReader(resource)) |
237 | scene.AddNewSceneObject(object1, false); | 243 | { |
244 | // FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion | ||
245 | soundData = br.ReadBytes(99999999); | ||
246 | UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
247 | string soundAssetFileName | ||
248 | = ArchiveConstants.ASSETS_PATH + soundUuid | ||
249 | + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV]; | ||
250 | tar.WriteFile(soundAssetFileName, soundData); | ||
251 | |||
252 | /* | ||
253 | AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData); | ||
254 | scene.AssetService.Store(soundAsset); | ||
255 | asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav"; | ||
256 | */ | ||
257 | |||
258 | TaskInventoryItem item1 | ||
259 | = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; | ||
260 | part1.Inventory.AddInventoryItem(item1, true); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | m_scene.AddNewSceneObject(object1, false); | ||
238 | 265 | ||
239 | string object1FileName = string.Format( | 266 | string object1FileName = string.Format( |
240 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | 267 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", |
241 | part1Name, | 268 | part1.Name, |
242 | Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z), | 269 | Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), |
243 | part1.UUID); | 270 | part1.UUID); |
244 | tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1)); | 271 | tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1)); |
245 | 272 | ||
@@ -249,27 +276,125 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
249 | 276 | ||
250 | lock (this) | 277 | lock (this) |
251 | { | 278 | { |
252 | scene.EventManager.OnOarFileLoaded += LoadCompleted; | 279 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; |
253 | archiverModule.DearchiveRegion(archiveReadStream); | 280 | m_archiverModule.DearchiveRegion(archiveReadStream); |
254 | } | 281 | } |
255 | 282 | ||
256 | Assert.That(m_lastErrorMessage, Is.Null); | 283 | Assert.That(m_lastErrorMessage, Is.Null); |
257 | 284 | ||
258 | SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name); | 285 | SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name); |
259 | 286 | ||
260 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); | 287 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); |
261 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1Name), "object1 names not identical"); | 288 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical"); |
262 | Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(groupPosition), "object1 group position not equal"); | 289 | Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal"); |
263 | Assert.That( | 290 | Assert.That( |
264 | object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal"); | 291 | object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal"); |
265 | Assert.That( | 292 | Assert.That( |
266 | object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal"); | 293 | object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal"); |
294 | |||
295 | TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; | ||
296 | Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); | ||
297 | AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); | ||
298 | Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); | ||
299 | Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); | ||
267 | 300 | ||
268 | // Temporary | 301 | // Temporary |
269 | Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); | 302 | Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); |
270 | } | 303 | } |
271 | 304 | ||
272 | /// <summary> | 305 | /// <summary> |
306 | /// Test loading the region settings of a V0.2 OpenSim Region Archive. | ||
307 | /// </summary> | ||
308 | [Test] | ||
309 | public void TestLoadOarV0_2RegionSettings() | ||
310 | { | ||
311 | TestHelper.InMethod(); | ||
312 | //log4net.Config.XmlConfigurator.Configure(); | ||
313 | |||
314 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
315 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
316 | |||
317 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | ||
318 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); | ||
319 | |||
320 | RegionSettings rs = new RegionSettings(); | ||
321 | rs.AgentLimit = 17; | ||
322 | rs.AllowDamage = true; | ||
323 | rs.AllowLandJoinDivide = true; | ||
324 | rs.AllowLandResell = true; | ||
325 | rs.BlockFly = true; | ||
326 | rs.BlockShowInSearch = true; | ||
327 | rs.BlockTerraform = true; | ||
328 | rs.DisableCollisions = true; | ||
329 | rs.DisablePhysics = true; | ||
330 | rs.DisableScripts = true; | ||
331 | rs.Elevation1NW = 15.9; | ||
332 | rs.Elevation1NE = 45.3; | ||
333 | rs.Elevation1SE = 49; | ||
334 | rs.Elevation1SW = 1.9; | ||
335 | rs.Elevation2NW = 4.5; | ||
336 | rs.Elevation2NE = 19.2; | ||
337 | rs.Elevation2SE = 9.2; | ||
338 | rs.Elevation2SW = 2.1; | ||
339 | rs.FixedSun = true; | ||
340 | rs.ObjectBonus = 1.4; | ||
341 | rs.RestrictPushing = true; | ||
342 | rs.TerrainLowerLimit = 0.4; | ||
343 | rs.TerrainRaiseLimit = 17.9; | ||
344 | rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
345 | rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
346 | rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
347 | rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
348 | rs.UseEstateSun = true; | ||
349 | rs.WaterHeight = 23; | ||
350 | |||
351 | tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); | ||
352 | |||
353 | tar.Close(); | ||
354 | |||
355 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
356 | |||
357 | lock (this) | ||
358 | { | ||
359 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
360 | m_archiverModule.DearchiveRegion(archiveReadStream); | ||
361 | } | ||
362 | |||
363 | Assert.That(m_lastErrorMessage, Is.Null); | ||
364 | RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings; | ||
365 | |||
366 | Assert.That(loadedRs.AgentLimit, Is.EqualTo(17)); | ||
367 | Assert.That(loadedRs.AllowDamage, Is.True); | ||
368 | Assert.That(loadedRs.AllowLandJoinDivide, Is.True); | ||
369 | Assert.That(loadedRs.AllowLandResell, Is.True); | ||
370 | Assert.That(loadedRs.BlockFly, Is.True); | ||
371 | Assert.That(loadedRs.BlockShowInSearch, Is.True); | ||
372 | Assert.That(loadedRs.BlockTerraform, Is.True); | ||
373 | Assert.That(loadedRs.DisableCollisions, Is.True); | ||
374 | Assert.That(loadedRs.DisablePhysics, Is.True); | ||
375 | Assert.That(loadedRs.DisableScripts, Is.True); | ||
376 | Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9)); | ||
377 | Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3)); | ||
378 | Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49)); | ||
379 | Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9)); | ||
380 | Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5)); | ||
381 | Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2)); | ||
382 | Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2)); | ||
383 | Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1)); | ||
384 | Assert.That(loadedRs.FixedSun, Is.True); | ||
385 | Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4)); | ||
386 | Assert.That(loadedRs.RestrictPushing, Is.True); | ||
387 | Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4)); | ||
388 | Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9)); | ||
389 | Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020"))); | ||
390 | Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040"))); | ||
391 | Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060"))); | ||
392 | Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080"))); | ||
393 | Assert.That(loadedRs.UseEstateSun, Is.True); | ||
394 | Assert.That(loadedRs.WaterHeight, Is.EqualTo(23)); | ||
395 | } | ||
396 | |||
397 | /// <summary> | ||
273 | /// Test merging a V0.2 OpenSim Region Archive into an existing scene | 398 | /// Test merging a V0.2 OpenSim Region Archive into an existing scene |
274 | /// </summary> | 399 | /// </summary> |
275 | //[Test] | 400 | //[Test] |
@@ -280,11 +405,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
280 | 405 | ||
281 | MemoryStream archiveWriteStream = new MemoryStream(); | 406 | MemoryStream archiveWriteStream = new MemoryStream(); |
282 | 407 | ||
283 | string part2Name = "objectMerge"; | 408 | // string part2Name = "objectMerge"; |
284 | PrimitiveBaseShape part2Shape = PrimitiveBaseShape.CreateCylinder(); | 409 | // PrimitiveBaseShape part2Shape = PrimitiveBaseShape.CreateCylinder(); |
285 | Vector3 part2GroupPosition = new Vector3(90, 80, 70); | 410 | // Vector3 part2GroupPosition = new Vector3(90, 80, 70); |
286 | Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); | 411 | // Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); |
287 | Vector3 part2OffsetPosition = new Vector3(20, 25, 30); | 412 | // Vector3 part2OffsetPosition = new Vector3(20, 25, 30); |
413 | |||
414 | SceneObjectPart part2 = CreateSceneObjectPart2(); | ||
288 | 415 | ||
289 | // Create an oar file that we can use for the merge | 416 | // Create an oar file that we can use for the merge |
290 | { | 417 | { |
@@ -293,63 +420,39 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
293 | TerrainModule terrainModule = new TerrainModule(); | 420 | TerrainModule terrainModule = new TerrainModule(); |
294 | 421 | ||
295 | Scene scene = SceneSetupHelpers.SetupScene(); | 422 | Scene scene = SceneSetupHelpers.SetupScene(); |
296 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | 423 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); |
297 | 424 | ||
298 | SceneObjectPart part2 | 425 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
299 | = new SceneObjectPart( | ||
300 | UUID.Zero, part2Shape, part2GroupPosition, part2RotationOffset, part2OffsetPosition); | ||
301 | part2.Name = part2Name; | ||
302 | SceneObjectGroup object2 = new SceneObjectGroup(part2); | ||
303 | |||
304 | scene.AddNewSceneObject(object2, false); | ||
305 | 426 | ||
306 | // Write out this scene | 427 | // Write out this scene |
307 | scene.EventManager.OnOarFileSaved += SaveCompleted; | 428 | scene.EventManager.OnOarFileSaved += SaveCompleted; |
308 | 429 | ||
309 | lock (this) | 430 | lock (this) |
310 | { | 431 | { |
311 | archiverModule.ArchiveRegion(archiveWriteStream); | 432 | m_archiverModule.ArchiveRegion(archiveWriteStream); |
312 | Monitor.Wait(this, 60000); | 433 | Monitor.Wait(this, 60000); |
313 | } | 434 | } |
314 | } | 435 | } |
315 | 436 | ||
316 | { | 437 | { |
317 | ArchiverModule archiverModule = new ArchiverModule(); | 438 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
318 | SerialiserModule serialiserModule = new SerialiserModule(); | 439 | m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); |
319 | TerrainModule terrainModule = new TerrainModule(); | ||
320 | |||
321 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
322 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | ||
323 | |||
324 | string part1Name = "objectExisting"; | ||
325 | PrimitiveBaseShape part1Shape = PrimitiveBaseShape.CreateCylinder(); | ||
326 | Vector3 part1GroupPosition = new Vector3(80, 70, 60); | ||
327 | Quaternion part1RotationOffset = new Quaternion(50, 60, 70, 80); | ||
328 | Vector3 part1OffsetPosition = new Vector3(15, 20, 25); | ||
329 | |||
330 | SceneObjectPart part1 | ||
331 | = new SceneObjectPart( | ||
332 | UUID.Zero, part1Shape, part1GroupPosition, part1RotationOffset, part1OffsetPosition); | ||
333 | part1.Name = part1Name; | ||
334 | SceneObjectGroup object1 = new SceneObjectGroup(part1); | ||
335 | |||
336 | scene.AddNewSceneObject(object1, false); | ||
337 | 440 | ||
338 | // Merge in the archive we created earlier | 441 | // Merge in the archive we created earlier |
339 | byte[] archive = archiveWriteStream.ToArray(); | 442 | byte[] archive = archiveWriteStream.ToArray(); |
340 | MemoryStream archiveReadStream = new MemoryStream(archive); | 443 | MemoryStream archiveReadStream = new MemoryStream(archive); |
341 | 444 | ||
342 | archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); | 445 | m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); |
343 | 446 | ||
344 | SceneObjectPart object1Existing = scene.GetSceneObjectPart(part1Name); | 447 | SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); |
345 | Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); | 448 | Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); |
346 | Assert.That(object1Existing.Name, Is.EqualTo(part1Name), "object1 names not identical after merge"); | 449 | Assert.That(object1Existing.Name, Is.EqualTo(part1.Name), "object1 names not identical after merge"); |
347 | Assert.That(object1Existing.GroupPosition, Is.EqualTo(part1GroupPosition), "object1 group position not equal after merge"); | 450 | Assert.That(object1Existing.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal after merge"); |
348 | 451 | ||
349 | SceneObjectPart object2PartMerged = scene.GetSceneObjectPart(part2Name); | 452 | SceneObjectPart object2PartMerged = m_scene.GetSceneObjectPart(part2.Name); |
350 | Assert.That(object2PartMerged, Is.Not.Null, "object2 was not present after merge"); | 453 | Assert.That(object2PartMerged, Is.Not.Null, "object2 was not present after merge"); |
351 | Assert.That(object2PartMerged.Name, Is.EqualTo(part2Name), "object2 names not identical after merge"); | 454 | Assert.That(object2PartMerged.Name, Is.EqualTo(part2.Name), "object2 names not identical after merge"); |
352 | Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2GroupPosition), "object2 group position not equal after merge"); | 455 | Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2.GroupPosition), "object2 group position not equal after merge"); |
353 | } | 456 | } |
354 | } | 457 | } |
355 | } | 458 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav b/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav new file mode 100755 index 0000000..b45ee54 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav | |||
Binary files differ | |||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 72dd373..4652d70 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -142,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
142 | private bool m_debugPermissions = false; | 142 | private bool m_debugPermissions = false; |
143 | private bool m_allowGridGods = false; | 143 | private bool m_allowGridGods = false; |
144 | private bool m_RegionOwnerIsGod = false; | 144 | private bool m_RegionOwnerIsGod = false; |
145 | private bool m_RegionManagerIsGod = false; | ||
145 | private bool m_ParcelOwnerIsGod = false; | 146 | private bool m_ParcelOwnerIsGod = false; |
146 | 147 | ||
147 | /// <value> | 148 | /// <value> |
@@ -184,6 +185,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
184 | m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", false); | 185 | m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", false); |
185 | m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); | 186 | m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); |
186 | m_RegionOwnerIsGod = myConfig.GetBoolean("region_owner_is_god", true); | 187 | m_RegionOwnerIsGod = myConfig.GetBoolean("region_owner_is_god", true); |
188 | m_RegionManagerIsGod = myConfig.GetBoolean("region_manager_is_god", false); | ||
187 | m_ParcelOwnerIsGod = myConfig.GetBoolean("parcel_owner_is_god", true); | 189 | m_ParcelOwnerIsGod = myConfig.GetBoolean("parcel_owner_is_god", true); |
188 | 190 | ||
189 | m_allowedScriptCreators | 191 | m_allowedScriptCreators |
@@ -479,10 +481,13 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
479 | 481 | ||
480 | if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) | 482 | if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) |
481 | { | 483 | { |
482 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user) | 484 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) |
483 | return true; | 485 | return true; |
484 | } | 486 | } |
485 | 487 | ||
488 | if (IsEstateManager(user) && m_RegionManagerIsGod) | ||
489 | return true; | ||
490 | |||
486 | if (m_allowGridGods) | 491 | if (m_allowGridGods) |
487 | { | 492 | { |
488 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); | 493 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); |
@@ -495,6 +500,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
495 | 500 | ||
496 | return false; | 501 | return false; |
497 | } | 502 | } |
503 | |||
498 | protected bool IsFriendWithPerms(UUID user,UUID objectOwner) | 504 | protected bool IsFriendWithPerms(UUID user,UUID objectOwner) |
499 | { | 505 | { |
500 | 506 | ||
@@ -896,9 +902,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
896 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 902 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
897 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 903 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
898 | 904 | ||
899 | if (IsEstateManager(user) && m_RegionOwnerIsGod) | ||
900 | return true; | ||
901 | |||
902 | return IsAdministrator(user); | 905 | return IsAdministrator(user); |
903 | } | 906 | } |
904 | 907 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 67395fa..fa9bf19 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -71,13 +71,18 @@ namespace OpenSim.Region.Framework.Interfaces | |||
71 | /// <summary> | 71 | /// <summary> |
72 | /// Start all the scripts contained in this entity's inventory | 72 | /// Start all the scripts contained in this entity's inventory |
73 | /// </summary> | 73 | /// </summary> |
74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); | 74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); |
75 | |||
75 | ArrayList GetScriptErrors(UUID itemID); | 76 | ArrayList GetScriptErrors(UUID itemID); |
76 | 77 | ||
77 | /// <summary> | 78 | /// <summary> |
78 | /// Stop all the scripts in this entity. | 79 | /// Stop all the scripts in this entity. |
79 | /// </summary> | 80 | /// </summary> |
80 | void RemoveScriptInstances(); | 81 | /// <param name="sceneObjectBeingDeleted"> |
82 | /// Should be true if these scripts are being removed because the scene | ||
83 | /// object is being deleted. This will prevent spurious updates to the client. | ||
84 | /// </param> | ||
85 | void RemoveScriptInstances(bool sceneObjectBeingDeleted); | ||
81 | 86 | ||
82 | /// <summary> | 87 | /// <summary> |
83 | /// Start a script which is in this entity's inventory. | 88 | /// Start a script which is in this entity's inventory. |
@@ -103,7 +108,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
103 | /// Stop a script which is in this prim's inventory. | 108 | /// Stop a script which is in this prim's inventory. |
104 | /// </summary> | 109 | /// </summary> |
105 | /// <param name="itemId"></param> | 110 | /// <param name="itemId"></param> |
106 | void RemoveScriptInstance(UUID itemId); | 111 | /// <param name="sceneObjectBeingDeleted"> |
112 | /// Should be true if these scripts are being removed because the scene | ||
113 | /// object is being deleted. This will prevent spurious updates to the client. | ||
114 | /// </param> | ||
115 | void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted); | ||
107 | 116 | ||
108 | /// <summary> | 117 | /// <summary> |
109 | /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative | 118 | /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative |
@@ -135,6 +144,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
135 | TaskInventoryItem GetInventoryItem(UUID itemId); | 144 | TaskInventoryItem GetInventoryItem(UUID itemId); |
136 | 145 | ||
137 | /// <summary> | 146 | /// <summary> |
147 | /// Get inventory items by name. | ||
148 | /// </summary> | ||
149 | /// <param name="name"></param> | ||
150 | /// <returns> | ||
151 | /// A list of inventory items with that name. | ||
152 | /// If no inventory item has that name then an empty list is returned. | ||
153 | /// </returns> | ||
154 | IList<TaskInventoryItem> GetInventoryItems(string name); | ||
155 | |||
156 | /// <summary> | ||
138 | /// Update an existing inventory item. | 157 | /// Update an existing inventory item. |
139 | /// </summary> | 158 | /// </summary> |
140 | /// <param name="item">The updated item. An item with the same id must already exist | 159 | /// <param name="item">The updated item. An item with the same id must already exist |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 74526c4..948b9dc 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -49,10 +49,49 @@ namespace OpenSim.Region.Framework.Interfaces | |||
49 | 49 | ||
50 | public interface IWorldComm | 50 | public interface IWorldComm |
51 | { | 51 | { |
52 | /// <summary> | ||
53 | /// Create a listen event callback with the specified filters. | ||
54 | /// The parameters localID,itemID are needed to uniquely identify | ||
55 | /// the script during 'peek' time. Parameter hostID is needed to | ||
56 | /// determine the position of the script. | ||
57 | /// </summary> | ||
58 | /// <param name="localID">localID of the script engine</param> | ||
59 | /// <param name="itemID">UUID of the script engine</param> | ||
60 | /// <param name="hostID">UUID of the SceneObjectPart</param> | ||
61 | /// <param name="channel">channel to listen on</param> | ||
62 | /// <param name="name">name to filter on</param> | ||
63 | /// <param name="id">key to filter on (user given, could be totally faked)</param> | ||
64 | /// <param name="msg">msg to filter on</param> | ||
65 | /// <returns>number of the scripts handle</returns> | ||
52 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); | 66 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); |
67 | |||
68 | /// <summary> | ||
69 | /// This method scans over the objects which registered an interest in listen callbacks. | ||
70 | /// For everyone it finds, it checks if it fits the given filter. If it does, then | ||
71 | /// enqueue the message for delivery to the objects listen event handler. | ||
72 | /// The enqueued ListenerInfo no longer has filter values, but the actually trigged values. | ||
73 | /// Objects that do an llSay have their messages delivered here and for nearby avatars, | ||
74 | /// the OnChatFromClient event is used. | ||
75 | /// </summary> | ||
76 | /// <param name="type">type of delvery (whisper,say,shout or regionwide)</param> | ||
77 | /// <param name="channel">channel to sent on</param> | ||
78 | /// <param name="name">name of sender (object or avatar)</param> | ||
79 | /// <param name="id">key of sender (object or avatar)</param> | ||
80 | /// <param name="msg">msg to sent</param> | ||
53 | void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); | 81 | void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); |
82 | |||
83 | /// <summary> | ||
84 | /// Are there any listen events ready to be dispatched? | ||
85 | /// </summary> | ||
86 | /// <returns>boolean indication</returns> | ||
54 | bool HasMessages(); | 87 | bool HasMessages(); |
88 | |||
89 | /// <summary> | ||
90 | /// Pop the first availlable listen event from the queue | ||
91 | /// </summary> | ||
92 | /// <returns>ListenerInfo with filter filled in</returns> | ||
55 | IWorldCommListenerInfo GetNextMessage(); | 93 | IWorldCommListenerInfo GetNextMessage(); |
94 | |||
56 | void ListenControl(UUID itemID, int handle, int active); | 95 | void ListenControl(UUID itemID, int handle, int active); |
57 | void ListenRemove(UUID itemID, int handle); | 96 | void ListenRemove(UUID itemID, int handle); |
58 | void DeleteListener(UUID itemID); | 97 | void DeleteListener(UUID itemID); |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 399379e..473920e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -27,11 +27,13 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Client; | 34 | using OpenSim.Framework.Client; |
33 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
34 | using Caps=OpenSim.Framework.Capabilities.Caps; | 36 | using Caps = OpenSim.Framework.Capabilities.Caps; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
36 | 38 | ||
37 | namespace OpenSim.Region.Framework.Scenes | 39 | namespace OpenSim.Region.Framework.Scenes |
@@ -41,6 +43,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
41 | /// </summary> | 43 | /// </summary> |
42 | public class EventManager | 44 | public class EventManager |
43 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
44 | public delegate void OnFrameDelegate(); | 48 | public delegate void OnFrameDelegate(); |
45 | 49 | ||
46 | public event OnFrameDelegate OnFrame; | 50 | public event OnFrameDelegate OnFrame; |
@@ -92,8 +96,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
92 | public delegate void OnShutdownDelegate(); | 96 | public delegate void OnShutdownDelegate(); |
93 | 97 | ||
94 | public event OnShutdownDelegate OnShutdown; | 98 | public event OnShutdownDelegate OnShutdown; |
95 | 99 | ||
96 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
97 | public delegate void ObjectDeGrabDelegate(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | 100 | public delegate void ObjectDeGrabDelegate(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); |
98 | public delegate void ScriptResetDelegate(uint localID, UUID itemID); | 101 | public delegate void ScriptResetDelegate(uint localID, UUID itemID); |
99 | 102 | ||
@@ -103,62 +106,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | 106 | ||
104 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; | 107 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; |
105 | 108 | ||
109 | /// <summary> | ||
110 | /// Called when an object is touched/grabbed. | ||
111 | /// </summary> | ||
112 | /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of | ||
113 | /// the root part. | ||
114 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
106 | public event ObjectGrabDelegate OnObjectGrab; | 115 | public event ObjectGrabDelegate OnObjectGrab; |
116 | |||
117 | public event ObjectGrabDelegate OnObjectGrabbing; | ||
107 | public event ObjectDeGrabDelegate OnObjectDeGrab; | 118 | public event ObjectDeGrabDelegate OnObjectDeGrab; |
108 | public event ScriptResetDelegate OnScriptReset; | 119 | public event ScriptResetDelegate OnScriptReset; |
109 | 120 | ||
110 | public event OnPermissionErrorDelegate OnPermissionError; | 121 | public event OnPermissionErrorDelegate OnPermissionError; |
111 | 122 | ||
112 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); | 123 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); |
113 | |||
114 | public event NewRezScript OnRezScript; | 124 | public event NewRezScript OnRezScript; |
115 | 125 | ||
116 | public delegate void RemoveScript(uint localID, UUID itemID); | 126 | public delegate void RemoveScript(uint localID, UUID itemID); |
117 | |||
118 | public event RemoveScript OnRemoveScript; | 127 | public event RemoveScript OnRemoveScript; |
119 | 128 | ||
120 | public delegate void StartScript(uint localID, UUID itemID); | 129 | public delegate void StartScript(uint localID, UUID itemID); |
121 | |||
122 | public event StartScript OnStartScript; | 130 | public event StartScript OnStartScript; |
123 | 131 | ||
124 | public delegate void StopScript(uint localID, UUID itemID); | 132 | public delegate void StopScript(uint localID, UUID itemID); |
125 | |||
126 | public event StopScript OnStopScript; | 133 | public event StopScript OnStopScript; |
127 | 134 | ||
128 | public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta); | 135 | public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta); |
129 | |||
130 | public event SceneGroupMoved OnSceneGroupMove; | 136 | public event SceneGroupMoved OnSceneGroupMove; |
131 | 137 | ||
132 | public delegate void SceneGroupGrabed(UUID groupID, Vector3 offset, UUID userID); | 138 | public delegate void SceneGroupGrabed(UUID groupID, Vector3 offset, UUID userID); |
133 | |||
134 | public event SceneGroupGrabed OnSceneGroupGrab; | 139 | public event SceneGroupGrabed OnSceneGroupGrab; |
135 | 140 | ||
136 | public delegate bool SceneGroupSpinStarted(UUID groupID); | 141 | public delegate bool SceneGroupSpinStarted(UUID groupID); |
137 | |||
138 | public event SceneGroupSpinStarted OnSceneGroupSpinStart; | 142 | public event SceneGroupSpinStarted OnSceneGroupSpinStart; |
139 | 143 | ||
140 | public delegate bool SceneGroupSpun(UUID groupID, Quaternion rotation); | 144 | public delegate bool SceneGroupSpun(UUID groupID, Quaternion rotation); |
141 | |||
142 | public event SceneGroupSpun OnSceneGroupSpin; | 145 | public event SceneGroupSpun OnSceneGroupSpin; |
143 | 146 | ||
144 | public delegate void LandObjectAdded(ILandObject newParcel); | 147 | public delegate void LandObjectAdded(ILandObject newParcel); |
145 | |||
146 | public event LandObjectAdded OnLandObjectAdded; | 148 | public event LandObjectAdded OnLandObjectAdded; |
147 | 149 | ||
148 | public delegate void LandObjectRemoved(UUID globalID); | 150 | public delegate void LandObjectRemoved(UUID globalID); |
149 | |||
150 | public event LandObjectRemoved OnLandObjectRemoved; | 151 | public event LandObjectRemoved OnLandObjectRemoved; |
151 | 152 | ||
152 | public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID); | 153 | public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID); |
153 | |||
154 | public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; | 154 | public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; |
155 | 155 | ||
156 | public delegate void SignificantClientMovement(IClientAPI remote_client); | 156 | public delegate void SignificantClientMovement(IClientAPI remote_client); |
157 | |||
158 | public event SignificantClientMovement OnSignificantClientMovement; | 157 | public event SignificantClientMovement OnSignificantClientMovement; |
159 | 158 | ||
160 | public delegate void IncomingInstantMessage(GridInstantMessage message); | 159 | public delegate void IncomingInstantMessage(GridInstantMessage message); |
161 | |||
162 | public event IncomingInstantMessage OnIncomingInstantMessage; | 160 | public event IncomingInstantMessage OnIncomingInstantMessage; |
163 | 161 | ||
164 | public event IncomingInstantMessage OnUnhandledInstantMessage; | 162 | public event IncomingInstantMessage OnUnhandledInstantMessage; |
@@ -214,14 +212,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | public delegate void RequestChangeWaterHeight(float height); | 212 | public delegate void RequestChangeWaterHeight(float height); |
215 | 213 | ||
216 | public event RequestChangeWaterHeight OnRequestChangeWaterHeight; | 214 | public event RequestChangeWaterHeight OnRequestChangeWaterHeight; |
217 | 215 | ||
218 | public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar); | 216 | /// <summary> |
219 | 217 | /// Fired if any avatar is 'killed' due to its health falling to zero | |
218 | /// </summary> | ||
220 | public event AvatarKillData OnAvatarKilled; | 219 | public event AvatarKillData OnAvatarKilled; |
220 | public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar); | ||
221 | 221 | ||
222 | public delegate void ScriptTimerEvent(uint localID, double timerinterval); | 222 | // public delegate void ScriptTimerEvent(uint localID, double timerinterval); |
223 | 223 | ||
224 | public event ScriptTimerEvent OnScriptTimerEvent; | 224 | // public event ScriptTimerEvent OnScriptTimerEvent; |
225 | 225 | ||
226 | public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); | 226 | public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); |
227 | public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); | 227 | public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); |
@@ -312,9 +312,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
312 | public event EmptyScriptCompileQueue OnEmptyScriptCompileQueue; | 312 | public event EmptyScriptCompileQueue OnEmptyScriptCompileQueue; |
313 | 313 | ||
314 | /// <summary> | 314 | /// <summary> |
315 | /// Called whenever an object is attached, or detached | 315 | /// Called whenever an object is attached, or detached from an in-world presence. |
316 | /// from an in-world presence. | ||
317 | /// </summary> | 316 | /// </summary> |
317 | /// If the object is being attached, then the avatarID will be present. If the object is being detached then | ||
318 | /// the avatarID is UUID.Zero (I know, this doesn't make much sense but now it's historical). | ||
318 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); | 319 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); |
319 | public event Attach OnAttach; | 320 | public event Attach OnAttach; |
320 | 321 | ||
@@ -387,607 +388,1263 @@ namespace OpenSim.Region.Framework.Scenes | |||
387 | public event LandBuy OnLandBuy; | 388 | public event LandBuy OnLandBuy; |
388 | public event LandBuy OnValidateLandBuy; | 389 | public event LandBuy OnValidateLandBuy; |
389 | 390 | ||
390 | /* Designated Event Deletage Instances */ | ||
391 | |||
392 | private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent; | ||
393 | private ScriptAtTargetEvent handlerScriptAtTargetEvent = null; | ||
394 | private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null; | ||
395 | private ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = null; | ||
396 | private ScriptNotAtRotTargetEvent handlerScriptNotAtRotTargetEvent = null; | ||
397 | private ClientMovement handlerClientMovement = null; //OnClientMovement; | ||
398 | private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError; | ||
399 | private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole; | ||
400 | private OnFrameDelegate handlerFrame = null; //OnFrame; | ||
401 | private OnNewClientDelegate handlerNewClient = null; //OnNewClient; | ||
402 | private OnClientConnectCoreDelegate handlerClientConnect = null; //OnClientConnect | ||
403 | private OnNewPresenceDelegate handlerNewPresence = null; //OnNewPresence; | ||
404 | private OnRemovePresenceDelegate handlerRemovePresence = null; //OnRemovePresence; | ||
405 | private OnBackupDelegate handlerBackup = null; //OnBackup; | ||
406 | private OnParcelPrimCountUpdateDelegate handlerParcelPrimCountUpdate = null; //OnParcelPrimCountUpdate; | ||
407 | private MoneyTransferEvent handlerMoneyTransfer = null; //OnMoneyTransfer; | ||
408 | private OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = null; //OnParcelPrimCountAdd; | ||
409 | private OnShutdownDelegate handlerShutdown = null; //OnShutdown; | ||
410 | private ObjectGrabDelegate handlerObjectGrab = null; //OnObjectGrab; | ||
411 | private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab; | ||
412 | private ScriptResetDelegate handlerScriptReset = null; // OnScriptReset | ||
413 | private NewRezScript handlerRezScript = null; //OnRezScript; | ||
414 | private RemoveScript handlerRemoveScript = null; //OnRemoveScript; | ||
415 | private StartScript handlerStartScript = null; //OnStartScript; | ||
416 | private StopScript handlerStopScript = null; //OnStopScript; | ||
417 | private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove; | ||
418 | private SceneGroupGrabed handlerSceneGroupGrab = null; //OnSceneGroupGrab; | ||
419 | private SceneGroupSpinStarted handlerSceneGroupSpinStarted = null; //OnSceneGroupSpinStart; | ||
420 | private SceneGroupSpun handlerSceneGroupSpin = null; //OnSceneGroupSpin; | ||
421 | private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded; | ||
422 | private LandObjectRemoved handlerLandObjectRemoved = null; //OnLandObjectRemoved; | ||
423 | private AvatarEnteringNewParcel handlerAvatarEnteringNewParcel = null; //OnAvatarEnteringNewParcel; | ||
424 | private IncomingInstantMessage handlerIncomingInstantMessage = null; //OnIncomingInstantMessage; | ||
425 | private IncomingInstantMessage handlerUnhandledInstantMessage = null; //OnUnhandledInstantMessage; | ||
426 | private ClientClosed handlerClientClosed = null; //OnClientClosed; | ||
427 | private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; | ||
428 | private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent; | ||
429 | private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; | ||
430 | private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; | ||
431 | private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; | ||
432 | private ChatFromWorldEvent handlerChatFromWorld = null; // OnChatFromWorld; | ||
433 | private ChatFromClientEvent handlerChatFromClient = null; // OnChatFromClient; | ||
434 | private ChatBroadcastEvent handlerChatBroadcast = null; // OnChatBroadcast; | ||
435 | private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; | ||
436 | private RequestChangeWaterHeight handlerRequestChangeWaterHeight = null; //OnRequestChangeWaterHeight | ||
437 | private ScriptControlEvent handlerScriptControlEvent = null; | ||
438 | private SignificantClientMovement handlerSignificantClientMovement = null; | ||
439 | |||
440 | private LandBuy handlerLandBuy = null; | ||
441 | private LandBuy handlerValidateLandBuy = null; | ||
442 | private AvatarKillData handlerAvatarKill = null; | ||
443 | |||
444 | private NoticeNoLandDataFromStorage handlerNoticeNoLandDataFromStorage = null; | ||
445 | private IncomingLandDataFromStorage handlerIncomingLandDataFromStorage = null; | ||
446 | private SetAllowForcefulBan handlerSetAllowForcefulBan = null; | ||
447 | private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null; | ||
448 | private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; | ||
449 | private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; | ||
450 | // TODO: unused: private ScriptTimerEvent handlerScriptTimerEvent = null; | ||
451 | private EstateToolsSunUpdate handlerEstateToolsSunUpdate = null; | ||
452 | |||
453 | private ScriptColliding handlerCollidingStart = null; | ||
454 | private ScriptColliding handlerColliding = null; | ||
455 | private ScriptColliding handlerCollidingEnd = null; | ||
456 | private ScriptColliding handlerLandCollidingStart = null; | ||
457 | private ScriptColliding handlerLandColliding = null; | ||
458 | private ScriptColliding handlerLandCollidingEnd = null; | ||
459 | private GetScriptRunning handlerGetScriptRunning = null; | ||
460 | |||
461 | private SunLindenHour handlerCurrentTimeAsLindenSunHour = null; | ||
462 | private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null; | ||
463 | |||
464 | private OarFileLoaded handlerOarFileLoaded = null; | ||
465 | private OarFileSaved handlerOarFileSaved = null; | ||
466 | |||
467 | private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null; | ||
468 | |||
469 | private Attach handlerOnAttach = null; | ||
470 | private RegionUp handlerOnRegionUp = null; | ||
471 | |||
472 | public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) | 391 | public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) |
473 | { | 392 | { |
474 | handlerOnAttach = OnAttach; | 393 | Attach handlerOnAttach = OnAttach; |
475 | if (handlerOnAttach != null) | 394 | if (handlerOnAttach != null) |
476 | handlerOnAttach(localID, itemID, avatarID); | 395 | { |
396 | foreach (Attach d in handlerOnAttach.GetInvocationList()) | ||
397 | { | ||
398 | try | ||
399 | { | ||
400 | d(localID, itemID, avatarID); | ||
401 | } | ||
402 | catch (Exception e) | ||
403 | { | ||
404 | m_log.ErrorFormat( | ||
405 | "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", | ||
406 | e.Message, e.StackTrace); | ||
407 | } | ||
408 | } | ||
409 | } | ||
477 | } | 410 | } |
478 | 411 | ||
479 | public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 412 | public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
480 | { | 413 | { |
481 | handlerGetScriptRunning = OnGetScriptRunning; | 414 | GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; |
482 | if (handlerGetScriptRunning != null) | 415 | if (handlerGetScriptRunning != null) |
483 | handlerGetScriptRunning(controllingClient, objectID, itemID); | 416 | { |
417 | foreach (GetScriptRunning d in handlerGetScriptRunning.GetInvocationList()) | ||
418 | { | ||
419 | try | ||
420 | { | ||
421 | d(controllingClient, objectID, itemID); | ||
422 | } | ||
423 | catch (Exception e) | ||
424 | { | ||
425 | m_log.ErrorFormat( | ||
426 | "[EVENT MANAGER]: Delegate for TriggerGetScriptRunning failed - continuing. {0} {1}", | ||
427 | e.Message, e.StackTrace); | ||
428 | } | ||
429 | } | ||
430 | } | ||
484 | } | 431 | } |
485 | 432 | ||
486 | public void TriggerOnScriptChangedEvent(uint localID, uint change) | 433 | public void TriggerOnScriptChangedEvent(uint localID, uint change) |
487 | { | 434 | { |
488 | handlerScriptChangedEvent = OnScriptChangedEvent; | 435 | ScriptChangedEvent handlerScriptChangedEvent = OnScriptChangedEvent; |
489 | if (handlerScriptChangedEvent != null) | 436 | if (handlerScriptChangedEvent != null) |
490 | handlerScriptChangedEvent(localID, change); | 437 | { |
438 | foreach (ScriptChangedEvent d in handlerScriptChangedEvent.GetInvocationList()) | ||
439 | { | ||
440 | try | ||
441 | { | ||
442 | d(localID, change); | ||
443 | } | ||
444 | catch (Exception e) | ||
445 | { | ||
446 | m_log.ErrorFormat( | ||
447 | "[EVENT MANAGER]: Delegate for TriggerOnScriptChangedEvent failed - continuing. {0} {1}", | ||
448 | e.Message, e.StackTrace); | ||
449 | } | ||
450 | } | ||
451 | } | ||
491 | } | 452 | } |
492 | 453 | ||
493 | public void TriggerOnClientMovement(ScenePresence avatar) | 454 | public void TriggerOnClientMovement(ScenePresence avatar) |
494 | { | 455 | { |
495 | handlerClientMovement = OnClientMovement; | 456 | ClientMovement handlerClientMovement = OnClientMovement; |
496 | if (handlerClientMovement != null) | 457 | if (handlerClientMovement != null) |
497 | handlerClientMovement(avatar); | 458 | { |
459 | foreach (ClientMovement d in handlerClientMovement.GetInvocationList()) | ||
460 | { | ||
461 | try | ||
462 | { | ||
463 | d(avatar); | ||
464 | } | ||
465 | catch (Exception e) | ||
466 | { | ||
467 | m_log.ErrorFormat( | ||
468 | "[EVENT MANAGER]: Delegate for TriggerOnClientMovement failed - continuing. {0} {1}", | ||
469 | e.Message, e.StackTrace); | ||
470 | } | ||
471 | } | ||
472 | } | ||
498 | } | 473 | } |
499 | 474 | ||
500 | public void TriggerPermissionError(UUID user, string reason) | 475 | public void TriggerPermissionError(UUID user, string reason) |
501 | { | 476 | { |
502 | handlerPermissionError = OnPermissionError; | 477 | OnPermissionErrorDelegate handlerPermissionError = OnPermissionError; |
503 | if (handlerPermissionError != null) | 478 | if (handlerPermissionError != null) |
504 | handlerPermissionError(user, reason); | 479 | { |
480 | foreach (OnPermissionErrorDelegate d in handlerPermissionError.GetInvocationList()) | ||
481 | { | ||
482 | try | ||
483 | { | ||
484 | d(user, reason); | ||
485 | } | ||
486 | catch (Exception e) | ||
487 | { | ||
488 | m_log.ErrorFormat( | ||
489 | "[EVENT MANAGER]: Delegate for TriggerPermissionError failed - continuing. {0} {1}", | ||
490 | e.Message, e.StackTrace); | ||
491 | } | ||
492 | } | ||
493 | } | ||
505 | } | 494 | } |
506 | 495 | ||
507 | public void TriggerOnPluginConsole(string[] args) | 496 | public void TriggerOnPluginConsole(string[] args) |
508 | { | 497 | { |
509 | handlerPluginConsole = OnPluginConsole; | 498 | OnPluginConsoleDelegate handlerPluginConsole = OnPluginConsole; |
510 | if (handlerPluginConsole != null) | 499 | if (handlerPluginConsole != null) |
511 | handlerPluginConsole(args); | 500 | { |
501 | foreach (OnPluginConsoleDelegate d in handlerPluginConsole.GetInvocationList()) | ||
502 | { | ||
503 | try | ||
504 | { | ||
505 | d(args); | ||
506 | } | ||
507 | catch (Exception e) | ||
508 | { | ||
509 | m_log.ErrorFormat( | ||
510 | "[EVENT MANAGER]: Delegate for TriggerOnPluginConsole failed - continuing. {0} {1}", | ||
511 | e.Message, e.StackTrace); | ||
512 | } | ||
513 | } | ||
514 | } | ||
512 | } | 515 | } |
513 | 516 | ||
514 | public void TriggerOnFrame() | 517 | public void TriggerOnFrame() |
515 | { | 518 | { |
516 | handlerFrame = OnFrame; | 519 | OnFrameDelegate handlerFrame = OnFrame; |
517 | if (handlerFrame != null) | 520 | if (handlerFrame != null) |
518 | { | 521 | { |
519 | handlerFrame(); | 522 | foreach (OnFrameDelegate d in handlerFrame.GetInvocationList()) |
520 | } | 523 | { |
524 | try | ||
525 | { | ||
526 | d(); | ||
527 | } | ||
528 | catch (Exception e) | ||
529 | { | ||
530 | m_log.ErrorFormat( | ||
531 | "[EVENT MANAGER]: Delegate for TriggerOnFrame failed - continuing. {0} {1}", | ||
532 | e.Message, e.StackTrace); | ||
533 | } | ||
534 | } | ||
535 | } | ||
521 | } | 536 | } |
522 | 537 | ||
523 | public void TriggerOnNewClient(IClientAPI client) | 538 | public void TriggerOnNewClient(IClientAPI client) |
524 | { | 539 | { |
525 | handlerNewClient = OnNewClient; | 540 | OnNewClientDelegate handlerNewClient = OnNewClient; |
526 | if (handlerNewClient != null) | 541 | if (handlerNewClient != null) |
527 | handlerNewClient(client); | 542 | { |
543 | foreach (OnNewClientDelegate d in handlerNewClient.GetInvocationList()) | ||
544 | { | ||
545 | try | ||
546 | { | ||
547 | d(client); | ||
548 | } | ||
549 | catch (Exception e) | ||
550 | { | ||
551 | m_log.ErrorFormat( | ||
552 | "[EVENT MANAGER]: Delegate for TriggerOnNewClient failed - continuing. {0} {1}", | ||
553 | e.Message, e.StackTrace); | ||
554 | } | ||
555 | } | ||
556 | } | ||
528 | 557 | ||
529 | if (client is IClientCore) | 558 | if (client is IClientCore) |
530 | { | 559 | { |
531 | handlerClientConnect = OnClientConnect; | 560 | OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect; |
532 | if (handlerClientConnect != null) | 561 | if (handlerClientConnect != null) |
533 | handlerClientConnect((IClientCore)client); | 562 | { |
563 | foreach (OnClientConnectCoreDelegate d in handlerClientConnect.GetInvocationList()) | ||
564 | { | ||
565 | try | ||
566 | { | ||
567 | d((IClientCore)client); | ||
568 | } | ||
569 | catch (Exception e) | ||
570 | { | ||
571 | m_log.ErrorFormat( | ||
572 | "[EVENT MANAGER]: Delegate for TriggerOnNewClient (IClientCore) failed - continuing. {0} {1}", | ||
573 | e.Message, e.StackTrace); | ||
574 | } | ||
575 | } | ||
576 | } | ||
534 | } | 577 | } |
535 | } | 578 | } |
536 | 579 | ||
537 | public void TriggerOnNewPresence(ScenePresence presence) | 580 | public void TriggerOnNewPresence(ScenePresence presence) |
538 | { | 581 | { |
539 | handlerNewPresence = OnNewPresence; | 582 | OnNewPresenceDelegate handlerNewPresence = OnNewPresence; |
540 | if (handlerNewPresence != null) | 583 | if (handlerNewPresence != null) |
541 | handlerNewPresence(presence); | 584 | { |
585 | foreach (OnNewPresenceDelegate d in handlerNewPresence.GetInvocationList()) | ||
586 | { | ||
587 | try | ||
588 | { | ||
589 | d(presence); | ||
590 | } | ||
591 | catch (Exception e) | ||
592 | { | ||
593 | m_log.ErrorFormat( | ||
594 | "[EVENT MANAGER]: Delegate for TriggerOnNewPresence failed - continuing. {0} {1}", | ||
595 | e.Message, e.StackTrace); | ||
596 | } | ||
597 | } | ||
598 | } | ||
542 | } | 599 | } |
543 | 600 | ||
544 | public void TriggerOnRemovePresence(UUID agentId) | 601 | public void TriggerOnRemovePresence(UUID agentId) |
545 | { | 602 | { |
546 | handlerRemovePresence = OnRemovePresence; | 603 | OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence; |
547 | if (handlerRemovePresence != null) | 604 | if (handlerRemovePresence != null) |
548 | { | 605 | { |
549 | handlerRemovePresence(agentId); | 606 | foreach (OnRemovePresenceDelegate d in handlerRemovePresence.GetInvocationList()) |
550 | } | 607 | { |
608 | try | ||
609 | { | ||
610 | d(agentId); | ||
611 | } | ||
612 | catch (Exception e) | ||
613 | { | ||
614 | m_log.ErrorFormat( | ||
615 | "[EVENT MANAGER]: Delegate for TriggerOnRemovePresence failed - continuing. {0} {1}", | ||
616 | e.Message, e.StackTrace); | ||
617 | } | ||
618 | } | ||
619 | } | ||
551 | } | 620 | } |
552 | 621 | ||
553 | public void TriggerOnBackup(IRegionDataStore dstore) | 622 | public void TriggerOnBackup(IRegionDataStore dstore) |
554 | { | 623 | { |
555 | handlerBackup = OnBackup; | 624 | OnBackupDelegate handlerOnAttach = OnBackup; |
556 | if (handlerBackup != null) | 625 | if (handlerOnAttach != null) |
557 | { | 626 | { |
558 | handlerBackup(dstore, false); | 627 | foreach (OnBackupDelegate d in handlerOnAttach.GetInvocationList()) |
559 | } | 628 | { |
629 | try | ||
630 | { | ||
631 | d(dstore, false); | ||
632 | } | ||
633 | catch (Exception e) | ||
634 | { | ||
635 | m_log.ErrorFormat( | ||
636 | "[EVENT MANAGER]: Delegate for TriggerOnBackup failed - continuing. {0} {1}", | ||
637 | e.Message, e.StackTrace); | ||
638 | } | ||
639 | } | ||
640 | } | ||
560 | } | 641 | } |
561 | 642 | ||
562 | public void TriggerParcelPrimCountUpdate() | 643 | public void TriggerParcelPrimCountUpdate() |
563 | { | 644 | { |
564 | handlerParcelPrimCountUpdate = OnParcelPrimCountUpdate; | 645 | OnParcelPrimCountUpdateDelegate handlerParcelPrimCountUpdate = OnParcelPrimCountUpdate; |
565 | if (handlerParcelPrimCountUpdate != null) | 646 | if (handlerParcelPrimCountUpdate != null) |
566 | { | 647 | { |
567 | handlerParcelPrimCountUpdate(); | 648 | foreach (OnParcelPrimCountUpdateDelegate d in handlerParcelPrimCountUpdate.GetInvocationList()) |
568 | } | 649 | { |
569 | } | 650 | try |
570 | 651 | { | |
571 | public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e) | 652 | d(); |
572 | { | 653 | } |
573 | handlerMoneyTransfer = OnMoneyTransfer; | 654 | catch (Exception e) |
655 | { | ||
656 | m_log.ErrorFormat( | ||
657 | "[EVENT MANAGER]: Delegate for TriggerParcelPrimCountUpdate failed - continuing. {0} {1}", | ||
658 | e.Message, e.StackTrace); | ||
659 | } | ||
660 | } | ||
661 | } | ||
662 | } | ||
663 | |||
664 | public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) | ||
665 | { | ||
666 | MoneyTransferEvent handlerMoneyTransfer = OnMoneyTransfer; | ||
574 | if (handlerMoneyTransfer != null) | 667 | if (handlerMoneyTransfer != null) |
575 | { | 668 | { |
576 | handlerMoneyTransfer(sender, e); | 669 | foreach (MoneyTransferEvent d in handlerMoneyTransfer.GetInvocationList()) |
577 | } | 670 | { |
671 | try | ||
672 | { | ||
673 | d(sender, args); | ||
674 | } | ||
675 | catch (Exception e) | ||
676 | { | ||
677 | m_log.ErrorFormat( | ||
678 | "[EVENT MANAGER]: Delegate for TriggerMoneyTransfer failed - continuing. {0} {1}", | ||
679 | e.Message, e.StackTrace); | ||
680 | } | ||
681 | } | ||
682 | } | ||
578 | } | 683 | } |
579 | 684 | ||
580 | public void TriggerTerrainTick() | 685 | public void TriggerTerrainTick() |
581 | { | 686 | { |
582 | handlerTerrainTick = OnTerrainTick; | 687 | OnTerrainTickDelegate handlerTerrainTick = OnTerrainTick; |
583 | if (handlerTerrainTick != null) | 688 | if (handlerTerrainTick != null) |
584 | { | 689 | { |
585 | handlerTerrainTick(); | 690 | foreach (OnTerrainTickDelegate d in handlerTerrainTick.GetInvocationList()) |
586 | } | 691 | { |
692 | try | ||
693 | { | ||
694 | d(); | ||
695 | } | ||
696 | catch (Exception e) | ||
697 | { | ||
698 | m_log.ErrorFormat( | ||
699 | "[EVENT MANAGER]: Delegate for TriggerTerrainTick failed - continuing. {0} {1}", | ||
700 | e.Message, e.StackTrace); | ||
701 | } | ||
702 | } | ||
703 | } | ||
587 | } | 704 | } |
588 | 705 | ||
589 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) | 706 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) |
590 | { | 707 | { |
591 | handlerParcelPrimCountAdd = OnParcelPrimCountAdd; | 708 | OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; |
592 | if (handlerParcelPrimCountAdd != null) | 709 | if (handlerParcelPrimCountAdd != null) |
593 | { | 710 | { |
594 | handlerParcelPrimCountAdd(obj); | 711 | foreach (OnParcelPrimCountAddDelegate d in handlerParcelPrimCountAdd.GetInvocationList()) |
595 | } | 712 | { |
713 | try | ||
714 | { | ||
715 | d(obj); | ||
716 | } | ||
717 | catch (Exception e) | ||
718 | { | ||
719 | m_log.ErrorFormat( | ||
720 | "[EVENT MANAGER]: Delegate for TriggerParcelPrimCountAdd failed - continuing. {0} {1}", | ||
721 | e.Message, e.StackTrace); | ||
722 | } | ||
723 | } | ||
724 | } | ||
596 | } | 725 | } |
597 | 726 | ||
598 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) | 727 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) |
599 | { | 728 | { |
600 | handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; | 729 | ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; |
601 | if (handlerObjectBeingRemovedFromScene != null) | 730 | if (handlerObjectBeingRemovedFromScene != null) |
602 | { | 731 | { |
603 | handlerObjectBeingRemovedFromScene(obj); | 732 | foreach (ObjectBeingRemovedFromScene d in handlerObjectBeingRemovedFromScene.GetInvocationList()) |
604 | } | 733 | { |
734 | try | ||
735 | { | ||
736 | d(obj); | ||
737 | } | ||
738 | catch (Exception e) | ||
739 | { | ||
740 | m_log.ErrorFormat( | ||
741 | "[EVENT MANAGER]: Delegate for TriggerObjectBeingRemovedFromScene failed - continuing. {0} {1}", | ||
742 | e.Message, e.StackTrace); | ||
743 | } | ||
744 | } | ||
745 | } | ||
605 | } | 746 | } |
606 | 747 | ||
607 | public void TriggerShutdown() | 748 | public void TriggerShutdown() |
608 | { | 749 | { |
609 | handlerShutdown = OnShutdown; | 750 | OnShutdownDelegate handlerShutdown = OnShutdown; |
610 | if (handlerShutdown != null) | 751 | if (handlerShutdown != null) |
611 | handlerShutdown(); | 752 | { |
753 | foreach (OnShutdownDelegate d in handlerShutdown.GetInvocationList()) | ||
754 | { | ||
755 | try | ||
756 | { | ||
757 | d(); | ||
758 | } | ||
759 | catch (Exception e) | ||
760 | { | ||
761 | m_log.ErrorFormat( | ||
762 | "[EVENT MANAGER]: Delegate for TriggerShutdown failed - continuing. {0} {1}", | ||
763 | e.Message, e.StackTrace); | ||
764 | } | ||
765 | } | ||
766 | } | ||
612 | } | 767 | } |
613 | 768 | ||
614 | public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | 769 | public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
615 | { | 770 | { |
616 | handlerObjectGrab = OnObjectGrab; | 771 | ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; |
617 | if (handlerObjectGrab != null) | 772 | if (handlerObjectGrab != null) |
618 | { | 773 | { |
619 | handlerObjectGrab(localID, originalID, offsetPos, remoteClient, surfaceArgs); | 774 | foreach (ObjectGrabDelegate d in handlerObjectGrab.GetInvocationList()) |
620 | } | 775 | { |
621 | } | 776 | try |
777 | { | ||
778 | d(localID, originalID, offsetPos, remoteClient, surfaceArgs); | ||
779 | } | ||
780 | catch (Exception e) | ||
781 | { | ||
782 | m_log.ErrorFormat( | ||
783 | "[EVENT MANAGER]: Delegate for TriggerObjectGrab failed - continuing. {0} {1}", | ||
784 | e.Message, e.StackTrace); | ||
785 | } | ||
786 | } | ||
787 | } | ||
788 | } | ||
789 | |||
790 | public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | ||
791 | { | ||
792 | ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; | ||
793 | if (handlerObjectGrabbing != null) | ||
794 | { | ||
795 | foreach (ObjectGrabDelegate d in handlerObjectGrabbing.GetInvocationList()) | ||
796 | { | ||
797 | try | ||
798 | { | ||
799 | d(localID, originalID, offsetPos, remoteClient, surfaceArgs); | ||
800 | } | ||
801 | catch (Exception e) | ||
802 | { | ||
803 | m_log.ErrorFormat( | ||
804 | "[EVENT MANAGER]: Delegate for TriggerObjectGrabbing failed - continuing. {0} {1}", | ||
805 | e.Message, e.StackTrace); | ||
806 | } | ||
807 | } | ||
808 | } | ||
809 | } | ||
622 | 810 | ||
623 | public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | 811 | public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
624 | { | 812 | { |
625 | handlerObjectDeGrab = OnObjectDeGrab; | 813 | ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; |
626 | if (handlerObjectDeGrab != null) | 814 | if (handlerObjectDeGrab != null) |
627 | { | 815 | { |
628 | handlerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs); | 816 | foreach (ObjectDeGrabDelegate d in handlerObjectDeGrab.GetInvocationList()) |
629 | } | 817 | { |
818 | try | ||
819 | { | ||
820 | d(localID, originalID, remoteClient, surfaceArgs); | ||
821 | } | ||
822 | catch (Exception e) | ||
823 | { | ||
824 | m_log.ErrorFormat( | ||
825 | "[EVENT MANAGER]: Delegate for TriggerObjectDeGrab failed - continuing. {0} {1}", | ||
826 | e.Message, e.StackTrace); | ||
827 | } | ||
828 | } | ||
829 | } | ||
630 | } | 830 | } |
631 | 831 | ||
632 | public void TriggerScriptReset(uint localID, UUID itemID) | 832 | public void TriggerScriptReset(uint localID, UUID itemID) |
633 | { | 833 | { |
634 | handlerScriptReset = OnScriptReset; | 834 | ScriptResetDelegate handlerScriptReset = OnScriptReset; |
635 | if (handlerScriptReset != null) | 835 | if (handlerScriptReset != null) |
636 | { | 836 | { |
637 | handlerScriptReset(localID, itemID); | 837 | foreach (ScriptResetDelegate d in handlerScriptReset.GetInvocationList()) |
638 | } | 838 | { |
839 | try | ||
840 | { | ||
841 | d(localID, itemID); | ||
842 | } | ||
843 | catch (Exception e) | ||
844 | { | ||
845 | m_log.ErrorFormat( | ||
846 | "[EVENT MANAGER]: Delegate for TriggerScriptReset failed - continuing. {0} {1}", | ||
847 | e.Message, e.StackTrace); | ||
848 | } | ||
849 | } | ||
850 | } | ||
639 | } | 851 | } |
640 | 852 | ||
641 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) | 853 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) |
642 | { | 854 | { |
643 | handlerRezScript = OnRezScript; | 855 | NewRezScript handlerRezScript = OnRezScript; |
644 | if (handlerRezScript != null) | 856 | if (handlerRezScript != null) |
645 | { | 857 | { |
646 | handlerRezScript(localID, itemID, script, startParam, | 858 | foreach (NewRezScript d in handlerRezScript.GetInvocationList()) |
647 | postOnRez, engine, stateSource); | 859 | { |
648 | } | 860 | try |
861 | { | ||
862 | d(localID, itemID, script, startParam, postOnRez, engine, stateSource); | ||
863 | } | ||
864 | catch (Exception e) | ||
865 | { | ||
866 | m_log.ErrorFormat( | ||
867 | "[EVENT MANAGER]: Delegate for TriggerRezScript failed - continuing. {0} {1}", | ||
868 | e.Message, e.StackTrace); | ||
869 | } | ||
870 | } | ||
871 | } | ||
649 | } | 872 | } |
650 | 873 | ||
651 | public void TriggerStartScript(uint localID, UUID itemID) | 874 | public void TriggerStartScript(uint localID, UUID itemID) |
652 | { | 875 | { |
653 | handlerStartScript = OnStartScript; | 876 | StartScript handlerStartScript = OnStartScript; |
654 | if (handlerStartScript != null) | 877 | if (handlerStartScript != null) |
655 | { | 878 | { |
656 | handlerStartScript(localID, itemID); | 879 | foreach (StartScript d in handlerStartScript.GetInvocationList()) |
657 | } | 880 | { |
881 | try | ||
882 | { | ||
883 | d(localID, itemID); | ||
884 | } | ||
885 | catch (Exception e) | ||
886 | { | ||
887 | m_log.ErrorFormat( | ||
888 | "[EVENT MANAGER]: Delegate for TriggerStartScript failed - continuing. {0} {1}", | ||
889 | e.Message, e.StackTrace); | ||
890 | } | ||
891 | } | ||
892 | } | ||
658 | } | 893 | } |
659 | 894 | ||
660 | public void TriggerStopScript(uint localID, UUID itemID) | 895 | public void TriggerStopScript(uint localID, UUID itemID) |
661 | { | 896 | { |
662 | handlerStopScript = OnStopScript; | 897 | StopScript handlerStopScript = OnStopScript; |
663 | if (handlerStopScript != null) | 898 | if (handlerStopScript != null) |
664 | { | 899 | { |
665 | handlerStopScript(localID, itemID); | 900 | foreach (StopScript d in handlerStopScript.GetInvocationList()) |
666 | } | 901 | { |
902 | try | ||
903 | { | ||
904 | d(localID, itemID); | ||
905 | } | ||
906 | catch (Exception e) | ||
907 | { | ||
908 | m_log.ErrorFormat( | ||
909 | "[EVENT MANAGER]: Delegate for TriggerStopScript failed - continuing. {0} {1}", | ||
910 | e.Message, e.StackTrace); | ||
911 | } | ||
912 | } | ||
913 | } | ||
667 | } | 914 | } |
668 | 915 | ||
669 | public void TriggerRemoveScript(uint localID, UUID itemID) | 916 | public void TriggerRemoveScript(uint localID, UUID itemID) |
670 | { | 917 | { |
671 | handlerRemoveScript = OnRemoveScript; | 918 | RemoveScript handlerRemoveScript = OnRemoveScript; |
672 | if (handlerRemoveScript != null) | 919 | if (handlerRemoveScript != null) |
673 | { | 920 | { |
674 | handlerRemoveScript(localID, itemID); | 921 | foreach (RemoveScript d in handlerRemoveScript.GetInvocationList()) |
675 | } | 922 | { |
923 | try | ||
924 | { | ||
925 | d(localID, itemID); | ||
926 | } | ||
927 | catch (Exception e) | ||
928 | { | ||
929 | m_log.ErrorFormat( | ||
930 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | ||
931 | e.Message, e.StackTrace); | ||
932 | } | ||
933 | } | ||
934 | } | ||
676 | } | 935 | } |
677 | 936 | ||
678 | public bool TriggerGroupMove(UUID groupID, Vector3 delta) | 937 | public bool TriggerGroupMove(UUID groupID, Vector3 delta) |
679 | { | 938 | { |
680 | handlerSceneGroupMove = OnSceneGroupMove; | 939 | bool result = true; |
681 | 940 | ||
941 | SceneGroupMoved handlerSceneGroupMove = OnSceneGroupMove; | ||
682 | if (handlerSceneGroupMove != null) | 942 | if (handlerSceneGroupMove != null) |
683 | { | 943 | { |
684 | return handlerSceneGroupMove(groupID, delta); | 944 | foreach (SceneGroupMoved d in handlerSceneGroupMove.GetInvocationList()) |
945 | { | ||
946 | try | ||
947 | { | ||
948 | if (d(groupID, delta) == false) | ||
949 | result = false; | ||
950 | } | ||
951 | catch (Exception e) | ||
952 | { | ||
953 | m_log.ErrorFormat( | ||
954 | "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", | ||
955 | e.Message, e.StackTrace); | ||
956 | } | ||
957 | } | ||
685 | } | 958 | } |
686 | return true; | 959 | |
960 | return result; | ||
687 | } | 961 | } |
688 | 962 | ||
689 | public bool TriggerGroupSpinStart(UUID groupID) | 963 | public bool TriggerGroupSpinStart(UUID groupID) |
690 | { | 964 | { |
691 | handlerSceneGroupSpinStarted = OnSceneGroupSpinStart; | 965 | bool result = true; |
692 | 966 | ||
967 | SceneGroupSpinStarted handlerSceneGroupSpinStarted = OnSceneGroupSpinStart; | ||
693 | if (handlerSceneGroupSpinStarted != null) | 968 | if (handlerSceneGroupSpinStarted != null) |
694 | { | 969 | { |
695 | return handlerSceneGroupSpinStarted(groupID); | 970 | foreach (SceneGroupSpinStarted d in handlerSceneGroupSpinStarted.GetInvocationList()) |
971 | { | ||
972 | try | ||
973 | { | ||
974 | if (d(groupID) == false) | ||
975 | result = false; | ||
976 | } | ||
977 | catch (Exception e) | ||
978 | { | ||
979 | m_log.ErrorFormat( | ||
980 | "[EVENT MANAGER]: Delegate for TriggerGroupSpinStart failed - continuing. {0} {1}", | ||
981 | e.Message, e.StackTrace); | ||
982 | } | ||
983 | } | ||
696 | } | 984 | } |
697 | return true; | 985 | |
986 | return result; | ||
698 | } | 987 | } |
699 | 988 | ||
700 | public bool TriggerGroupSpin(UUID groupID, Quaternion rotation) | 989 | public bool TriggerGroupSpin(UUID groupID, Quaternion rotation) |
701 | { | 990 | { |
702 | handlerSceneGroupSpin = OnSceneGroupSpin; | 991 | bool result = true; |
703 | 992 | ||
993 | SceneGroupSpun handlerSceneGroupSpin = OnSceneGroupSpin; | ||
704 | if (handlerSceneGroupSpin != null) | 994 | if (handlerSceneGroupSpin != null) |
705 | { | 995 | { |
706 | return handlerSceneGroupSpin(groupID, rotation); | 996 | foreach (SceneGroupSpun d in handlerSceneGroupSpin.GetInvocationList()) |
997 | { | ||
998 | try | ||
999 | { | ||
1000 | if (d(groupID, rotation) == false) | ||
1001 | result = false; | ||
1002 | } | ||
1003 | catch (Exception e) | ||
1004 | { | ||
1005 | m_log.ErrorFormat( | ||
1006 | "[EVENT MANAGER]: Delegate for TriggerGroupSpin failed - continuing. {0} {1}", | ||
1007 | e.Message, e.StackTrace); | ||
1008 | } | ||
1009 | } | ||
707 | } | 1010 | } |
708 | return true; | 1011 | |
1012 | return result; | ||
709 | } | 1013 | } |
710 | 1014 | ||
711 | public void TriggerGroupGrab(UUID groupID, Vector3 offset, UUID userID) | 1015 | public void TriggerGroupGrab(UUID groupID, Vector3 offset, UUID userID) |
712 | { | 1016 | { |
713 | handlerSceneGroupGrab = OnSceneGroupGrab; | 1017 | SceneGroupGrabed handlerSceneGroupGrab = OnSceneGroupGrab; |
714 | if (handlerSceneGroupGrab != null) | 1018 | if (handlerSceneGroupGrab != null) |
715 | { | 1019 | { |
716 | handlerSceneGroupGrab(groupID, offset, userID); | 1020 | foreach (SceneGroupGrabed d in handlerSceneGroupGrab.GetInvocationList()) |
717 | } | 1021 | { |
1022 | try | ||
1023 | { | ||
1024 | d(groupID, offset, userID); | ||
1025 | } | ||
1026 | catch (Exception e) | ||
1027 | { | ||
1028 | m_log.ErrorFormat( | ||
1029 | "[EVENT MANAGER]: Delegate for TriggerGroupGrab failed - continuing. {0} {1}", | ||
1030 | e.Message, e.StackTrace); | ||
1031 | } | ||
1032 | } | ||
1033 | } | ||
718 | } | 1034 | } |
719 | 1035 | ||
720 | public void TriggerLandObjectAdded(ILandObject newParcel) | 1036 | public void TriggerLandObjectAdded(ILandObject newParcel) |
721 | { | 1037 | { |
722 | handlerLandObjectAdded = OnLandObjectAdded; | 1038 | LandObjectAdded handlerLandObjectAdded = OnLandObjectAdded; |
723 | |||
724 | if (handlerLandObjectAdded != null) | 1039 | if (handlerLandObjectAdded != null) |
725 | { | 1040 | { |
726 | handlerLandObjectAdded(newParcel); | 1041 | foreach (LandObjectAdded d in handlerLandObjectAdded.GetInvocationList()) |
727 | } | 1042 | { |
1043 | try | ||
1044 | { | ||
1045 | d(newParcel); | ||
1046 | } | ||
1047 | catch (Exception e) | ||
1048 | { | ||
1049 | m_log.ErrorFormat( | ||
1050 | "[EVENT MANAGER]: Delegate for TriggerLandObjectAdded failed - continuing. {0} {1}", | ||
1051 | e.Message, e.StackTrace); | ||
1052 | } | ||
1053 | } | ||
1054 | } | ||
728 | } | 1055 | } |
729 | 1056 | ||
730 | public void TriggerLandObjectRemoved(UUID globalID) | 1057 | public void TriggerLandObjectRemoved(UUID globalID) |
731 | { | 1058 | { |
732 | handlerLandObjectRemoved = OnLandObjectRemoved; | 1059 | LandObjectRemoved handlerLandObjectRemoved = OnLandObjectRemoved; |
733 | if (handlerLandObjectRemoved != null) | 1060 | if (handlerLandObjectRemoved != null) |
734 | { | 1061 | { |
735 | handlerLandObjectRemoved(globalID); | 1062 | foreach (LandObjectRemoved d in handlerLandObjectRemoved.GetInvocationList()) |
736 | } | 1063 | { |
1064 | try | ||
1065 | { | ||
1066 | d(globalID); | ||
1067 | } | ||
1068 | catch (Exception e) | ||
1069 | { | ||
1070 | m_log.ErrorFormat( | ||
1071 | "[EVENT MANAGER]: Delegate for TriggerLandObjectRemoved failed - continuing. {0} {1}", | ||
1072 | e.Message, e.StackTrace); | ||
1073 | } | ||
1074 | } | ||
1075 | } | ||
737 | } | 1076 | } |
738 | 1077 | ||
739 | public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) | 1078 | public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) |
740 | { | 1079 | { |
741 | //triggerLandObjectRemoved(localParcelID); | ||
742 | |||
743 | TriggerLandObjectAdded(newParcel); | 1080 | TriggerLandObjectAdded(newParcel); |
744 | } | 1081 | } |
745 | 1082 | ||
746 | public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) | 1083 | public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) |
747 | { | 1084 | { |
748 | handlerAvatarEnteringNewParcel = OnAvatarEnteringNewParcel; | 1085 | AvatarEnteringNewParcel handlerAvatarEnteringNewParcel = OnAvatarEnteringNewParcel; |
749 | |||
750 | if (handlerAvatarEnteringNewParcel != null) | 1086 | if (handlerAvatarEnteringNewParcel != null) |
751 | { | 1087 | { |
752 | handlerAvatarEnteringNewParcel(avatar, localLandID, regionID); | 1088 | foreach (AvatarEnteringNewParcel d in handlerAvatarEnteringNewParcel.GetInvocationList()) |
753 | } | 1089 | { |
1090 | try | ||
1091 | { | ||
1092 | d(avatar, localLandID, regionID); | ||
1093 | } | ||
1094 | catch (Exception e) | ||
1095 | { | ||
1096 | m_log.ErrorFormat( | ||
1097 | "[EVENT MANAGER]: Delegate for TriggerAvatarEnteringNewParcel failed - continuing. {0} {1}", | ||
1098 | e.Message, e.StackTrace); | ||
1099 | } | ||
1100 | } | ||
1101 | } | ||
754 | } | 1102 | } |
755 | 1103 | ||
756 | public void TriggerIncomingInstantMessage(GridInstantMessage message) | 1104 | public void TriggerIncomingInstantMessage(GridInstantMessage message) |
757 | { | 1105 | { |
758 | handlerIncomingInstantMessage = OnIncomingInstantMessage; | 1106 | IncomingInstantMessage handlerIncomingInstantMessage = OnIncomingInstantMessage; |
759 | if (handlerIncomingInstantMessage != null) | 1107 | if (handlerIncomingInstantMessage != null) |
760 | { | 1108 | { |
761 | handlerIncomingInstantMessage(message); | 1109 | foreach (IncomingInstantMessage d in handlerIncomingInstantMessage.GetInvocationList()) |
762 | } | 1110 | { |
1111 | try | ||
1112 | { | ||
1113 | d(message); | ||
1114 | } | ||
1115 | catch (Exception e) | ||
1116 | { | ||
1117 | m_log.ErrorFormat( | ||
1118 | "[EVENT MANAGER]: Delegate for TriggerIncomingInstantMessage failed - continuing. {0} {1}", | ||
1119 | e.Message, e.StackTrace); | ||
1120 | } | ||
1121 | } | ||
1122 | } | ||
763 | } | 1123 | } |
764 | 1124 | ||
765 | public void TriggerUnhandledInstantMessage(GridInstantMessage message) | 1125 | public void TriggerUnhandledInstantMessage(GridInstantMessage message) |
766 | { | 1126 | { |
767 | handlerUnhandledInstantMessage = OnUnhandledInstantMessage; | 1127 | IncomingInstantMessage handlerUnhandledInstantMessage = OnUnhandledInstantMessage; |
768 | if (handlerUnhandledInstantMessage != null) | 1128 | if (handlerUnhandledInstantMessage != null) |
769 | { | 1129 | { |
770 | handlerUnhandledInstantMessage(message); | 1130 | foreach (IncomingInstantMessage d in handlerUnhandledInstantMessage.GetInvocationList()) |
771 | } | 1131 | { |
1132 | try | ||
1133 | { | ||
1134 | d(message); | ||
1135 | } | ||
1136 | catch (Exception e) | ||
1137 | { | ||
1138 | m_log.ErrorFormat( | ||
1139 | "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", | ||
1140 | e.Message, e.StackTrace); | ||
1141 | } | ||
1142 | } | ||
1143 | } | ||
772 | } | 1144 | } |
773 | 1145 | ||
774 | public void TriggerClientClosed(UUID ClientID, Scene scene) | 1146 | public void TriggerClientClosed(UUID ClientID, Scene scene) |
775 | { | 1147 | { |
776 | handlerClientClosed = OnClientClosed; | 1148 | ClientClosed handlerClientClosed = OnClientClosed; |
777 | if (handlerClientClosed != null) | 1149 | if (handlerClientClosed != null) |
778 | { | 1150 | { |
779 | handlerClientClosed(ClientID, scene); | 1151 | foreach (ClientClosed d in handlerClientClosed.GetInvocationList()) |
780 | } | 1152 | { |
1153 | try | ||
1154 | { | ||
1155 | d(ClientID, scene); | ||
1156 | } | ||
1157 | catch (Exception e) | ||
1158 | { | ||
1159 | m_log.ErrorFormat( | ||
1160 | "[EVENT MANAGER]: Delegate for TriggerClientClosed failed - continuing. {0} {1}", | ||
1161 | e.Message, e.StackTrace); | ||
1162 | } | ||
1163 | } | ||
1164 | } | ||
781 | } | 1165 | } |
782 | 1166 | ||
783 | public void TriggerOnMakeChildAgent(ScenePresence presence) | 1167 | public void TriggerOnMakeChildAgent(ScenePresence presence) |
784 | { | 1168 | { |
785 | handlerMakeChildAgent = OnMakeChildAgent; | 1169 | OnMakeChildAgentDelegate handlerMakeChildAgent = OnMakeChildAgent; |
786 | if (handlerMakeChildAgent != null) | 1170 | if (handlerMakeChildAgent != null) |
787 | { | 1171 | { |
788 | handlerMakeChildAgent(presence); | 1172 | foreach (OnMakeChildAgentDelegate d in handlerMakeChildAgent.GetInvocationList()) |
789 | } | 1173 | { |
1174 | try | ||
1175 | { | ||
1176 | d(presence); | ||
1177 | } | ||
1178 | catch (Exception e) | ||
1179 | { | ||
1180 | m_log.ErrorFormat( | ||
1181 | "[EVENT MANAGER]: Delegate for TriggerOnMakeChildAgent failed - continuing. {0} {1}", | ||
1182 | e.Message, e.StackTrace); | ||
1183 | } | ||
1184 | } | ||
1185 | } | ||
790 | } | 1186 | } |
791 | 1187 | ||
792 | public void TriggerOnMakeRootAgent(ScenePresence presence) | 1188 | public void TriggerOnMakeRootAgent(ScenePresence presence) |
793 | { | 1189 | { |
794 | handlerMakeRootAgent = OnMakeRootAgent; | 1190 | OnMakeRootAgentDelegate handlerMakeRootAgent = OnMakeRootAgent; |
795 | if (handlerMakeRootAgent != null) | 1191 | if (handlerMakeRootAgent != null) |
796 | { | 1192 | { |
797 | handlerMakeRootAgent(presence); | 1193 | foreach (OnMakeRootAgentDelegate d in handlerMakeRootAgent.GetInvocationList()) |
798 | } | 1194 | { |
1195 | try | ||
1196 | { | ||
1197 | d(presence); | ||
1198 | } | ||
1199 | catch (Exception e) | ||
1200 | { | ||
1201 | m_log.ErrorFormat( | ||
1202 | "[EVENT MANAGER]: Delegate for TriggerOnMakeRootAgent failed - continuing. {0} {1}", | ||
1203 | e.Message, e.StackTrace); | ||
1204 | } | ||
1205 | } | ||
1206 | } | ||
799 | } | 1207 | } |
800 | 1208 | ||
801 | public void TriggerOnRegisterCaps(UUID agentID, Caps caps) | 1209 | public void TriggerOnRegisterCaps(UUID agentID, Caps caps) |
802 | { | 1210 | { |
803 | handlerRegisterCaps = OnRegisterCaps; | 1211 | RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; |
804 | if (handlerRegisterCaps != null) | 1212 | if (handlerRegisterCaps != null) |
805 | { | 1213 | { |
806 | handlerRegisterCaps(agentID, caps); | 1214 | foreach (RegisterCapsEvent d in handlerRegisterCaps.GetInvocationList()) |
807 | } | 1215 | { |
1216 | try | ||
1217 | { | ||
1218 | d(agentID, caps); | ||
1219 | } | ||
1220 | catch (Exception e) | ||
1221 | { | ||
1222 | m_log.ErrorFormat( | ||
1223 | "[EVENT MANAGER]: Delegate for TriggerOnRegisterCaps failed - continuing. {0} {1}", | ||
1224 | e.Message, e.StackTrace); | ||
1225 | } | ||
1226 | } | ||
1227 | } | ||
808 | } | 1228 | } |
809 | 1229 | ||
810 | public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) | 1230 | public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) |
811 | { | 1231 | { |
812 | handlerDeregisterCaps = OnDeregisterCaps; | 1232 | DeregisterCapsEvent handlerDeregisterCaps = OnDeregisterCaps; |
813 | if (handlerDeregisterCaps != null) | 1233 | if (handlerDeregisterCaps != null) |
814 | { | 1234 | { |
815 | handlerDeregisterCaps(agentID, caps); | 1235 | foreach (DeregisterCapsEvent d in handlerDeregisterCaps.GetInvocationList()) |
816 | } | 1236 | { |
1237 | try | ||
1238 | { | ||
1239 | d(agentID, caps); | ||
1240 | } | ||
1241 | catch (Exception e) | ||
1242 | { | ||
1243 | m_log.ErrorFormat( | ||
1244 | "[EVENT MANAGER]: Delegate for TriggerOnDeregisterCaps failed - continuing. {0} {1}", | ||
1245 | e.Message, e.StackTrace); | ||
1246 | } | ||
1247 | } | ||
1248 | } | ||
817 | } | 1249 | } |
818 | 1250 | ||
819 | public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) | 1251 | public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) |
820 | { | 1252 | { |
821 | handlerNewInventoryItemUpdateComplete = OnNewInventoryItemUploadComplete; | 1253 | NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = OnNewInventoryItemUploadComplete; |
822 | if (handlerNewInventoryItemUpdateComplete != null) | 1254 | if (handlerNewInventoryItemUpdateComplete != null) |
823 | { | 1255 | { |
824 | handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel); | 1256 | foreach (NewInventoryItemUploadComplete d in handlerNewInventoryItemUpdateComplete.GetInvocationList()) |
825 | } | 1257 | { |
826 | } | 1258 | try |
827 | 1259 | { | |
828 | public void TriggerLandBuy(Object sender, LandBuyArgs e) | 1260 | d(agentID, AssetID, AssetName, userlevel); |
829 | { | 1261 | } |
830 | handlerLandBuy = OnLandBuy; | 1262 | catch (Exception e) |
1263 | { | ||
1264 | m_log.ErrorFormat( | ||
1265 | "[EVENT MANAGER]: Delegate for TriggerOnNewInventoryItemUploadComplete failed - continuing. {0} {1}", | ||
1266 | e.Message, e.StackTrace); | ||
1267 | } | ||
1268 | } | ||
1269 | } | ||
1270 | } | ||
1271 | |||
1272 | public void TriggerLandBuy(Object sender, LandBuyArgs args) | ||
1273 | { | ||
1274 | LandBuy handlerLandBuy = OnLandBuy; | ||
831 | if (handlerLandBuy != null) | 1275 | if (handlerLandBuy != null) |
832 | { | 1276 | { |
833 | handlerLandBuy(sender, e); | 1277 | foreach (LandBuy d in handlerLandBuy.GetInvocationList()) |
834 | } | 1278 | { |
835 | } | 1279 | try |
836 | 1280 | { | |
837 | public void TriggerValidateLandBuy(Object sender, LandBuyArgs e) | 1281 | d(sender, args); |
838 | { | 1282 | } |
839 | handlerValidateLandBuy = OnValidateLandBuy; | 1283 | catch (Exception e) |
1284 | { | ||
1285 | m_log.ErrorFormat( | ||
1286 | "[EVENT MANAGER]: Delegate for TriggerLandBuy failed - continuing. {0} {1}", | ||
1287 | e.Message, e.StackTrace); | ||
1288 | } | ||
1289 | } | ||
1290 | } | ||
1291 | } | ||
1292 | |||
1293 | public void TriggerValidateLandBuy(Object sender, LandBuyArgs args) | ||
1294 | { | ||
1295 | LandBuy handlerValidateLandBuy = OnValidateLandBuy; | ||
840 | if (handlerValidateLandBuy != null) | 1296 | if (handlerValidateLandBuy != null) |
841 | { | 1297 | { |
842 | handlerValidateLandBuy(sender, e); | 1298 | foreach (LandBuy d in handlerValidateLandBuy.GetInvocationList()) |
843 | } | 1299 | { |
1300 | try | ||
1301 | { | ||
1302 | d(sender, args); | ||
1303 | } | ||
1304 | catch (Exception e) | ||
1305 | { | ||
1306 | m_log.ErrorFormat( | ||
1307 | "[EVENT MANAGER]: Delegate for TriggerValidateLandBuy failed - continuing. {0} {1}", | ||
1308 | e.Message, e.StackTrace); | ||
1309 | } | ||
1310 | } | ||
1311 | } | ||
844 | } | 1312 | } |
845 | 1313 | ||
846 | public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) | 1314 | public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) |
847 | { | 1315 | { |
848 | handlerScriptAtTargetEvent = OnScriptAtTargetEvent; | 1316 | ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent; |
849 | if (handlerScriptAtTargetEvent != null) | 1317 | if (handlerScriptAtTargetEvent != null) |
850 | { | 1318 | { |
851 | handlerScriptAtTargetEvent(localID, handle, targetpos, currentpos); | 1319 | foreach (ScriptAtTargetEvent d in handlerScriptAtTargetEvent.GetInvocationList()) |
852 | } | 1320 | { |
1321 | try | ||
1322 | { | ||
1323 | d(localID, handle, targetpos, currentpos); | ||
1324 | } | ||
1325 | catch (Exception e) | ||
1326 | { | ||
1327 | m_log.ErrorFormat( | ||
1328 | "[EVENT MANAGER]: Delegate for TriggerAtTargetEvent failed - continuing. {0} {1}", | ||
1329 | e.Message, e.StackTrace); | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
853 | } | 1333 | } |
854 | 1334 | ||
855 | public void TriggerNotAtTargetEvent(uint localID) | 1335 | public void TriggerNotAtTargetEvent(uint localID) |
856 | { | 1336 | { |
857 | handlerScriptNotAtTargetEvent = OnScriptNotAtTargetEvent; | 1337 | ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = OnScriptNotAtTargetEvent; |
858 | if (handlerScriptNotAtTargetEvent != null) | 1338 | if (handlerScriptNotAtTargetEvent != null) |
859 | { | 1339 | { |
860 | handlerScriptNotAtTargetEvent(localID); | 1340 | foreach (ScriptNotAtTargetEvent d in handlerScriptNotAtTargetEvent.GetInvocationList()) |
861 | } | 1341 | { |
1342 | try | ||
1343 | { | ||
1344 | d(localID); | ||
1345 | } | ||
1346 | catch (Exception e) | ||
1347 | { | ||
1348 | m_log.ErrorFormat( | ||
1349 | "[EVENT MANAGER]: Delegate for TriggerNotAtTargetEvent failed - continuing. {0} {1}", | ||
1350 | e.Message, e.StackTrace); | ||
1351 | } | ||
1352 | } | ||
1353 | } | ||
862 | } | 1354 | } |
863 | 1355 | ||
864 | public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) | 1356 | public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) |
865 | { | 1357 | { |
866 | handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; | 1358 | ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; |
867 | if (handlerScriptAtRotTargetEvent != null) | 1359 | if (handlerScriptAtRotTargetEvent != null) |
868 | { | 1360 | { |
869 | handlerScriptAtRotTargetEvent(localID, handle, targetrot, currentrot); | 1361 | foreach (ScriptAtRotTargetEvent d in handlerScriptAtRotTargetEvent.GetInvocationList()) |
870 | } | 1362 | { |
1363 | try | ||
1364 | { | ||
1365 | d(localID, handle, targetrot, currentrot); | ||
1366 | } | ||
1367 | catch (Exception e) | ||
1368 | { | ||
1369 | m_log.ErrorFormat( | ||
1370 | "[EVENT MANAGER]: Delegate for TriggerAtRotTargetEvent failed - continuing. {0} {1}", | ||
1371 | e.Message, e.StackTrace); | ||
1372 | } | ||
1373 | } | ||
1374 | } | ||
871 | } | 1375 | } |
872 | 1376 | ||
873 | public void TriggerNotAtRotTargetEvent(uint localID) | 1377 | public void TriggerNotAtRotTargetEvent(uint localID) |
874 | { | 1378 | { |
875 | handlerScriptNotAtRotTargetEvent = OnScriptNotAtRotTargetEvent; | 1379 | ScriptNotAtRotTargetEvent handlerScriptNotAtRotTargetEvent = OnScriptNotAtRotTargetEvent; |
876 | if (handlerScriptNotAtRotTargetEvent != null) | 1380 | if (handlerScriptNotAtRotTargetEvent != null) |
877 | { | 1381 | { |
878 | handlerScriptNotAtRotTargetEvent(localID); | 1382 | foreach (ScriptNotAtRotTargetEvent d in handlerScriptNotAtRotTargetEvent.GetInvocationList()) |
879 | } | 1383 | { |
1384 | try | ||
1385 | { | ||
1386 | d(localID); | ||
1387 | } | ||
1388 | catch (Exception e) | ||
1389 | { | ||
1390 | m_log.ErrorFormat( | ||
1391 | "[EVENT MANAGER]: Delegate for TriggerNotAtRotTargetEvent failed - continuing. {0} {1}", | ||
1392 | e.Message, e.StackTrace); | ||
1393 | } | ||
1394 | } | ||
1395 | } | ||
880 | } | 1396 | } |
881 | 1397 | ||
882 | public void TriggerRequestChangeWaterHeight(float height) | 1398 | public void TriggerRequestChangeWaterHeight(float height) |
883 | { | 1399 | { |
884 | handlerRequestChangeWaterHeight = OnRequestChangeWaterHeight; | 1400 | RequestChangeWaterHeight handlerRequestChangeWaterHeight = OnRequestChangeWaterHeight; |
885 | if (handlerRequestChangeWaterHeight != null) | 1401 | if (handlerRequestChangeWaterHeight != null) |
886 | { | 1402 | { |
887 | handlerRequestChangeWaterHeight(height); | 1403 | foreach (RequestChangeWaterHeight d in handlerRequestChangeWaterHeight.GetInvocationList()) |
888 | } | 1404 | { |
1405 | try | ||
1406 | { | ||
1407 | d(height); | ||
1408 | } | ||
1409 | catch (Exception e) | ||
1410 | { | ||
1411 | m_log.ErrorFormat( | ||
1412 | "[EVENT MANAGER]: Delegate for TriggerRequestChangeWaterHeight failed - continuing. {0} {1}", | ||
1413 | e.Message, e.StackTrace); | ||
1414 | } | ||
1415 | } | ||
1416 | } | ||
889 | } | 1417 | } |
890 | 1418 | ||
891 | public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) | 1419 | public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) |
892 | { | 1420 | { |
893 | handlerAvatarKill = OnAvatarKilled; | 1421 | AvatarKillData handlerAvatarKill = OnAvatarKilled; |
894 | if (handlerAvatarKill != null) | 1422 | if (handlerAvatarKill != null) |
895 | { | 1423 | { |
896 | handlerAvatarKill(KillerObjectLocalID, DeadAvatar); | 1424 | foreach (AvatarKillData d in handlerAvatarKill.GetInvocationList()) |
897 | } | 1425 | { |
1426 | try | ||
1427 | { | ||
1428 | d(KillerObjectLocalID, DeadAvatar); | ||
1429 | } | ||
1430 | catch (Exception e) | ||
1431 | { | ||
1432 | m_log.ErrorFormat( | ||
1433 | "[EVENT MANAGER]: Delegate for TriggerAvatarKill failed - continuing. {0} {1}", | ||
1434 | e.Message, e.StackTrace); | ||
1435 | } | ||
1436 | } | ||
1437 | } | ||
898 | } | 1438 | } |
899 | 1439 | ||
900 | public void TriggerSignificantClientMovement(IClientAPI client) | 1440 | public void TriggerSignificantClientMovement(IClientAPI client) |
901 | { | 1441 | { |
902 | handlerSignificantClientMovement = OnSignificantClientMovement; | 1442 | SignificantClientMovement handlerSignificantClientMovement = OnSignificantClientMovement; |
903 | if (handlerSignificantClientMovement != null) | 1443 | if (handlerSignificantClientMovement != null) |
904 | { | 1444 | { |
905 | handlerSignificantClientMovement(client); | 1445 | foreach (SignificantClientMovement d in handlerSignificantClientMovement.GetInvocationList()) |
906 | } | 1446 | { |
1447 | try | ||
1448 | { | ||
1449 | d(client); | ||
1450 | } | ||
1451 | catch (Exception e) | ||
1452 | { | ||
1453 | m_log.ErrorFormat( | ||
1454 | "[EVENT MANAGER]: Delegate for TriggerSignificantClientMovement failed - continuing. {0} {1}", | ||
1455 | e.Message, e.StackTrace); | ||
1456 | } | ||
1457 | } | ||
1458 | } | ||
907 | } | 1459 | } |
908 | 1460 | ||
909 | public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) | 1461 | public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) |
910 | { | 1462 | { |
911 | handlerChatFromWorld = OnChatFromWorld; | 1463 | ChatFromWorldEvent handlerChatFromWorld = OnChatFromWorld; |
912 | if (handlerChatFromWorld != null) | 1464 | if (handlerChatFromWorld != null) |
913 | { | 1465 | { |
914 | handlerChatFromWorld(sender, chat); | 1466 | foreach (ChatFromWorldEvent d in handlerChatFromWorld.GetInvocationList()) |
915 | } | 1467 | { |
1468 | try | ||
1469 | { | ||
1470 | d(sender, chat); | ||
1471 | } | ||
1472 | catch (Exception e) | ||
1473 | { | ||
1474 | m_log.ErrorFormat( | ||
1475 | "[EVENT MANAGER]: Delegate for TriggerOnChatFromWorld failed - continuing. {0} {1}", | ||
1476 | e.Message, e.StackTrace); | ||
1477 | } | ||
1478 | } | ||
1479 | } | ||
916 | } | 1480 | } |
917 | 1481 | ||
918 | public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) | 1482 | public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) |
919 | { | 1483 | { |
920 | handlerChatFromClient = OnChatFromClient; | 1484 | ChatFromClientEvent handlerChatFromClient = OnChatFromClient; |
921 | if (handlerChatFromClient != null) | 1485 | if (handlerChatFromClient != null) |
922 | { | 1486 | { |
923 | handlerChatFromClient(sender, chat); | 1487 | foreach (ChatFromClientEvent d in handlerChatFromClient.GetInvocationList()) |
924 | } | 1488 | { |
1489 | try | ||
1490 | { | ||
1491 | d(sender, chat); | ||
1492 | } | ||
1493 | catch (Exception e) | ||
1494 | { | ||
1495 | m_log.ErrorFormat( | ||
1496 | "[EVENT MANAGER]: Delegate for TriggerOnChatFromClient failed - continuing. {0} {1}", | ||
1497 | e.Message, e.StackTrace); | ||
1498 | } | ||
1499 | } | ||
1500 | } | ||
925 | } | 1501 | } |
926 | 1502 | ||
927 | public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) | 1503 | public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) |
928 | { | 1504 | { |
929 | handlerChatBroadcast = OnChatBroadcast; | 1505 | ChatBroadcastEvent handlerChatBroadcast = OnChatBroadcast; |
930 | if (handlerChatBroadcast != null) | 1506 | if (handlerChatBroadcast != null) |
931 | { | 1507 | { |
932 | handlerChatBroadcast(sender, chat); | 1508 | foreach (ChatBroadcastEvent d in handlerChatBroadcast.GetInvocationList()) |
933 | } | 1509 | { |
1510 | try | ||
1511 | { | ||
1512 | d(sender, chat); | ||
1513 | } | ||
1514 | catch (Exception e) | ||
1515 | { | ||
1516 | m_log.ErrorFormat( | ||
1517 | "[EVENT MANAGER]: Delegate for TriggerOnChatBroadcast failed - continuing. {0} {1}", | ||
1518 | e.Message, e.StackTrace); | ||
1519 | } | ||
1520 | } | ||
1521 | } | ||
934 | } | 1522 | } |
935 | 1523 | ||
936 | internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) | 1524 | internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) |
937 | { | 1525 | { |
938 | handlerScriptControlEvent = OnScriptControlEvent; | 1526 | ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent; |
939 | if (handlerScriptControlEvent != null) | 1527 | if (handlerScriptControlEvent != null) |
940 | { | 1528 | { |
941 | handlerScriptControlEvent(p, scriptUUID, avatarID, held, _changed); | 1529 | foreach (ScriptControlEvent d in handlerScriptControlEvent.GetInvocationList()) |
942 | } | 1530 | { |
1531 | try | ||
1532 | { | ||
1533 | d(p, scriptUUID, avatarID, held, _changed); | ||
1534 | } | ||
1535 | catch (Exception e) | ||
1536 | { | ||
1537 | m_log.ErrorFormat( | ||
1538 | "[EVENT MANAGER]: Delegate for TriggerControlEvent failed - continuing. {0} {1}", | ||
1539 | e.Message, e.StackTrace); | ||
1540 | } | ||
1541 | } | ||
1542 | } | ||
943 | } | 1543 | } |
944 | 1544 | ||
945 | public void TriggerNoticeNoLandDataFromStorage() | 1545 | public void TriggerNoticeNoLandDataFromStorage() |
946 | { | 1546 | { |
947 | handlerNoticeNoLandDataFromStorage = OnNoticeNoLandDataFromStorage; | 1547 | NoticeNoLandDataFromStorage handlerNoticeNoLandDataFromStorage = OnNoticeNoLandDataFromStorage; |
948 | if (handlerNoticeNoLandDataFromStorage != null) | 1548 | if (handlerNoticeNoLandDataFromStorage != null) |
949 | { | 1549 | { |
950 | handlerNoticeNoLandDataFromStorage(); | 1550 | foreach (NoticeNoLandDataFromStorage d in handlerNoticeNoLandDataFromStorage.GetInvocationList()) |
951 | 1551 | { | |
952 | } | 1552 | try |
1553 | { | ||
1554 | d(); | ||
1555 | } | ||
1556 | catch (Exception e) | ||
1557 | { | ||
1558 | m_log.ErrorFormat( | ||
1559 | "[EVENT MANAGER]: Delegate for TriggerNoticeNoLandDataFromStorage failed - continuing. {0} {1}", | ||
1560 | e.Message, e.StackTrace); | ||
1561 | } | ||
1562 | } | ||
1563 | } | ||
953 | } | 1564 | } |
954 | 1565 | ||
955 | public void TriggerIncomingLandDataFromStorage(List<LandData> landData) | 1566 | public void TriggerIncomingLandDataFromStorage(List<LandData> landData) |
956 | { | 1567 | { |
957 | handlerIncomingLandDataFromStorage = OnIncomingLandDataFromStorage; | 1568 | IncomingLandDataFromStorage handlerIncomingLandDataFromStorage = OnIncomingLandDataFromStorage; |
958 | if (handlerIncomingLandDataFromStorage != null) | 1569 | if (handlerIncomingLandDataFromStorage != null) |
959 | { | 1570 | { |
960 | handlerIncomingLandDataFromStorage(landData); | 1571 | foreach (IncomingLandDataFromStorage d in handlerIncomingLandDataFromStorage.GetInvocationList()) |
961 | 1572 | { | |
962 | } | 1573 | try |
1574 | { | ||
1575 | d(landData); | ||
1576 | } | ||
1577 | catch (Exception e) | ||
1578 | { | ||
1579 | m_log.ErrorFormat( | ||
1580 | "[EVENT MANAGER]: Delegate for TriggerIncomingLandDataFromStorage failed - continuing. {0} {1}", | ||
1581 | e.Message, e.StackTrace); | ||
1582 | } | ||
1583 | } | ||
1584 | } | ||
963 | } | 1585 | } |
964 | 1586 | ||
965 | public void TriggerSetAllowForcefulBan(bool allow) | 1587 | public void TriggerSetAllowForcefulBan(bool allow) |
966 | { | 1588 | { |
967 | handlerSetAllowForcefulBan = OnSetAllowForcefulBan; | 1589 | SetAllowForcefulBan handlerSetAllowForcefulBan = OnSetAllowForcefulBan; |
968 | if (handlerSetAllowForcefulBan != null) | 1590 | if (handlerSetAllowForcefulBan != null) |
969 | { | 1591 | { |
970 | handlerSetAllowForcefulBan(allow); | 1592 | foreach (SetAllowForcefulBan d in handlerSetAllowForcefulBan.GetInvocationList()) |
971 | 1593 | { | |
972 | } | 1594 | try |
1595 | { | ||
1596 | d(allow); | ||
1597 | } | ||
1598 | catch (Exception e) | ||
1599 | { | ||
1600 | m_log.ErrorFormat( | ||
1601 | "[EVENT MANAGER]: Delegate for TriggerSetAllowForcefulBan failed - continuing. {0} {1}", | ||
1602 | e.Message, e.StackTrace); | ||
1603 | } | ||
1604 | } | ||
1605 | } | ||
973 | } | 1606 | } |
974 | 1607 | ||
975 | public void TriggerRequestParcelPrimCountUpdate() | 1608 | public void TriggerRequestParcelPrimCountUpdate() |
976 | { | 1609 | { |
977 | handlerRequestParcelPrimCountUpdate = OnRequestParcelPrimCountUpdate; | 1610 | RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = OnRequestParcelPrimCountUpdate; |
978 | if (handlerRequestParcelPrimCountUpdate != null) | 1611 | if (handlerRequestParcelPrimCountUpdate != null) |
979 | { | 1612 | { |
980 | handlerRequestParcelPrimCountUpdate(); | 1613 | foreach (RequestParcelPrimCountUpdate d in handlerRequestParcelPrimCountUpdate.GetInvocationList()) |
981 | } | 1614 | { |
1615 | try | ||
1616 | { | ||
1617 | d(); | ||
1618 | } | ||
1619 | catch (Exception e) | ||
1620 | { | ||
1621 | m_log.ErrorFormat( | ||
1622 | "[EVENT MANAGER]: Delegate for TriggerRequestParcelPrimCountUpdate failed - continuing. {0} {1}", | ||
1623 | e.Message, e.StackTrace); | ||
1624 | } | ||
1625 | } | ||
1626 | } | ||
982 | } | 1627 | } |
983 | 1628 | ||
984 | public void TriggerParcelPrimCountTainted() | 1629 | public void TriggerParcelPrimCountTainted() |
985 | { | 1630 | { |
986 | handlerParcelPrimCountTainted = OnParcelPrimCountTainted; | 1631 | ParcelPrimCountTainted handlerParcelPrimCountTainted = OnParcelPrimCountTainted; |
987 | if (handlerParcelPrimCountTainted != null) | 1632 | if (handlerParcelPrimCountTainted != null) |
988 | { | 1633 | { |
989 | handlerParcelPrimCountTainted(); | 1634 | foreach (ParcelPrimCountTainted d in handlerParcelPrimCountTainted.GetInvocationList()) |
990 | } | 1635 | { |
1636 | try | ||
1637 | { | ||
1638 | d(); | ||
1639 | } | ||
1640 | catch (Exception e) | ||
1641 | { | ||
1642 | m_log.ErrorFormat( | ||
1643 | "[EVENT MANAGER]: Delegate for TriggerParcelPrimCountTainted failed - continuing. {0} {1}", | ||
1644 | e.Message, e.StackTrace); | ||
1645 | } | ||
1646 | } | ||
1647 | } | ||
991 | } | 1648 | } |
992 | 1649 | ||
993 | // this lets us keep track of nasty script events like timer, etc. | 1650 | // this lets us keep track of nasty script events like timer, etc. |
@@ -1010,99 +1667,277 @@ namespace OpenSim.Region.Framework.Scenes | |||
1010 | /// <param name="FixedSunHour">The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1</param> | 1667 | /// <param name="FixedSunHour">The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1</param> |
1011 | public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour) | 1668 | public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour) |
1012 | { | 1669 | { |
1013 | handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate; | 1670 | EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate; |
1014 | if (handlerEstateToolsSunUpdate != null) | 1671 | if (handlerEstateToolsSunUpdate != null) |
1015 | { | 1672 | { |
1016 | handlerEstateToolsSunUpdate(regionHandle, FixedTime, useEstateTime, FixedSunHour); | 1673 | foreach (EstateToolsSunUpdate d in handlerEstateToolsSunUpdate.GetInvocationList()) |
1017 | } | 1674 | { |
1675 | try | ||
1676 | { | ||
1677 | d(regionHandle, FixedTime, useEstateTime, FixedSunHour); | ||
1678 | } | ||
1679 | catch (Exception e) | ||
1680 | { | ||
1681 | m_log.ErrorFormat( | ||
1682 | "[EVENT MANAGER]: Delegate for TriggerEstateToolsSunUpdate failed - continuing. {0} {1}", | ||
1683 | e.Message, e.StackTrace); | ||
1684 | } | ||
1685 | } | ||
1686 | } | ||
1018 | } | 1687 | } |
1019 | 1688 | ||
1020 | public float GetCurrentTimeAsSunLindenHour() | 1689 | public float GetCurrentTimeAsSunLindenHour() |
1021 | { | 1690 | { |
1022 | handlerCurrentTimeAsLindenSunHour = OnGetCurrentTimeAsLindenSunHour; | 1691 | SunLindenHour handlerCurrentTimeAsLindenSunHour = OnGetCurrentTimeAsLindenSunHour; |
1023 | if (handlerCurrentTimeAsLindenSunHour != null) | 1692 | if (handlerCurrentTimeAsLindenSunHour != null) |
1024 | { | 1693 | { |
1025 | return handlerCurrentTimeAsLindenSunHour(); | 1694 | foreach (SunLindenHour d in handlerCurrentTimeAsLindenSunHour.GetInvocationList()) |
1695 | { | ||
1696 | try | ||
1697 | { | ||
1698 | return d(); | ||
1699 | } | ||
1700 | catch (Exception e) | ||
1701 | { | ||
1702 | m_log.ErrorFormat( | ||
1703 | "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", | ||
1704 | e.Message, e.StackTrace); | ||
1705 | } | ||
1706 | } | ||
1026 | } | 1707 | } |
1708 | |||
1027 | return 6; | 1709 | return 6; |
1028 | } | 1710 | } |
1029 | 1711 | ||
1030 | public void TriggerOarFileLoaded(Guid requestId, string message) | 1712 | public void TriggerOarFileLoaded(Guid requestId, string message) |
1031 | { | 1713 | { |
1032 | handlerOarFileLoaded = OnOarFileLoaded; | 1714 | OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded; |
1033 | if (handlerOarFileLoaded != null) | 1715 | if (handlerOarFileLoaded != null) |
1034 | handlerOarFileLoaded(requestId, message); | 1716 | { |
1717 | foreach (OarFileLoaded d in handlerOarFileLoaded.GetInvocationList()) | ||
1718 | { | ||
1719 | try | ||
1720 | { | ||
1721 | d(requestId, message); | ||
1722 | } | ||
1723 | catch (Exception e) | ||
1724 | { | ||
1725 | m_log.ErrorFormat( | ||
1726 | "[EVENT MANAGER]: Delegate for TriggerOarFileLoaded failed - continuing. {0} {1}", | ||
1727 | e.Message, e.StackTrace); | ||
1728 | } | ||
1729 | } | ||
1730 | } | ||
1035 | } | 1731 | } |
1036 | 1732 | ||
1037 | public void TriggerOarFileSaved(Guid requestId, string message) | 1733 | public void TriggerOarFileSaved(Guid requestId, string message) |
1038 | { | 1734 | { |
1039 | handlerOarFileSaved = OnOarFileSaved; | 1735 | OarFileSaved handlerOarFileSaved = OnOarFileSaved; |
1040 | if (handlerOarFileSaved != null) | 1736 | if (handlerOarFileSaved != null) |
1041 | handlerOarFileSaved(requestId, message); | 1737 | { |
1738 | foreach (OarFileSaved d in handlerOarFileSaved.GetInvocationList()) | ||
1739 | { | ||
1740 | try | ||
1741 | { | ||
1742 | d(requestId, message); | ||
1743 | } | ||
1744 | catch (Exception e) | ||
1745 | { | ||
1746 | m_log.ErrorFormat( | ||
1747 | "[EVENT MANAGER]: Delegate for TriggerOarFileSaved failed - continuing. {0} {1}", | ||
1748 | e.Message, e.StackTrace); | ||
1749 | } | ||
1750 | } | ||
1751 | } | ||
1042 | } | 1752 | } |
1043 | 1753 | ||
1044 | public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) | 1754 | public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) |
1045 | { | 1755 | { |
1046 | handlerEmptyScriptCompileQueue = OnEmptyScriptCompileQueue; | 1756 | EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = OnEmptyScriptCompileQueue; |
1047 | if (handlerEmptyScriptCompileQueue != null) | 1757 | if (handlerEmptyScriptCompileQueue != null) |
1048 | handlerEmptyScriptCompileQueue(numScriptsFailed, message); | 1758 | { |
1759 | foreach (EmptyScriptCompileQueue d in handlerEmptyScriptCompileQueue.GetInvocationList()) | ||
1760 | { | ||
1761 | try | ||
1762 | { | ||
1763 | d(numScriptsFailed, message); | ||
1764 | } | ||
1765 | catch (Exception e) | ||
1766 | { | ||
1767 | m_log.ErrorFormat( | ||
1768 | "[EVENT MANAGER]: Delegate for TriggerEmptyScriptCompileQueue failed - continuing. {0} {1}", | ||
1769 | e.Message, e.StackTrace); | ||
1770 | } | ||
1771 | } | ||
1772 | } | ||
1049 | } | 1773 | } |
1050 | 1774 | ||
1051 | public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) | 1775 | public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) |
1052 | { | 1776 | { |
1053 | handlerCollidingStart = OnScriptColliderStart; | 1777 | ScriptColliding handlerCollidingStart = OnScriptColliderStart; |
1054 | if (handlerCollidingStart != null) | 1778 | if (handlerCollidingStart != null) |
1055 | handlerCollidingStart(localId, colliders); | 1779 | { |
1780 | foreach (ScriptColliding d in handlerCollidingStart.GetInvocationList()) | ||
1781 | { | ||
1782 | try | ||
1783 | { | ||
1784 | d(localId, colliders); | ||
1785 | } | ||
1786 | catch (Exception e) | ||
1787 | { | ||
1788 | m_log.ErrorFormat( | ||
1789 | "[EVENT MANAGER]: Delegate for TriggerScriptCollidingStart failed - continuing. {0} {1}", | ||
1790 | e.Message, e.StackTrace); | ||
1791 | } | ||
1792 | } | ||
1793 | } | ||
1056 | } | 1794 | } |
1057 | 1795 | ||
1058 | public void TriggerScriptColliding(uint localId, ColliderArgs colliders) | 1796 | public void TriggerScriptColliding(uint localId, ColliderArgs colliders) |
1059 | { | 1797 | { |
1060 | handlerColliding = OnScriptColliding; | 1798 | ScriptColliding handlerColliding = OnScriptColliding; |
1061 | if (handlerColliding != null) | 1799 | if (handlerColliding != null) |
1062 | handlerColliding(localId, colliders); | 1800 | { |
1801 | foreach (ScriptColliding d in handlerColliding.GetInvocationList()) | ||
1802 | { | ||
1803 | try | ||
1804 | { | ||
1805 | d(localId, colliders); | ||
1806 | } | ||
1807 | catch (Exception e) | ||
1808 | { | ||
1809 | m_log.ErrorFormat( | ||
1810 | "[EVENT MANAGER]: Delegate for TriggerScriptColliding failed - continuing. {0} {1}", | ||
1811 | e.Message, e.StackTrace); | ||
1812 | } | ||
1813 | } | ||
1814 | } | ||
1063 | } | 1815 | } |
1064 | 1816 | ||
1065 | public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) | 1817 | public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) |
1066 | { | 1818 | { |
1067 | handlerCollidingEnd = OnScriptCollidingEnd; | 1819 | ScriptColliding handlerCollidingEnd = OnScriptCollidingEnd; |
1068 | if (handlerCollidingEnd != null) | 1820 | if (handlerCollidingEnd != null) |
1069 | handlerCollidingEnd(localId, colliders); | 1821 | { |
1822 | foreach (ScriptColliding d in handlerCollidingEnd.GetInvocationList()) | ||
1823 | { | ||
1824 | try | ||
1825 | { | ||
1826 | d(localId, colliders); | ||
1827 | } | ||
1828 | catch (Exception e) | ||
1829 | { | ||
1830 | m_log.ErrorFormat( | ||
1831 | "[EVENT MANAGER]: Delegate for TriggerScriptCollidingEnd failed - continuing. {0} {1}", | ||
1832 | e.Message, e.StackTrace); | ||
1833 | } | ||
1834 | } | ||
1835 | } | ||
1070 | } | 1836 | } |
1071 | 1837 | ||
1072 | public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) | 1838 | public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) |
1073 | { | 1839 | { |
1074 | handlerLandCollidingStart = OnScriptLandColliderStart; | 1840 | ScriptColliding handlerLandCollidingStart = OnScriptLandColliderStart; |
1075 | if (handlerLandCollidingStart != null) | 1841 | if (handlerLandCollidingStart != null) |
1076 | handlerLandCollidingStart(localId, colliders); | 1842 | { |
1843 | foreach (ScriptColliding d in handlerLandCollidingStart.GetInvocationList()) | ||
1844 | { | ||
1845 | try | ||
1846 | { | ||
1847 | d(localId, colliders); | ||
1848 | } | ||
1849 | catch (Exception e) | ||
1850 | { | ||
1851 | m_log.ErrorFormat( | ||
1852 | "[EVENT MANAGER]: Delegate for TriggerScriptLandCollidingStart failed - continuing. {0} {1}", | ||
1853 | e.Message, e.StackTrace); | ||
1854 | } | ||
1855 | } | ||
1856 | } | ||
1077 | } | 1857 | } |
1078 | 1858 | ||
1079 | public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) | 1859 | public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) |
1080 | { | 1860 | { |
1081 | handlerLandColliding = OnScriptLandColliding; | 1861 | ScriptColliding handlerLandColliding = OnScriptLandColliding; |
1082 | if (handlerLandColliding != null) | 1862 | if (handlerLandColliding != null) |
1083 | handlerLandColliding(localId, colliders); | 1863 | { |
1864 | foreach (ScriptColliding d in handlerLandColliding.GetInvocationList()) | ||
1865 | { | ||
1866 | try | ||
1867 | { | ||
1868 | d(localId, colliders); | ||
1869 | } | ||
1870 | catch (Exception e) | ||
1871 | { | ||
1872 | m_log.ErrorFormat( | ||
1873 | "[EVENT MANAGER]: Delegate for TriggerScriptLandColliding failed - continuing. {0} {1}", | ||
1874 | e.Message, e.StackTrace); | ||
1875 | } | ||
1876 | } | ||
1877 | } | ||
1084 | } | 1878 | } |
1085 | 1879 | ||
1086 | public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) | 1880 | public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) |
1087 | { | 1881 | { |
1088 | handlerLandCollidingEnd = OnScriptLandColliderEnd; | 1882 | ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd; |
1089 | if (handlerLandCollidingEnd != null) | 1883 | if (handlerLandCollidingEnd != null) |
1090 | handlerLandCollidingEnd(localId, colliders); | 1884 | { |
1885 | foreach (ScriptColliding d in handlerLandCollidingEnd.GetInvocationList()) | ||
1886 | { | ||
1887 | try | ||
1888 | { | ||
1889 | d(localId, colliders); | ||
1890 | } | ||
1891 | catch (Exception e) | ||
1892 | { | ||
1893 | m_log.ErrorFormat( | ||
1894 | "[EVENT MANAGER]: Delegate for TriggerScriptLandCollidingEnd failed - continuing. {0} {1}", | ||
1895 | e.Message, e.StackTrace); | ||
1896 | } | ||
1897 | } | ||
1898 | } | ||
1091 | } | 1899 | } |
1092 | 1900 | ||
1093 | public void TriggerSetRootAgentScene(UUID agentID, Scene scene) | 1901 | public void TriggerSetRootAgentScene(UUID agentID, Scene scene) |
1094 | { | 1902 | { |
1095 | handlerSetRootAgentScene = OnSetRootAgentScene; | 1903 | OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene; |
1096 | if (handlerSetRootAgentScene != null) | 1904 | if (handlerSetRootAgentScene != null) |
1097 | handlerSetRootAgentScene(agentID, scene); | 1905 | { |
1906 | foreach (OnSetRootAgentSceneDelegate d in handlerSetRootAgentScene.GetInvocationList()) | ||
1907 | { | ||
1908 | try | ||
1909 | { | ||
1910 | d(agentID, scene); | ||
1911 | } | ||
1912 | catch (Exception e) | ||
1913 | { | ||
1914 | m_log.ErrorFormat( | ||
1915 | "[EVENT MANAGER]: Delegate for TriggerSetRootAgentScene failed - continuing. {0} {1}", | ||
1916 | e.Message, e.StackTrace); | ||
1917 | } | ||
1918 | } | ||
1919 | } | ||
1098 | } | 1920 | } |
1099 | 1921 | ||
1100 | public void TriggerOnRegionUp(GridRegion otherRegion) | 1922 | public void TriggerOnRegionUp(GridRegion otherRegion) |
1101 | { | 1923 | { |
1102 | handlerOnRegionUp = OnRegionUp; | 1924 | RegionUp handlerOnRegionUp = OnRegionUp; |
1103 | if (handlerOnRegionUp != null) | 1925 | if (handlerOnRegionUp != null) |
1104 | handlerOnRegionUp(otherRegion); | 1926 | { |
1927 | foreach (RegionUp d in handlerOnRegionUp.GetInvocationList()) | ||
1928 | { | ||
1929 | try | ||
1930 | { | ||
1931 | d(otherRegion); | ||
1932 | } | ||
1933 | catch (Exception e) | ||
1934 | { | ||
1935 | m_log.ErrorFormat( | ||
1936 | "[EVENT MANAGER]: Delegate for TriggerOnRegionUp failed - continuing. {0} {1}", | ||
1937 | e.Message, e.StackTrace); | ||
1938 | } | ||
1939 | } | ||
1940 | } | ||
1105 | } | 1941 | } |
1106 | |||
1107 | } | 1942 | } |
1108 | } | 1943 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 45806dd..e032a07 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | 197 | ||
198 | if (isScriptRunning) | 198 | if (isScriptRunning) |
199 | { | 199 | { |
200 | part.Inventory.RemoveScriptInstance(item.ItemID); | 200 | part.Inventory.RemoveScriptInstance(item.ItemID, false); |
201 | } | 201 | } |
202 | 202 | ||
203 | // Update item with new asset | 203 | // Update item with new asset |
@@ -794,8 +794,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
794 | 794 | ||
795 | if (item.Type == 10) | 795 | if (item.Type == 10) |
796 | { | 796 | { |
797 | part.RemoveScriptEvents(itemID); | ||
797 | EventManager.TriggerRemoveScript(localID, itemID); | 798 | EventManager.TriggerRemoveScript(localID, itemID); |
798 | } | 799 | } |
800 | |||
799 | group.RemoveInventoryItem(localID, itemID); | 801 | group.RemoveInventoryItem(localID, itemID); |
800 | part.GetProperties(remoteClient); | 802 | part.GetProperties(remoteClient); |
801 | } | 803 | } |
@@ -1879,9 +1881,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1879 | } | 1881 | } |
1880 | } | 1882 | } |
1881 | 1883 | ||
1882 | public void AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | 1884 | /// <summary> |
1885 | /// Attach an object. | ||
1886 | /// </summary> | ||
1887 | /// <param name="controllingClient"></param> | ||
1888 | /// <param name="localID"></param> | ||
1889 | /// <param name="attachPoint"></param> | ||
1890 | /// <param name="rot"></param> | ||
1891 | /// <param name="pos"></param> | ||
1892 | /// <param name="silent"></param> | ||
1893 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
1894 | public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | ||
1883 | { | 1895 | { |
1884 | m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); | 1896 | return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); |
1885 | } | 1897 | } |
1886 | 1898 | ||
1887 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 1899 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 342b3c5..bc10230 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -292,6 +292,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | public virtual void ProcessObjectGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) | ||
296 | { | ||
297 | List<EntityBase> EntityList = GetEntities(); | ||
298 | |||
299 | SurfaceTouchEventArgs surfaceArg = null; | ||
300 | if (surfaceArgs != null && surfaceArgs.Count > 0) | ||
301 | surfaceArg = surfaceArgs[0]; | ||
302 | |||
303 | foreach (EntityBase ent in EntityList) | ||
304 | { | ||
305 | if (ent is SceneObjectGroup) | ||
306 | { | ||
307 | SceneObjectGroup obj = ent as SceneObjectGroup; | ||
308 | if (obj != null) | ||
309 | { | ||
310 | // Is this prim part of the group | ||
311 | if (obj.HasChildPrim(objectID)) | ||
312 | { | ||
313 | SceneObjectPart part = obj.GetChildPart(objectID); | ||
314 | |||
315 | // If the touched prim handles touches, deliver it | ||
316 | // If not, deliver to root prim | ||
317 | if ((part.ScriptEvents & scriptEvents.touch) != 0) | ||
318 | EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); | ||
319 | // Deliver to the root prim if the touched prim doesn't handle touches | ||
320 | // or if we're meant to pass on touches anyway. Don't send to root prim | ||
321 | // if prim touched is the root prim as we just did it | ||
322 | if (((part.ScriptEvents & scriptEvents.touch) == 0) || | ||
323 | (part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) | ||
324 | { | ||
325 | EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg); | ||
326 | } | ||
327 | |||
328 | return; | ||
329 | } | ||
330 | } | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
295 | public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) | 335 | public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) |
296 | { | 336 | { |
297 | List<EntityBase> EntityList = GetEntities(); | 337 | List<EntityBase> EntityList = GetEntities(); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f800d5f..f109589 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1102,7 +1102,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1102 | { | 1102 | { |
1103 | if (ent is SceneObjectGroup) | 1103 | if (ent is SceneObjectGroup) |
1104 | { | 1104 | { |
1105 | ((SceneObjectGroup) ent).RemoveScriptInstances(); | 1105 | ((SceneObjectGroup) ent).RemoveScriptInstances(false); |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | } | 1108 | } |
@@ -1977,13 +1977,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1977 | /// <param name="silent">Suppress broadcasting changes to other clients.</param> | 1977 | /// <param name="silent">Suppress broadcasting changes to other clients.</param> |
1978 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) | 1978 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) |
1979 | { | 1979 | { |
1980 | // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); | ||
1981 | |||
1980 | //SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 1982 | //SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
1981 | 1983 | ||
1982 | // Serialise calls to RemoveScriptInstances to avoid | 1984 | // Serialise calls to RemoveScriptInstances to avoid |
1983 | // deadlocking on m_parts inside SceneObjectGroup | 1985 | // deadlocking on m_parts inside SceneObjectGroup |
1984 | lock (m_deleting_scene_object) | 1986 | lock (m_deleting_scene_object) |
1985 | { | 1987 | { |
1986 | group.RemoveScriptInstances(); | 1988 | group.RemoveScriptInstances(true); |
1987 | } | 1989 | } |
1988 | 1990 | ||
1989 | foreach (SceneObjectPart part in group.Children.Values) | 1991 | foreach (SceneObjectPart part in group.Children.Values) |
@@ -2011,6 +2013,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2011 | } | 2013 | } |
2012 | 2014 | ||
2013 | group.DeleteGroup(silent); | 2015 | group.DeleteGroup(silent); |
2016 | |||
2017 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | ||
2014 | } | 2018 | } |
2015 | 2019 | ||
2016 | /// <summary> | 2020 | /// <summary> |
@@ -2539,6 +2543,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2539 | client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; | 2543 | client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; |
2540 | client.OnObjectPermissions += HandleObjectPermissionsUpdate; | 2544 | client.OnObjectPermissions += HandleObjectPermissionsUpdate; |
2541 | client.OnGrabObject += ProcessObjectGrab; | 2545 | client.OnGrabObject += ProcessObjectGrab; |
2546 | client.OnGrabUpdate += ProcessObjectGrabUpdate; | ||
2542 | client.OnDeGrabObject += ProcessObjectDeGrab; | 2547 | client.OnDeGrabObject += ProcessObjectDeGrab; |
2543 | client.OnUndo += m_sceneGraph.HandleUndo; | 2548 | client.OnUndo += m_sceneGraph.HandleUndo; |
2544 | client.OnObjectDescription += m_sceneGraph.PrimDescription; | 2549 | client.OnObjectDescription += m_sceneGraph.PrimDescription; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fbd11c6..7bd4329 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -479,25 +479,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | if (part == null) | 479 | if (part == null) |
480 | return; | 480 | return; |
481 | 481 | ||
482 | if (!m_parentScene.Permissions.CanTakeObject( | 482 | if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) |
483 | part.UUID, remoteClient.AgentId)) | ||
484 | return; | 483 | return; |
485 | 484 | ||
486 | // Calls attach with a Zero position | 485 | // Calls attach with a Zero position |
487 | AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false); | 486 | if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) |
488 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | ||
489 | |||
490 | // Save avatar attachment information | ||
491 | ScenePresence presence; | ||
492 | if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
493 | { | 487 | { |
494 | m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt); | 488 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
495 | m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 489 | |
490 | // Save avatar attachment information | ||
491 | ScenePresence presence; | ||
492 | if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
493 | { | ||
494 | m_log.Info( | ||
495 | "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
496 | + ", AttachmentPoint: " + AttachmentPt); | ||
497 | |||
498 | m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
499 | } | ||
496 | } | 500 | } |
497 | } | 501 | } |
498 | 502 | ||
499 | public SceneObjectGroup RezSingleAttachment( | 503 | /// <summary> |
500 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 504 | /// Rez an attachment |
505 | /// </summary> | ||
506 | /// <param name="remoteClient"></param> | ||
507 | /// <param name="itemID"></param> | ||
508 | /// <param name="AttachmentPt"></param> | ||
509 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | ||
510 | public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
501 | { | 511 | { |
502 | IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>(); | 512 | IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>(); |
503 | if (invAccess != null) | 513 | if (invAccess != null) |
@@ -560,7 +570,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | } | 570 | } |
561 | } | 571 | } |
562 | 572 | ||
563 | protected internal void AttachObject( | 573 | /// <summary> |
574 | /// Attach a scene object to an avatar. | ||
575 | /// </summary> | ||
576 | /// <param name="remoteClient"></param> | ||
577 | /// <param name="objectLocalID"></param> | ||
578 | /// <param name="AttachmentPt"></param> | ||
579 | /// <param name="rot"></param> | ||
580 | /// <param name="attachPos"></param> | ||
581 | /// <param name="silent"></param> | ||
582 | /// <returns>true if the attachment was successful, false otherwise</returns> | ||
583 | protected internal bool AttachObject( | ||
564 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) | 584 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) |
565 | { | 585 | { |
566 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | 586 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); |
@@ -589,10 +609,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
589 | // Stick it on left hand with Zero Offset from the attachment point. | 609 | // Stick it on left hand with Zero Offset from the attachment point. |
590 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | 610 | AttachmentPt = (uint)AttachmentPoint.LeftHand; |
591 | attachPos = Vector3.Zero; | 611 | attachPos = Vector3.Zero; |
592 | |||
593 | } | 612 | } |
594 | 613 | ||
595 | |||
596 | group.SetAttachmentPoint((byte)AttachmentPt); | 614 | group.SetAttachmentPoint((byte)AttachmentPt); |
597 | group.AbsolutePosition = attachPos; | 615 | group.AbsolutePosition = attachPos; |
598 | 616 | ||
@@ -615,15 +633,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
615 | // it get cleaned up | 633 | // it get cleaned up |
616 | // | 634 | // |
617 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 635 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
618 | group.HasGroupChanged = false; | 636 | group.HasGroupChanged = false; |
619 | } | 637 | } |
620 | else | 638 | else |
621 | { | 639 | { |
622 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); | 640 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); |
641 | return false; | ||
623 | } | 642 | } |
624 | } | 643 | } |
625 | else | 644 | else |
645 | { | ||
626 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); | 646 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); |
647 | return false; | ||
648 | } | ||
649 | |||
650 | return true; | ||
627 | } | 651 | } |
628 | 652 | ||
629 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) | 653 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 5a06bdb..71354b4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -74,13 +74,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | /// <summary> | 74 | /// <summary> |
75 | /// Stop the scripts contained in all the prims in this group | 75 | /// Stop the scripts contained in all the prims in this group |
76 | /// </summary> | 76 | /// </summary> |
77 | public void RemoveScriptInstances() | 77 | /// <param name="sceneObjectBeingDeleted"> |
78 | /// Should be true if these scripts are being removed because the scene | ||
79 | /// object is being deleted. This will prevent spurious updates to the client. | ||
80 | /// </param> | ||
81 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | ||
78 | { | 82 | { |
79 | lock (m_parts) | 83 | lock (m_parts) |
80 | { | 84 | { |
81 | foreach (SceneObjectPart part in m_parts.Values) | 85 | foreach (SceneObjectPart part in m_parts.Values) |
82 | { | 86 | { |
83 | part.Inventory.RemoveScriptInstances(); | 87 | part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); |
84 | } | 88 | } |
85 | } | 89 | } |
86 | } | 90 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ec41ac7..8c56870 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -235,6 +235,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
235 | set { m_rootPart.GroupID = value; } | 235 | set { m_rootPart.GroupID = value; } |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <value> | ||
239 | /// The parts of this scene object group. You must lock this property before using it. | ||
240 | /// </value> | ||
238 | public Dictionary<UUID, SceneObjectPart> Children | 241 | public Dictionary<UUID, SceneObjectPart> Children |
239 | { | 242 | { |
240 | get { return m_parts; } | 243 | get { return m_parts; } |
@@ -2097,7 +2100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2097 | } | 2100 | } |
2098 | 2101 | ||
2099 | /// <summary> | 2102 | /// <summary> |
2100 | /// Get a child part with a given UUID | 2103 | /// Get a part with a given UUID |
2101 | /// </summary> | 2104 | /// </summary> |
2102 | /// <param name="primID"></param> | 2105 | /// <param name="primID"></param> |
2103 | /// <returns>null if a child part with the primID was not found</returns> | 2106 | /// <returns>null if a child part with the primID was not found</returns> |
@@ -2112,7 +2115,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2112 | } | 2115 | } |
2113 | 2116 | ||
2114 | /// <summary> | 2117 | /// <summary> |
2115 | /// Get a child part with a given local ID | 2118 | /// Get a part with a given local ID |
2116 | /// </summary> | 2119 | /// </summary> |
2117 | /// <param name="localID"></param> | 2120 | /// <param name="localID"></param> |
2118 | /// <returns>null if a child part with the local ID was not found</returns> | 2121 | /// <returns>null if a child part with the local ID was not found</returns> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 56b2f13..dd797fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -90,12 +90,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
90 | SCALE = 0x40 | 90 | SCALE = 0x40 |
91 | } | 91 | } |
92 | 92 | ||
93 | public enum PrimType : int | ||
94 | { | ||
95 | BOX = 0, | ||
96 | CYLINDER = 1, | ||
97 | PRISM = 2, | ||
98 | SPHERE = 3, | ||
99 | TORUS = 4, | ||
100 | TUBE = 5, | ||
101 | RING = 6, | ||
102 | SCULPT = 7 | ||
103 | } | ||
104 | |||
93 | #endregion Enumerations | 105 | #endregion Enumerations |
94 | 106 | ||
95 | public class SceneObjectPart : IScriptHost | 107 | public class SceneObjectPart : IScriptHost |
96 | { | 108 | { |
109 | /// <value> | ||
110 | /// Denote all sides of the prim | ||
111 | /// </value> | ||
112 | public const int ALL_SIDES = -1; | ||
113 | |||
97 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 114 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
98 | 115 | ||
116 | /// <value> | ||
117 | /// Is this sop a root part? | ||
118 | /// </value> | ||
119 | [XmlIgnore] | ||
120 | public bool IsRoot | ||
121 | { | ||
122 | get { return ParentGroup.RootPart == this; } | ||
123 | } | ||
124 | |||
99 | // use only one serializer to give the runtime a chance to optimize it (it won't do that if you | 125 | // use only one serializer to give the runtime a chance to optimize it (it won't do that if you |
100 | // use a new instance every time) | 126 | // use a new instance every time) |
101 | private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); | 127 | private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); |
@@ -737,6 +763,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | } | 763 | } |
738 | } | 764 | } |
739 | 765 | ||
766 | /// <value> | ||
767 | /// Text color. | ||
768 | /// </value> | ||
740 | public Color Color | 769 | public Color Color |
741 | { | 770 | { |
742 | get { return m_color; } | 771 | get { return m_color; } |
@@ -1901,7 +1930,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1901 | foreach (uint localId in startedColliders) | 1930 | foreach (uint localId in startedColliders) |
1902 | { | 1931 | { |
1903 | if (localId == 0) | 1932 | if (localId == 0) |
1904 | return; | 1933 | continue; |
1905 | // always running this check because if the user deletes the object it would return a null reference. | 1934 | // always running this check because if the user deletes the object it would return a null reference. |
1906 | if (m_parentGroup == null) | 1935 | if (m_parentGroup == null) |
1907 | return; | 1936 | return; |
@@ -2037,7 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2037 | { | 2066 | { |
2038 | // always running this check because if the user deletes the object it would return a null reference. | 2067 | // always running this check because if the user deletes the object it would return a null reference. |
2039 | if (localId == 0) | 2068 | if (localId == 0) |
2040 | return; | 2069 | continue; |
2041 | 2070 | ||
2042 | if (m_parentGroup == null) | 2071 | if (m_parentGroup == null) |
2043 | return; | 2072 | return; |
@@ -2169,7 +2198,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2169 | foreach (uint localId in endedColliders) | 2198 | foreach (uint localId in endedColliders) |
2170 | { | 2199 | { |
2171 | if (localId == 0) | 2200 | if (localId == 0) |
2172 | return; | 2201 | continue; |
2173 | 2202 | ||
2174 | // always running this check because if the user deletes the object it would return a null reference. | 2203 | // always running this check because if the user deletes the object it would return a null reference. |
2175 | if (m_parentGroup == null) | 2204 | if (m_parentGroup == null) |
@@ -2479,7 +2508,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2479 | //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); | 2508 | //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); |
2480 | //ScheduleFullUpdate(); | 2509 | //ScheduleFullUpdate(); |
2481 | } | 2510 | } |
2482 | 2511 | ||
2483 | public void RemoveScriptEvents(UUID scriptid) | 2512 | public void RemoveScriptEvents(UUID scriptid) |
2484 | { | 2513 | { |
2485 | lock (m_scriptEvents) | 2514 | lock (m_scriptEvents) |
@@ -2533,6 +2562,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2533 | /// </summary> | 2562 | /// </summary> |
2534 | public void ScheduleFullUpdate() | 2563 | public void ScheduleFullUpdate() |
2535 | { | 2564 | { |
2565 | // m_log.DebugFormat("[SCENE OBJECT PART]: Scheduling full update for {0} {1}", Name, LocalId); | ||
2566 | |||
2536 | if (m_parentGroup != null) | 2567 | if (m_parentGroup != null) |
2537 | { | 2568 | { |
2538 | m_parentGroup.QueueForUpdateCheck(); | 2569 | m_parentGroup.QueueForUpdateCheck(); |
@@ -2953,6 +2984,178 @@ namespace OpenSim.Region.Framework.Scenes | |||
2953 | } | 2984 | } |
2954 | } | 2985 | } |
2955 | 2986 | ||
2987 | /// <summary> | ||
2988 | /// Set the color of prim faces | ||
2989 | /// </summary> | ||
2990 | /// <param name="color"></param> | ||
2991 | /// <param name="face"></param> | ||
2992 | public void SetFaceColor(Vector3 color, int face) | ||
2993 | { | ||
2994 | Primitive.TextureEntry tex = Shape.Textures; | ||
2995 | Color4 texcolor; | ||
2996 | if (face >= 0 && face < GetNumberOfSides()) | ||
2997 | { | ||
2998 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
2999 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
3000 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
3001 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
3002 | tex.FaceTextures[face].RGBA = texcolor; | ||
3003 | UpdateTexture(tex); | ||
3004 | return; | ||
3005 | } | ||
3006 | else if (face == ALL_SIDES) | ||
3007 | { | ||
3008 | for (uint i = 0; i < GetNumberOfSides(); i++) | ||
3009 | { | ||
3010 | if (tex.FaceTextures[i] != null) | ||
3011 | { | ||
3012 | texcolor = tex.FaceTextures[i].RGBA; | ||
3013 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
3014 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
3015 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
3016 | tex.FaceTextures[i].RGBA = texcolor; | ||
3017 | } | ||
3018 | texcolor = tex.DefaultTexture.RGBA; | ||
3019 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
3020 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
3021 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
3022 | tex.DefaultTexture.RGBA = texcolor; | ||
3023 | } | ||
3024 | UpdateTexture(tex); | ||
3025 | return; | ||
3026 | } | ||
3027 | } | ||
3028 | |||
3029 | /// <summary> | ||
3030 | /// Get the number of sides that this part has. | ||
3031 | /// </summary> | ||
3032 | /// <returns></returns> | ||
3033 | public int GetNumberOfSides() | ||
3034 | { | ||
3035 | int ret = 0; | ||
3036 | bool hasCut; | ||
3037 | bool hasHollow; | ||
3038 | bool hasDimple; | ||
3039 | bool hasProfileCut; | ||
3040 | |||
3041 | PrimType primType = GetPrimType(); | ||
3042 | HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
3043 | |||
3044 | switch (primType) | ||
3045 | { | ||
3046 | case PrimType.BOX: | ||
3047 | ret = 6; | ||
3048 | if (hasCut) ret += 2; | ||
3049 | if (hasHollow) ret += 1; | ||
3050 | break; | ||
3051 | case PrimType.CYLINDER: | ||
3052 | ret = 3; | ||
3053 | if (hasCut) ret += 2; | ||
3054 | if (hasHollow) ret += 1; | ||
3055 | break; | ||
3056 | case PrimType.PRISM: | ||
3057 | ret = 5; | ||
3058 | if (hasCut) ret += 2; | ||
3059 | if (hasHollow) ret += 1; | ||
3060 | break; | ||
3061 | case PrimType.SPHERE: | ||
3062 | ret = 1; | ||
3063 | if (hasCut) ret += 2; | ||
3064 | if (hasDimple) ret += 2; | ||
3065 | if (hasHollow) ret += 1; | ||
3066 | break; | ||
3067 | case PrimType.TORUS: | ||
3068 | ret = 1; | ||
3069 | if (hasCut) ret += 2; | ||
3070 | if (hasProfileCut) ret += 2; | ||
3071 | if (hasHollow) ret += 1; | ||
3072 | break; | ||
3073 | case PrimType.TUBE: | ||
3074 | ret = 4; | ||
3075 | if (hasCut) ret += 2; | ||
3076 | if (hasProfileCut) ret += 2; | ||
3077 | if (hasHollow) ret += 1; | ||
3078 | break; | ||
3079 | case PrimType.RING: | ||
3080 | ret = 3; | ||
3081 | if (hasCut) ret += 2; | ||
3082 | if (hasProfileCut) ret += 2; | ||
3083 | if (hasHollow) ret += 1; | ||
3084 | break; | ||
3085 | case PrimType.SCULPT: | ||
3086 | ret = 1; | ||
3087 | break; | ||
3088 | } | ||
3089 | return ret; | ||
3090 | } | ||
3091 | |||
3092 | /// <summary> | ||
3093 | /// Tell us what type this prim is | ||
3094 | /// </summary> | ||
3095 | /// <param name="primShape"></param> | ||
3096 | /// <returns></returns> | ||
3097 | public PrimType GetPrimType() | ||
3098 | { | ||
3099 | if (Shape.SculptEntry) | ||
3100 | return PrimType.SCULPT; | ||
3101 | if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
3102 | { | ||
3103 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3104 | return PrimType.BOX; | ||
3105 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3106 | return PrimType.TUBE; | ||
3107 | } | ||
3108 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
3109 | { | ||
3110 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3111 | return PrimType.CYLINDER; | ||
3112 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
3113 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3114 | return PrimType.TORUS; | ||
3115 | } | ||
3116 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
3117 | { | ||
3118 | if (Shape.PathCurve == (byte)Extrusion.Curve1 || Shape.PathCurve == (byte)Extrusion.Curve2) | ||
3119 | return PrimType.SPHERE; | ||
3120 | } | ||
3121 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
3122 | { | ||
3123 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3124 | return PrimType.PRISM; | ||
3125 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3126 | return PrimType.RING; | ||
3127 | } | ||
3128 | |||
3129 | return PrimType.BOX; | ||
3130 | } | ||
3131 | |||
3132 | /// <summary> | ||
3133 | /// Tell us if this object has cut, hollow, dimple, and other factors affecting the number of faces | ||
3134 | /// </summary> | ||
3135 | /// <param name="primType"></param> | ||
3136 | /// <param name="shape"></param> | ||
3137 | /// <param name="hasCut"></param> | ||
3138 | /// <param name="hasHollow"></param> | ||
3139 | /// <param name="hasDimple"></param> | ||
3140 | /// <param name="hasProfileCut"></param> | ||
3141 | protected static void HasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | ||
3142 | out bool hasDimple, out bool hasProfileCut) | ||
3143 | { | ||
3144 | if (primType == PrimType.BOX | ||
3145 | || | ||
3146 | primType == PrimType.CYLINDER | ||
3147 | || | ||
3148 | primType == PrimType.PRISM) | ||
3149 | |||
3150 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
3151 | else | ||
3152 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
3153 | |||
3154 | hasHollow = shape.ProfileHollow > 0; | ||
3155 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | ||
3156 | hasProfileCut = hasDimple; // is it the same thing? | ||
3157 | } | ||
3158 | |||
2956 | public void SetGroup(UUID groupID, IClientAPI client) | 3159 | public void SetGroup(UUID groupID, IClientAPI client) |
2957 | { | 3160 | { |
2958 | _groupID = groupID; | 3161 | _groupID = groupID; |
@@ -2984,6 +3187,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2984 | } | 3187 | } |
2985 | } | 3188 | } |
2986 | 3189 | ||
3190 | /// <summary> | ||
3191 | /// Set the events that this part will pass on to listeners. | ||
3192 | /// </summary> | ||
3193 | /// <param name="scriptid"></param> | ||
3194 | /// <param name="events"></param> | ||
2987 | public void SetScriptEvents(UUID scriptid, int events) | 3195 | public void SetScriptEvents(UUID scriptid, int events) |
2988 | { | 3196 | { |
2989 | // scriptEvents oldparts; | 3197 | // scriptEvents oldparts; |
@@ -3936,9 +4144,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3936 | ScheduleFullUpdate(); | 4144 | ScheduleFullUpdate(); |
3937 | } | 4145 | } |
3938 | 4146 | ||
3939 | // Added to handle bug in libsecondlife's TextureEntry.ToBytes() | 4147 | /// <summary> |
3940 | // not handling RGBA properly. Cycles through, and "fixes" the color | 4148 | /// Update the textures on the part. |
3941 | // info | 4149 | /// </summary> |
4150 | /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() | ||
4151 | /// not handling RGBA properly. Cycles through, and "fixes" the color | ||
4152 | /// info | ||
4153 | /// <param name="tex"></param> | ||
3942 | public void UpdateTexture(Primitive.TextureEntry tex) | 4154 | public void UpdateTexture(Primitive.TextureEntry tex) |
3943 | { | 4155 | { |
3944 | //Color4 tmpcolor; | 4156 | //Color4 tmpcolor; |
@@ -4042,6 +4254,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4042 | 4254 | ||
4043 | if (m_parentGroup == null) | 4255 | if (m_parentGroup == null) |
4044 | { | 4256 | { |
4257 | // m_log.DebugFormat( | ||
4258 | // "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents() since m_parentGroup == null", Name, LocalId); | ||
4045 | ScheduleFullUpdate(); | 4259 | ScheduleFullUpdate(); |
4046 | return; | 4260 | return; |
4047 | } | 4261 | } |
@@ -4058,9 +4272,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4058 | LocalFlags=(PrimFlags)objectflagupdate; | 4272 | LocalFlags=(PrimFlags)objectflagupdate; |
4059 | 4273 | ||
4060 | if (m_parentGroup != null && m_parentGroup.RootPart == this) | 4274 | if (m_parentGroup != null && m_parentGroup.RootPart == this) |
4275 | { | ||
4061 | m_parentGroup.aggregateScriptEvents(); | 4276 | m_parentGroup.aggregateScriptEvents(); |
4277 | } | ||
4062 | else | 4278 | else |
4279 | { | ||
4280 | // m_log.DebugFormat( | ||
4281 | // "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); | ||
4063 | ScheduleFullUpdate(); | 4282 | ScheduleFullUpdate(); |
4283 | } | ||
4064 | } | 4284 | } |
4065 | 4285 | ||
4066 | public int registerTargetWaypoint(Vector3 target, float tolerance) | 4286 | public int registerTargetWaypoint(Vector3 target, float tolerance) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 168912e..d0de513 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -229,7 +229,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
229 | /// <summary> | 229 | /// <summary> |
230 | /// Stop all the scripts in this prim. | 230 | /// Stop all the scripts in this prim. |
231 | /// </summary> | 231 | /// </summary> |
232 | public void RemoveScriptInstances() | 232 | /// <param name="sceneObjectBeingDeleted"> |
233 | /// Should be true if these scripts are being removed because the scene | ||
234 | /// object is being deleted. This will prevent spurious updates to the client. | ||
235 | /// </param> | ||
236 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | ||
233 | { | 237 | { |
234 | lock (Items) | 238 | lock (Items) |
235 | { | 239 | { |
@@ -237,8 +241,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | { | 241 | { |
238 | if ((int)InventoryType.LSL == item.InvType) | 242 | if ((int)InventoryType.LSL == item.InvType) |
239 | { | 243 | { |
240 | RemoveScriptInstance(item.ItemID); | 244 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
241 | m_part.RemoveScriptEvents(item.ItemID); | ||
242 | } | 245 | } |
243 | } | 246 | } |
244 | } | 247 | } |
@@ -266,8 +269,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | if (stateSource == 1 && // Prim crossing | 269 | if (stateSource == 1 && // Prim crossing |
267 | m_part.ParentGroup.Scene.m_trustBinaries) | 270 | m_part.ParentGroup.Scene.m_trustBinaries) |
268 | { | 271 | { |
269 | m_items[item.ItemID].PermsMask = 0; | 272 | lock (m_items) |
270 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 273 | { |
274 | m_items[item.ItemID].PermsMask = 0; | ||
275 | m_items[item.ItemID].PermsGranter = UUID.Zero; | ||
276 | } | ||
277 | |||
271 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 278 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
272 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 279 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
273 | m_part.ParentGroup.AddActiveScriptCount(1); | 280 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -275,33 +282,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
275 | return; | 282 | return; |
276 | } | 283 | } |
277 | 284 | ||
278 | m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) | 285 | m_part.ParentGroup.Scene.AssetService.Get( |
279 | { | 286 | item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) |
280 | if (null == asset) | 287 | { |
281 | { | 288 | if (null == asset) |
282 | m_log.ErrorFormat( | 289 | { |
283 | "[PRIM INVENTORY]: " + | 290 | m_log.ErrorFormat( |
284 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 291 | "[PRIM INVENTORY]: " + |
285 | item.Name, item.ItemID, m_part.AbsolutePosition, | 292 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
286 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); | 293 | item.Name, item.ItemID, m_part.AbsolutePosition, |
287 | } | 294 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); |
288 | else | 295 | } |
289 | { | 296 | else |
290 | if (m_part.ParentGroup.m_savedScriptState != null) | 297 | { |
291 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 298 | if (m_part.ParentGroup.m_savedScriptState != null) |
292 | m_items[item.ItemID].PermsMask = 0; | 299 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
293 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 300 | |
294 | string script = Utils.BytesToString(asset.Data); | 301 | lock (m_items) |
295 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 302 | { |
296 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 303 | m_items[item.ItemID].PermsMask = 0; |
297 | m_part.ParentGroup.AddActiveScriptCount(1); | 304 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
298 | m_part.ScheduleFullUpdate(); | 305 | } |
299 | } | 306 | |
300 | }); | 307 | string script = Utils.BytesToString(asset.Data); |
301 | } | 308 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
302 | } | 309 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
303 | 310 | m_part.ParentGroup.AddActiveScriptCount(1); | |
304 | static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 311 | m_part.ScheduleFullUpdate(); |
312 | } | ||
313 | } | ||
314 | ); | ||
315 | } | ||
316 | } | ||
305 | 317 | ||
306 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 318 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
307 | { | 319 | { |
@@ -387,10 +399,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
387 | /// Stop a script which is in this prim's inventory. | 399 | /// Stop a script which is in this prim's inventory. |
388 | /// </summary> | 400 | /// </summary> |
389 | /// <param name="itemId"></param> | 401 | /// <param name="itemId"></param> |
390 | public void RemoveScriptInstance(UUID itemId) | 402 | /// <param name="sceneObjectBeingDeleted"> |
403 | /// Should be true if this script is being removed because the scene | ||
404 | /// object is being deleted. This will prevent spurious updates to the client. | ||
405 | /// </param> | ||
406 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | ||
391 | { | 407 | { |
392 | if (m_items.ContainsKey(itemId)) | 408 | bool scriptPresent = false; |
409 | |||
410 | lock (m_items) | ||
411 | { | ||
412 | if (m_items.ContainsKey(itemId)) | ||
413 | scriptPresent = true; | ||
414 | } | ||
415 | |||
416 | if (scriptPresent) | ||
393 | { | 417 | { |
418 | if (!sceneObjectBeingDeleted) | ||
419 | m_part.RemoveScriptEvents(itemId); | ||
420 | |||
394 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId); | 421 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId); |
395 | m_part.ParentGroup.AddActiveScriptCount(-1); | 422 | m_part.ParentGroup.AddActiveScriptCount(-1); |
396 | } | 423 | } |
@@ -458,13 +485,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | /// <param name="item"></param> | 485 | /// <param name="item"></param> |
459 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 486 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
460 | { | 487 | { |
461 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 488 | List<TaskInventoryItem> il; |
489 | |||
490 | lock (m_items) | ||
491 | { | ||
492 | il = new List<TaskInventoryItem>(m_items.Values); | ||
493 | } | ||
494 | |||
462 | foreach (TaskInventoryItem i in il) | 495 | foreach (TaskInventoryItem i in il) |
463 | { | 496 | { |
464 | if (i.Name == item.Name) | 497 | if (i.Name == item.Name) |
465 | { | 498 | { |
466 | if (i.InvType == (int)InventoryType.LSL) | 499 | if (i.InvType == (int)InventoryType.LSL) |
467 | RemoveScriptInstance(i.ItemID); | 500 | RemoveScriptInstance(i.ItemID, false); |
468 | 501 | ||
469 | RemoveInventoryItem(i.ItemID); | 502 | RemoveInventoryItem(i.ItemID); |
470 | break; | 503 | break; |
@@ -540,11 +573,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
540 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 573 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
541 | { | 574 | { |
542 | TaskInventoryItem item; | 575 | TaskInventoryItem item; |
543 | m_items.TryGetValue(itemId, out item); | 576 | |
577 | lock (m_items) | ||
578 | m_items.TryGetValue(itemId, out item); | ||
544 | 579 | ||
545 | return item; | 580 | return item; |
546 | } | 581 | } |
582 | |||
583 | /// <summary> | ||
584 | /// Get inventory items by name. | ||
585 | /// </summary> | ||
586 | /// <param name="name"></param> | ||
587 | /// <returns> | ||
588 | /// A list of inventory items with that name. | ||
589 | /// If no inventory item has that name then an empty list is returned. | ||
590 | /// </returns> | ||
591 | public IList<TaskInventoryItem> GetInventoryItems(string name) | ||
592 | { | ||
593 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | ||
594 | |||
595 | lock (m_items) | ||
596 | { | ||
597 | foreach (TaskInventoryItem item in m_items.Values) | ||
598 | { | ||
599 | if (item.Name == name) | ||
600 | items.Add(item); | ||
601 | } | ||
602 | } | ||
547 | 603 | ||
604 | return items; | ||
605 | } | ||
606 | |||
548 | /// <summary> | 607 | /// <summary> |
549 | /// Update an existing inventory item. | 608 | /// Update an existing inventory item. |
550 | /// </summary> | 609 | /// </summary> |
@@ -612,6 +671,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
612 | int type = m_items[itemID].InvType; | 671 | int type = m_items[itemID].InvType; |
613 | if (type == 10) // Script | 672 | if (type == 10) // Script |
614 | { | 673 | { |
674 | m_part.RemoveScriptEvents(itemID); | ||
615 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 675 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
616 | } | 676 | } |
617 | m_items.Remove(itemID); | 677 | m_items.Remove(itemID); |
@@ -841,54 +901,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
841 | { | 901 | { |
842 | uint mask=0x7fffffff; | 902 | uint mask=0x7fffffff; |
843 | 903 | ||
844 | foreach (TaskInventoryItem item in m_items.Values) | 904 | lock (m_items) |
845 | { | 905 | { |
846 | if (item.InvType != (int)InventoryType.Object) | 906 | foreach (TaskInventoryItem item in m_items.Values) |
847 | { | ||
848 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
849 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
850 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
851 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
852 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
853 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
854 | } | ||
855 | else | ||
856 | { | 907 | { |
857 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 908 | if (item.InvType != (int)InventoryType.Object) |
858 | mask &= ~((uint)PermissionMask.Copy >> 13); | 909 | { |
859 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 910 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
860 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 911 | mask &= ~((uint)PermissionMask.Copy >> 13); |
861 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | 912 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) |
862 | mask &= ~((uint)PermissionMask.Modify >> 13); | 913 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
914 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
915 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
916 | } | ||
917 | else | ||
918 | { | ||
919 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
920 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
921 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
922 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
923 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
924 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
925 | } | ||
926 | |||
927 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
928 | mask &= ~(uint)PermissionMask.Copy; | ||
929 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
930 | mask &= ~(uint)PermissionMask.Transfer; | ||
931 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
932 | mask &= ~(uint)PermissionMask.Modify; | ||
863 | } | 933 | } |
864 | |||
865 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
866 | mask &= ~(uint)PermissionMask.Copy; | ||
867 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
868 | mask &= ~(uint)PermissionMask.Transfer; | ||
869 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
870 | mask &= ~(uint)PermissionMask.Modify; | ||
871 | } | 934 | } |
935 | |||
872 | return mask; | 936 | return mask; |
873 | } | 937 | } |
874 | 938 | ||
875 | public void ApplyNextOwnerPermissions() | 939 | public void ApplyNextOwnerPermissions() |
876 | { | 940 | { |
877 | foreach (TaskInventoryItem item in m_items.Values) | 941 | lock (m_items) |
878 | { | 942 | { |
879 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 943 | foreach (TaskInventoryItem item in m_items.Values) |
880 | { | 944 | { |
881 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 945 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
882 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 946 | { |
883 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 947 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
884 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | 948 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
885 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | 949 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
886 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | 950 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; |
887 | item.CurrentPermissions |= 8; | 951 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
952 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
953 | item.CurrentPermissions |= 8; | ||
954 | } | ||
955 | item.CurrentPermissions &= item.NextPermissions; | ||
956 | item.BasePermissions &= item.NextPermissions; | ||
957 | item.EveryonePermissions &= item.NextPermissions; | ||
888 | } | 958 | } |
889 | item.CurrentPermissions &= item.NextPermissions; | ||
890 | item.BasePermissions &= item.NextPermissions; | ||
891 | item.EveryonePermissions &= item.NextPermissions; | ||
892 | } | 959 | } |
893 | 960 | ||
894 | m_part.TriggerScriptChangedEvent(Changed.OWNER); | 961 | m_part.TriggerScriptChangedEvent(Changed.OWNER); |
@@ -896,22 +963,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | 963 | ||
897 | public void ApplyGodPermissions(uint perms) | 964 | public void ApplyGodPermissions(uint perms) |
898 | { | 965 | { |
899 | foreach (TaskInventoryItem item in m_items.Values) | 966 | lock (m_items) |
900 | { | 967 | { |
901 | item.CurrentPermissions = perms; | 968 | foreach (TaskInventoryItem item in m_items.Values) |
902 | item.BasePermissions = perms; | 969 | { |
970 | item.CurrentPermissions = perms; | ||
971 | item.BasePermissions = perms; | ||
972 | } | ||
903 | } | 973 | } |
904 | } | 974 | } |
905 | 975 | ||
906 | public bool ContainsScripts() | 976 | public bool ContainsScripts() |
907 | { | 977 | { |
908 | foreach (TaskInventoryItem item in m_items.Values) | 978 | lock (m_items) |
909 | { | 979 | { |
910 | if (item.InvType == (int)InventoryType.LSL) | 980 | foreach (TaskInventoryItem item in m_items.Values) |
911 | { | 981 | { |
912 | return true; | 982 | if (item.InvType == (int)InventoryType.LSL) |
983 | { | ||
984 | return true; | ||
985 | } | ||
913 | } | 986 | } |
914 | } | 987 | } |
988 | |||
915 | return false; | 989 | return false; |
916 | } | 990 | } |
917 | 991 | ||
@@ -919,8 +993,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | { | 993 | { |
920 | List<UUID> ret = new List<UUID>(); | 994 | List<UUID> ret = new List<UUID>(); |
921 | 995 | ||
922 | foreach (TaskInventoryItem item in m_items.Values) | 996 | lock (m_items) |
923 | ret.Add(item.ItemID); | 997 | { |
998 | foreach (TaskInventoryItem item in m_items.Values) | ||
999 | ret.Add(item.ItemID); | ||
1000 | } | ||
924 | 1001 | ||
925 | return ret; | 1002 | return ret; |
926 | } | 1003 | } |
@@ -933,26 +1010,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
933 | if (engines == null) // No engine at all | 1010 | if (engines == null) // No engine at all |
934 | return ret; | 1011 | return ret; |
935 | 1012 | ||
936 | foreach (TaskInventoryItem item in m_items.Values) | 1013 | lock (m_items) |
937 | { | 1014 | { |
938 | if (item.InvType == (int)InventoryType.LSL) | 1015 | foreach (TaskInventoryItem item in m_items.Values) |
939 | { | 1016 | { |
940 | foreach (IScriptModule e in engines) | 1017 | if (item.InvType == (int)InventoryType.LSL) |
941 | { | 1018 | { |
942 | if (e != null) | 1019 | foreach (IScriptModule e in engines) |
943 | { | 1020 | { |
944 | string n = e.GetXMLState(item.ItemID); | 1021 | if (e != null) |
945 | if (n != String.Empty) | ||
946 | { | 1022 | { |
947 | if (!ret.ContainsKey(item.ItemID)) | 1023 | string n = e.GetXMLState(item.ItemID); |
948 | ret[item.ItemID] = n; | 1024 | if (n != String.Empty) |
949 | break; | 1025 | { |
1026 | if (!ret.ContainsKey(item.ItemID)) | ||
1027 | ret[item.ItemID] = n; | ||
1028 | break; | ||
1029 | } | ||
950 | } | 1030 | } |
951 | } | 1031 | } |
952 | } | 1032 | } |
953 | } | 1033 | } |
954 | } | 1034 | } |
1035 | |||
955 | return ret; | 1036 | return ret; |
956 | } | 1037 | } |
957 | } | 1038 | } |
958 | } | 1039 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index afb5b9a..29f607b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -104,6 +104,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | } | 104 | } |
105 | protected ScenePresenceAnimator m_animator; | 105 | protected ScenePresenceAnimator m_animator; |
106 | 106 | ||
107 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | ||
108 | |||
107 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); | 109 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); |
108 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 110 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
109 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 111 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
@@ -217,7 +219,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
217 | 219 | ||
218 | protected AvatarAppearance m_appearance; | 220 | protected AvatarAppearance m_appearance; |
219 | 221 | ||
220 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | ||
221 | public List<SceneObjectGroup> Attachments | 222 | public List<SceneObjectGroup> Attachments |
222 | { | 223 | { |
223 | get { return m_attachments; } | 224 | get { return m_attachments; } |
@@ -636,12 +637,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
636 | #endregion | 637 | #endregion |
637 | 638 | ||
638 | #region Constructor(s) | 639 | #region Constructor(s) |
639 | 640 | ||
640 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) | 641 | public ScenePresence() |
641 | { | 642 | { |
642 | m_animator = new ScenePresenceAnimator(this); | ||
643 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 643 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
644 | CreateSceneViewer(); | 644 | CreateSceneViewer(); |
645 | m_animator = new ScenePresenceAnimator(this); | ||
646 | } | ||
647 | |||
648 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | ||
649 | { | ||
645 | m_rootRegionHandle = reginfo.RegionHandle; | 650 | m_rootRegionHandle = reginfo.RegionHandle; |
646 | m_controllingClient = client; | 651 | m_controllingClient = client; |
647 | m_firstname = m_controllingClient.FirstName; | 652 | m_firstname = m_controllingClient.FirstName; |
@@ -665,7 +670,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
665 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); | 670 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); |
666 | m_reprioritization_timer.AutoReset = false; | 671 | m_reprioritization_timer.AutoReset = false; |
667 | 672 | ||
668 | |||
669 | AdjustKnownSeeds(); | 673 | AdjustKnownSeeds(); |
670 | 674 | ||
671 | // TODO: I think, this won't send anything, as we are still a child here... | 675 | // TODO: I think, this won't send anything, as we are still a child here... |
@@ -1294,6 +1298,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1294 | 1298 | ||
1295 | if (m_allowMovement) | 1299 | if (m_allowMovement) |
1296 | { | 1300 | { |
1301 | if (agentData.UseClientAgentPosition) | ||
1302 | { | ||
1303 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; | ||
1304 | m_moveToPositionTarget = agentData.ClientAgentPosition; | ||
1305 | } | ||
1306 | |||
1297 | int i = 0; | 1307 | int i = 0; |
1298 | 1308 | ||
1299 | bool update_rotation = false; | 1309 | bool update_rotation = false; |
@@ -1400,7 +1410,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1400 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1410 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1401 | { | 1411 | { |
1402 | //Check the error term of the current position in relation to the target position | 1412 | //Check the error term of the current position in relation to the target position |
1403 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5f) | 1413 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) |
1404 | { | 1414 | { |
1405 | // we are close enough to the target | 1415 | // we are close enough to the target |
1406 | m_moveToPositionTarget = Vector3.Zero; | 1416 | m_moveToPositionTarget = Vector3.Zero; |
@@ -2795,7 +2805,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2795 | protected void CrossToNewRegion() | 2805 | protected void CrossToNewRegion() |
2796 | { | 2806 | { |
2797 | InTransit(); | 2807 | InTransit(); |
2798 | m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); | 2808 | try |
2809 | { | ||
2810 | m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); | ||
2811 | } | ||
2812 | catch | ||
2813 | { | ||
2814 | m_scene.CrossAgentToNewRegion(this, false); | ||
2815 | } | ||
2799 | } | 2816 | } |
2800 | 2817 | ||
2801 | public void InTransit() | 2818 | public void InTransit() |
@@ -2873,7 +2890,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2873 | { | 2890 | { |
2874 | RemoveNeighbourRegion(handle); | 2891 | RemoveNeighbourRegion(handle); |
2875 | } | 2892 | } |
2876 | |||
2877 | } | 2893 | } |
2878 | 2894 | ||
2879 | #endregion | 2895 | #endregion |
@@ -3037,7 +3053,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3037 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 3053 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3038 | if (attPoints != null) | 3054 | if (attPoints != null) |
3039 | { | 3055 | { |
3040 | m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); | 3056 | //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); |
3041 | int i = 0; | 3057 | int i = 0; |
3042 | AttachmentData[] attachs = new AttachmentData[attPoints.Count]; | 3058 | AttachmentData[] attachs = new AttachmentData[attPoints.Count]; |
3043 | foreach (int point in attPoints) | 3059 | foreach (int point in attPoints) |
@@ -3261,17 +3277,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3261 | uint killerObj = 0; | 3277 | uint killerObj = 0; |
3262 | foreach (uint localid in coldata.Keys) | 3278 | foreach (uint localid in coldata.Keys) |
3263 | { | 3279 | { |
3264 | if (coldata[localid].PenetrationDepth <= 0.10f || m_invulnerable) | 3280 | SceneObjectPart part = Scene.GetSceneObjectPart(localid); |
3265 | continue; | ||
3266 | //if (localid == 0) | ||
3267 | //continue; | ||
3268 | |||
3269 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
3270 | 3281 | ||
3271 | if (part != null && part.ParentGroup.Damage != -1.0f) | 3282 | if (part != null && part.ParentGroup.Damage != -1.0f) |
3272 | Health -= part.ParentGroup.Damage; | 3283 | Health -= part.ParentGroup.Damage; |
3273 | else | 3284 | else |
3274 | Health -= coldata[localid].PenetrationDepth * 5.0f; | 3285 | { |
3286 | if (coldata[localid].PenetrationDepth >= 0.10f) | ||
3287 | Health -= coldata[localid].PenetrationDepth * 5.0f; | ||
3288 | } | ||
3275 | 3289 | ||
3276 | if (Health <= 0.0f) | 3290 | if (Health <= 0.0f) |
3277 | { | 3291 | { |
@@ -3289,9 +3303,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | } | 3303 | } |
3290 | if (m_health <= 0) | 3304 | if (m_health <= 0) |
3291 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3305 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3292 | } | 3306 | } |
3293 | |||
3294 | |||
3295 | } | 3307 | } |
3296 | 3308 | ||
3297 | public void setHealthWithUpdate(float health) | 3309 | public void setHealthWithUpdate(float health) |
@@ -3338,13 +3350,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3338 | m_animator = null; | 3350 | m_animator = null; |
3339 | } | 3351 | } |
3340 | 3352 | ||
3341 | public ScenePresence() | ||
3342 | { | ||
3343 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | ||
3344 | CreateSceneViewer(); | ||
3345 | m_animator = new ScenePresenceAnimator(this); | ||
3346 | } | ||
3347 | |||
3348 | public void AddAttachment(SceneObjectGroup gobj) | 3353 | public void AddAttachment(SceneObjectGroup gobj) |
3349 | { | 3354 | { |
3350 | lock (m_attachments) | 3355 | lock (m_attachments) |
@@ -3843,4 +3848,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3843 | } | 3848 | } |
3844 | } | 3849 | } |
3845 | } | 3850 | } |
3846 | } \ No newline at end of file | 3851 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index b4866b2..2ddc31b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -116,7 +116,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
116 | 116 | ||
117 | static string ConvertMRMKeywords(string script) | 117 | static string ConvertMRMKeywords(string script) |
118 | { | 118 | { |
119 | script = script.Replace("microthreaded void ", "IEnumerable"); | 119 | script = script.Replace("microthreaded void", "IEnumerable"); |
120 | script = script.Replace("relax;", "yield return null;"); | 120 | script = script.Replace("relax;", "yield return null;"); |
121 | 121 | ||
122 | return script; | 122 | return script; |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 973aa84..44b2727 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -1575,6 +1575,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
1575 | { | 1575 | { |
1576 | //Console.WriteLine("Move " + m_primName); | 1576 | //Console.WriteLine("Move " + m_primName); |
1577 | if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 | 1577 | if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 |
1578 | /* | ||
1578 | // NON-'VEHICLES' are dealt with here | 1579 | // NON-'VEHICLES' are dealt with here |
1579 | if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f)) | 1580 | if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f)) |
1580 | { | 1581 | { |
@@ -1587,6 +1588,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
1587 | avel2.Z = 0; | 1588 | avel2.Z = 0; |
1588 | d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z); | 1589 | d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z); |
1589 | } | 1590 | } |
1591 | */ | ||
1590 | //float PID_P = 900.0f; | 1592 | //float PID_P = 900.0f; |
1591 | 1593 | ||
1592 | float m_mass = CalculateMass(); | 1594 | float m_mass = CalculateMass(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ee2a94c..e77425a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -55,7 +55,7 @@ using OpenSim.Services.Interfaces; | |||
55 | using OpenSim.Services.Interfaces; | 55 | using OpenSim.Services.Interfaces; |
56 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 56 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
57 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 57 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
58 | 58 | using PrimType = OpenSim.Region.Framework.Scenes.PrimType; | |
59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; | 59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; |
60 | 60 | ||
61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
@@ -1331,44 +1331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1331 | { | 1331 | { |
1332 | m_host.AddScriptLPS(1); | 1332 | m_host.AddScriptLPS(1); |
1333 | 1333 | ||
1334 | SetColor(m_host, color, face); | 1334 | if (face == ScriptBaseClass.ALL_SIDES) |
1335 | } | 1335 | face = SceneObjectPart.ALL_SIDES; |
1336 | 1336 | ||
1337 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | 1337 | m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); |
1338 | { | ||
1339 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1340 | Color4 texcolor; | ||
1341 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1342 | { | ||
1343 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1344 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1345 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1346 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1347 | tex.FaceTextures[face].RGBA = texcolor; | ||
1348 | part.UpdateTexture(tex); | ||
1349 | return; | ||
1350 | } | ||
1351 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1352 | { | ||
1353 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1354 | { | ||
1355 | if (tex.FaceTextures[i] != null) | ||
1356 | { | ||
1357 | texcolor = tex.FaceTextures[i].RGBA; | ||
1358 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1359 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1360 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1361 | tex.FaceTextures[i].RGBA = texcolor; | ||
1362 | } | ||
1363 | texcolor = tex.DefaultTexture.RGBA; | ||
1364 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1365 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1366 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1367 | tex.DefaultTexture.RGBA = texcolor; | ||
1368 | } | ||
1369 | part.UpdateTexture(tex); | ||
1370 | return; | ||
1371 | } | ||
1372 | } | 1338 | } |
1373 | 1339 | ||
1374 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1340 | public void SetTexGen(SceneObjectPart part, int face,int style) |
@@ -1515,7 +1481,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1515 | { | 1481 | { |
1516 | int i; | 1482 | int i; |
1517 | double sum = 0.0; | 1483 | double sum = 0.0; |
1518 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) | 1484 | for (i = 0 ; i < GetNumberOfSides(part); i++) |
1519 | sum += (double)tex.GetFace((uint)i).RGBA.A; | 1485 | sum += (double)tex.GetFace((uint)i).RGBA.A; |
1520 | return sum; | 1486 | return sum; |
1521 | } | 1487 | } |
@@ -1662,7 +1628,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1662 | { | 1628 | { |
1663 | int i; | 1629 | int i; |
1664 | 1630 | ||
1665 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) | 1631 | for (i = 0 ; i < GetNumberOfSides(part); i++) |
1666 | { | 1632 | { |
1667 | texcolor = tex.GetFace((uint)i).RGBA; | 1633 | texcolor = tex.GetFace((uint)i).RGBA; |
1668 | rgb.x += texcolor.R; | 1634 | rgb.x += texcolor.R; |
@@ -3415,7 +3381,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3415 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3381 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3416 | 3382 | ||
3417 | foreach (SceneObjectPart part in parts) | 3383 | foreach (SceneObjectPart part in parts) |
3418 | SetColor(part, color, face); | 3384 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); |
3419 | } | 3385 | } |
3420 | 3386 | ||
3421 | public void llCreateLink(string target, int parent) | 3387 | public void llCreateLink(string target, int parent) |
@@ -4262,7 +4228,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4262 | { | 4228 | { |
4263 | if (item.Type == 10 && item.ItemID == m_itemID) | 4229 | if (item.Type == 10 && item.ItemID == m_itemID) |
4264 | { | 4230 | { |
4265 | result = item.Name!=null?item.Name:String.Empty; | 4231 | result = item.Name != null ? item.Name : String.Empty; |
4266 | break; | 4232 | break; |
4267 | } | 4233 | } |
4268 | } | 4234 | } |
@@ -4271,63 +4237,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4271 | return result; | 4237 | return result; |
4272 | } | 4238 | } |
4273 | 4239 | ||
4274 | // this function to understand which shape it is (taken from meshmerizer) | ||
4275 | // quite useful can be used by meshmerizer to have a centralized point of understanding the shape | ||
4276 | // except that it refers to scripting constants | ||
4277 | public int getScriptPrimType(PrimitiveBaseShape primShape) | ||
4278 | { | ||
4279 | if (primShape.SculptEntry) | ||
4280 | return ScriptBaseClass.PRIM_TYPE_SCULPT; | ||
4281 | if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
4282 | { | ||
4283 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4284 | return ScriptBaseClass.PRIM_TYPE_BOX; | ||
4285 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4286 | return ScriptBaseClass.PRIM_TYPE_TUBE; | ||
4287 | } | ||
4288 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
4289 | { | ||
4290 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4291 | return ScriptBaseClass.PRIM_TYPE_CYLINDER; | ||
4292 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
4293 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4294 | return ScriptBaseClass.PRIM_TYPE_TORUS; | ||
4295 | } | ||
4296 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
4297 | { | ||
4298 | if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2) | ||
4299 | return ScriptBaseClass.PRIM_TYPE_SPHERE; | ||
4300 | } | ||
4301 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
4302 | { | ||
4303 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4304 | return ScriptBaseClass.PRIM_TYPE_PRISM; | ||
4305 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4306 | return ScriptBaseClass.PRIM_TYPE_RING; | ||
4307 | } | ||
4308 | return ScriptBaseClass.PRIM_TYPE_BOX; | ||
4309 | } | ||
4310 | |||
4311 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | ||
4312 | protected void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | ||
4313 | out bool hasDimple, out bool hasProfileCut) | ||
4314 | { | ||
4315 | if (primType == ScriptBaseClass.PRIM_TYPE_BOX | ||
4316 | || | ||
4317 | primType == ScriptBaseClass.PRIM_TYPE_CYLINDER | ||
4318 | || | ||
4319 | primType == ScriptBaseClass.PRIM_TYPE_PRISM) | ||
4320 | |||
4321 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
4322 | else | ||
4323 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
4324 | |||
4325 | hasHollow = shape.ProfileHollow > 0; | ||
4326 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | ||
4327 | hasProfileCut = hasDimple; // is it the same thing? | ||
4328 | |||
4329 | } | ||
4330 | |||
4331 | public LSL_Integer llGetNumberOfSides() | 4240 | public LSL_Integer llGetNumberOfSides() |
4332 | { | 4241 | { |
4333 | m_host.AddScriptLPS(1); | 4242 | m_host.AddScriptLPS(1); |
@@ -4337,63 +4246,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4337 | 4246 | ||
4338 | protected int GetNumberOfSides(SceneObjectPart part) | 4247 | protected int GetNumberOfSides(SceneObjectPart part) |
4339 | { | 4248 | { |
4340 | int ret = 0; | 4249 | int sides = part.GetNumberOfSides(); |
4341 | bool hasCut; | ||
4342 | bool hasHollow; | ||
4343 | bool hasDimple; | ||
4344 | bool hasProfileCut; | ||
4345 | |||
4346 | int primType = getScriptPrimType(part.Shape); | ||
4347 | hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
4348 | 4250 | ||
4349 | switch (primType) | 4251 | if (part.GetPrimType() == PrimType.SPHERE && part.Shape.ProfileHollow > 0) |
4350 | { | 4252 | { |
4351 | case ScriptBaseClass.PRIM_TYPE_BOX: | 4253 | // Make up for a bug where LSL shows 4 sides rather than 2 |
4352 | ret = 6; | 4254 | sides += 2; |
4353 | if (hasCut) ret += 2; | ||
4354 | if (hasHollow) ret += 1; | ||
4355 | break; | ||
4356 | case ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
4357 | ret = 3; | ||
4358 | if (hasCut) ret += 2; | ||
4359 | if (hasHollow) ret += 1; | ||
4360 | break; | ||
4361 | case ScriptBaseClass.PRIM_TYPE_PRISM: | ||
4362 | ret = 5; | ||
4363 | if (hasCut) ret += 2; | ||
4364 | if (hasHollow) ret += 1; | ||
4365 | break; | ||
4366 | case ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
4367 | ret = 1; | ||
4368 | if (hasCut) ret += 2; | ||
4369 | if (hasDimple) ret += 2; | ||
4370 | if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1) | ||
4371 | break; | ||
4372 | case ScriptBaseClass.PRIM_TYPE_TORUS: | ||
4373 | ret = 1; | ||
4374 | if (hasCut) ret += 2; | ||
4375 | if (hasProfileCut) ret += 2; | ||
4376 | if (hasHollow) ret += 1; | ||
4377 | break; | ||
4378 | case ScriptBaseClass.PRIM_TYPE_TUBE: | ||
4379 | ret = 4; | ||
4380 | if (hasCut) ret += 2; | ||
4381 | if (hasProfileCut) ret += 2; | ||
4382 | if (hasHollow) ret += 1; | ||
4383 | break; | ||
4384 | case ScriptBaseClass.PRIM_TYPE_RING: | ||
4385 | ret = 3; | ||
4386 | if (hasCut) ret += 2; | ||
4387 | if (hasProfileCut) ret += 2; | ||
4388 | if (hasHollow) ret += 1; | ||
4389 | break; | ||
4390 | case ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
4391 | ret = 1; | ||
4392 | break; | ||
4393 | } | 4255 | } |
4394 | return ret; | ||
4395 | } | ||
4396 | 4256 | ||
4257 | return sides; | ||
4258 | } | ||
4259 | |||
4397 | 4260 | ||
4398 | /* The new / changed functions were tested with the following LSL script: | 4261 | /* The new / changed functions were tested with the following LSL script: |
4399 | 4262 | ||
@@ -4418,8 +4281,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4418 | } | 4281 | } |
4419 | */ | 4282 | */ |
4420 | 4283 | ||
4421 | |||
4422 | |||
4423 | // Xantor 29/apr/2008 | 4284 | // Xantor 29/apr/2008 |
4424 | // Returns rotation described by rotating angle radians about axis. | 4285 | // Returns rotation described by rotating angle radians about axis. |
4425 | // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) | 4286 | // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) |
@@ -7020,10 +6881,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7020 | LSL_Vector color=rules.GetVector3Item(idx++); | 6881 | LSL_Vector color=rules.GetVector3Item(idx++); |
7021 | double alpha=(double)rules.GetLSLFloatItem(idx++); | 6882 | double alpha=(double)rules.GetLSLFloatItem(idx++); |
7022 | 6883 | ||
7023 | SetColor(part, color, face); | 6884 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); |
7024 | SetAlpha(part, alpha, face); | 6885 | SetAlpha(part, alpha, face); |
7025 | 6886 | ||
7026 | break; | 6887 | break; |
6888 | |||
7027 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 6889 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
7028 | if (remain < 7) | 6890 | if (remain < 7) |
7029 | return; | 6891 | return; |
@@ -7039,6 +6901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7039 | SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); | 6901 | SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); |
7040 | 6902 | ||
7041 | break; | 6903 | break; |
6904 | |||
7042 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 6905 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
7043 | if (remain < 5) | 6906 | if (remain < 5) |
7044 | return; | 6907 | return; |
@@ -7051,6 +6914,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7051 | SetPointLight(part, light, lightcolor, intensity, radius, falloff); | 6914 | SetPointLight(part, light, lightcolor, intensity, radius, falloff); |
7052 | 6915 | ||
7053 | break; | 6916 | break; |
6917 | |||
7054 | case (int)ScriptBaseClass.PRIM_GLOW: | 6918 | case (int)ScriptBaseClass.PRIM_GLOW: |
7055 | if (remain < 2) | 6919 | if (remain < 2) |
7056 | return; | 6920 | return; |
@@ -7060,6 +6924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7060 | SetGlow(part, face, glow); | 6924 | SetGlow(part, face, glow); |
7061 | 6925 | ||
7062 | break; | 6926 | break; |
6927 | |||
7063 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 6928 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7064 | if (remain < 3) | 6929 | if (remain < 3) |
7065 | return; | 6930 | return; |
@@ -7070,6 +6935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7070 | SetShiny(part, face, shiny, bump); | 6935 | SetShiny(part, face, shiny, bump); |
7071 | 6936 | ||
7072 | break; | 6937 | break; |
6938 | |||
7073 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 6939 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7074 | if (remain < 2) | 6940 | if (remain < 2) |
7075 | return; | 6941 | return; |
@@ -7077,6 +6943,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7077 | bool st = rules.GetLSLIntegerItem(idx++); | 6943 | bool st = rules.GetLSLIntegerItem(idx++); |
7078 | SetFullBright(part, face , st); | 6944 | SetFullBright(part, face , st); |
7079 | break; | 6945 | break; |
6946 | |||
7080 | case (int)ScriptBaseClass.PRIM_MATERIAL: | 6947 | case (int)ScriptBaseClass.PRIM_MATERIAL: |
7081 | if (remain < 1) | 6948 | if (remain < 1) |
7082 | return; | 6949 | return; |
@@ -7086,6 +6953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7086 | 6953 | ||
7087 | part.Material = Convert.ToByte(mat); | 6954 | part.Material = Convert.ToByte(mat); |
7088 | break; | 6955 | break; |
6956 | |||
7089 | case (int)ScriptBaseClass.PRIM_PHANTOM: | 6957 | case (int)ScriptBaseClass.PRIM_PHANTOM: |
7090 | if (remain < 1) | 6958 | if (remain < 1) |
7091 | return; | 6959 | return; |
@@ -7100,6 +6968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7100 | 6968 | ||
7101 | part.ScriptSetPhantomStatus(phantom); | 6969 | part.ScriptSetPhantomStatus(phantom); |
7102 | break; | 6970 | break; |
6971 | |||
7103 | case (int)ScriptBaseClass.PRIM_PHYSICS: | 6972 | case (int)ScriptBaseClass.PRIM_PHYSICS: |
7104 | if (remain < 1) | 6973 | if (remain < 1) |
7105 | return; | 6974 | return; |
@@ -7113,6 +6982,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7113 | 6982 | ||
7114 | part.ScriptSetPhysicsStatus(physics); | 6983 | part.ScriptSetPhysicsStatus(physics); |
7115 | break; | 6984 | break; |
6985 | |||
7116 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 6986 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: |
7117 | if (remain < 1) | 6987 | if (remain < 1) |
7118 | return; | 6988 | return; |
@@ -7380,7 +7250,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7380 | 7250 | ||
7381 | public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) | 7251 | public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) |
7382 | { | 7252 | { |
7383 | |||
7384 | LSL_List res = new LSL_List(); | 7253 | LSL_List res = new LSL_List(); |
7385 | int idx=0; | 7254 | int idx=0; |
7386 | while (idx < rules.Length) | 7255 | while (idx < rules.Length) |
@@ -7442,7 +7311,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7442 | case (int)ScriptBaseClass.PRIM_TYPE: | 7311 | case (int)ScriptBaseClass.PRIM_TYPE: |
7443 | // implementing box | 7312 | // implementing box |
7444 | PrimitiveBaseShape Shape = part.Shape; | 7313 | PrimitiveBaseShape Shape = part.Shape; |
7445 | int primType = getScriptPrimType(part.Shape); | 7314 | int primType = (int)part.GetPrimType(); |
7446 | res.Add(new LSL_Integer(primType)); | 7315 | res.Add(new LSL_Integer(primType)); |
7447 | double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX | 7316 | double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX |
7448 | double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. | 7317 | double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. |
@@ -7522,7 +7391,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7522 | Primitive.TextureEntry tex = part.Shape.Textures; | 7391 | Primitive.TextureEntry tex = part.Shape.Textures; |
7523 | if (face == ScriptBaseClass.ALL_SIDES) | 7392 | if (face == ScriptBaseClass.ALL_SIDES) |
7524 | { | 7393 | { |
7525 | for (face = 0 ; face < GetNumberOfSides(part) ; face++) | 7394 | for (face = 0 ; face < GetNumberOfSides(part); face++) |
7526 | { | 7395 | { |
7527 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 7396 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); |
7528 | 7397 | ||
@@ -7564,7 +7433,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7564 | Color4 texcolor; | 7433 | Color4 texcolor; |
7565 | if (face == ScriptBaseClass.ALL_SIDES) | 7434 | if (face == ScriptBaseClass.ALL_SIDES) |
7566 | { | 7435 | { |
7567 | for (face = 0 ; face < GetNumberOfSides(part) ; face++) | 7436 | for (face = 0 ; face < GetNumberOfSides(part); face++) |
7568 | { | 7437 | { |
7569 | texcolor = tex.GetFace((uint)face).RGBA; | 7438 | texcolor = tex.GetFace((uint)face).RGBA; |
7570 | res.Add(new LSL_Vector(texcolor.R, | 7439 | res.Add(new LSL_Vector(texcolor.R, |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 16309ef..09b79d0 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -55,6 +55,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
55 | m_log.Info("[XEngine] Hooking up to server events"); | 55 | m_log.Info("[XEngine] Hooking up to server events"); |
56 | myScriptEngine.World.EventManager.OnAttach += attach; | 56 | myScriptEngine.World.EventManager.OnAttach += attach; |
57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; | 57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; |
58 | myScriptEngine.World.EventManager.OnObjectGrabbing += touch; | ||
58 | myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; | 59 | myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; |
59 | myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; | 60 | myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; |
60 | myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; | 61 | myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; |
@@ -148,7 +149,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
148 | } | 149 | } |
149 | 150 | ||
150 | public void touch(uint localID, uint originalID, Vector3 offsetPos, | 151 | public void touch(uint localID, uint originalID, Vector3 offsetPos, |
151 | IClientAPI remoteClient) | 152 | IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
152 | { | 153 | { |
153 | // Add to queue for all scripts in ObjectID object | 154 | // Add to queue for all scripts in ObjectID object |
154 | DetectParams[] det = new DetectParams[1]; | 155 | DetectParams[] det = new DetectParams[1]; |
@@ -172,6 +173,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
172 | SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); | 173 | SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); |
173 | det[0].LinkNum = originalPart.LinkNum; | 174 | det[0].LinkNum = originalPart.LinkNum; |
174 | } | 175 | } |
176 | if (surfaceArgs != null) | ||
177 | { | ||
178 | det[0].SurfaceTouchArgs = surfaceArgs; | ||
179 | } | ||
175 | 180 | ||
176 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 181 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
177 | "touch", new Object[] { new LSL_Types.LSLInteger(1) }, | 182 | "touch", new Object[] { new LSL_Types.LSLInteger(1) }, |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 6dd94bb..c552b92 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -806,12 +806,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
806 | instance.ClearQueue(); | 806 | instance.ClearQueue(); |
807 | instance.Stop(0); | 807 | instance.Stop(0); |
808 | 808 | ||
809 | SceneObjectPart part = | ||
810 | m_Scene.GetSceneObjectPart(localID); | ||
811 | |||
812 | if (part != null) | ||
813 | part.RemoveScriptEvents(itemID); | ||
814 | |||
815 | // bool objectRemoved = false; | 809 | // bool objectRemoved = false; |
816 | 810 | ||
817 | lock (m_PrimObjects) | 811 | lock (m_PrimObjects) |
@@ -846,7 +840,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
846 | 840 | ||
847 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 841 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
848 | if (handlerObjectRemoved != null) | 842 | if (handlerObjectRemoved != null) |
843 | { | ||
844 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
849 | handlerObjectRemoved(part.UUID); | 845 | handlerObjectRemoved(part.UUID); |
846 | } | ||
850 | 847 | ||
851 | CleanAssemblies(); | 848 | CleanAssemblies(); |
852 | } | 849 | } |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 3f33da6..f33bb90 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
63 | 63 | ||
64 | if (p.Length > 0) | 64 | if (p.Length > 0) |
65 | { | 65 | { |
66 | result = m_AssetService.Delete(p[0]); | 66 | // result = m_AssetService.Delete(p[0]); |
67 | } | 67 | } |
68 | 68 | ||
69 | XmlSerializer xs = new XmlSerializer(typeof(bool)); | 69 | XmlSerializer xs = new XmlSerializer(typeof(bool)); |
diff --git a/OpenSim/Tools/Configger/ConfigurationLoader.cs b/OpenSim/Tools/Configger/ConfigurationLoader.cs new file mode 100644 index 0000000..49af417 --- /dev/null +++ b/OpenSim/Tools/Configger/ConfigurationLoader.cs | |||
@@ -0,0 +1,251 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Reflection; | ||
5 | using System.Threading; | ||
6 | using System.Xml; | ||
7 | using log4net; | ||
8 | using Nini.Config; | ||
9 | |||
10 | namespace Careminster | ||
11 | { | ||
12 | /// <summary> | ||
13 | /// Loads the Configuration files into nIni | ||
14 | /// </summary> | ||
15 | public class ConfigurationLoader | ||
16 | { | ||
17 | /// <summary> | ||
18 | /// A source of Configuration data | ||
19 | /// </summary> | ||
20 | protected IConfigSource m_config; | ||
21 | |||
22 | /// <summary> | ||
23 | /// Console logger | ||
24 | /// </summary> | ||
25 | private static readonly ILog m_log = | ||
26 | LogManager.GetLogger( | ||
27 | MethodBase.GetCurrentMethod().DeclaringType); | ||
28 | |||
29 | public ConfigurationLoader() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | /// <summary> | ||
34 | /// Loads the region configuration | ||
35 | /// </summary> | ||
36 | /// <param name="argvSource">Parameters passed into the process when started</param> | ||
37 | /// <param name="configSettings"></param> | ||
38 | /// <param name="networkInfo"></param> | ||
39 | /// <returns>A configuration that gets passed to modules</returns> | ||
40 | public IConfigSource LoadConfigSettings() | ||
41 | { | ||
42 | bool iniFileExists = false; | ||
43 | |||
44 | List<string> sources = new List<string>(); | ||
45 | |||
46 | string iniFileName = "OpenSim.ini"; | ||
47 | string iniFilePath = Path.Combine(".", iniFileName); | ||
48 | |||
49 | if (IsUri(iniFileName)) | ||
50 | { | ||
51 | if (!sources.Contains(iniFileName)) | ||
52 | sources.Add(iniFileName); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | if (File.Exists(iniFilePath)) | ||
57 | { | ||
58 | if (!sources.Contains(iniFilePath)) | ||
59 | sources.Add(iniFilePath); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | m_config = new IniConfigSource(); | ||
64 | m_config.Merge(DefaultConfig()); | ||
65 | |||
66 | m_log.Info("[CONFIG] Reading configuration settings"); | ||
67 | |||
68 | if (sources.Count == 0) | ||
69 | { | ||
70 | m_log.FatalFormat("[CONFIG] Could not load any configuration"); | ||
71 | m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?"); | ||
72 | Environment.Exit(1); | ||
73 | } | ||
74 | |||
75 | for (int i = 0 ; i < sources.Count ; i++) | ||
76 | { | ||
77 | if (ReadConfig(sources[i])) | ||
78 | iniFileExists = true; | ||
79 | AddIncludes(sources); | ||
80 | } | ||
81 | |||
82 | if (!iniFileExists) | ||
83 | { | ||
84 | m_log.FatalFormat("[CONFIG] Could not load any configuration"); | ||
85 | m_log.FatalFormat("[CONFIG] Configuration exists, but there was an error loading it!"); | ||
86 | Environment.Exit(1); | ||
87 | } | ||
88 | |||
89 | return m_config; | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Adds the included files as ini configuration files | ||
94 | /// </summary> | ||
95 | /// <param name="sources">List of URL strings or filename strings</param> | ||
96 | private void AddIncludes(List<string> sources) | ||
97 | { | ||
98 | //loop over config sources | ||
99 | foreach (IConfig config in m_config.Configs) | ||
100 | { | ||
101 | // Look for Include-* in the key name | ||
102 | string[] keys = config.GetKeys(); | ||
103 | foreach (string k in keys) | ||
104 | { | ||
105 | if (k.StartsWith("Include-")) | ||
106 | { | ||
107 | // read the config file to be included. | ||
108 | string file = config.GetString(k); | ||
109 | if (IsUri(file)) | ||
110 | { | ||
111 | if (!sources.Contains(file)) | ||
112 | sources.Add(file); | ||
113 | } | ||
114 | else | ||
115 | { | ||
116 | string basepath = Path.GetFullPath("."); | ||
117 | string path = Path.Combine(basepath, file); | ||
118 | string[] paths = Util.Glob(path); | ||
119 | foreach (string p in paths) | ||
120 | { | ||
121 | if (!sources.Contains(p)) | ||
122 | sources.Add(p); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | /// <summary> | ||
130 | /// Check if we can convert the string to a URI | ||
131 | /// </summary> | ||
132 | /// <param name="file">String uri to the remote resource</param> | ||
133 | /// <returns>true if we can convert the string to a Uri object</returns> | ||
134 | bool IsUri(string file) | ||
135 | { | ||
136 | Uri configUri; | ||
137 | |||
138 | return Uri.TryCreate(file, UriKind.Absolute, | ||
139 | out configUri) && configUri.Scheme == Uri.UriSchemeHttp; | ||
140 | } | ||
141 | |||
142 | /// <summary> | ||
143 | /// Provide same ini loader functionality for standard ini and master ini - file system or XML over http | ||
144 | /// </summary> | ||
145 | /// <param name="iniPath">Full path to the ini</param> | ||
146 | /// <returns></returns> | ||
147 | private bool ReadConfig(string iniPath) | ||
148 | { | ||
149 | bool success = false; | ||
150 | |||
151 | if (!IsUri(iniPath)) | ||
152 | { | ||
153 | m_log.InfoFormat("[CONFIG] Reading configuration file {0}", | ||
154 | Path.GetFullPath(iniPath)); | ||
155 | |||
156 | m_config.Merge(new IniConfigSource(iniPath)); | ||
157 | success = true; | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", | ||
162 | iniPath); | ||
163 | |||
164 | // The ini file path is a http URI | ||
165 | // Try to read it | ||
166 | // | ||
167 | try | ||
168 | { | ||
169 | XmlReader r = XmlReader.Create(iniPath); | ||
170 | XmlConfigSource cs = new XmlConfigSource(r); | ||
171 | m_config.Merge(cs); | ||
172 | |||
173 | success = true; | ||
174 | } | ||
175 | catch (Exception e) | ||
176 | { | ||
177 | m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath); | ||
178 | Environment.Exit(1); | ||
179 | } | ||
180 | } | ||
181 | return success; | ||
182 | } | ||
183 | |||
184 | /// <summary> | ||
185 | /// Setup a default config values in case they aren't present in the ini file | ||
186 | /// </summary> | ||
187 | /// <returns>A Configuration source containing the default configuration</returns> | ||
188 | private static IConfigSource DefaultConfig() | ||
189 | { | ||
190 | IConfigSource defaultConfig = new IniConfigSource(); | ||
191 | |||
192 | { | ||
193 | IConfig config = defaultConfig.Configs["Startup"]; | ||
194 | |||
195 | if (null == config) | ||
196 | config = defaultConfig.AddConfig("Startup"); | ||
197 | |||
198 | config.Set("region_info_source", "filesystem"); | ||
199 | |||
200 | config.Set("gridmode", false); | ||
201 | config.Set("physics", "OpenDynamicsEngine"); | ||
202 | config.Set("meshing", "Meshmerizer"); | ||
203 | config.Set("physical_prim", true); | ||
204 | config.Set("see_into_this_sim_from_neighbor", true); | ||
205 | config.Set("serverside_object_permissions", false); | ||
206 | config.Set("storage_plugin", "OpenSim.Data.SQLite.dll"); | ||
207 | config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3"); | ||
208 | config.Set("storage_prim_inventories", true); | ||
209 | config.Set("startup_console_commands_file", String.Empty); | ||
210 | config.Set("shutdown_console_commands_file", String.Empty); | ||
211 | config.Set("DefaultScriptEngine", "XEngine"); | ||
212 | config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); | ||
213 | // life doesn't really work without this | ||
214 | config.Set("EventQueue", true); | ||
215 | } | ||
216 | |||
217 | { | ||
218 | IConfig config = defaultConfig.Configs["StandAlone"]; | ||
219 | |||
220 | if (null == config) | ||
221 | config = defaultConfig.AddConfig("StandAlone"); | ||
222 | |||
223 | config.Set("accounts_authenticate", true); | ||
224 | config.Set("welcome_message", "Welcome to OpenSimulator"); | ||
225 | config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll"); | ||
226 | config.Set("inventory_source", ""); | ||
227 | config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); | ||
228 | config.Set("user_source", ""); | ||
229 | config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar)); | ||
230 | } | ||
231 | |||
232 | { | ||
233 | IConfig config = defaultConfig.Configs["Network"]; | ||
234 | |||
235 | if (null == config) | ||
236 | config = defaultConfig.AddConfig("Network"); | ||
237 | |||
238 | config.Set("default_location_x", 1000); | ||
239 | config.Set("default_location_y", 1000); | ||
240 | config.Set("grid_send_key", "null"); | ||
241 | config.Set("grid_recv_key", "null"); | ||
242 | config.Set("user_send_key", "null"); | ||
243 | config.Set("user_recv_key", "null"); | ||
244 | config.Set("secure_inventory_server", "true"); | ||
245 | } | ||
246 | |||
247 | return defaultConfig; | ||
248 | } | ||
249 | |||
250 | } | ||
251 | } | ||
diff --git a/OpenSim/Tools/Configger/Main.cs b/OpenSim/Tools/Configger/Main.cs new file mode 100644 index 0000000..c85f0d2 --- /dev/null +++ b/OpenSim/Tools/Configger/Main.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | using Nini.Config; | ||
2 | using System; | ||
3 | |||
4 | namespace Careminster | ||
5 | { | ||
6 | public class Configger | ||
7 | { | ||
8 | public static int Main(string[] args) | ||
9 | { | ||
10 | ArgvConfigSource argvConfig = new ArgvConfigSource(args); | ||
11 | argvConfig.AddSwitch("Startup", "format", "f"); | ||
12 | |||
13 | IConfig startupConfig = argvConfig.Configs["Startup"]; | ||
14 | |||
15 | string format = startupConfig.GetString("format", "ini"); | ||
16 | |||
17 | ConfigurationLoader loader = new ConfigurationLoader(); | ||
18 | |||
19 | IConfigSource s = loader.LoadConfigSettings(); | ||
20 | |||
21 | if (format == "mysql") | ||
22 | { | ||
23 | foreach (IConfig c in s.Configs) | ||
24 | { | ||
25 | foreach (string k in c.GetKeys()) | ||
26 | { | ||
27 | string v = c.GetString(k); | ||
28 | |||
29 | if (k.StartsWith("Include-")) | ||
30 | continue; | ||
31 | Console.WriteLine("insert ignore into config (section, name, value) values ('{0}', '{1}', '{2}');", c.Name, k, v); | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | else if (format == "xml") | ||
36 | { | ||
37 | Console.WriteLine("<Nini>"); | ||
38 | |||
39 | foreach (IConfig c in s.Configs) | ||
40 | { | ||
41 | int count = 0; | ||
42 | |||
43 | foreach (string k in c.GetKeys()) | ||
44 | { | ||
45 | if (k.StartsWith("Include-")) | ||
46 | continue; | ||
47 | |||
48 | count++; | ||
49 | } | ||
50 | |||
51 | if (count > 0) | ||
52 | { | ||
53 | Console.WriteLine("<Section Name=\"{0}\">", c.Name); | ||
54 | |||
55 | foreach (string k in c.GetKeys()) | ||
56 | { | ||
57 | string v = c.GetString(k); | ||
58 | |||
59 | if (k.StartsWith("Include-")) | ||
60 | continue; | ||
61 | Console.WriteLine(" <Key Name=\"{0}\" Value=\"{1}\" />", k, v); | ||
62 | |||
63 | Console.WriteLine("</Section>"); | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | Console.WriteLine("</Nini>"); | ||
68 | } | ||
69 | else if (format == "ini") | ||
70 | { | ||
71 | foreach (IConfig c in s.Configs) | ||
72 | { | ||
73 | int count = 0; | ||
74 | |||
75 | foreach (string k in c.GetKeys()) | ||
76 | { | ||
77 | if (k.StartsWith("Include-")) | ||
78 | continue; | ||
79 | |||
80 | count++; | ||
81 | } | ||
82 | |||
83 | if (count > 0) | ||
84 | { | ||
85 | Console.WriteLine("[{0}]", c.Name); | ||
86 | |||
87 | foreach (string k in c.GetKeys()) | ||
88 | { | ||
89 | string v = c.GetString(k); | ||
90 | |||
91 | if (k.StartsWith("Include-")) | ||
92 | continue; | ||
93 | Console.WriteLine("{0} = \"{1}\"", k, v); | ||
94 | } | ||
95 | |||
96 | Console.WriteLine(); | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | else | ||
101 | { | ||
102 | Console.WriteLine("Error: unknown format: {0}", format); | ||
103 | } | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | } | ||
108 | } | ||
diff --git a/OpenSim/Tools/Configger/Util.cs b/OpenSim/Tools/Configger/Util.cs new file mode 100644 index 0000000..6f8aa76 --- /dev/null +++ b/OpenSim/Tools/Configger/Util.cs | |||
@@ -0,0 +1,79 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Globalization; | ||
5 | using System.IO; | ||
6 | using System.IO.Compression; | ||
7 | using System.Net; | ||
8 | using System.Net.Sockets; | ||
9 | using System.Reflection; | ||
10 | using System.Text; | ||
11 | using System.Text.RegularExpressions; | ||
12 | using System.Threading; | ||
13 | using log4net; | ||
14 | using Nini.Config; | ||
15 | |||
16 | namespace Careminster | ||
17 | { | ||
18 | public static class Util | ||
19 | { | ||
20 | public static string[] Glob(string path) | ||
21 | { | ||
22 | string vol=String.Empty; | ||
23 | |||
24 | if (Path.VolumeSeparatorChar != Path.DirectorySeparatorChar) | ||
25 | { | ||
26 | string[] vcomps = path.Split(new char[] {Path.VolumeSeparatorChar}, 2, StringSplitOptions.RemoveEmptyEntries); | ||
27 | |||
28 | if (vcomps.Length > 1) | ||
29 | { | ||
30 | path = vcomps[1]; | ||
31 | vol = vcomps[0]; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries); | ||
36 | |||
37 | // Glob | ||
38 | |||
39 | path = vol; | ||
40 | if (vol != String.Empty) | ||
41 | path += new String(new char[] {Path.VolumeSeparatorChar, Path.DirectorySeparatorChar}); | ||
42 | else | ||
43 | path = new String(new char[] {Path.DirectorySeparatorChar}); | ||
44 | |||
45 | List<string> paths = new List<string>(); | ||
46 | List<string> found = new List<string>(); | ||
47 | paths.Add(path); | ||
48 | |||
49 | int compIndex = -1; | ||
50 | foreach (string c in comps) | ||
51 | { | ||
52 | compIndex++; | ||
53 | |||
54 | List<string> addpaths = new List<string>(); | ||
55 | foreach (string p in paths) | ||
56 | { | ||
57 | string[] dirs = Directory.GetDirectories(p, c); | ||
58 | |||
59 | if (dirs.Length != 0) | ||
60 | { | ||
61 | foreach (string dir in dirs) | ||
62 | addpaths.Add(Path.Combine(path, dir)); | ||
63 | } | ||
64 | |||
65 | // Only add files if that is the last path component | ||
66 | if (compIndex == comps.Length - 1) | ||
67 | { | ||
68 | string[] files = Directory.GetFiles(p, c); | ||
69 | foreach (string f in files) | ||
70 | found.Add(f); | ||
71 | } | ||
72 | } | ||
73 | paths = addpaths; | ||
74 | } | ||
75 | |||
76 | return found.ToArray(); | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example index 543d20d..0535765 100644 --- a/bin/OpenSim.Server.ini.example +++ b/bin/OpenSim.Server.ini.example | |||
@@ -123,3 +123,16 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
123 | 123 | ||
124 | WelcomeMessage = "Welcome, Avatar!" | 124 | WelcomeMessage = "Welcome, Avatar!" |
125 | 125 | ||
126 | ; * This is the new style grid service. | ||
127 | ; * "Realm" is the table that is used for user lookup. | ||
128 | ; * It defaults to "regions", which uses the legacy tables | ||
129 | ; * | ||
130 | [GridService] | ||
131 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | ||
132 | StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" | ||
133 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;" | ||
134 | Realm = "regions" | ||
135 | |||
136 | ; If true, duplicate region names are allowed on the grid. If false, no duplicate names are allowed | ||
137 | ; Default is false | ||
138 | ; AllowDuplicateNames = "True" | ||
diff --git a/bin/OpenSim.exe.config b/bin/OpenSim.exe.config index c2d93c0..3c7adf5 100644..100755 --- a/bin/OpenSim.exe.config +++ b/bin/OpenSim.exe.config | |||
@@ -12,7 +12,7 @@ | |||
12 | <log4net> | 12 | <log4net> |
13 | <appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console"> | 13 | <appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console"> |
14 | <layout type="log4net.Layout.PatternLayout"> | 14 | <layout type="log4net.Layout.PatternLayout"> |
15 | <conversionPattern value="%date{HH:mm:ss} - %message%newline" /> | 15 | <conversionPattern value="%date{HH:mm:ss} - %message" /> |
16 | </layout> | 16 | </layout> |
17 | </appender> | 17 | </appender> |
18 | 18 | ||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 6cb3f02..dd487b7 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -191,6 +191,7 @@ | |||
191 | ; This allows somne control over permissions | 191 | ; This allows somne control over permissions |
192 | ; please note that this still doesn't duplicate SL, and is not intended to | 192 | ; please note that this still doesn't duplicate SL, and is not intended to |
193 | ;region_owner_is_god = true | 193 | ;region_owner_is_god = true |
194 | ;region_manager_is_god = false | ||
194 | ;parcel_owner_is_god = true | 195 | ;parcel_owner_is_god = true |
195 | 196 | ||
196 | ; Control user types that are allowed to create new scripts | 197 | ; Control user types that are allowed to create new scripts |
diff --git a/prebuild.xml b/prebuild.xml index ca2871f..2e73445 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -1915,6 +1915,7 @@ | |||
1915 | <Reference name="OpenMetaverseTypes.dll"/> | 1915 | <Reference name="OpenMetaverseTypes.dll"/> |
1916 | <Reference name="OpenMetaverse.dll"/> | 1916 | <Reference name="OpenMetaverse.dll"/> |
1917 | <Reference name="Nini.dll" /> | 1917 | <Reference name="Nini.dll" /> |
1918 | <Reference name="Mono.Addins" /> | ||
1918 | <Reference name="log4net.dll" /> | 1919 | <Reference name="log4net.dll" /> |
1919 | <Files> | 1920 | <Files> |
1920 | <Match pattern="*.cs" recurse="true"/> | 1921 | <Match pattern="*.cs" recurse="true"/> |
@@ -1976,6 +1977,7 @@ | |||
1976 | <Reference name="log4net.dll"/> | 1977 | <Reference name="log4net.dll"/> |
1977 | <Reference name="protobuf-net"/> | 1978 | <Reference name="protobuf-net"/> |
1978 | <Reference name="MXP.dll"/> | 1979 | <Reference name="MXP.dll"/> |
1980 | <Reference name="Mono.Addins"/> | ||
1979 | <Files> | 1981 | <Files> |
1980 | <Match pattern="*.cs" recurse="true"/> | 1982 | <Match pattern="*.cs" recurse="true"/> |
1981 | </Files> | 1983 | </Files> |
@@ -2486,6 +2488,7 @@ | |||
2486 | <Reference name="OpenSim.Framework.Statistics"/> | 2488 | <Reference name="OpenSim.Framework.Statistics"/> |
2487 | <Reference name="OpenSim.Region.Physics.Manager"/> | 2489 | <Reference name="OpenSim.Region.Physics.Manager"/> |
2488 | <Reference name="Mono.Data.SqliteClient"/> | 2490 | <Reference name="Mono.Data.SqliteClient"/> |
2491 | <Reference name="Mono.Addins"/> | ||
2489 | 2492 | ||
2490 | <!-- For scripting in funny languages by default --> | 2493 | <!-- For scripting in funny languages by default --> |
2491 | <Reference name="Microsoft.JScript"/> | 2494 | <Reference name="Microsoft.JScript"/> |
@@ -2557,6 +2560,28 @@ | |||
2557 | </Files> | 2560 | </Files> |
2558 | </Project> | 2561 | </Project> |
2559 | 2562 | ||
2563 | <Project frameworkVersion="v3_5" name="OpenSim.Tools.Configger" path="OpenSim/Tools/Configger" type="Exe"> | ||
2564 | <Configuration name="Debug"> | ||
2565 | <Options> | ||
2566 | <OutputPath>../../../bin/</OutputPath> | ||
2567 | </Options> | ||
2568 | </Configuration> | ||
2569 | <Configuration name="Release"> | ||
2570 | <Options> | ||
2571 | <OutputPath>../../../bin/</OutputPath> | ||
2572 | </Options> | ||
2573 | </Configuration> | ||
2574 | |||
2575 | <ReferencePath>../../../bin/</ReferencePath> | ||
2576 | <Reference name="System"/> | ||
2577 | <Reference name="Nini.dll"/> | ||
2578 | <Reference name="log4net.dll"/> | ||
2579 | |||
2580 | <Files> | ||
2581 | <Match pattern="*.cs" recurse="true"/> | ||
2582 | </Files> | ||
2583 | </Project> | ||
2584 | |||
2560 | <!-- Test Suite --> | 2585 | <!-- Test Suite --> |
2561 | <Project frameworkVersion="v3_5" name="OpenSim.TestSuite" path="OpenSim/TestSuite" type="Exe"> | 2586 | <Project frameworkVersion="v3_5" name="OpenSim.TestSuite" path="OpenSim/TestSuite" type="Exe"> |
2562 | <Configuration name="Debug"> | 2587 | <Configuration name="Debug"> |
@@ -2963,6 +2988,7 @@ | |||
2963 | <Match path="Agent/TextureSender/Tests" pattern="*.cs" recurse="true" /> | 2988 | <Match path="Agent/TextureSender/Tests" pattern="*.cs" recurse="true" /> |
2964 | <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true" /> | 2989 | <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true" /> |
2965 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true" /> | 2990 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true" /> |
2991 | <Match path="World/Archiver/Tests/Resources" pattern="*" buildAction="EmbeddedResource"/> | ||
2966 | <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true" /> | 2992 | <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true" /> |
2967 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> | 2993 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> |
2968 | <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true" /> | 2994 | <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true" /> |