diff options
author | Melanie | 2009-10-05 10:17:23 +0100 |
---|---|---|
committer | Melanie | 2009-10-05 10:17:23 +0100 |
commit | 0744292b479446eb1ebec828afafacc0189709ca (patch) | |
tree | 3c43b5f425aff61d3625b75b7aef35ce5062ae56 /OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |
parent | Merge branch 'master' into vehicles (diff) | |
parent | Make the asset connector async Get overload return false if the asset (diff) | |
download | opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.zip opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.gz opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.bz2 opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.xz |
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLLegacyRegionData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 531 |
1 files changed, 234 insertions, 297 deletions
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index f25bfd7..fe0914b 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -268,6 +268,8 @@ namespace OpenSim.Data.MySQL | |||
268 | 268 | ||
269 | public void RemoveObject(UUID obj, UUID regionUUID) | 269 | public void RemoveObject(UUID obj, UUID regionUUID) |
270 | { | 270 | { |
271 | List<UUID> uuids = new List<UUID>(); | ||
272 | |||
271 | // Formerly, this used to check the region UUID. | 273 | // Formerly, this used to check the region UUID. |
272 | // That makes no sense, as we remove the contents of a prim | 274 | // That makes no sense, as we remove the contents of a prim |
273 | // unconditionally, but the prim dependent on the region ID. | 275 | // unconditionally, but the prim dependent on the region ID. |
@@ -278,43 +280,31 @@ namespace OpenSim.Data.MySQL | |||
278 | // | 280 | // |
279 | lock (m_Connection) | 281 | lock (m_Connection) |
280 | { | 282 | { |
281 | MySqlCommand cmd = m_Connection.CreateCommand(); | 283 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
282 | |||
283 | cmd.CommandText = "select UUID from prims where "+ | ||
284 | "SceneGroupID= ?UUID"; | ||
285 | |||
286 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); | ||
287 | |||
288 | List<UUID> uuids = new List<UUID>(); | ||
289 | |||
290 | IDataReader reader = ExecuteReader(cmd); | ||
291 | |||
292 | try | ||
293 | { | 284 | { |
294 | while (reader.Read()) | 285 | cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; |
286 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); | ||
287 | |||
288 | using (IDataReader reader = ExecuteReader(cmd)) | ||
295 | { | 289 | { |
296 | uuids.Add(new UUID(reader["UUID"].ToString())); | 290 | while (reader.Read()) |
291 | uuids.Add(new UUID(reader["UUID"].ToString())); | ||
297 | } | 292 | } |
298 | } | ||
299 | finally | ||
300 | { | ||
301 | reader.Close(); | ||
302 | } | ||
303 | |||
304 | // delete the main prims | ||
305 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; | ||
306 | ExecuteNonQuery(cmd); | ||
307 | cmd.Dispose(); | ||
308 | 293 | ||
309 | // there is no way this should be < 1 unless there is | 294 | // delete the main prims |
310 | // a very corrupt database, but in that case be extra | 295 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; |
311 | // safe anyway. | 296 | ExecuteNonQuery(cmd); |
312 | if (uuids.Count > 0) | ||
313 | { | ||
314 | RemoveShapes(uuids); | ||
315 | RemoveItems(uuids); | ||
316 | } | 297 | } |
317 | } | 298 | } |
299 | |||
300 | // there is no way this should be < 1 unless there is | ||
301 | // a very corrupt database, but in that case be extra | ||
302 | // safe anyway. | ||
303 | if (uuids.Count > 0) | ||
304 | { | ||
305 | RemoveShapes(uuids); | ||
306 | RemoveItems(uuids); | ||
307 | } | ||
318 | } | 308 | } |
319 | 309 | ||
320 | /// <summary> | 310 | /// <summary> |
@@ -326,19 +316,16 @@ namespace OpenSim.Data.MySQL | |||
326 | { | 316 | { |
327 | lock (m_Connection) | 317 | lock (m_Connection) |
328 | { | 318 | { |
329 | MySqlCommand cmd = m_Connection.CreateCommand(); | 319 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
330 | 320 | { | |
331 | cmd.CommandText = "delete from primitems where " + | 321 | cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; |
332 | "PrimID = ?PrimID"; | 322 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); |
333 | |||
334 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); | ||
335 | 323 | ||
336 | ExecuteNonQuery(cmd); | 324 | ExecuteNonQuery(cmd); |
337 | cmd.Dispose(); | 325 | } |
338 | } | 326 | } |
339 | } | 327 | } |
340 | 328 | ||
341 | |||
342 | /// <summary> | 329 | /// <summary> |
343 | /// Remove all persisted shapes for a list of prims | 330 | /// Remove all persisted shapes for a list of prims |
344 | /// The caller must acquire the necessrary synchronization locks | 331 | /// The caller must acquire the necessrary synchronization locks |
@@ -349,28 +336,27 @@ namespace OpenSim.Data.MySQL | |||
349 | lock (m_Connection) | 336 | lock (m_Connection) |
350 | { | 337 | { |
351 | string sql = "delete from primshapes where "; | 338 | string sql = "delete from primshapes where "; |
352 | MySqlCommand cmd = m_Connection.CreateCommand(); | 339 | |
353 | 340 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | |
354 | for (int i = 0; i < uuids.Count; i++) | ||
355 | { | 341 | { |
356 | if ((i + 1) == uuids.Count) | 342 | for (int i = 0; i < uuids.Count; i++) |
357 | {// end of the list | ||
358 | sql += "(UUID = ?UUID" + i + ")"; | ||
359 | } | ||
360 | else | ||
361 | { | 343 | { |
362 | sql += "(UUID = ?UUID" + i + ") or "; | 344 | if ((i + 1) == uuids.Count) |
345 | {// end of the list | ||
346 | sql += "(UUID = ?UUID" + i + ")"; | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | sql += "(UUID = ?UUID" + i + ") or "; | ||
351 | } | ||
363 | } | 352 | } |
364 | } | 353 | cmd.CommandText = sql; |
365 | cmd.CommandText = sql; | ||
366 | 354 | ||
367 | for (int i = 0; i < uuids.Count; i++) | 355 | for (int i = 0; i < uuids.Count; i++) |
368 | { | 356 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); |
369 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); | ||
370 | } | ||
371 | 357 | ||
372 | ExecuteNonQuery(cmd); | 358 | ExecuteNonQuery(cmd); |
373 | cmd.Dispose(); | 359 | } |
374 | } | 360 | } |
375 | } | 361 | } |
376 | 362 | ||
@@ -384,28 +370,28 @@ namespace OpenSim.Data.MySQL | |||
384 | lock (m_Connection) | 370 | lock (m_Connection) |
385 | { | 371 | { |
386 | string sql = "delete from primitems where "; | 372 | string sql = "delete from primitems where "; |
387 | MySqlCommand cmd = m_Connection.CreateCommand(); | 373 | |
388 | 374 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | |
389 | for (int i = 0; i < uuids.Count; i++) | ||
390 | { | 375 | { |
391 | if ((i + 1) == uuids.Count) | 376 | for (int i = 0; i < uuids.Count; i++) |
392 | {// end of the list | ||
393 | sql += "(PrimID = ?PrimID" + i + ")"; | ||
394 | } | ||
395 | else | ||
396 | { | 377 | { |
397 | sql += "(PrimID = ?PrimID" + i + ") or "; | 378 | if ((i + 1) == uuids.Count) |
379 | { | ||
380 | // end of the list | ||
381 | sql += "(PrimID = ?PrimID" + i + ")"; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | sql += "(PrimID = ?PrimID" + i + ") or "; | ||
386 | } | ||
398 | } | 387 | } |
399 | } | 388 | cmd.CommandText = sql; |
400 | cmd.CommandText = sql; | ||
401 | 389 | ||
402 | for (int i = 0; i < uuids.Count; i++) | 390 | for (int i = 0; i < uuids.Count; i++) |
403 | { | 391 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); |
404 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); | ||
405 | } | ||
406 | 392 | ||
407 | ExecuteNonQuery(cmd); | 393 | ExecuteNonQuery(cmd); |
408 | cmd.Dispose(); | 394 | } |
409 | } | 395 | } |
410 | } | 396 | } |
411 | 397 | ||
@@ -418,77 +404,71 @@ namespace OpenSim.Data.MySQL | |||
418 | 404 | ||
419 | lock (m_Connection) | 405 | lock (m_Connection) |
420 | { | 406 | { |
421 | MySqlCommand cmd = m_Connection.CreateCommand(); | 407 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
422 | 408 | { | |
423 | cmd.CommandText = "select *, " + | 409 | cmd.CommandText = "select *, " + |
424 | "case when prims.UUID = SceneGroupID " + | 410 | "case when prims.UUID = SceneGroupID " + |
425 | "then 0 else 1 end as sort from prims " + | 411 | "then 0 else 1 end as sort from prims " + |
426 | "left join primshapes on prims.UUID = primshapes.UUID "+ | 412 | "left join primshapes on prims.UUID = primshapes.UUID " + |
427 | "where RegionUUID = ?RegionUUID " + | 413 | "where RegionUUID = ?RegionUUID " + |
428 | "order by SceneGroupID asc, sort asc, LinkNumber asc"; | 414 | "order by SceneGroupID asc, sort asc, LinkNumber asc"; |
429 | |||
430 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
431 | 415 | ||
432 | IDataReader reader = ExecuteReader(cmd); | 416 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); |
433 | 417 | ||
434 | try | 418 | using (IDataReader reader = ExecuteReader(cmd)) |
435 | { | ||
436 | while (reader.Read()) | ||
437 | { | 419 | { |
438 | SceneObjectPart prim = BuildPrim(reader); | 420 | while (reader.Read()) |
439 | if (reader["Shape"] is DBNull) | 421 | { |
440 | prim.Shape = PrimitiveBaseShape.Default; | 422 | SceneObjectPart prim = BuildPrim(reader); |
441 | else | 423 | if (reader["Shape"] is DBNull) |
442 | prim.Shape = BuildShape(reader); | 424 | prim.Shape = PrimitiveBaseShape.Default; |
425 | else | ||
426 | prim.Shape = BuildShape(reader); | ||
443 | 427 | ||
444 | prims[prim.UUID] = prim; | 428 | prims[prim.UUID] = prim; |
445 | 429 | ||
446 | UUID groupID = new UUID(reader["SceneGroupID"].ToString()); | 430 | UUID groupID = new UUID(reader["SceneGroupID"].ToString()); |
447 | 431 | ||
448 | if (groupID != lastGroupID) // New SOG | 432 | if (groupID != lastGroupID) // New SOG |
449 | { | ||
450 | if (grp != null) | ||
451 | objects[grp.UUID] = grp; | ||
452 | |||
453 | lastGroupID = groupID; | ||
454 | |||
455 | // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are | ||
456 | // recorded as the root prim (for which the UUID must equal the persisted group UUID). In | ||
457 | // this case, force the UUID to be the same as the group UUID so that at least these can be | ||
458 | // deleted (we need to change the UUID so that any other prims in the linkset can also be | ||
459 | // deleted). | ||
460 | if (prim.UUID != groupID && groupID != UUID.Zero) | ||
461 | { | 433 | { |
462 | m_log.WarnFormat( | 434 | if (grp != null) |
463 | "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", | 435 | objects[grp.UUID] = grp; |
464 | prim.Name, prim.UUID, prim.GroupPosition, groupID); | 436 | |
465 | 437 | lastGroupID = groupID; | |
466 | prim.UUID = groupID; | 438 | |
439 | // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are | ||
440 | // recorded as the root prim (for which the UUID must equal the persisted group UUID). In | ||
441 | // this case, force the UUID to be the same as the group UUID so that at least these can be | ||
442 | // deleted (we need to change the UUID so that any other prims in the linkset can also be | ||
443 | // deleted). | ||
444 | if (prim.UUID != groupID && groupID != UUID.Zero) | ||
445 | { | ||
446 | m_log.WarnFormat( | ||
447 | "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", | ||
448 | prim.Name, prim.UUID, prim.GroupPosition, groupID); | ||
449 | |||
450 | prim.UUID = groupID; | ||
451 | } | ||
452 | |||
453 | grp = new SceneObjectGroup(prim); | ||
467 | } | 454 | } |
455 | else | ||
456 | { | ||
457 | // Black magic to preserve link numbers | ||
458 | // | ||
459 | int link = prim.LinkNum; | ||
468 | 460 | ||
469 | grp = new SceneObjectGroup(prim); | 461 | grp.AddPart(prim); |
470 | } | ||
471 | else | ||
472 | { | ||
473 | // Black magic to preserve link numbers | ||
474 | // | ||
475 | int link = prim.LinkNum; | ||
476 | |||
477 | grp.AddPart(prim); | ||
478 | 462 | ||
479 | if (link != 0) | 463 | if (link != 0) |
480 | prim.LinkNum = link; | 464 | prim.LinkNum = link; |
465 | } | ||
481 | } | 466 | } |
482 | } | 467 | } |
483 | } | ||
484 | finally | ||
485 | { | ||
486 | reader.Close(); | ||
487 | } | ||
488 | 468 | ||
489 | if (grp != null) | 469 | if (grp != null) |
490 | objects[grp.UUID] = grp; | 470 | objects[grp.UUID] = grp; |
491 | cmd.Dispose(); | 471 | } |
492 | } | 472 | } |
493 | 473 | ||
494 | // Instead of attempting to LoadItems on every prim, | 474 | // Instead of attempting to LoadItems on every prim, |
@@ -498,34 +478,29 @@ namespace OpenSim.Data.MySQL | |||
498 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | 478 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); |
499 | lock (m_Connection) | 479 | lock (m_Connection) |
500 | { | 480 | { |
501 | MySqlCommand itemCmd = m_Connection.CreateCommand(); | 481 | using (MySqlCommand itemCmd = m_Connection.CreateCommand()) |
502 | itemCmd.CommandText = "select distinct primID from primitems"; | ||
503 | IDataReader itemReader = ExecuteReader(itemCmd); | ||
504 | try | ||
505 | { | 482 | { |
506 | while (itemReader.Read()) | 483 | itemCmd.CommandText = "select distinct primID from primitems"; |
484 | using (IDataReader itemReader = ExecuteReader(itemCmd)) | ||
507 | { | 485 | { |
508 | if (!(itemReader["primID"] is DBNull)) | 486 | while (itemReader.Read()) |
509 | { | 487 | { |
510 | UUID primID = new UUID(itemReader["primID"].ToString()); | 488 | if (!(itemReader["primID"] is DBNull)) |
511 | if (prims.ContainsKey(primID)) | ||
512 | { | 489 | { |
513 | primsWithInventory.Add(prims[primID]); | 490 | UUID primID = new UUID(itemReader["primID"].ToString()); |
491 | if (prims.ContainsKey(primID)) | ||
492 | { | ||
493 | primsWithInventory.Add(prims[primID]); | ||
494 | } | ||
514 | } | 495 | } |
515 | } | 496 | } |
516 | } | 497 | } |
517 | } | 498 | } |
518 | finally | ||
519 | { | ||
520 | itemReader.Close(); | ||
521 | } | ||
522 | itemCmd.Dispose(); | ||
523 | } | 499 | } |
524 | 500 | ||
525 | foreach (SceneObjectPart prim in primsWithInventory) | 501 | foreach (SceneObjectPart prim in primsWithInventory) |
526 | { | ||
527 | LoadItems(prim); | 502 | LoadItems(prim); |
528 | } | 503 | |
529 | m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); | 504 | m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); |
530 | return new List<SceneObjectGroup>(objects.Values); | 505 | return new List<SceneObjectGroup>(objects.Values); |
531 | } | 506 | } |
@@ -538,34 +513,25 @@ namespace OpenSim.Data.MySQL | |||
538 | { | 513 | { |
539 | lock (m_Connection) | 514 | lock (m_Connection) |
540 | { | 515 | { |
541 | MySqlCommand cmd = m_Connection.CreateCommand(); | 516 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
542 | |||
543 | cmd.CommandText = "select * from primitems where "+ | ||
544 | "PrimID = ?PrimID"; | ||
545 | 517 | ||
546 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | 518 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
547 | |||
548 | IDataReader reader = ExecuteReader(cmd); | ||
549 | List<TaskInventoryItem> inventory = | ||
550 | new List<TaskInventoryItem>(); | ||
551 | |||
552 | try | ||
553 | { | 519 | { |
554 | while (reader.Read()) | 520 | cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; |
521 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | ||
522 | |||
523 | using (IDataReader reader = ExecuteReader(cmd)) | ||
555 | { | 524 | { |
556 | TaskInventoryItem item = BuildItem(reader); | 525 | while (reader.Read()) |
526 | { | ||
527 | TaskInventoryItem item = BuildItem(reader); | ||
557 | 528 | ||
558 | item.ParentID = prim.UUID; // Values in database are | 529 | item.ParentID = prim.UUID; // Values in database are often wrong |
559 | // often wrong | 530 | inventory.Add(item); |
560 | inventory.Add(item); | 531 | } |
561 | } | 532 | } |
562 | } | 533 | } |
563 | finally | ||
564 | { | ||
565 | reader.Close(); | ||
566 | } | ||
567 | 534 | ||
568 | cmd.Dispose(); | ||
569 | prim.Inventory.RestoreInventoryItems(inventory); | 535 | prim.Inventory.RestoreInventoryItems(inventory); |
570 | } | 536 | } |
571 | } | 537 | } |
@@ -576,23 +542,21 @@ namespace OpenSim.Data.MySQL | |||
576 | 542 | ||
577 | lock (m_Connection) | 543 | lock (m_Connection) |
578 | { | 544 | { |
579 | MySqlCommand cmd = m_Connection.CreateCommand(); | 545 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
546 | { | ||
547 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | ||
548 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
580 | 549 | ||
581 | cmd.CommandText = "delete from terrain where " + | 550 | ExecuteNonQuery(cmd); |
582 | "RegionUUID = ?RegionUUID"; | ||
583 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
584 | 551 | ||
585 | ExecuteNonQuery(cmd); | 552 | cmd.CommandText = "insert into terrain (RegionUUID, " + |
586 | |||
587 | cmd.CommandText = "insert into terrain (RegionUUID, " + | ||
588 | "Revision, Heightfield) values (?RegionUUID, " + | 553 | "Revision, Heightfield) values (?RegionUUID, " + |
589 | "1, ?Heightfield)"; | 554 | "1, ?Heightfield)"; |
590 | 555 | ||
591 | cmd.Parameters.AddWithValue("Heightfield", | 556 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); |
592 | SerializeTerrain(ter)); | 557 | |
593 | 558 | ExecuteNonQuery(cmd); | |
594 | ExecuteNonQuery(cmd); | 559 | } |
595 | cmd.Dispose(); | ||
596 | } | 560 | } |
597 | } | 561 | } |
598 | 562 | ||
@@ -602,42 +566,40 @@ namespace OpenSim.Data.MySQL | |||
602 | 566 | ||
603 | lock (m_Connection) | 567 | lock (m_Connection) |
604 | { | 568 | { |
605 | MySqlCommand cmd = m_Connection.CreateCommand(); | 569 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
606 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + | 570 | { |
607 | "from terrain where RegionUUID = ?RegionUUID "+ | 571 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + |
572 | "from terrain where RegionUUID = ?RegionUUID " + | ||
608 | "order by Revision desc limit 1"; | 573 | "order by Revision desc limit 1"; |
609 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | 574 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
610 | |||
611 | IDataReader reader = ExecuteReader(cmd); | ||
612 | 575 | ||
613 | try | 576 | using (IDataReader reader = ExecuteReader(cmd)) |
614 | { | ||
615 | while (reader.Read()) | ||
616 | { | 577 | { |
617 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 578 | while (reader.Read()) |
618 | terrain.Initialize(); | 579 | { |
580 | int rev = Convert.ToInt32(reader["Revision"]); | ||
619 | 581 | ||
620 | MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); | 582 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; |
621 | int rev = 0; | 583 | terrain.Initialize(); |
622 | 584 | ||
623 | BinaryReader br = new BinaryReader(mstr); | 585 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) |
624 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
625 | { | ||
626 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
627 | { | 586 | { |
628 | terrain[x, y] = br.ReadDouble(); | 587 | using (BinaryReader br = new BinaryReader(mstr)) |
588 | { | ||
589 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
590 | { | ||
591 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
592 | { | ||
593 | terrain[x, y] = br.ReadDouble(); | ||
594 | } | ||
595 | } | ||
596 | } | ||
597 | |||
598 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); | ||
629 | } | 599 | } |
630 | rev = Convert.ToInt32(reader["Revision"]); | ||
631 | } | 600 | } |
632 | m_log.InfoFormat("[REGION DB]: Loaded terrain " + | ||
633 | "revision r{0}", rev); | ||
634 | } | 601 | } |
635 | } | 602 | } |
636 | finally | ||
637 | { | ||
638 | reader.Close(); | ||
639 | } | ||
640 | cmd.Dispose(); | ||
641 | } | 603 | } |
642 | 604 | ||
643 | return terrain; | 605 | return terrain; |
@@ -647,14 +609,13 @@ namespace OpenSim.Data.MySQL | |||
647 | { | 609 | { |
648 | lock (m_Connection) | 610 | lock (m_Connection) |
649 | { | 611 | { |
650 | MySqlCommand cmd = m_Connection.CreateCommand(); | 612 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
651 | 613 | { | |
652 | cmd.CommandText = "delete from land where UUID = ?UUID"; | 614 | cmd.CommandText = "delete from land where UUID = ?UUID"; |
653 | 615 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | |
654 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | ||
655 | 616 | ||
656 | ExecuteNonQuery(cmd); | 617 | ExecuteNonQuery(cmd); |
657 | cmd.Dispose(); | 618 | } |
658 | } | 619 | } |
659 | } | 620 | } |
660 | 621 | ||
@@ -662,9 +623,9 @@ namespace OpenSim.Data.MySQL | |||
662 | { | 623 | { |
663 | lock (m_Connection) | 624 | lock (m_Connection) |
664 | { | 625 | { |
665 | MySqlCommand cmd = m_Connection.CreateCommand(); | 626 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
666 | 627 | { | |
667 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + | 628 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + |
668 | "LocalLandID, Bitmap, Name, Description, " + | 629 | "LocalLandID, Bitmap, Name, Description, " + |
669 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + | 630 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + |
670 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + | 631 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + |
@@ -685,28 +646,26 @@ namespace OpenSim.Data.MySQL | |||
685 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | 646 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + |
686 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; | 647 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; |
687 | 648 | ||
688 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | 649 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); |
689 | 650 | ||
690 | ExecuteNonQuery(cmd); | 651 | ExecuteNonQuery(cmd); |
691 | |||
692 | cmd.CommandText = "delete from landaccesslist where " + | ||
693 | "LandUUID = ?UUID"; | ||
694 | |||
695 | ExecuteNonQuery(cmd); | ||
696 | 652 | ||
697 | cmd.Parameters.Clear(); | 653 | cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; |
698 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
699 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
700 | "?Flags)"; | ||
701 | 654 | ||
702 | foreach (ParcelManager.ParcelAccessEntry entry in | ||
703 | parcel.LandData.ParcelAccessList) | ||
704 | { | ||
705 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | ||
706 | ExecuteNonQuery(cmd); | 655 | ExecuteNonQuery(cmd); |
656 | |||
707 | cmd.Parameters.Clear(); | 657 | cmd.Parameters.Clear(); |
658 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
659 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
660 | "?Flags)"; | ||
661 | |||
662 | foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) | ||
663 | { | ||
664 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | ||
665 | ExecuteNonQuery(cmd); | ||
666 | cmd.Parameters.Clear(); | ||
667 | } | ||
708 | } | 668 | } |
709 | cmd.Dispose(); | ||
710 | } | 669 | } |
711 | } | 670 | } |
712 | 671 | ||
@@ -716,35 +675,28 @@ namespace OpenSim.Data.MySQL | |||
716 | 675 | ||
717 | lock (m_Connection) | 676 | lock (m_Connection) |
718 | { | 677 | { |
719 | MySqlCommand cmd = m_Connection.CreateCommand(); | 678 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
720 | |||
721 | cmd.CommandText = "select * from regionsettings where " + | ||
722 | "regionUUID = ?RegionUUID"; | ||
723 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); | ||
724 | |||
725 | IDataReader reader = ExecuteReader(cmd); | ||
726 | |||
727 | try | ||
728 | { | 679 | { |
729 | if (reader.Read()) | 680 | cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; |
730 | { | 681 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); |
731 | rs = BuildRegionSettings(reader); | 682 | |
732 | rs.OnSave += StoreRegionSettings; | 683 | using (IDataReader reader = ExecuteReader(cmd)) |
733 | } | ||
734 | else | ||
735 | { | 684 | { |
736 | rs = new RegionSettings(); | 685 | if (reader.Read()) |
737 | rs.RegionUUID = regionUUID; | 686 | { |
738 | rs.OnSave += StoreRegionSettings; | 687 | rs = BuildRegionSettings(reader); |
688 | rs.OnSave += StoreRegionSettings; | ||
689 | } | ||
690 | else | ||
691 | { | ||
692 | rs = new RegionSettings(); | ||
693 | rs.RegionUUID = regionUUID; | ||
694 | rs.OnSave += StoreRegionSettings; | ||
739 | 695 | ||
740 | StoreRegionSettings(rs); | 696 | StoreRegionSettings(rs); |
697 | } | ||
741 | } | 698 | } |
742 | } | 699 | } |
743 | finally | ||
744 | { | ||
745 | reader.Close(); | ||
746 | } | ||
747 | cmd.Dispose(); | ||
748 | } | 700 | } |
749 | 701 | ||
750 | return rs; | 702 | return rs; |
@@ -754,9 +706,9 @@ namespace OpenSim.Data.MySQL | |||
754 | { | 706 | { |
755 | lock (m_Connection) | 707 | lock (m_Connection) |
756 | { | 708 | { |
757 | MySqlCommand cmd = m_Connection.CreateCommand(); | 709 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
758 | 710 | { | |
759 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | 711 | cmd.CommandText = "replace into regionsettings (regionUUID, " + |
760 | "block_terraform, block_fly, allow_damage, " + | 712 | "block_terraform, block_fly, allow_damage, " + |
761 | "restrict_pushing, allow_land_resell, " + | 713 | "restrict_pushing, allow_land_resell, " + |
762 | "allow_land_join_divide, block_show_in_search, " + | 714 | "allow_land_join_divide, block_show_in_search, " + |
@@ -766,8 +718,8 @@ namespace OpenSim.Data.MySQL | |||
766 | "terrain_texture_2, terrain_texture_3, " + | 718 | "terrain_texture_2, terrain_texture_3, " + |
767 | "terrain_texture_4, elevation_1_nw, " + | 719 | "terrain_texture_4, elevation_1_nw, " + |
768 | "elevation_2_nw, elevation_1_ne, " + | 720 | "elevation_2_nw, elevation_1_ne, " + |
769 | "elevation_2_ne, elevation_1_se, "+ | 721 | "elevation_2_ne, elevation_1_se, " + |
770 | "elevation_2_se, elevation_1_sw, "+ | 722 | "elevation_2_se, elevation_1_sw, " + |
771 | "elevation_2_sw, water_height, " + | 723 | "elevation_2_sw, water_height, " + |
772 | "terrain_raise_limit, terrain_lower_limit, " + | 724 | "terrain_raise_limit, terrain_lower_limit, " + |
773 | "use_estate_sun, fixed_sun, sun_position, " + | 725 | "use_estate_sun, fixed_sun, sun_position, " + |
@@ -789,11 +741,10 @@ namespace OpenSim.Data.MySQL | |||
789 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | 741 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + |
790 | "?LoadedCreationDateTime, ?LoadedCreationID)"; | 742 | "?LoadedCreationDateTime, ?LoadedCreationID)"; |
791 | 743 | ||
792 | FillRegionSettingsCommand(cmd, rs); | 744 | FillRegionSettingsCommand(cmd, rs); |
793 | |||
794 | ExecuteNonQuery(cmd); | ||
795 | cmd.Dispose(); | ||
796 | 745 | ||
746 | ExecuteNonQuery(cmd); | ||
747 | } | ||
797 | } | 748 | } |
798 | } | 749 | } |
799 | 750 | ||
@@ -803,52 +754,38 @@ namespace OpenSim.Data.MySQL | |||
803 | 754 | ||
804 | lock (m_Connection) | 755 | lock (m_Connection) |
805 | { | 756 | { |
806 | MySqlCommand cmd = m_Connection.CreateCommand(); | 757 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
807 | |||
808 | cmd.CommandText = "select * from land where " + | ||
809 | "RegionUUID = ?RegionUUID"; | ||
810 | |||
811 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
812 | |||
813 | IDataReader reader = ExecuteReader(cmd); | ||
814 | |||
815 | try | ||
816 | { | 758 | { |
817 | while (reader.Read()) | 759 | cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; |
760 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
761 | |||
762 | using (IDataReader reader = ExecuteReader(cmd)) | ||
818 | { | 763 | { |
819 | LandData newLand = BuildLandData(reader); | 764 | while (reader.Read()) |
820 | landData.Add(newLand); | 765 | { |
766 | LandData newLand = BuildLandData(reader); | ||
767 | landData.Add(newLand); | ||
768 | } | ||
821 | } | 769 | } |
822 | } | 770 | } |
823 | finally | ||
824 | { | ||
825 | reader.Close(); | ||
826 | } | ||
827 | 771 | ||
828 | foreach (LandData land in landData) | 772 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
829 | { | 773 | { |
830 | cmd.Parameters.Clear(); | 774 | foreach (LandData land in landData) |
831 | |||
832 | cmd.CommandText = "select * from landaccesslist " + | ||
833 | "where LandUUID = ?LandUUID"; | ||
834 | |||
835 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
836 | |||
837 | reader = ExecuteReader(cmd); | ||
838 | |||
839 | try | ||
840 | { | 775 | { |
841 | while (reader.Read()) | 776 | cmd.Parameters.Clear(); |
777 | cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; | ||
778 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
779 | |||
780 | using (IDataReader reader = ExecuteReader(cmd)) | ||
842 | { | 781 | { |
843 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | 782 | while (reader.Read()) |
783 | { | ||
784 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | ||
785 | } | ||
844 | } | 786 | } |
845 | } | 787 | } |
846 | finally | ||
847 | { | ||
848 | reader.Close(); | ||
849 | } | ||
850 | } | 788 | } |
851 | cmd.Dispose(); | ||
852 | } | 789 | } |
853 | 790 | ||
854 | return landData; | 791 | return landData; |