Merge branch 'master' into varregion

This commit is contained in:
Robert Adams
2014-01-21 11:31:51 -08:00
29 changed files with 1328 additions and 878 deletions

View File

@@ -51,10 +51,17 @@ namespace OpenSim.Region.Framework.Interfaces
UUID = 5
}
public struct JsonStoreStats
{
public int StoreCount;
}
public delegate void TakeValueCallback(string s);
public interface IJsonStoreModule
{
JsonStoreStats GetStoreStats();
bool AttachObjectStore(UUID objectID);
bool CreateStore(string value, ref UUID result);
bool DestroyStore(UUID storeID);

View File

@@ -3930,32 +3930,52 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// m_log.DebugFormat(
// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
// RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
// Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags
if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero &&
RegionInfo.EstateSettings.AllowDirectTeleport == false &&
!viahome && !godlike)
{
SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
// Can have multiple SpawnPoints
List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
if (spawnpoints.Count > 1)
if (telehub != null)
{
// We have multiple SpawnPoints, Route the agent to a random or sequential one
if (SpawnPointRouting == "random")
acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
// Can have multiple SpawnPoints
List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
if (spawnpoints.Count > 1)
{
// We have multiple SpawnPoints, Route the agent to a random or sequential one
if (SpawnPointRouting == "random")
acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
else
acd.startpos = spawnpoints[SpawnPoint()].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
}
else if (spawnpoints.Count == 1)
{
// We have a single SpawnPoint and will route the agent to it
acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
}
else
acd.startpos = spawnpoints[SpawnPoint()].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
{
m_log.DebugFormat(
"[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.",
RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
}
}
else
{
// We have a single SpawnPoint and will route the agent to it
acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
m_log.DebugFormat(
"[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.",
RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
}
return true;

View File

@@ -0,0 +1,119 @@
/*
* 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 Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.World.Estate;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
{
/// <summary>
/// Scene telehub tests
/// </summary>
/// <remarks>
/// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour
/// in the case of an error condition
/// </remarks>
[TestFixture]
public class SceneTelehubTests : OpenSimTestCase
{
/// <summary>
/// Test for desired behaviour when a telehub has no spawn points
/// </summary>
[Test]
public void TestNoTelehubSpawnPoints()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
EstateManagementModule emm = new EstateManagementModule();
SceneHelpers sh = new SceneHelpers();
Scene scene = sh.SetupScene();
SceneHelpers.SetupSceneModules(scene, emm);
UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
// Must still be possible to successfully log in
UUID loggingInUserId = TestHelpers.ParseTail(0x2);
UserAccount ua
= UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
SceneHelpers.AddScenePresence(scene, ua);
Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
}
/// <summary>
/// Test for desired behaviour when the scene object nominated as a telehub object does not exist.
/// </summary>
[Test]
public void TestNoTelehubSceneObject()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
EstateManagementModule emm = new EstateManagementModule();
SceneHelpers sh = new SceneHelpers();
Scene scene = sh.SetupScene();
SceneHelpers.SetupSceneModules(scene, emm);
UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner);
emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId);
scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
scene.DeleteSceneObject(telehubSo, false);
// Must still be possible to successfully log in
UUID loggingInUserId = TestHelpers.ParseTail(0x2);
UserAccount ua
= UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
SceneHelpers.AddScenePresence(scene, ua);
Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
}
}
}

View File

@@ -62,8 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
= AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero);
m_assetService.Store(corruptAsset);
IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids);
IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>();
m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, (sbyte)AssetType.Object, foundAssetUuids);
// We count the uuid as gathered even if the asset itself is corrupt.
Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
@@ -78,9 +78,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
TestHelpers.InMethod();
UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>();
m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
m_uuidGatherer.GatherAssetUuids(missingAssetUuid, (sbyte)AssetType.Object, foundAssetUuids);
// We count the uuid as gathered even if the asset itself is missing.
Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
@@ -103,8 +103,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString());
m_assetService.Store(ncAsset);
IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids);
IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>();
m_uuidGatherer.GatherAssetUuids(ncAssetId, (sbyte)AssetType.Notecard, foundAssetUuids);
// We count the uuid as gathered even if the asset itself is corrupt.
Assert.That(foundAssetUuids.Count, Is.EqualTo(2));

View File

@@ -38,6 +38,7 @@ using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
namespace OpenSim.Region.Framework.Scenes
{
@@ -83,7 +84,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
/// <param name="assetType">The type of the asset for the uuid given</param>
/// <param name="assetUuids">The assets gathered</param>
public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
public void GatherAssetUuids(UUID assetUuid, sbyte assetType, IDictionary<UUID, sbyte> assetUuids)
{
// avoid infinite loops
if (assetUuids.ContainsKey(assetUuid))
@@ -93,23 +94,27 @@ namespace OpenSim.Region.Framework.Scenes
{
assetUuids[assetUuid] = assetType;
if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
{
GetWearableAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Gesture == assetType)
else if ((sbyte)AssetType.Gesture == assetType)
{
GetGestureAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Notecard == assetType)
else if ((sbyte)AssetType.Notecard == assetType)
{
GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.LSLText == assetType)
else if ((sbyte)AssetType.LSLText == assetType)
{
GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
}
else if (AssetType.Object == assetType)
else if ((sbyte)OpenSimAssetType.Material == assetType)
{
GetMaterialAssetUuids(assetUuid, assetUuids);
}
else if ((sbyte)AssetType.Object == assetType)
{
GetSceneObjectAssetUuids(assetUuid, assetUuids);
}
@@ -136,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes
/// A dictionary which is populated with the asset UUIDs gathered and the type of that asset.
/// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown.
/// </param>
public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, sbyte> assetUuids)
{
// m_log.DebugFormat(
// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -156,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes
{
// Get the prim's default texture. This will be used for faces which don't have their own texture
if (textureEntry.DefaultTexture != null)
assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture;
if (textureEntry.FaceTextures != null)
{
@@ -164,20 +169,20 @@ namespace OpenSim.Region.Framework.Scenes
foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
{
if (texture != null)
assetUuids[texture.TextureID] = AssetType.Texture;
assetUuids[texture.TextureID] = (sbyte)AssetType.Texture;
}
}
}
// If the prim is a sculpt then preserve this information too
if (part.Shape.SculptTexture != UUID.Zero)
assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
assetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
if (part.Shape.ProjectionTextureUUID != UUID.Zero)
assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture;
assetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
if (part.CollisionSound != UUID.Zero)
assetUuids[part.CollisionSound] = AssetType.Sound;
assetUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
if (part.ParticleSystem.Length > 0)
{
@@ -185,7 +190,7 @@ namespace OpenSim.Region.Framework.Scenes
{
Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
if (ps.Texture != UUID.Zero)
assetUuids[ps.Texture] = AssetType.Texture;
assetUuids[ps.Texture] = (sbyte)AssetType.Texture;
}
catch (Exception e)
{
@@ -205,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes
// tii.Name, tii.Type, part.Name, part.UUID);
if (!assetUuids.ContainsKey(tii.AssetID))
GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
GatherAssetUuids(tii.AssetID, (sbyte)tii.Type, assetUuids);
}
// FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
@@ -214,7 +219,9 @@ namespace OpenSim.Region.Framework.Scenes
// Scene.EventManager is present.
// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
GatherMaterialsUuids(part, assetUuids);
// still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
GatherMaterialsUuids(part, assetUuids);
}
catch (Exception e)
{
@@ -225,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
// /// <summary>
// /// The callback made when we request the asset for an object from the asset service.
// /// </summary>
@@ -241,10 +248,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
/// stored in legacy format in part.DynAttrs
/// </summary>
/// <param name="part"></param>
/// <param name="assetUuids"></param>
public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
//public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids)
{
// scan thru the dynAttrs map of this part for any textures used as materials
OSD osdMaterials = null;
@@ -280,7 +289,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID normalMapId = mat["NormMap"].AsUUID();
if (normalMapId != UUID.Zero)
{
assetUuids[normalMapId] = AssetType.Texture;
assetUuids[normalMapId] = (sbyte)AssetType.Texture;
//m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
}
}
@@ -289,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID specularMapId = mat["SpecMap"].AsUUID();
if (specularMapId != UUID.Zero)
{
assetUuids[specularMapId] = AssetType.Texture;
assetUuids[specularMapId] = (sbyte)AssetType.Texture;
//m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
}
}
@@ -344,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="scriptUuid"></param>
/// <param name="assetUuids">Dictionary in which to record the references</param>
private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids)
private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids)
{
// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);
@@ -364,7 +373,7 @@ namespace OpenSim.Region.Framework.Scenes
// Embedded asset references (if not false positives) could be for many types of asset, so we will
// label these as unknown.
assetUuids[uuid] = AssetType.Unknown;
assetUuids[uuid] = (sbyte)AssetType.Unknown;
}
}
}
@@ -374,7 +383,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="wearableAssetUuid"></param>
/// <param name="assetUuids">Dictionary in which to record the references</param>
private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids)
{
AssetBase assetBase = GetAsset(wearableAssetUuid);
@@ -389,7 +398,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (UUID uuid in wearableAsset.Textures.Values)
{
assetUuids[uuid] = AssetType.Texture;
assetUuids[uuid] = (sbyte)AssetType.Texture;
}
}
}
@@ -401,7 +410,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="sceneObject"></param>
/// <param name="assetUuids"></param>
private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids)
{
AssetBase objectAsset = GetAsset(sceneObjectUuid);
@@ -430,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="gestureUuid"></param>
/// <param name="assetUuids"></param>
private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids)
{
AssetBase assetBase = GetAsset(gestureUuid);
if (null == assetBase)
@@ -464,9 +473,29 @@ namespace OpenSim.Region.Framework.Scenes
// If it can be parsed as a UUID, it is an asset ID
UUID uuid;
if (UUID.TryParse(id, out uuid))
assetUuids[uuid] = AssetType.Animation;
assetUuids[uuid] = (sbyte)AssetType.Animation;
}
}
/// <summary>
/// Get the asset uuid's referenced in a material.
/// </summary>
private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids)
{
AssetBase assetBase = GetAsset(materialUuid);
if (null == assetBase)
return;
OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data);
UUID normMap = mat["NormMap"].AsUUID();
if (normMap != UUID.Zero)
assetUuids[normMap] = (sbyte)AssetType.Texture;
UUID specMap = mat["SpecMap"].AsUUID();
if (specMap != UUID.Zero)
assetUuids[specMap] = (sbyte)AssetType.Texture;
}
}
public class HGUuidGatherer : UuidGatherer