aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs28
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs57
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs52
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs14
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs400
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs174
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs54
27 files changed, 604 insertions, 275 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4d74b2a..5baf078 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -34,13 +34,13 @@ using Nini.Config;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
41using OpenSim.Services.Connectors.Friends; 42using OpenSim.Services.Connectors.Friends;
42using OpenSim.Server.Base; 43using OpenSim.Server.Base;
43using OpenSim.Framework.Servers.HttpServer;
44using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 44using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
45using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; 45using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
46using GridRegion = OpenSim.Services.Interfaces.GridRegion; 46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index fdfcd10..919ea33 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -33,7 +33,6 @@ using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Framework.Client; 36using OpenSim.Framework.Client;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 01170aa..f3d2f26 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -471,16 +471,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
471 if (m_creatorIdForAssetId.ContainsKey(assetId)) 471 if (m_creatorIdForAssetId.ContainsKey(assetId))
472 { 472 {
473 string xmlData = Utils.BytesToString(data); 473 string xmlData = Utils.BytesToString(data);
474 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); 474 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
475 foreach (SceneObjectPart sop in sog.Parts) 475
476 CoalescedSceneObjects coa = null;
477 if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
478 {
479// m_log.DebugFormat(
480// "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);
481
482 sceneObjects.AddRange(coa.Objects);
483 }
484 else
476 { 485 {
477 if (sop.CreatorData == null || sop.CreatorData == "") 486 sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData));
478 {
479 sop.CreatorID = m_creatorIdForAssetId[assetId];
480 }
481 } 487 }
482 488
483 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); 489 foreach (SceneObjectGroup sog in sceneObjects)
490 foreach (SceneObjectPart sop in sog.Parts)
491 if (sop.CreatorData == null || sop.CreatorData == "")
492 sop.CreatorID = m_creatorIdForAssetId[assetId];
493
494 if (coa != null)
495 data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
496 else
497 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0]));
484 } 498 }
485 } 499 }
486 500
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
index e5127a0..5ba08ee 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -68,17 +68,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), 68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr", 69 FirstName = "Mr",
70 LastName = "Tiddles" }; 70 LastName = "Tiddles" };
71
71 protected UserAccount m_uaLL1 72 protected UserAccount m_uaLL1
72 = new UserAccount { 73 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), 74 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord", 75 FirstName = "Lord",
75 LastName = "Lucan" }; 76 LastName = "Lucan" };
77
76 protected UserAccount m_uaLL2 78 protected UserAccount m_uaLL2
77 = new UserAccount { 79 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), 80 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord", 81 FirstName = "Lord",
80 LastName = "Lucan" }; 82 LastName = "Lucan" };
83
81 protected string m_item1Name = "Ray Gun Item"; 84 protected string m_item1Name = "Ray Gun Item";
85 protected string m_coaItemName = "Coalesced Item";
82 86
83 [SetUp] 87 [SetUp]
84 public virtual void SetUp() 88 public virtual void SetUp()
@@ -97,38 +101,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
97// log4net.Config.XmlConfigurator.Configure(); 101// log4net.Config.XmlConfigurator.Configure();
98 102
99 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 103 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
100 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 104 Scene scene = SceneSetupHelpers.SetupScene();
101 SceneSetupHelpers.SetupSceneModules(scene, archiverModule); 105 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
102 106
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); 107 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
104 108
105 MemoryStream archiveWriteStream = new MemoryStream(); 109 MemoryStream archiveWriteStream = new MemoryStream();
106 110
107 // Create asset 111 // Create scene object asset
108 SceneObjectGroup object1; 112 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
109 SceneObjectPart part1; 113 SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);
110 {
111 string partName = "Ray Gun Object";
112 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
113 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
114 Vector3 groupPosition = new Vector3(10, 20, 30);
115 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
116 Vector3 offsetPosition = new Vector3(5, 10, 15);
117
118 part1
119 = new SceneObjectPart(
120 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
121 part1.Name = partName;
122
123 object1 = new SceneObjectGroup(part1);
124 scene.AddNewSceneObject(object1, false);
125 }
126 114
127 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 115 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
128 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 116 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
129 scene.AssetService.Store(asset1); 117 scene.AssetService.Store(asset1);
130 118
131 // Create item 119 // Create scene object item
132 InventoryItemBase item1 = new InventoryItemBase(); 120 InventoryItemBase item1 = new InventoryItemBase();
133 item1.Name = m_item1Name; 121 item1.Name = m_item1Name;
134 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); 122 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
@@ -139,8 +127,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
139 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; 127 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
140 scene.AddInventoryItem(item1); 128 scene.AddInventoryItem(item1);
141 129
130 // Create coalesced objects asset
131 SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
132 cobj1.AbsolutePosition = new Vector3(15, 30, 45);
133
134 SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
135 cobj2.AbsolutePosition = new Vector3(25, 50, 75);
136
137 CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);
138
139 AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa);
140 scene.AssetService.Store(coaAsset);
141
142 // Create coalesced objects inventory item
143 InventoryItemBase coaItem = new InventoryItemBase();
144 coaItem.Name = m_coaItemName;
145 coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180");
146 coaItem.AssetID = coaAsset.FullID;
147 coaItem.GroupID = UUID.Random();
148 coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID;
149 coaItem.Owner = m_uaLL1.PrincipalID;
150 coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
151 scene.AddInventoryItem(coaItem);
152
142 archiverModule.ArchiveInventory( 153 archiverModule.ArchiveInventory(
143 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream); 154 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream);
144 155
145 m_iarStreamBytes = archiveWriteStream.ToArray(); 156 m_iarStreamBytes = archiveWriteStream.ToArray();
146 } 157 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 7f156f8..d03f6da 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -62,9 +62,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
62 SerialiserModule serialiserModule = new SerialiserModule(); 62 SerialiserModule serialiserModule = new SerialiserModule();
63 m_archiverModule = new InventoryArchiverModule(); 63 m_archiverModule = new InventoryArchiverModule();
64 64
65 m_scene = SceneSetupHelpers.SetupScene("Inventory"); 65 m_scene = SceneSetupHelpers.SetupScene();
66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); 66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
67 } 67 }
68
69 [Test]
70 public void TestLoadCoalesecedItem()
71 {
72 TestHelper.InMethod();
73// log4net.Config.XmlConfigurator.Configure();
74
75 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password");
76 m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);
77
78 InventoryItemBase coaItem
79 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
80
81 Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");
82
83 string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);
84
85 CoalescedSceneObjects coa;
86 bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);
87
88 Assert.That(readResult, Is.True);
89 Assert.That(coa.Count, Is.EqualTo(2));
90
91 List<SceneObjectGroup> coaObjects = coa.Objects;
92 Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
93 Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));
94
95 Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
96 Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
97 }
68 98
69 /// <summary> 99 /// <summary>
70 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive 100 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
@@ -84,24 +114,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
84 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); 114 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
85 115
86 // Create asset 116 // Create asset
87 SceneObjectGroup object1; 117 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
88 SceneObjectPart part1; 118 SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
89 {
90 string partName = "My Little Dog Object";
91 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
92 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
93 Vector3 groupPosition = new Vector3(10, 20, 30);
94 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
95 Vector3 offsetPosition = new Vector3(5, 10, 15);
96
97 part1
98 = new SceneObjectPart(
99 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
100 part1.Name = partName;
101
102 object1 = new SceneObjectGroup(part1);
103 m_scene.AddNewSceneObject(object1, false);
104 }
105 119
106 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 120 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
107 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 121 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
index 0e8f647..c7dae52 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
63 63
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65 65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 66 Scene scene = SceneSetupHelpers.SetupScene();
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule); 67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68 68
69 // Create user 69 // Create user
@@ -180,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
180 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 180 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
181 181
182 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 182 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
183 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 183 Scene scene = SceneSetupHelpers.SetupScene();
184 184
185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
186 186
@@ -223,7 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
223 223
224 SerialiserModule serialiserModule = new SerialiserModule(); 224 SerialiserModule serialiserModule = new SerialiserModule();
225 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 225 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
226 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 226 Scene scene = SceneSetupHelpers.SetupScene();
227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
228 228
229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password"); 229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
@@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
248 248
249 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 249 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
250 250
251 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 251 Scene scene = SceneSetupHelpers.SetupScene();
252 SceneSetupHelpers.SetupSceneModules(scene, archiverModule); 252 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
253 253
254 // Create user 254 // Create user
@@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
327 TestHelper.InMethod(); 327 TestHelper.InMethod();
328// log4net.Config.XmlConfigurator.Configure(); 328// log4net.Config.XmlConfigurator.Configure();
329 329
330 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 330 Scene scene = SceneSetupHelpers.SetupScene();
331 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); 331 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
332 332
333 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); 333 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
@@ -394,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
394 TestHelper.InMethod(); 394 TestHelper.InMethod();
395 //log4net.Config.XmlConfigurator.Configure(); 395 //log4net.Config.XmlConfigurator.Configure();
396 396
397 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 397 Scene scene = SceneSetupHelpers.SetupScene();
398 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); 398 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
399 399
400 string folder1ExistingName = "a"; 400 string folder1ExistingName = "a";
@@ -445,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
445 TestHelper.InMethod(); 445 TestHelper.InMethod();
446// log4net.Config.XmlConfigurator.Configure(); 446// log4net.Config.XmlConfigurator.Configure();
447 447
448 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 448 Scene scene = SceneSetupHelpers.SetupScene();
449 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); 449 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
450 450
451 string folder1ExistingName = "a"; 451 string folder1ExistingName = "a";
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 73b0a35..5d19025 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
222 deletes[g.OwnerID].Add(g); 222 deletes[g.OwnerID].Add(g);
223 } 223 }
224 224
225 // This is pethod scoped and will be returned. It will be the 225 // This is method scoped and will be returned. It will be the
226 // last created asset id 226 // last created asset id
227 UUID assetID = UUID.Zero; 227 UUID assetID = UUID.Zero;
228 228
@@ -230,8 +230,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
230 // with distinct destinations as well. 230 // with distinct destinations as well.
231 foreach (List<SceneObjectGroup> objlist in deletes.Values) 231 foreach (List<SceneObjectGroup> objlist in deletes.Values)
232 { 232 {
233 Dictionary<UUID, string> xmlStrings = 233 CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
234 new Dictionary<UUID, string>(); 234 Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
235 235
236 foreach (SceneObjectGroup objectGroup in objlist) 236 foreach (SceneObjectGroup objectGroup in objlist)
237 { 237 {
@@ -245,7 +245,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
245 : objectGroup.AbsolutePosition.X, 245 : objectGroup.AbsolutePosition.X,
246 objectGroup.AbsolutePosition.Z); 246 objectGroup.AbsolutePosition.Z);
247 247
248 Vector3 originalPosition = objectGroup.AbsolutePosition; 248 originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
249 249
250 objectGroup.AbsolutePosition = inventoryStoredPosition; 250 objectGroup.AbsolutePosition = inventoryStoredPosition;
251 251
@@ -259,209 +259,37 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
259 (uint)PermissionMask.Modify); 259 (uint)PermissionMask.Modify);
260 objectGroup.RootPart.NextOwnerMask |= 260 objectGroup.RootPart.NextOwnerMask |=
261 (uint)PermissionMask.Move; 261 (uint)PermissionMask.Move;
262 262
263 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 263 coa.Add(objectGroup);
264
265 objectGroup.AbsolutePosition = originalPosition;
266
267 xmlStrings[objectGroup.UUID] = sceneObjectXml;
268 } 264 }
269 265
270 string itemXml; 266 string itemXml;
271 267
272 if (objlist.Count > 1) 268 if (objlist.Count > 1)
273 { 269 itemXml = CoalescedSceneObjectsSerializer.ToXml(coa);
274 float minX, minY, minZ;
275 float maxX, maxY, maxZ;
276
277 Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
278 out minX, out maxX, out minY, out maxY,
279 out minZ, out maxZ);
280
281 // CreateWrapper
282 XmlDocument itemDoc = new XmlDocument();
283 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
284 itemDoc.AppendChild(root);
285
286 // Embed the offsets into the group XML
287 for ( int i = 0 ; i < objlist.Count ; i++ )
288 {
289 XmlDocument doc = new XmlDocument();
290 SceneObjectGroup g = objlist[i];
291 doc.LoadXml(xmlStrings[g.UUID]);
292 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
293 e.SetAttribute("offsetx", offsets[i].X.ToString());
294 e.SetAttribute("offsety", offsets[i].Y.ToString());
295 e.SetAttribute("offsetz", offsets[i].Z.ToString());
296
297 XmlNode objectNode = itemDoc.ImportNode(e, true);
298 root.AppendChild(objectNode);
299 }
300
301 float sizeX = maxX - minX;
302 float sizeY = maxY - minY;
303 float sizeZ = maxZ - minZ;
304
305 root.SetAttribute("x", sizeX.ToString());
306 root.SetAttribute("y", sizeY.ToString());
307 root.SetAttribute("z", sizeZ.ToString());
308
309 itemXml = itemDoc.InnerXml;
310 }
311 else 270 else
312 { 271 itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]);
313 itemXml = xmlStrings[objlist[0].UUID]; 272
314 } 273 // Restore the position of each group now that it has been stored to inventory.
315 274 foreach (SceneObjectGroup objectGroup in objlist)
316 // Get the user info of the item destination 275 objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
317 //
318 UUID userID = UUID.Zero;
319
320 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
321 action == DeRezAction.SaveToExistingUserInventoryItem)
322 {
323 // Take or take copy require a taker
324 // Saving changes requires a local user
325 //
326 if (remoteClient == null)
327 return UUID.Zero;
328
329 userID = remoteClient.AgentId;
330 }
331 else
332 {
333 // All returns / deletes go to the object owner
334 //
335
336 userID = objlist[0].RootPart.OwnerID;
337 }
338 276
339 if (userID == UUID.Zero) // Can't proceed 277 InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
340 { 278 if (item == null)
341 return UUID.Zero; 279 return UUID.Zero;
342 } 280
343 281 // Can't know creator is the same, so null it in inventory
344 // If we're returning someone's item, it goes back to the 282 if (objlist.Count > 1)
345 // owner's Lost And Found folder.
346 // Delete is treated like return in this case
347 // Deleting your own items makes them go to trash
348 //
349
350 InventoryFolderBase folder = null;
351 InventoryItemBase item = null;
352
353 if (DeRezAction.SaveToExistingUserInventoryItem == action)
354 { 283 {
355 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); 284 item.CreatorId = UUID.Zero.ToString();
356 item = m_Scene.InventoryService.GetItem(item); 285 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
357
358 //item = userInfo.RootFolder.FindItem(
359 // objectGroup.RootPart.FromUserInventoryItemID);
360
361 if (null == item)
362 {
363 m_log.DebugFormat(
364 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
365 objlist[0].Name, objlist[0].UUID);
366 return UUID.Zero;
367 }
368 } 286 }
369 else 287 else
370 { 288 {
371 // Folder magic 289 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
372 // 290 item.SaleType = objlist[0].RootPart.ObjectSaleType;
373 if (action == DeRezAction.Delete) 291 item.SalePrice = objlist[0].RootPart.SalePrice;
374 { 292 }
375 // Deleting someone else's item
376 //
377 if (remoteClient == null ||
378 objlist[0].OwnerID != remoteClient.AgentId)
379 {
380
381 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
382 }
383 else
384 {
385 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
386 }
387 }
388 else if (action == DeRezAction.Return)
389 {
390
391 // Dump to lost + found unconditionally
392 //
393 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
394 }
395
396 if (folderID == UUID.Zero && folder == null)
397 {
398 if (action == DeRezAction.Delete)
399 {
400 // Deletes go to trash by default
401 //
402 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
403 }
404 else
405 {
406 if (remoteClient == null ||
407 objlist[0].OwnerID != remoteClient.AgentId)
408 {
409 // Taking copy of another person's item. Take to
410 // Objects folder.
411 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
412 }
413 else
414 {
415 // Catch all. Use lost & found
416 //
417
418 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
419 }
420 }
421 }
422
423 // Override and put into where it came from, if it came
424 // from anywhere in inventory
425 //
426 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
427 {
428 if (objlist[0].RootPart.FromFolderID != UUID.Zero)
429 {
430 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
431 folder = m_Scene.InventoryService.GetFolder(f);
432 }
433 }
434
435 if (folder == null) // None of the above
436 {
437 folder = new InventoryFolderBase(folderID);
438
439 if (folder == null) // Nowhere to put it
440 {
441 return UUID.Zero;
442 }
443 }
444
445 item = new InventoryItemBase();
446 // Can't know creator is the same, so null it in inventory
447 if (objlist.Count > 1)
448 item.CreatorId = UUID.Zero.ToString();
449 else
450 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
451 item.ID = UUID.Random();
452 item.InvType = (int)InventoryType.Object;
453 item.Folder = folder.ID;
454 item.Owner = userID;
455 if (objlist.Count > 1)
456 {
457 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
458 }
459 else
460 {
461 item.SaleType = objlist[0].RootPart.ObjectSaleType;
462 item.SalePrice = objlist[0].RootPart.SalePrice;
463 }
464 }
465 293
466 AssetBase asset = CreateAsset( 294 AssetBase asset = CreateAsset(
467 objlist[0].GetPartName(objlist[0].RootPart.LocalId), 295 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
@@ -470,17 +298,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
470 Utils.StringToBytes(itemXml), 298 Utils.StringToBytes(itemXml),
471 objlist[0].OwnerID.ToString()); 299 objlist[0].OwnerID.ToString());
472 m_Scene.AssetService.Store(asset); 300 m_Scene.AssetService.Store(asset);
473 assetID = asset.FullID; 301
302 item.AssetID = asset.FullID;
303 assetID = asset.FullID;
474 304
475 if (DeRezAction.SaveToExistingUserInventoryItem == action) 305 if (DeRezAction.SaveToExistingUserInventoryItem == action)
476 { 306 {
477 item.AssetID = asset.FullID;
478 m_Scene.InventoryService.UpdateItem(item); 307 m_Scene.InventoryService.UpdateItem(item);
479 } 308 }
480 else 309 else
481 { 310 {
482 item.AssetID = asset.FullID;
483
484 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; 311 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
485 foreach (SceneObjectGroup grp in objlist) 312 foreach (SceneObjectGroup grp in objlist)
486 effectivePerms &= grp.GetEffectivePermissions(); 313 effectivePerms &= grp.GetEffectivePermissions();
@@ -545,9 +372,156 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
545 } 372 }
546 } 373 }
547 } 374 }
375
548 return assetID; 376 return assetID;
549 } 377 }
378
379 /// <summary>
380 /// Create an item using details for the given scene object.
381 /// </summary>
382 /// <param name="action"></param>
383 /// <param name="remoteClient"></param>
384 /// <param name="so"></param>
385 /// <param name="folderID"></param>
386 /// <returns></returns>
387 protected InventoryItemBase CreateItemForObject(
388 DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID)
389 {
390 // Get the user info of the item destination
391 //
392 UUID userID = UUID.Zero;
393
394 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
395 action == DeRezAction.SaveToExistingUserInventoryItem)
396 {
397 // Take or take copy require a taker
398 // Saving changes requires a local user
399 //
400 if (remoteClient == null)
401 return null;
402
403 userID = remoteClient.AgentId;
404 }
405 else
406 {
407 // All returns / deletes go to the object owner
408 //
409 userID = so.RootPart.OwnerID;
410 }
411
412 if (userID == UUID.Zero) // Can't proceed
413 {
414 return null;
415 }
416
417 // If we're returning someone's item, it goes back to the
418 // owner's Lost And Found folder.
419 // Delete is treated like return in this case
420 // Deleting your own items makes them go to trash
421 //
422
423 InventoryFolderBase folder = null;
424 InventoryItemBase item = null;
425
426 if (DeRezAction.SaveToExistingUserInventoryItem == action)
427 {
428 item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID);
429 item = m_Scene.InventoryService.GetItem(item);
430
431 //item = userInfo.RootFolder.FindItem(
432 // objectGroup.RootPart.FromUserInventoryItemID);
433
434 if (null == item)
435 {
436 m_log.DebugFormat(
437 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
438 so.Name, so.UUID);
439
440 return null;
441 }
442 }
443 else
444 {
445 // Folder magic
446 //
447 if (action == DeRezAction.Delete)
448 {
449 // Deleting someone else's item
450 //
451 if (remoteClient == null ||
452 so.OwnerID != remoteClient.AgentId)
453 {
454 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
455 }
456 else
457 {
458 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
459 }
460 }
461 else if (action == DeRezAction.Return)
462 {
463 // Dump to lost + found unconditionally
464 //
465 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
466 }
550 467
468 if (folderID == UUID.Zero && folder == null)
469 {
470 if (action == DeRezAction.Delete)
471 {
472 // Deletes go to trash by default
473 //
474 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
475 }
476 else
477 {
478 if (remoteClient == null || so.OwnerID != remoteClient.AgentId)
479 {
480 // Taking copy of another person's item. Take to
481 // Objects folder.
482 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
483 }
484 else
485 {
486 // Catch all. Use lost & found
487 //
488
489 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
490 }
491 }
492 }
493
494 // Override and put into where it came from, if it came
495 // from anywhere in inventory
496 //
497 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
498 {
499 if (so.RootPart.FromFolderID != UUID.Zero)
500 {
501 InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID);
502 folder = m_Scene.InventoryService.GetFolder(f);
503 }
504 }
505
506 if (folder == null) // None of the above
507 {
508 folder = new InventoryFolderBase(folderID);
509
510 if (folder == null) // Nowhere to put it
511 {
512 return null;
513 }
514 }
515
516 item = new InventoryItemBase();
517 item.ID = UUID.Random();
518 item.InvType = (int)InventoryType.Object;
519 item.Folder = folder.ID;
520 item.Owner = userID;
521 }
522
523 return item;
524 }
551 525
552 /// <summary> 526 /// <summary>
553 /// Rez an object into the scene from the user's inventory 527 /// Rez an object into the scene from the user's inventory
@@ -659,9 +633,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
659 itemId, n.OuterXml); 633 itemId, n.OuterXml);
660 objlist.Add(g); 634 objlist.Add(g);
661 XmlElement el = (XmlElement)n; 635 XmlElement el = (XmlElement)n;
662 float x = Convert.ToSingle(el.GetAttribute("offsetx")); 636
663 float y = Convert.ToSingle(el.GetAttribute("offsety")); 637 string rawX = el.GetAttribute("offsetx");
664 float z = Convert.ToSingle(el.GetAttribute("offsetz")); 638 string rawY = el.GetAttribute("offsety");
639 string rawZ = el.GetAttribute("offsetz");
640//
641// m_log.DebugFormat(
642// "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>",
643// g.Name, rawX, rawY, rawZ);
644
645 float x = Convert.ToSingle(rawX);
646 float y = Convert.ToSingle(rawY);
647 float z = Convert.ToSingle(rawZ);
665 veclist.Add(new Vector3(x, y, z)); 648 veclist.Add(new Vector3(x, y, z));
666 } 649 }
667 } 650 }
@@ -753,10 +736,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
753 // affect the name stored in the serialization, transfer 736 // affect the name stored in the serialization, transfer
754 // the correct name from the inventory to the 737 // the correct name from the inventory to the
755 // object itself before we rez. 738 // object itself before we rez.
756 rootPart.Name = item.Name; 739 //
757 rootPart.Description = item.Description; 740 // Only do these for the first object if we are rezzing a coalescence.
758 rootPart.ObjectSaleType = item.SaleType; 741 if (i == 0)
759 rootPart.SalePrice = item.SalePrice; 742 {
743 rootPart.Name = item.Name;
744 rootPart.Description = item.Description;
745 rootPart.ObjectSaleType = item.SaleType;
746 rootPart.SalePrice = item.SalePrice;
747 }
760 748
761 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 749 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
762 if ((rootPart.OwnerID != item.Owner) || 750 if ((rootPart.OwnerID != item.Owner) ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
new file mode 100644
index 0000000..8d53cf1
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
@@ -0,0 +1,174 @@
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
42using OpenSim.Region.CoreModules.Framework.InventoryAccess;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48using OpenSim.Tests.Common.Setup;
49
50namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
51{
52 [TestFixture]
53 public class InventoryAccessModuleTests
54 {
55 protected TestScene m_scene;
56 protected BasicInventoryAccessModule m_iam;
57 protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
58 protected TestClient m_tc;
59
60 [SetUp]
61 public void SetUp()
62 {
63 m_iam = new BasicInventoryAccessModule();
64
65 IConfigSource config = new IniConfigSource();
66 config.AddConfig("Modules");
67 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
68
69 m_scene = SceneSetupHelpers.SetupScene();
70 SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam);
71
72 // Create user
73 string userFirstName = "Jock";
74 string userLastName = "Stirrup";
75 string userPassword = "troll";
76 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword);
77
78 AgentCircuitData acd = new AgentCircuitData();
79 acd.AgentID = m_userId;
80 m_tc = new TestClient(acd, m_scene);
81 }
82
83 [Test]
84 public void TestRezCoalescedObject()
85 {
86 TestHelper.InMethod();
87// log4net.Config.XmlConfigurator.Configure();
88
89 // Create asset
90 SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
91 object1.AbsolutePosition = new Vector3(15, 30, 45);
92
93 SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
94 object2.AbsolutePosition = new Vector3(25, 50, 75);
95
96 CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
97
98 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
99 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa);
100 m_scene.AssetService.Store(asset1);
101
102 // Create item
103 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
104 string item1Name = "My Little Dog";
105 InventoryItemBase item1 = new InventoryItemBase();
106 item1.Name = item1Name;
107 item1.AssetID = asset1.FullID;
108 item1.ID = item1Id;
109 InventoryFolderBase objsFolder
110 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
111 item1.Folder = objsFolder.ID;
112 m_scene.AddInventoryItem(item1);
113
114 SceneObjectGroup so
115 = m_iam.RezObject(
116 m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
117
118 Assert.That(so, Is.Not.Null);
119
120 Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2));
121
122 SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name);
123 Assert.That(retrievedObj1Part, Is.Null);
124
125 retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name);
126 Assert.That(retrievedObj1Part, Is.Not.Null);
127 Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name));
128
129 // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom
130 // object is unit square.
131 Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f)));
132
133 SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name);
134 Assert.That(retrievedObj2Part, Is.Not.Null);
135 Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name));
136 Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f)));
137 }
138
139 [Test]
140 public void TestRezObject()
141 {
142 TestHelper.InMethod();
143// log4net.Config.XmlConfigurator.Configure();
144
145 // Create asset
146 SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40);
147
148 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
149 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
150 m_scene.AssetService.Store(asset1);
151
152 // Create item
153 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
154 string item1Name = "My Little Dog";
155 InventoryItemBase item1 = new InventoryItemBase();
156 item1.Name = item1Name;
157 item1.AssetID = asset1.FullID;
158 item1.ID = item1Id;
159 InventoryFolderBase objsFolder
160 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
161 item1.Folder = objsFolder.ID;
162 m_scene.AddInventoryItem(item1);
163
164 SceneObjectGroup so
165 = m_iam.RezObject(
166 m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
167
168 Assert.That(so, Is.Not.Null);
169
170 SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID);
171 Assert.That(retrievedPart, Is.Not.Null);
172 }
173 }
174} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
index e25700d..422f394 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
index 02acddc..2b5beba 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
index 6d975af..f29c074 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index 2f96bcb..d2343c9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
index 209cf0d..53a8ace 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
@@ -31,9 +31,8 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base; 37using OpenSim.Server.Handlers.Base;
39 38
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
index fcc69e9..fc64203 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
index 2a9366c..f759470 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
index 35518d5..5c32632 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
index 5ee1c97..86b4926 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 36using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 1b3419d..51d1d59 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -195,6 +195,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
195 195
196 public byte[] GetData(string id) 196 public byte[] GetData(string id)
197 { 197 {
198// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Requesting data for asset {0}", id);
199
198 AssetBase asset = m_Cache.Get(id); 200 AssetBase asset = m_Cache.Get(id);
199 201
200 if (asset != null) 202 if (asset != null)
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index b6d64ac..ab90e90 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -259,6 +259,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
259 259
260 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) 260 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
261 { 261 {
262// m_log.DebugFormat(
263// "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
264// remoteClient.Name, estateCovenantID);
265
262 Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; 266 Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
263 Scene.RegionInfo.RegionSettings.Save(); 267 Scene.RegionInfo.RegionSettings.Save();
264 TriggerRegionInfoChange(); 268 TriggerRegionInfoChange();
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index dafaa0c..a866fd9 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
237 public void Init() 237 public void Init()
238 { 238 {
239 m_serialiserModule = new SerialiserModule(); 239 m_serialiserModule = new SerialiserModule();
240 m_scene = SceneSetupHelpers.SetupScene(""); 240 m_scene = SceneSetupHelpers.SetupScene();
241 SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); 241 SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
242 } 242 }
243 243
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index d6fa093..21a9999 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -124,6 +124,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
124 colours.Save(stream, ImageFormat.Png); 124 colours.Save(stream, ImageFormat.Png);
125 } 125 }
126 126
127 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
128 int offsetX, int offsetY,
129 int fileWidth, int fileHeight,
130 int regionSizeX, int regionSizeY)
131
132 {
133 // We need to do this because:
134 // "Saving the image to the same file it was constructed from is not allowed and throws an exception."
135 string tempName = offsetX + "_ " + offsetY + "_" + filename;
136
137 Bitmap entireBitmap = null;
138 Bitmap thisBitmap = null;
139 if (File.Exists(filename))
140 {
141 File.Copy(filename, tempName);
142 entireBitmap = new Bitmap(tempName);
143 if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY)
144 {
145 // old file, let's overwrite it
146 entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
147 }
148 }
149 else
150 {
151 entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
152 }
153
154 thisBitmap = CreateGrayscaleBitmapFromMap(m_channel);
155 Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY);
156 for (int x = 0; x < regionSizeX; x++)
157 for (int y = 0; y < regionSizeY; y++)
158 entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y));
159
160 Save(entireBitmap, filename);
161 thisBitmap.Dispose();
162 entireBitmap.Dispose();
163
164 if (File.Exists(tempName))
165 File.Delete(tempName);
166 }
167
168 protected virtual void Save(Bitmap bmp, string filename)
169 {
170 bmp.Save(filename, ImageFormat.Png);
171 }
172
127 #endregion 173 #endregion
128 174
129 public override string ToString() 175 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
index 8667607..1a0d8ec 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
@@ -76,6 +76,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
76 colours.Save(stream, ImageFormat.Jpeg); 76 colours.Save(stream, ImageFormat.Jpeg);
77 } 77 }
78 78
79 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
80 int offsetX, int offsetY,
81 int fileWidth, int fileHeight,
82 int regionSizeX, int regionSizeY)
83 {
84 throw new System.Exception("Not Implemented");
85 }
86
79 #endregion 87 #endregion
80 88
81 public override string ToString() 89 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs
index a70ef13..fad7641 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs
@@ -240,6 +240,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
240 get { return ".raw"; } 240 get { return ".raw"; }
241 } 241 }
242 242
243 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
244 int offsetX, int offsetY,
245 int fileWidth, int fileHeight,
246 int regionSizeX, int regionSizeY)
247 {
248 throw new System.Exception("Not Implemented");
249 }
250
243 #endregion 251 #endregion
244 252
245 public override string ToString() 253 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
index 3c76665..ba073ca 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
@@ -160,6 +160,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
160 bs.Close(); 160 bs.Close();
161 } 161 }
162 162
163 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
164 int offsetX, int offsetY,
165 int fileWidth, int fileHeight,
166 int regionSizeX, int regionSizeY)
167 {
168 throw new System.Exception("Not Implemented");
169 }
163 #endregion 170 #endregion
164 171
165 public override string ToString() 172 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
index 2919897..2f37d9d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
@@ -308,6 +308,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
308 get { return ".ter"; } 308 get { return ".ter"; }
309 } 309 }
310 310
311 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
312 int offsetX, int offsetY,
313 int fileWidth, int fileHeight,
314 int regionSizeX, int regionSizeY)
315 {
316 throw new System.Exception("Not Implemented");
317 }
318
311 #endregion 319 #endregion
312 320
313 public override string ToString() 321 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs
index 7403281..7237f90 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs
@@ -38,5 +38,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
38 ITerrainChannel LoadStream(Stream stream); 38 ITerrainChannel LoadStream(Stream stream);
39 void SaveFile(string filename, ITerrainChannel map); 39 void SaveFile(string filename, ITerrainChannel map);
40 void SaveStream(Stream stream, ITerrainChannel map); 40 void SaveStream(Stream stream, ITerrainChannel map);
41 void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY);
41 } 42 }
42} \ No newline at end of file 43} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 8a79d78..9c7b2fa 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -541,6 +541,39 @@ namespace OpenSim.Region.CoreModules.World.Terrain
541 } 541 }
542 542
543 /// <summary> 543 /// <summary>
544 /// Saves the terrain to a larger terrain file.
545 /// </summary>
546 /// <param name="filename">The terrain file to save</param>
547 /// <param name="fileWidth">The width of the file in units</param>
548 /// <param name="fileHeight">The height of the file in units</param>
549 /// <param name="fileStartX">Where to begin our slice</param>
550 /// <param name="fileStartY">Where to begin our slice</param>
551 public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
552 {
553 int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX;
554 int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY;
555
556 if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight)
557 {
558 // this region is included in the tile request
559 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
560 {
561 if (filename.EndsWith(loader.Key))
562 {
563 lock (m_scene)
564 {
565 loader.Value.SaveFile(m_channel, filename, offsetX, offsetY,
566 fileWidth, fileHeight,
567 (int)Constants.RegionSize,
568 (int)Constants.RegionSize);
569 }
570 return;
571 }
572 }
573 }
574 }
575
576 /// <summary>
544 /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections 577 /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections
545 /// </summary> 578 /// </summary>
546 private void EventManager_OnTerrainTick() 579 private void EventManager_OnTerrainTick()
@@ -860,6 +893,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
860 SaveToFile((string) args[0]); 893 SaveToFile((string) args[0]);
861 } 894 }
862 895
896 private void InterfaceSaveTileFile(Object[] args)
897 {
898 SaveToFile((string)args[0],
899 (int)args[1],
900 (int)args[2],
901 (int)args[3],
902 (int)args[4]);
903 }
904
863 private void InterfaceBakeTerrain(Object[] args) 905 private void InterfaceBakeTerrain(Object[] args)
864 { 906 {
865 UpdateRevertMap(); 907 UpdateRevertMap();
@@ -1115,6 +1157,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1115 loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", 1157 loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
1116 "Integer"); 1158 "Integer");
1117 1159
1160 Command saveToTileCommand =
1161 new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file.");
1162 saveToTileCommand.AddArgument("filename",
1163 "The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " +
1164 supportedFileExtensions, "String");
1165 saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
1166 saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
1167 saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
1168 "Integer");
1169 saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
1170 "Integer");
1118 // Terrain adjustments 1171 // Terrain adjustments
1119 Command fillRegionCommand = 1172 Command fillRegionCommand =
1120 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); 1173 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
@@ -1166,6 +1219,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1166 m_commander.RegisterCommand("load", loadFromFileCommand); 1219 m_commander.RegisterCommand("load", loadFromFileCommand);
1167 m_commander.RegisterCommand("load-tile", loadFromTileCommand); 1220 m_commander.RegisterCommand("load-tile", loadFromTileCommand);
1168 m_commander.RegisterCommand("save", saveToFileCommand); 1221 m_commander.RegisterCommand("save", saveToFileCommand);
1222 m_commander.RegisterCommand("save-tile", saveToTileCommand);
1169 m_commander.RegisterCommand("fill", fillRegionCommand); 1223 m_commander.RegisterCommand("fill", fillRegionCommand);
1170 m_commander.RegisterCommand("elevate", elevateCommand); 1224 m_commander.RegisterCommand("elevate", elevateCommand);
1171 m_commander.RegisterCommand("lower", lowerCommand); 1225 m_commander.RegisterCommand("lower", lowerCommand);