Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor

This commit is contained in:
Melanie
2011-04-17 18:42:06 +02:00
74 changed files with 1426 additions and 1079 deletions

View File

@@ -54,6 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
private Scene m_scene;
private IAssetService m_assetService;
private bool m_enabled = true;
#region IRegionModuleBase Members
@@ -65,7 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
public void Initialise(IConfigSource source)
{
IConfig startupConfig = source.Configs["Startup"];
if (startupConfig == null)
return;
if (!startupConfig.GetBoolean("ColladaMesh",true))
m_enabled = false;
}
public void AddRegion(Scene pScene)
@@ -101,16 +107,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
public void RegisterCaps(UUID agentID, Caps caps)
{
if(!m_enabled)
return;
UUID capID = UUID.Random();
// m_log.Info("[GETMESH]: /CAPS/" + capID);
caps.RegisterHandler("GetMesh",
new RestHTTPHandler("GET", "/CAPS/" + capID,
delegate(Hashtable m_dhttpMethod)
{
return ProcessGetMesh(m_dhttpMethod, agentID, caps);
}));
}
#endregion

View File

@@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
private Scene m_scene;
// private IAssetService m_assetService;
private bool m_dumpAssetsToFile = false;
private bool m_enabled = true;
#region IRegionModuleBase Members
@@ -67,7 +68,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
public void Initialise(IConfigSource source)
{
IConfig startupConfig = source.Configs["Startup"];
if (startupConfig == null)
return;
if (!startupConfig.GetBoolean("ColladaMesh",true))
m_enabled = false;
}
public void AddRegion(Scene pScene)
@@ -103,6 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets
public void RegisterCaps(UUID agentID, Caps caps)
{
if(!m_enabled)
return;
UUID capID = UUID.Random();
// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID);

View File

@@ -34,13 +34,13 @@ using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Friends;
using OpenSim.Server.Base;
using OpenSim.Framework.Servers.HttpServer;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;

View File

@@ -33,7 +33,6 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;

View File

@@ -466,16 +466,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (m_creatorIdForAssetId.ContainsKey(assetId))
{
string xmlData = Utils.BytesToString(data);
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
foreach (SceneObjectPart sop in sog.Parts)
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
CoalescedSceneObjects coa = null;
if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
{
if (sop.CreatorData == null || sop.CreatorData == "")
{
sop.CreatorID = m_creatorIdForAssetId[assetId];
}
// m_log.DebugFormat(
// "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);
sceneObjects.AddRange(coa.Objects);
}
else
{
sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData));
}
data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
foreach (SceneObjectGroup sog in sceneObjects)
foreach (SceneObjectPart sop in sog.Parts)
if (sop.CreatorData == null || sop.CreatorData == "")
sop.CreatorID = m_creatorIdForAssetId[assetId];
if (coa != null)
data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
else
data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0]));
}
}

View File

@@ -68,17 +68,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
FirstName = "Mr",
LastName = "Tiddles" };
protected UserAccount m_uaLL1
= new UserAccount {
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
FirstName = "Lord",
LastName = "Lucan" };
protected UserAccount m_uaLL2
= new UserAccount {
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
FirstName = "Lord",
LastName = "Lucan" };
LastName = "Lucan" };
protected string m_item1Name = "Ray Gun Item";
protected string m_coaItemName = "Coalesced Item";
[SetUp]
public virtual void SetUp()
@@ -97,38 +101,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// log4net.Config.XmlConfigurator.Configure();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
MemoryStream archiveWriteStream = new MemoryStream();
// Create asset
SceneObjectGroup object1;
SceneObjectPart part1;
{
string partName = "Ray Gun Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
scene.AddNewSceneObject(object1, false);
}
// Create scene object asset
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
scene.AssetService.Store(asset1);
// Create item
// Create scene object item
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = m_item1Name;
item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
@@ -139,8 +127,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
scene.AddInventoryItem(item1);
// Create coalesced objects asset
SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
cobj1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
cobj2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);
AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa);
scene.AssetService.Store(coaAsset);
// Create coalesced objects inventory item
InventoryItemBase coaItem = new InventoryItemBase();
coaItem.Name = m_coaItemName;
coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180");
coaItem.AssetID = coaAsset.FullID;
coaItem.GroupID = UUID.Random();
coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID;
coaItem.Owner = m_uaLL1.PrincipalID;
coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
scene.AddInventoryItem(coaItem);
archiverModule.ArchiveInventory(
Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream);
m_iarStreamBytes = archiveWriteStream.ToArray();
}

View File

