mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Merge branch 'master' into newmultiattach
Conflicts: OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
This commit is contained in:
@@ -289,21 +289,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
if (!Enabled)
|
||||
return false;
|
||||
|
||||
if (AttachObjectInternal(sp, group, attachmentPt, silent, temp, append))
|
||||
{
|
||||
m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return AttachObjectInternal(sp, group, attachmentPt, silent, temp, append);
|
||||
}
|
||||
|
||||
private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
|
||||
// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
|
||||
|
||||
/// <summary>
|
||||
/// Internal method which actually does all the work for attaching an object.
|
||||
/// </summary>
|
||||
/// <returns>The object attached.</returns>
|
||||
/// <param name='sp'></param>
|
||||
/// <param name='group'>The object to attach.</param>
|
||||
/// <param name='attachmentPt'></param>
|
||||
/// <param name='silent'></param>
|
||||
/// <param name='temp'></param>
|
||||
/// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
|
||||
private bool AttachObjectInternal(
|
||||
IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts)
|
||||
{
|
||||
if (group.GetSittingAvatarsCount() != 0)
|
||||
{
|
||||
// m_log.WarnFormat(
|
||||
@@ -314,6 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
}
|
||||
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||
|
||||
if (attachments.Contains(group))
|
||||
{
|
||||
// m_log.WarnFormat(
|
||||
@@ -374,6 +376,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append);
|
||||
|
||||
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
||||
|
||||
if (resumeScripts)
|
||||
{
|
||||
// Fire after attach, so we don't get messy perms dialogs
|
||||
// 4 == AttachedRez
|
||||
group.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
|
||||
group.ResumeScripts();
|
||||
}
|
||||
|
||||
// Do this last so that event listeners have access to all the effects of the attachment
|
||||
m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -400,8 +413,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return null;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
|
||||
// (AttachmentPoint)AttachmentPt, itemID, sp.Name);
|
||||
// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2} in {3}",
|
||||
// (AttachmentPoint)AttachmentPt, itemID, sp.Name, m_scene.Name);
|
||||
|
||||
bool append = (AttachmentPt & 0x80) != 0;
|
||||
AttachmentPt &= 0x7f;
|
||||
@@ -533,6 +546,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return;
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Detaching object {0} {1} for {2} in {3}",
|
||||
// so.Name, so.LocalId, sp.Name, m_scene.Name);
|
||||
|
||||
// Scripts MUST be snapshotted before the object is
|
||||
// removed from the scene because doing otherwise will
|
||||
// clobber the run flag
|
||||
@@ -854,61 +871,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remove any previous attachments
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||
string previousAttachmentScriptedState = null;
|
||||
|
||||
// At the moment we can only deal with a single attachment
|
||||
if (attachments.Count != 0)
|
||||
DetachSingleAttachmentToInv(sp, attachments[0]);
|
||||
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
|
||||
// objatt.Name, sp.Name, attachmentPt, m_scene.Name);
|
||||
|
||||
// HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
|
||||
objatt.HasGroupChanged = false;
|
||||
bool tainted = false;
|
||||
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
|
||||
tainted = true;
|
||||
// HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
|
||||
objatt.HasGroupChanged = false;
|
||||
bool tainted = false;
|
||||
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
|
||||
tainted = true;
|
||||
|
||||
// FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
|
||||
// course of events. If not, then it's probably not worth trying to recover the situation
|
||||
// since this is more likely to trigger further exceptions and confuse later debugging. If
|
||||
// exceptions can be thrown in expected error conditions (not NREs) then make this consistent
|
||||
// since other normal error conditions will simply return false instead.
|
||||
// This will throw if the attachment fails
|
||||
try
|
||||
{
|
||||
AttachObjectInternal(sp, objatt, attachmentPt, false, false, append);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
|
||||
objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
|
||||
|
||||
// Make sure the object doesn't stick around and bail
|
||||
sp.RemoveAttachment(objatt);
|
||||
m_scene.DeleteSceneObject(objatt, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (tainted)
|
||||
objatt.HasGroupChanged = true;
|
||||
|
||||
// Fire after attach, so we don't get messy perms dialogs
|
||||
// 4 == AttachedRez
|
||||
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
|
||||
objatt.ResumeScripts();
|
||||
|
||||
// Do this last so that event listeners have access to all the effects of the attachment
|
||||
m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
|
||||
|
||||
return objatt;
|
||||
// FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
|
||||
// course of events. If not, then it's probably not worth trying to recover the situation
|
||||
// since this is more likely to trigger further exceptions and confuse later debugging. If
|
||||
// exceptions can be thrown in expected error conditions (not NREs) then make this consistent
|
||||
// since other normal error conditions will simply return false instead.
|
||||
// This will throw if the attachment fails
|
||||
try
|
||||
{
|
||||
AttachObjectInternal(sp, objatt, attachmentPt, false, false, append);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
|
||||
objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
|
||||
|
||||
// Make sure the object doesn't stick around and bail
|
||||
sp.RemoveAttachment(objatt);
|
||||
m_scene.DeleteSceneObject(objatt, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (tainted)
|
||||
objatt.HasGroupChanged = true;
|
||||
|
||||
return objatt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -228,6 +228,120 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWearAttachmentFromGround()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
|
||||
|
||||
SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID);
|
||||
|
||||
{
|
||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
|
||||
|
||||
m_numberOfAttachEventsFired = 0;
|
||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false);
|
||||
|
||||
// Check status on scene presence
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(so.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check item status
|
||||
Assert.That(
|
||||
sp.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||
Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
|
||||
InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
|
||||
Assert.That(attachmentItem, Is.Not.Null);
|
||||
Assert.That(attachmentItem.Name, Is.EqualTo(so.Name));
|
||||
|
||||
InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
|
||||
Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
// Test wearing a different attachment from the ground.
|
||||
{
|
||||
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false);
|
||||
|
||||
// Check status on scene presence
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(so2.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check item status
|
||||
Assert.That(
|
||||
sp.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||
Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
|
||||
InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
|
||||
Assert.That(attachmentItem, Is.Not.Null);
|
||||
Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));
|
||||
|
||||
InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
|
||||
Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
// Test rewearing an already worn attachment from ground. Nothing should happen.
|
||||
{
|
||||
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false);
|
||||
|
||||
// Check status on scene presence
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(so2.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check item status
|
||||
Assert.That(
|
||||
sp.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||
Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
|
||||
InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
|
||||
Assert.That(attachmentItem, Is.Not.Null);
|
||||
Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));
|
||||
|
||||
InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
|
||||
Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that we do not attempt to attach an in-world object that someone else is sitting on.
|
||||
/// </summary>
|
||||
@@ -275,29 +389,140 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||
|
||||
InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
|
||||
|
||||
m_numberOfAttachEventsFired = 0;
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
{
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
// Check scene presence status
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
// Test attaching an already attached attachment
|
||||
{
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(
|
||||
sp, attItem.ID, (uint)AttachmentPoint.Chest);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
Assert.That(attSo.UsesPhysics, Is.False);
|
||||
Assert.That(attSo.IsTemporary, Is.False);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test wearing an attachment from inventory, as opposed to explicit choosing the rez point
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestWearAttachmentFromInventory()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
Scene scene = CreateTestScene();
|
||||
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
|
||||
|
||||
InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20);
|
||||
InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21);
|
||||
|
||||
{
|
||||
m_numberOfAttachEventsFired = 0;
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default);
|
||||
|
||||
// default attachment point is currently the left hand.
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem1.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
// Test wearing a second attachment at the same position
|
||||
// Until multiple attachments at one point is implemented, this will remove the first attachment
|
||||
// This test relies on both attachments having the same default attachment point (in this case LeftHand
|
||||
// since none other has been set).
|
||||
{
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);
|
||||
|
||||
// default attachment point is currently the left hand.
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
// Test wearing an already attached attachment
|
||||
{
|
||||
scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);
|
||||
|
||||
// default attachment point is currently the left hand.
|
||||
Assert.That(sp.HasAttachments(), Is.True);
|
||||
List<SceneObjectGroup> attachments = sp.GetAttachments();
|
||||
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||
SceneObjectGroup attSo = attachments[0];
|
||||
Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
|
||||
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
|
||||
Assert.That(attSo.IsAttachment);
|
||||
|
||||
// Check appearance status
|
||||
Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
|
||||
Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
|
||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||
|
||||
// Check events
|
||||
Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -39,7 +39,7 @@ using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
|
||||
namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
|
||||
public class DAExampleModule : INonSharedRegionModule
|
||||
@@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
|
||||
|
||||
private static readonly bool ENABLED = false; // enable for testing
|
||||
|
||||
public const string DANamespace = "DAExample Module";
|
||||
|
||||
protected Scene m_scene;
|
||||
protected IDialogModule m_dialogMod;
|
||||
|
||||
@@ -85,19 +87,29 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
|
||||
{
|
||||
OSDMap attrs = null;
|
||||
SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId);
|
||||
if (!sop.DynAttrs.TryGetValue(Name, out attrs))
|
||||
|
||||
if (sop == null)
|
||||
return true;
|
||||
|
||||
if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs))
|
||||
attrs = new OSDMap();
|
||||
|
||||
OSDInteger newValue;
|
||||
|
||||
if (!attrs.ContainsKey("moves"))
|
||||
newValue = new OSDInteger(1);
|
||||
else
|
||||
newValue = new OSDInteger(((OSDInteger)attrs["moves"]).AsInteger() + 1);
|
||||
|
||||
attrs["moves"] = newValue;
|
||||
|
||||
sop.DynAttrs[Name] = attrs;
|
||||
// We have to lock on the entire dynamic attributes map to avoid race conditions with serialization code.
|
||||
lock (sop.DynAttrs)
|
||||
{
|
||||
if (!attrs.ContainsKey("moves"))
|
||||
newValue = new OSDInteger(1);
|
||||
else
|
||||
newValue = new OSDInteger(attrs["moves"].AsInteger() + 1);
|
||||
|
||||
attrs["moves"] = newValue;
|
||||
|
||||
sop.DynAttrs[DANamespace] = attrs;
|
||||
}
|
||||
|
||||
sop.ParentGroup.HasGroupChanged = true;
|
||||
|
||||
m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue));
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.Reflection;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Example module for experimenting with and demonstrating dynamic object ideas.
|
||||
/// </summary>
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DOExampleModule")]
|
||||
public class DOExampleModule : INonSharedRegionModule
|
||||
{
|
||||
public class MyObject
|
||||
{
|
||||
public int Moves { get; set; }
|
||||
|
||||
public MyObject(int moves)
|
||||
{
|
||||
Moves = moves;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static readonly bool ENABLED = false; // enable for testing
|
||||
|
||||
private Scene m_scene;
|
||||
private IDialogModule m_dialogMod;
|
||||
|
||||
public string Name { get { return "DOExample Module"; } }
|
||||
public Type ReplaceableInterface { get { return null; } }
|
||||
|
||||
public void Initialise(IConfigSource source) {}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.EventManager.OnObjectAddedToScene += OnObjectAddedToScene;
|
||||
m_scene.EventManager.OnSceneGroupMove += OnSceneGroupMove;
|
||||
m_dialogMod = m_scene.RequestModuleInterface<IDialogModule>();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
m_scene.EventManager.OnSceneGroupMove -= OnSceneGroupMove;
|
||||
}
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene) {}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
RemoveRegion(m_scene);
|
||||
}
|
||||
|
||||
private void OnObjectAddedToScene(SceneObjectGroup so)
|
||||
{
|
||||
SceneObjectPart rootPart = so.RootPart;
|
||||
|
||||
OSDMap attrs;
|
||||
|
||||
int movesSoFar = 0;
|
||||
|
||||
// Console.WriteLine("Here for {0}", so.Name);
|
||||
|
||||
if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs))
|
||||
{
|
||||
movesSoFar = attrs["moves"].AsInteger();
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name);
|
||||
}
|
||||
|
||||
rootPart.DynObjs.Add(Name, new MyObject(movesSoFar));
|
||||
}
|
||||
|
||||
private bool OnSceneGroupMove(UUID groupId, Vector3 delta)
|
||||
{
|
||||
SceneObjectGroup so = m_scene.GetSceneObjectGroup(groupId);
|
||||
|
||||
if (so == null)
|
||||
return true;
|
||||
|
||||
object rawObj = so.RootPart.DynObjs.Get(Name);
|
||||
|
||||
if (rawObj != null)
|
||||
{
|
||||
MyObject myObj = (MyObject)rawObj;
|
||||
|
||||
m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", so.Name, so.UUID, ++myObj.Moves));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
/// </summary>
|
||||
public bool WaitForAgentArrivedAtDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true then we ask the viewer to disable teleport cancellation and ignore teleport requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is useful in situations where teleport is very likely to always succeed and we want to avoid a
|
||||
/// situation where avatars can be come 'stuck' due to a failed teleport cancellation. Unfortunately, the
|
||||
/// nature of the teleport protocol makes it extremely difficult (maybe impossible) to make teleport
|
||||
/// cancellation consistently suceed.
|
||||
/// </remarks>
|
||||
public bool DisableInterRegionTeleportCancellation { get; set; }
|
||||
|
||||
protected bool m_Enabled = false;
|
||||
|
||||
public Scene Scene { get; private set; }
|
||||
@@ -116,6 +127,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
IConfig transferConfig = source.Configs["EntityTransfer"];
|
||||
if (transferConfig != null)
|
||||
{
|
||||
DisableInterRegionTeleportCancellation
|
||||
= transferConfig.GetBoolean("DisableInterRegionTeleportCancellation", false);
|
||||
|
||||
WaitForAgentArrivedAtDestination
|
||||
= transferConfig.GetBoolean("wait_for_callback", WaitForAgentArrivedAtDestinationDefault);
|
||||
|
||||
@@ -150,6 +164,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
{
|
||||
client.OnTeleportHomeRequest += TeleportHome;
|
||||
client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
|
||||
|
||||
if (!DisableInterRegionTeleportCancellation)
|
||||
client.OnTeleportCancel += OnClientCancelTeleport;
|
||||
}
|
||||
|
||||
public virtual void Close() {}
|
||||
@@ -168,6 +185,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
#region Agent Teleports
|
||||
|
||||
private void OnClientCancelTeleport(IClientAPI client)
|
||||
{
|
||||
m_entityTransferStateMachine.UpdateInTransit(client.AgentId, AgentTransferState.Cancelling);
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, Scene.Name);
|
||||
}
|
||||
|
||||
public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
|
||||
{
|
||||
if (sp.Scene.Permissions.IsGridGod(sp.UUID))
|
||||
@@ -519,6 +544,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
if (sp.ParentID != (uint)0)
|
||||
sp.StandUp();
|
||||
|
||||
if (DisableInterRegionTeleportCancellation)
|
||||
teleportFlags |= (uint)TeleportFlags.DisableCancel;
|
||||
|
||||
// At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to
|
||||
// the viewer. However, it might mean that the viewer does not see the black teleport screen (untested).
|
||||
sp.ControllingClient.SendTeleportStart(teleportFlags);
|
||||
@@ -567,6 +595,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request",
|
||||
sp.Name, finalDestination.RegionName, sp.Scene.Name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Past this point we have to attempt clean up if the teleport fails, so update transfer state.
|
||||
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
|
||||
|
||||
@@ -631,7 +668,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
return;
|
||||
}
|
||||
|
||||
sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest");
|
||||
if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request",
|
||||
sp.Name, finalDestination.RegionName, sp.Scene.Name);
|
||||
|
||||
CleanupAbortedInterRegionTeleport(sp, finalDestination);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}",
|
||||
@@ -714,14 +760,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
// }
|
||||
}
|
||||
|
||||
protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout)
|
||||
/// <summary>
|
||||
/// Clean up an inter-region teleport that did not complete, either because of simulator failure or cancellation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// All operations here must be idempotent so that we can call this method at any point in the teleport process
|
||||
/// up until we send the TeleportFinish event quene event to the viewer.
|
||||
/// <remarks>
|
||||
/// <param name='sp'> </param>
|
||||
/// <param name='finalDestination'></param>
|
||||
protected virtual void CleanupAbortedInterRegionTeleport(ScenePresence sp, GridRegion finalDestination)
|
||||
{
|
||||
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
|
||||
|
||||
// Client never contacted destination. Let's restore everything back
|
||||
sp.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
|
||||
|
||||
// Fail. Reset it back
|
||||
sp.IsChildAgent = false;
|
||||
ReInstantiateScripts(sp);
|
||||
|
||||
@@ -729,7 +780,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
// Finally, kill the agent we just created at the destination.
|
||||
Scene.SimulationService.CloseAgent(finalDestination, sp.UUID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal that the inter-region teleport failed and perform cleanup.
|
||||
/// </summary>
|
||||
/// <param name='sp'></param>
|
||||
/// <param name='finalDestination'></param>
|
||||
/// <param name='logout'></param>
|
||||
protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout)
|
||||
{
|
||||
CleanupAbortedInterRegionTeleport(sp, finalDestination);
|
||||
|
||||
sp.ControllingClient.SendTeleportFailed(
|
||||
string.Format("Problems connecting to destination {0}", finalDestination.RegionName));
|
||||
sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout);
|
||||
}
|
||||
|
||||
@@ -1206,6 +1270,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
// region doesn't take it
|
||||
m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
|
||||
|
||||
m_log.WarnFormat(
|
||||
"[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.",
|
||||
neighbourRegion.RegionName, agent.Name);
|
||||
|
||||
ReInstantiateScripts(agent);
|
||||
agent.AddToPhysicalScene(isFlying);
|
||||
|
||||
@@ -1225,6 +1293,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
neighbourRegion.RegionHandle);
|
||||
return agent;
|
||||
}
|
||||
|
||||
// No turning back
|
||||
agent.IsChildAgent = true;
|
||||
|
||||
@@ -2092,7 +2161,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
public bool IsInTransit(UUID id)
|
||||
{
|
||||
return m_entityTransferStateMachine.IsInTransit(id);
|
||||
return m_entityTransferStateMachine.GetAgentTransferState(id) != null;
|
||||
}
|
||||
|
||||
protected void ReInstantiateScripts(ScenePresence sp)
|
||||
|
||||
@@ -51,8 +51,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
/// This is a state machine.
|
||||
///
|
||||
/// [Entry] => Preparing
|
||||
/// Preparing => { Transferring || CleaningUp || [Exit] }
|
||||
/// Transferring => { ReceivedAtDestination || CleaningUp }
|
||||
/// Preparing => { Transferring || Cancelling || CleaningUp || [Exit] }
|
||||
/// Transferring => { ReceivedAtDestination || Cancelling || CleaningUp }
|
||||
/// Cancelling => CleaningUp
|
||||
/// ReceivedAtDestination => CleaningUp
|
||||
/// CleaningUp => [Exit]
|
||||
///
|
||||
@@ -64,7 +65,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
Preparing, // The agent is being prepared for transfer
|
||||
Transferring, // The agent is in the process of being transferred to a destination
|
||||
ReceivedAtDestination, // The destination has notified us that the agent has been successfully received
|
||||
CleaningUp // The agent is being changed to child/removed after a transfer
|
||||
CleaningUp, // The agent is being changed to child/removed after a transfer
|
||||
Cancelling // The user has cancelled the teleport but we have yet to act upon this.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,42 +117,110 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
/// <param name='newState'></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref='Exception'>Illegal transitions will throw an Exception</exception>
|
||||
internal void UpdateInTransit(UUID id, AgentTransferState newState)
|
||||
internal bool UpdateInTransit(UUID id, AgentTransferState newState)
|
||||
{
|
||||
bool transitionOkay = false;
|
||||
|
||||
// We don't want to throw an exception on cancel since this can come it at any time.
|
||||
bool failIfNotOkay = true;
|
||||
|
||||
// Should be a failure message if failure is not okay.
|
||||
string failureMessage = null;
|
||||
|
||||
AgentTransferState? oldState = null;
|
||||
|
||||
lock (m_agentsInTransit)
|
||||
{
|
||||
// Illegal to try and update an agent that's not actually in transit.
|
||||
if (!m_agentsInTransit.ContainsKey(id))
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"Agent with ID {0} is not registered as in transit in {1}",
|
||||
id, m_mod.Scene.RegionInfo.RegionName));
|
||||
{
|
||||
if (newState != AgentTransferState.Cancelling)
|
||||
failureMessage = string.Format(
|
||||
"Agent with ID {0} is not registered as in transit in {1}",
|
||||
id, m_mod.Scene.RegionInfo.RegionName);
|
||||
else
|
||||
failIfNotOkay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldState = m_agentsInTransit[id];
|
||||
|
||||
AgentTransferState oldState = m_agentsInTransit[id];
|
||||
if (newState == AgentTransferState.CleaningUp && oldState != AgentTransferState.CleaningUp)
|
||||
{
|
||||
transitionOkay = true;
|
||||
}
|
||||
else if (newState == AgentTransferState.Transferring && oldState == AgentTransferState.Preparing)
|
||||
{
|
||||
transitionOkay = true;
|
||||
}
|
||||
else if (newState == AgentTransferState.ReceivedAtDestination && oldState == AgentTransferState.Transferring)
|
||||
{
|
||||
transitionOkay = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newState == AgentTransferState.Cancelling
|
||||
&& (oldState == AgentTransferState.Preparing || oldState == AgentTransferState.Transferring))
|
||||
{
|
||||
transitionOkay = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
failIfNotOkay = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool transitionOkay = false;
|
||||
|
||||
if (newState == AgentTransferState.CleaningUp && oldState != AgentTransferState.CleaningUp)
|
||||
transitionOkay = true;
|
||||
else if (newState == AgentTransferState.Transferring && oldState == AgentTransferState.Preparing)
|
||||
transitionOkay = true;
|
||||
else if (newState == AgentTransferState.ReceivedAtDestination && oldState == AgentTransferState.Transferring)
|
||||
transitionOkay = true;
|
||||
if (!transitionOkay)
|
||||
failureMessage
|
||||
= string.Format(
|
||||
"Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}",
|
||||
id, oldState, newState, m_mod.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
if (transitionOkay)
|
||||
{
|
||||
m_agentsInTransit[id] = newState;
|
||||
else
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}",
|
||||
id, oldState, newState, m_mod.Scene.RegionInfo.RegionName));
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[ENTITY TRANSFER STATE MACHINE]: Changed agent with id {0} from state {1} to {2} in {3}",
|
||||
// id, oldState, newState, m_mod.Scene.Name);
|
||||
}
|
||||
else if (failIfNotOkay)
|
||||
{
|
||||
throw new Exception(failureMessage);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// if (oldState != null)
|
||||
// m_log.DebugFormat(
|
||||
// "[ENTITY TRANSFER STATE MACHINE]: Ignored change of agent with id {0} from state {1} to {2} in {3}",
|
||||
// id, oldState, newState, m_mod.Scene.Name);
|
||||
// else
|
||||
// m_log.DebugFormat(
|
||||
// "[ENTITY TRANSFER STATE MACHINE]: Ignored change of agent with id {0} to state {1} in {2} since agent not in transit",
|
||||
// id, newState, m_mod.Scene.Name);
|
||||
// }
|
||||
}
|
||||
|
||||
return transitionOkay;
|
||||
}
|
||||
|
||||
internal bool IsInTransit(UUID id)
|
||||
/// <summary>
|
||||
/// Gets the current agent transfer state.
|
||||
/// </summary>
|
||||
/// <returns>Null if the agent is not in transit</returns>
|
||||
/// <param name='id'>
|
||||
/// Identifier.
|
||||
/// </param>
|
||||
internal AgentTransferState? GetAgentTransferState(UUID id)
|
||||
{
|
||||
lock (m_agentsInTransit)
|
||||
return m_agentsInTransit.ContainsKey(id);
|
||||
{
|
||||
if (!m_agentsInTransit.ContainsKey(id))
|
||||
return null;
|
||||
else
|
||||
return m_agentsInTransit[id];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -203,14 +273,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
lock (m_agentsInTransit)
|
||||
{
|
||||
if (!IsInTransit(id))
|
||||
AgentTransferState? currentState = GetAgentTransferState(id);
|
||||
|
||||
if (currentState == null)
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
"Asked to wait for destination callback for agent with ID {0} in {1} but agent is not in transit",
|
||||
id, m_mod.Scene.RegionInfo.RegionName));
|
||||
|
||||
AgentTransferState currentState = m_agentsInTransit[id];
|
||||
|
||||
if (currentState != AgentTransferState.Transferring && currentState != AgentTransferState.ReceivedAtDestination)
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
|
||||
@@ -414,8 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
}
|
||||
private void RegisterStatsManagerRegionStatistics()
|
||||
{
|
||||
string regionName = m_scene.RegionInfo.RegionName;
|
||||
|
||||
MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); });
|
||||
MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); });
|
||||
MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); });
|
||||
|
||||
@@ -516,6 +516,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
foreach (string line in GetLines(data, dataDelim))
|
||||
{
|
||||
string nextLine = line.Trim();
|
||||
|
||||
// m_log.DebugFormat("[VECTOR RENDER MODULE]: Processing line '{0}'", nextLine);
|
||||
|
||||
//replace with switch, or even better, do some proper parsing
|
||||
if (nextLine.StartsWith("MoveTo"))
|
||||
{
|
||||
@@ -829,6 +832,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||
float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture);
|
||||
PointF point = new PointF(x, y);
|
||||
points[i / 2] = point;
|
||||
|
||||
// m_log.DebugFormat("[VECTOR RENDER MODULE]: Got point {0}", points[i / 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,12 +219,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
|
||||
// s.RegionInfo.RegionName, destination.RegionHandle);
|
||||
// destination.RegionName, destination.RegionID);
|
||||
|
||||
return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData);
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle);
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL COMMS]: Did not find region {0} {1} for ChildAgentUpdate",
|
||||
// destination.RegionName, destination.RegionID);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -239,7 +242,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
// note that we really don't need the GridRegion for this call
|
||||
foreach (Scene s in m_scenes.Values)
|
||||
{
|
||||
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
|
||||
// m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
|
||||
s.IncomingChildAgentDataUpdate(cAgentData);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
return null;
|
||||
}
|
||||
|
||||
public ILandObject GetLandObject(Vector3 position)
|
||||
{
|
||||
return GetLandObject(position.X, position.Y);
|
||||
}
|
||||
|
||||
public ILandObject GetLandObject(int x, int y)
|
||||
{
|
||||
if (m_landManagementModule != null)
|
||||
|
||||
Reference in New Issue
Block a user