aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-24 02:43:31 +0000
committerJustin Clark-Casey (justincc)2012-11-24 02:43:31 +0000
commit82690e138448ebac6456ab03dcca4b0a8a1cc57a (patch)
tree0b5de164235b49d9d66f09582b857cd129d68b96 /OpenSim/Region/CoreModules
parentminor: Add some currently commented out debug log lines for investigating iss... (diff)
downloadopensim-SC_OLD-82690e138448ebac6456ab03dcca4b0a8a1cc57a.zip
opensim-SC_OLD-82690e138448ebac6456ab03dcca4b0a8a1cc57a.tar.gz
opensim-SC_OLD-82690e138448ebac6456ab03dcca4b0a8a1cc57a.tar.bz2
opensim-SC_OLD-82690e138448ebac6456ab03dcca4b0a8a1cc57a.tar.xz
Fix bug where loading an OAR with a deeded parcel would always set the parcel owner ID to the estate owner even if the group UUID was present.
Aims to address http://opensimulator.org/mantis/view.php?id=6355 As part of this work, an incomplete IXGroupsData was added which currently only allows store/fetch/delete of group records (i.e. no membership data etc) This is subject to change and currently only an in-memory storage implementation exists for regression test purposes.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs312
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs13
5 files changed, 224 insertions, 147 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 60bbf9b..c810242 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -552,19 +552,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
552 552
553 // Validate User and Group UUID's 553 // Validate User and Group UUID's
554 554
555 if (!ResolveUserUuid(scene, parcel.OwnerID)) 555 if (parcel.IsGroupOwned)
556 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
557
558 if (!ResolveGroupUuid(parcel.GroupID))
559 { 556 {
560// m_log.DebugFormat("[ARCHIVE READ REQUEST]: Could not find group {0}", parcel.GroupID); 557 if (!ResolveGroupUuid(parcel.GroupID))
561 parcel.GroupID = UUID.Zero; 558 {
562 parcel.IsGroupOwned = false; 559 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
560 parcel.GroupID = UUID.Zero;
561 parcel.IsGroupOwned = false;
562 }
563 }
564 else
565 {
566 if (!ResolveUserUuid(scene, parcel.OwnerID))
567 parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner;
568
569 if (!ResolveGroupUuid(parcel.GroupID))
570 parcel.GroupID = UUID.Zero;
563 } 571 }
564// else
565// {
566// m_log.DebugFormat("[ARCHIVE READ REQUEST]: Found group {0}", parcel.GroupID);
567// }
568 572
569 List<LandAccessEntry> accessList = new List<LandAccessEntry>(); 573 List<LandAccessEntry> accessList = new List<LandAccessEntry>();
570 foreach (LandAccessEntry entry in parcel.ParcelAccessList) 574 foreach (LandAccessEntry entry in parcel.ParcelAccessList)
@@ -576,8 +580,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
576 parcel.ParcelAccessList = accessList; 580 parcel.ParcelAccessList = accessList;
577 581
578// m_log.DebugFormat( 582// m_log.DebugFormat(
579// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", 583// "[ARCHIVER]: Adding parcel {0}, local id {1}, owner {2}, group {3}, isGroupOwned {4}, area {5}",
580// parcel.Name, parcel.LocalID, parcel.Area); 584// parcel.Name, parcel.LocalID, parcel.OwnerID, parcel.GroupID, parcel.IsGroupOwned, parcel.Area);
581 585
582 landData.Add(parcel); 586 landData.Add(parcel);
583 } 587 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
index d751b1c..7bdd65c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
@@ -167,7 +167,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
167 } 167 }
168 scenesGroup.CalcSceneLocations(); 168 scenesGroup.CalcSceneLocations();
169 169
170
171 m_archiveWriter = new TarArchiveWriter(m_saveStream); 170 m_archiveWriter = new TarArchiveWriter(m_saveStream);
172 171
173 try 172 try
@@ -216,7 +215,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
216 } 215 }
217 } 216 }
218 217
219
220 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) 218 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids)
221 { 219 {
222 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); 220 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName);
@@ -540,7 +538,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
540 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); 538 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y));
541 } 539 }
542 540
543
544 protected void Save(Scene scene, List<SceneObjectGroup> sceneObjects, string regionDir) 541 protected void Save(Scene scene, List<SceneObjectGroup> sceneObjects, string regionDir)
545 { 542 {
546 if (regionDir != string.Empty) 543 if (regionDir != string.Empty)
@@ -560,8 +557,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
560 foreach (ILandObject lo in landObjects) 557 foreach (ILandObject lo in landObjects)
561 { 558 {
562 LandData landData = lo.LandData; 559 LandData landData = lo.LandData;
563 string landDataPath = String.Format("{0}{1}{2}.xml", 560 string landDataPath
564 regionDir, ArchiveConstants.LANDDATA_PATH, landData.GlobalID.ToString()); 561 = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData));
565 m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); 562 m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options));
566 } 563 }
567 564
@@ -604,7 +601,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
604 601
605 CloseArchive(String.Empty); 602 CloseArchive(String.Empty);
606 } 603 }
607
608 604
609 /// <summary> 605 /// <summary>
610 /// Closes the archive and notifies that we're done. 606 /// Closes the archive and notifies that we're done.
@@ -629,6 +625,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver
629 625
630 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); 626 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage);
631 } 627 }
632
633 } 628 }
634} 629} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 82f49b0..7cc3519 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -31,16 +31,19 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using Nini.Config;
34using NUnit.Framework; 35using NUnit.Framework;
35using OpenMetaverse; 36using OpenMetaverse;
36using OpenMetaverse.Assets; 37using OpenMetaverse.Assets;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 39using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 40using OpenSim.Framework.Serialization.External;
41using OpenSim.Region.CoreModules.World.Land;
40using OpenSim.Region.CoreModules.World.Serialiser; 42using OpenSim.Region.CoreModules.World.Serialiser;
41using OpenSim.Region.CoreModules.World.Terrain; 43using OpenSim.Region.CoreModules.World.Terrain;
42using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization; 45using OpenSim.Region.Framework.Scenes.Serialization;
46using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
44using OpenSim.Tests.Common; 47using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock; 48using OpenSim.Tests.Common.Mock;
46using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants; 49using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants;
@@ -127,6 +130,53 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
127 130
128 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; 131 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName };
129 } 132 }
133
134 private void CreateTestObjects(Scene scene, out SceneObjectGroup sog1, out SceneObjectGroup sog2, out UUID ncAssetUuid)
135 {
136 SceneObjectPart part1 = CreateSceneObjectPart1();
137 sog1 = new SceneObjectGroup(part1);
138 scene.AddNewSceneObject(sog1, false);
139
140 AssetNotecard nc = new AssetNotecard();
141 nc.BodyText = "Hello World!";
142 nc.Encode();
143 ncAssetUuid = UUID.Random();
144 UUID ncItemUuid = UUID.Random();
145 AssetBase ncAsset
146 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
147 m_scene.AssetService.Store(ncAsset);
148
149 TaskInventoryItem ncItem
150 = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
151 SceneObjectPart part2 = CreateSceneObjectPart2();
152 sog2 = new SceneObjectGroup(part2);
153 part2.Inventory.AddInventoryItem(ncItem, true);
154
155 scene.AddNewSceneObject(sog2, false);
156 }
157
158 private static void CreateSoundAsset(TarArchiveWriter tar, Assembly assembly, string soundDataResourceName, out byte[] soundData, out UUID soundUuid)
159 {
160 using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
161 {
162 using (BinaryReader br = new BinaryReader(resource))
163 {
164 // FIXME: Use the inspector instead
165 soundData = br.ReadBytes(99999999);
166 soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
167 string soundAssetFileName
168 = ArchiveConstants.ASSETS_PATH + soundUuid
169 + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
170 tar.WriteFile(soundAssetFileName, soundData);
171
172 /*
173 AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
174 scene.AssetService.Store(soundAsset);
175 asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
176 */
177 }
178 }
179 }
130 180
131 /// <summary> 181 /// <summary>
132 /// Test saving an OpenSim Region Archive. 182 /// Test saving an OpenSim Region Archive.
@@ -204,30 +254,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
204 // TODO: Test presence of more files and contents of files. 254 // TODO: Test presence of more files and contents of files.
205 } 255 }
206 256
207 private void CreateTestObjects(Scene scene, out SceneObjectGroup sog1, out SceneObjectGroup sog2, out UUID ncAssetUuid)
208 {
209 SceneObjectPart part1 = CreateSceneObjectPart1();
210 sog1 = new SceneObjectGroup(part1);
211 scene.AddNewSceneObject(sog1, false);
212
213 AssetNotecard nc = new AssetNotecard();
214 nc.BodyText = "Hello World!";
215 nc.Encode();
216 ncAssetUuid = UUID.Random();
217 UUID ncItemUuid = UUID.Random();
218 AssetBase ncAsset
219 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
220 m_scene.AssetService.Store(ncAsset);
221
222 TaskInventoryItem ncItem
223 = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
224 SceneObjectPart part2 = CreateSceneObjectPart2();
225 sog2 = new SceneObjectGroup(part2);
226 part2.Inventory.AddInventoryItem(ncItem, true);
227
228 scene.AddNewSceneObject(sog2, false);
229 }
230
231 /// <summary> 257 /// <summary>
232 /// Test saving an OpenSim Region Archive with the no assets option 258 /// Test saving an OpenSim Region Archive with the no assets option
233 /// </summary> 259 /// </summary>
@@ -309,59 +335,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
309 } 335 }
310 336
311 /// <summary> 337 /// <summary>
312 /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g.
313 /// 2 can come after 3).
314 /// </summary>
315 [Test]
316 public void TestLoadOarUnorderedParts()
317 {
318 TestHelpers.InMethod();
319
320 UUID ownerId = TestHelpers.ParseTail(0xaaaa);
321
322 MemoryStream archiveWriteStream = new MemoryStream();
323 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
324
325 tar.WriteFile(
326 ArchiveConstants.CONTROL_FILE_PATH,
327 new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
328
329 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11);
330 SceneObjectPart sop2
331 = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
332 SceneObjectPart sop3
333 = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);
334
335 // Add the parts so they will be written out in reverse order to the oar
336 sog1.AddPart(sop3);
337 sop3.LinkNum = 3;
338 sog1.AddPart(sop2);
339 sop2.LinkNum = 2;
340
341 tar.WriteFile(
342 ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
343 SceneObjectSerializer.ToXml2Format(sog1));
344
345 tar.Close();
346
347 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
348
349 lock (this)
350 {
351 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
352 m_archiverModule.DearchiveRegion(archiveReadStream);
353 }
354
355 Assert.That(m_lastErrorMessage, Is.Null);
356
357 SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2");
358 Assert.That(part2.LinkNum, Is.EqualTo(2));
359
360 SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3");
361 Assert.That(part3.LinkNum, Is.EqualTo(3));
362 }
363
364 /// <summary>
365 /// Test loading an OpenSim Region Archive. 338 /// Test loading an OpenSim Region Archive.
366 /// </summary> 339 /// </summary>
367 [Test] 340 [Test]
@@ -435,50 +408,57 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
435 TestLoadedRegion(part1, soundItemName, soundData); 408 TestLoadedRegion(part1, soundItemName, soundData);
436 } 409 }
437 410
438 private static void CreateSoundAsset(TarArchiveWriter tar, Assembly assembly, string soundDataResourceName, out byte[] soundData, out UUID soundUuid) 411 /// <summary>
412 /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g.
413 /// 2 can come after 3).
414 /// </summary>
415 [Test]
416 public void TestLoadOarUnorderedParts()
439 { 417 {
440 using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName)) 418 TestHelpers.InMethod();
441 {
442 using (BinaryReader br = new BinaryReader(resource))
443 {
444 // FIXME: Use the inspector instead
445 soundData = br.ReadBytes(99999999);
446 soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
447 string soundAssetFileName
448 = ArchiveConstants.ASSETS_PATH + soundUuid
449 + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
450 tar.WriteFile(soundAssetFileName, soundData);
451 419
452 /* 420 UUID ownerId = TestHelpers.ParseTail(0xaaaa);
453 AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
454 scene.AssetService.Store(soundAsset);
455 asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
456 */
457 }
458 }
459 }
460 421
461 private void TestLoadedRegion(SceneObjectPart part1, string soundItemName, byte[] soundData) 422 MemoryStream archiveWriteStream = new MemoryStream();
462 { 423 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
463 SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);
464 424
465 Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); 425 tar.WriteFile(
466 Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical"); 426 ArchiveConstants.CONTROL_FILE_PATH,
467 Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal"); 427 new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
468 Assert.That(
469 object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal");
470 Assert.That(
471 object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal");
472 Assert.That(object1PartLoaded.SitTargetOrientation, Is.EqualTo(part1.SitTargetOrientation));
473 Assert.That(object1PartLoaded.SitTargetPosition, Is.EqualTo(part1.SitTargetPosition));
474 428
475 TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; 429 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11);
476 Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); 430 SceneObjectPart sop2
477 AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); 431 = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
478 Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); 432 SceneObjectPart sop3
479 Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); 433 = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);
480 434
481 Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels"); 435 // Add the parts so they will be written out in reverse order to the oar
436 sog1.AddPart(sop3);
437 sop3.LinkNum = 3;
438 sog1.AddPart(sop2);
439 sop2.LinkNum = 2;
440
441 tar.WriteFile(
442 ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
443 SceneObjectSerializer.ToXml2Format(sog1));
444
445 tar.Close();
446
447 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
448
449 lock (this)
450 {
451 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
452 m_archiverModule.DearchiveRegion(archiveReadStream);
453 }
454
455 Assert.That(m_lastErrorMessage, Is.Null);
456
457 SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2");
458 Assert.That(part2.LinkNum, Is.EqualTo(2));
459
460 SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3");
461 Assert.That(part3.LinkNum, Is.EqualTo(3));
482 } 462 }
483 463
484 /// <summary> 464 /// <summary>
@@ -563,6 +543,81 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
563 } 543 }
564 544
565 /// <summary> 545 /// <summary>
546 /// Test OAR loading where the land parcel is group deeded.
547 /// </summary>
548 /// <remarks>
549 /// In this situation, the owner ID is set to the group ID.
550 /// </remarks>
551 [Test]
552 public void TestLoadOarDeededLand()
553 {
554 TestHelpers.InMethod();
555 TestHelpers.EnableLogging();
556
557 UUID landID = TestHelpers.ParseTail(0x10);
558
559 MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();
560
561 IConfigSource configSource = new IniConfigSource();
562 IConfig config = configSource.AddConfig("Groups");
563 config.Set("Enabled", true);
564 config.Set("Module", "GroupsModule");
565 config.Set("DebugEnabled", true);
566 SceneHelpers.SetupSceneModules(
567 m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });
568
569 // Create group in scene for loading
570 // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
571 UUID groupID
572 = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);
573
574 // Construct OAR
575 MemoryStream oarStream = new MemoryStream();
576 TarArchiveWriter tar = new TarArchiveWriter(oarStream);
577
578 tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
579 tar.WriteFile(
580 ArchiveConstants.CONTROL_FILE_PATH,
581 new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
582
583 LandObject lo = new LandObject(groupID, true, null);
584
585 // FIXME: We set directly rather than call SetLandBitmap in order not to do an AABB value update, which
586 // requests the terrain heightmap from an active scene. This is confusing and not a long-term solution.
587 //lo.LandBitmap = lo.BasicFullRegionLandBitmap();
588 lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
589
590 // FIXME: We have to make a separate call to update the LandData's copy of the land bitmap, even though this is
591 // identical to the LandObject copy. This should be changed so there's only one copy of the data if at all
592 // possible
593 //lo.UpdateLandBitmapByteArray();
594
595 LandData ld = lo.LandData;
596 ld.GlobalID = landID;
597
598 string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
599 tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null));
600 tar.Close();
601
602 oarStream = new MemoryStream(oarStream.ToArray());
603
604 // Load OAR
605 lock (this)
606 {
607 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
608 m_archiverModule.DearchiveRegion(oarStream);
609 }
610
611 ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
612 LandData rLd = rLo.LandData;
613
614 Assert.That(rLd.GlobalID, Is.EqualTo(landID));
615 Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
616 Assert.That(rLd.GroupID, Is.EqualTo(groupID));
617 Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
618 }
619
620 /// <summary>
566 /// Test loading the region settings of an OpenSim Region Archive. 621 /// Test loading the region settings of an OpenSim Region Archive.
567 /// </summary> 622 /// </summary>
568 [Test] 623 [Test]
@@ -781,9 +836,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
781 } 836 }
782 } 837 }
783 838
784
785 // Save OAR 839 // Save OAR
786
787 MemoryStream archiveWriteStream = new MemoryStream(); 840 MemoryStream archiveWriteStream = new MemoryStream();
788 m_scene.EventManager.OnOarFileSaved += SaveCompleted; 841 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
789 842
@@ -800,7 +853,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
800 853
801 854
802 // Check that the OAR contains the expected data 855 // Check that the OAR contains the expected data
803
804 Assert.That(m_lastRequestId, Is.EqualTo(requestId)); 856 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
805 857
806 byte[] archive = archiveWriteStream.ToArray(); 858 byte[] archive = archiveWriteStream.ToArray();
@@ -976,5 +1028,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
976 TestLoadedRegion(part1, soundItemName, soundData); 1028 TestLoadedRegion(part1, soundItemName, soundData);
977 } 1029 }
978 1030
1031 private void TestLoadedRegion(SceneObjectPart part1, string soundItemName, byte[] soundData)
1032 {
1033 SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);
1034
1035 Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
1036 Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical");
1037 Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal");
1038 Assert.That(
1039 object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal");
1040 Assert.That(
1041 object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal");
1042 Assert.That(object1PartLoaded.SitTargetOrientation, Is.EqualTo(part1.SitTargetOrientation));
1043 Assert.That(object1PartLoaded.SitTargetPosition, Is.EqualTo(part1.SitTargetPosition));
1044
1045 TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
1046 Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
1047 AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
1048 Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
1049 Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
1050
1051 Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels");
1052 }
979 } 1053 }
980} 1054} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 8682798..7149aad 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1378,10 +1378,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1378 1378
1379 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1379 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1380 { 1380 {
1381// m_log.DebugFormat(
1382// "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name);
1383
1381 for (int i = 0; i < data.Count; i++) 1384 for (int i = 0; i < data.Count; i++)
1382 {
1383 IncomingLandObjectFromStorage(data[i]); 1385 IncomingLandObjectFromStorage(data[i]);
1384 }
1385 } 1386 }
1386 1387
1387 public void IncomingLandObjectFromStorage(LandData data) 1388 public void IncomingLandObjectFromStorage(LandData data)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 8829f27..5969d45 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -727,9 +727,10 @@ namespace OpenSim.Region.CoreModules.World.Land
727 int ty = min_y * 4; 727 int ty = min_y * 4;
728 if (ty > ((int)Constants.RegionSize - 1)) 728 if (ty > ((int)Constants.RegionSize - 1))
729 ty = ((int)Constants.RegionSize - 1); 729 ty = ((int)Constants.RegionSize - 1);
730
730 LandData.AABBMin = 731 LandData.AABBMin =
731 new Vector3((float) (min_x * 4), (float) (min_y * 4), 732 new Vector3(
732 (float) m_scene.Heightmap[tx, ty]); 733 (float)(min_x * 4), (float)(min_y * 4), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0);
733 734
734 tx = max_x * 4; 735 tx = max_x * 4;
735 if (tx > ((int)Constants.RegionSize - 1)) 736 if (tx > ((int)Constants.RegionSize - 1))
@@ -737,9 +738,11 @@ namespace OpenSim.Region.CoreModules.World.Land
737 ty = max_y * 4; 738 ty = max_y * 4;
738 if (ty > ((int)Constants.RegionSize - 1)) 739 if (ty > ((int)Constants.RegionSize - 1))
739 ty = ((int)Constants.RegionSize - 1); 740 ty = ((int)Constants.RegionSize - 1);
740 LandData.AABBMax = 741
741 new Vector3((float) (max_x * 4), (float) (max_y * 4), 742 LandData.AABBMax
742 (float) m_scene.Heightmap[tx, ty]); 743 = new Vector3(
744 (float)(max_x * 4), (float)(max_y * 4), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0);
745
743 LandData.Area = tempArea; 746 LandData.Area = tempArea;
744 } 747 }
745 748