@@ -62,9 +62,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
m_archiverModule = new InventoryArchiverModule();
m_scene = SceneSetupHelpers.SetupScene("Inventory");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
}
[Test]
public void TestLoadCoalesecedItem()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password");
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);
InventoryItemBase coaItem
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");
string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);
CoalescedSceneObjects coa;
bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);
Assert.That(readResult, Is.True);
Assert.That(coa.Count, Is.EqualTo(2));
List<SceneObjectGroup> coaObjects = coa.Objects;
Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));
Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
}
/// <summary>
/// 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
UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
// Create asset
SceneObjectGroup object1;
SceneObjectPart part1;
{
string partName = "My Little Dog Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
m_scene.AddNewSceneObject(object1, false);
}
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);

View File

@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
// Create user
@@ -180,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
@@ -223,7 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
@@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
// Create user
@@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
@@ -394,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
string folder1ExistingName = "a";
@@ -445,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
string folder1ExistingName = "a";

View File

@@ -129,35 +129,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
///
/// DeleteToInventory
/// Used in DeleteToInventory
///
public override UUID DeleteToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
protected override void ExportAsset(UUID agentID, UUID assetID)
{
UUID ret = UUID.Zero;
// HACK: Only works for lists of length one.
// Intermediate version, just to make things compile
foreach (SceneObjectGroup g in objectGroups)
ret = DeleteToInventory(action, folderID, g, remoteClient);
return ret;
}
// DO NOT OVERRIDE THE BASE METHOD
public new virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient)
{
UUID assetID = base.DeleteToInventory(action, folderID, new List<SceneObjectGroup>() {objectGroup}, remoteClient);
if (!assetID.Equals(UUID.Zero))
{
if (remoteClient != null)
UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
}
UploadInventoryItem(agentID, assetID, "", 0);
else
m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
return assetID;
}
///

View File

@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
float minX, minY, minZ;
float maxX, maxY, maxZ;
Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist,
out minX, out maxX, out minY, out maxY,
out minZ, out maxZ);
@@ -785,8 +785,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// affect the name stored in the serialization, transfer
// the correct name from the inventory to the
// object itself before we rez.
// On coalesced objects, this has no effect.
if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
// On coalesced objects, do the first one
if (((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) || i == 0)
{
rootPart.Name = item.Name;
rootPart.Description = item.Description;
@@ -984,5 +984,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
#endregion
protected virtual void ExportAsset(UUID agentID, UUID assetID)
{
}
}
}

View File

@@ -0,0 +1,174 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
using OpenSim.Framework.Communications;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
{
[TestFixture]
public class InventoryAccessModuleTests
{
protected TestScene m_scene;
protected BasicInventoryAccessModule m_iam;
protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
protected TestClient m_tc;
[SetUp]
public void SetUp()
{
m_iam = new BasicInventoryAccessModule();
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam);
// Create user
string userFirstName = "Jock";
string userLastName = "Stirrup";
string userPassword = "troll";
UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = m_userId;
m_tc = new TestClient(acd, m_scene);
}
[Test]
public void TestRezCoalescedObject()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
object1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
object2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa);
m_scene.AssetService.Store(asset1);
// Create item
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
string item1Name = "My Little Dog";
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = item1Name;
item1.AssetID = asset1.FullID;
item1.ID = item1Id;
InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
item1.Folder = objsFolder.ID;
m_scene.AddInventoryItem(item1);
SceneObjectGroup so
= m_iam.RezObject(
m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
Assert.That(so, Is.Not.Null);
Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2));
SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name);
Assert.That(retrievedObj1Part, Is.Null);
retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name);
Assert.That(retrievedObj1Part, Is.Not.Null);
Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name));
// Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom
// object is unit square.
Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f)));
SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name);
Assert.That(retrievedObj2Part, Is.Not.Null);
Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name));
Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f)));
}
[Test]
public void TestRezObject()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
m_scene.AssetService.Store(asset1);
// Create item
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
string item1Name = "My Little Dog";
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = item1Name;
item1.AssetID = asset1.FullID;
item1.ID = item1Id;
InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
item1.Folder = objsFolder.ID;
m_scene.AddInventoryItem(item1);
SceneObjectGroup so
= m_iam.RezObject(
m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
Assert.That(so, Is.Not.Null);
SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID);
Assert.That(retrievedPart, Is.Not.Null);
}
}
}

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,9 +31,8 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;

View File

@@ -195,6 +195,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
public byte[] GetData(string id)
{
// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Requesting data for asset {0}", id);
AssetBase asset = m_Cache.Get(id);
if (asset != null)

View File

@@ -261,6 +261,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
{
// m_log.DebugFormat(
// "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
// remoteClient.Name, estateCovenantID);
Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
Scene.RegionInfo.RegionSettings.Save();
TriggerRegionInfoChange();

View File

@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
public void Init()
{
m_serialiserModule = new SerialiserModule();
m_scene = SceneSetupHelpers.SetupScene("");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
}

View File

@@ -124,6 +124,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
colours.Save(stream, ImageFormat.Png);
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
// We need to do this because:
// "Saving the image to the same file it was constructed from is not allowed and throws an exception."
string tempName = offsetX + "_ " + offsetY + "_" + filename;
Bitmap entireBitmap = null;
Bitmap thisBitmap = null;
if (File.Exists(filename))
{
File.Copy(filename, tempName);
entireBitmap = new Bitmap(tempName);
if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY)
{
// old file, let's overwrite it
entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
}
}
else
{
entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY);
}
thisBitmap = CreateGrayscaleBitmapFromMap(m_channel);
Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY);
for (int x = 0; x < regionSizeX; x++)
for (int y = 0; y < regionSizeY; y++)
entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y));
Save(entireBitmap, filename);
thisBitmap.Dispose();
entireBitmap.Dispose();
if (File.Exists(tempName))
File.Delete(tempName);
}
protected virtual void Save(Bitmap bmp, string filename)
{
bmp.Save(filename, ImageFormat.Png);
}
#endregion
public override string ToString()

View File

@@ -76,6 +76,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
colours.Save(stream, ImageFormat.Jpeg);
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
throw new System.Exception("Not Implemented");
}
#endregion
public override string ToString()

View File

@@ -240,6 +240,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
get { return ".raw"; }
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
throw new System.Exception("Not Implemented");
}
#endregion
public override string ToString()

View File

@@ -160,6 +160,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
bs.Close();
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
throw new System.Exception("Not Implemented");
}
#endregion
public override string ToString()

View File

@@ -308,6 +308,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
get { return ".ter"; }
}
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
throw new System.Exception("Not Implemented");
}
#endregion
public override string ToString()

View File

@@ -38,5 +38,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
ITerrainChannel LoadStream(Stream stream);
void SaveFile(string filename, ITerrainChannel map);
void SaveStream(Stream stream, ITerrainChannel map);
void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY);
}
}

View File

@@ -540,6 +540,39 @@ namespace OpenSim.Region.CoreModules.World.Terrain
}
}
/// <summary>
/// Saves the terrain to a larger terrain file.
/// </summary>
/// <param name="filename">The terrain file to save</param>
/// <param name="fileWidth">The width of the file in units</param>
/// <param name="fileHeight">The height of the file in units</param>
/// <param name="fileStartX">Where to begin our slice</param>
/// <param name="fileStartY">Where to begin our slice</param>
public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
{
int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX;
int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY;
if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight)
{
// this region is included in the tile request
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
if (filename.EndsWith(loader.Key))
{
lock (m_scene)
{
loader.Value.SaveFile(m_channel, filename, offsetX, offsetY,
fileWidth, fileHeight,
(int)Constants.RegionSize,
(int)Constants.RegionSize);
}
return;
}
}
}
}
/// <summary>
/// Performs updates to the region periodically, synchronising physics and other heightmap aware sections
/// </summary>
@@ -862,6 +895,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
SaveToFile((string) args[0]);
}
private void InterfaceSaveTileFile(Object[] args)
{
SaveToFile((string)args[0],
(int)args[1],
(int)args[2],
(int)args[3],
(int)args[4]);
}
private void InterfaceBakeTerrain(Object[] args)
{
UpdateRevertMap();
@@ -1117,6 +1159,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain
loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
"Integer");
Command saveToTileCommand =
new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file.");
saveToTileCommand.AddArgument("filename",
"The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " +
supportedFileExtensions, "String");
saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
"Integer");
saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
"Integer");
// Terrain adjustments
Command fillRegionCommand =
new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
@@ -1168,6 +1221,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
m_commander.RegisterCommand("load", loadFromFileCommand);
m_commander.RegisterCommand("load-tile", loadFromTileCommand);
m_commander.RegisterCommand("save", saveToFileCommand);
m_commander.RegisterCommand("save-tile", saveToTileCommand);
m_commander.RegisterCommand("fill", fillRegionCommand);
m_commander.RegisterCommand("elevate", elevateCommand);
m_commander.RegisterCommand("lower", lowerCommand);