From 33a894f3d2cc95a7a512b86f39f3c6a6afabb015 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:15:21 +0100
Subject: refactor: move SOP.IsAttachment and AttachmentPoint up into SOG to
avoid pointless duplication of identical values
---
.../Avatar/Attachments/AttachmentsModule.cs | 13 ++++++-------
.../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 18 +++++++++---------
.../Framework/EntityTransfer/EntityTransferModule.cs | 2 +-
.../Framework/InventoryAccess/InventoryAccessModule.cs | 2 +-
4 files changed, 17 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 3e1cb02..b976020 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -369,11 +369,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
-// remoteClient.Name, att.Name, itemID);
+// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}",
+// sp.Name, att.Name, att.LocalId, itemID, AttachmentPt);
if (!att.IsDeleted)
- AttachmentPt = att.RootPart.AttachmentPoint;
+ AttachmentPt = att.AttachmentPoint;
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item);
@@ -547,7 +547,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
);
group.RootPart.SetParentLocalId(0);
- group.RootPart.IsAttachment = false;
+ group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
@@ -569,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Finally, we restore the object's attachment status.
byte attachmentPoint = sog.GetAttachmentPoint();
sog.UpdateGroupPosition(pos);
- sog.RootPart.IsAttachment = false;
+ sog.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
sog.SetAttachmentPoint(attachmentPoint);
sog.HasGroupChanged = true;
@@ -666,8 +666,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.AbsolutePosition = attachOffset;
so.RootPart.AttachedPos = attachOffset;
- so.RootPart.IsAttachment = true;
-
+ so.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index b7d21fd..790a651 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -110,6 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
+ Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
@@ -132,9 +133,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att";
- InventoryItemBase attItem
- = UserInventoryHelpers.CreateInventoryItem(
- scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
+ UserInventoryHelpers.CreateInventoryItem(
+ scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -145,6 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
+ Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
@@ -166,9 +167,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att";
- InventoryItemBase attItem
- = UserInventoryHelpers.CreateInventoryItem(
- scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
+ UserInventoryHelpers.CreateInventoryItem(
+ scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
UUID attSoId = m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -198,9 +198,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att";
- InventoryItemBase attItem
- = UserInventoryHelpers.CreateInventoryItem(
- scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
+ UserInventoryHelpers.CreateInventoryItem(
+ scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -242,6 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
+ Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index f5d49c5..7963e53 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1782,7 +1782,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Set the parent localID to 0 so it transfers over properly.
gobj.RootPart.SetParentLocalId(0);
gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
- gobj.RootPart.IsAttachment = false;
+ gobj.IsAttachment = false;
//gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName);
CrossPrimGroupIntoNewRegion(destination, gobj, silent);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 65ba87b..fcb7eea 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -841,7 +841,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (attachment)
{
group.RootPart.Flags |= PrimFlags.Phantom;
- group.RootPart.IsAttachment = true;
+ group.IsAttachment = true;
}
// If we're rezzing an attachment then don't ask
--
cgit v1.1
From b7700428ec298f29ae4cbb0e1090728fe3b93602 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:20:15 +0100
Subject: refactor: camel case AttachmentPoint method arg as per code standards
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b976020..d9259b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -363,22 +363,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
- ///
+ ///
///
private UUID ShowAttachInUserInventory(
- SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt)
+ SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint)
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}",
// sp.Name, att.Name, att.LocalId, itemID, AttachmentPt);
if (!att.IsDeleted)
- AttachmentPt = att.AttachmentPoint;
+ attachmentPoint = att.AttachmentPoint;
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item);
- bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
+ bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
--
cgit v1.1
From 1615e7d29fb6961a3ffe791fde4318f819c1a4b7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:33:24 +0100
Subject: Eliminate duplicate AttachmentPoint properties by always using the
one stored in the root part's state field.
---
.../Avatar/Attachments/AttachmentsModule.cs | 42 +++++++++++-----------
.../Attachments/Tests/AttachmentsModuleTests.cs | 3 --
.../Region/CoreModules/World/Sound/SoundModule.cs | 4 +--
3 files changed, 23 insertions(+), 26 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index d9259b3..2d5eb18 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -167,13 +167,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return AttachObject(sp, group, AttachmentPt, silent);
}
- private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent)
+ private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
{
// 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);
- if (sp.GetAttachments(AttachmentPt).Contains(group))
+ if (sp.GetAttachments(attachmentPt).Contains(group))
{
// m_log.WarnFormat(
// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
@@ -186,39 +186,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
- AttachmentPt &= 0x7f;
+ attachmentPt &= 0x7f;
// If the attachment point isn't the same as the one previously used
// set it's offset position = 0 so that it appears on the attachment point
// and not in a weird location somewhere unknown.
- if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
+ if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
{
attachPos = Vector3.Zero;
}
// AttachmentPt 0 means the client chose to 'wear' the attachment.
- if (AttachmentPt == 0)
+ if (attachmentPt == 0)
{
// Check object for stored attachment point
- AttachmentPt = (uint)group.GetAttachmentPoint();
+ attachmentPt = group.AttachmentPoint;
}
// if we still didn't find a suitable attachment point.......
- if (AttachmentPt == 0)
+ if (attachmentPt == 0)
{
// Stick it on left hand with Zero Offset from the attachment point.
- AttachmentPt = (uint)AttachmentPoint.LeftHand;
+ attachmentPt = (uint)AttachmentPoint.LeftHand;
attachPos = Vector3.Zero;
}
- group.SetAttachmentPoint((byte)AttachmentPt);
+ group.AttachmentPoint = attachmentPt;
group.AbsolutePosition = attachPos;
// Remove any previous attachments
UUID itemID = UUID.Zero;
foreach (SceneObjectGroup grp in sp.Attachments)
{
- if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
+ if (grp.AttachmentPoint == attachmentPt)
{
itemID = grp.GetFromItemID();
break;
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (itemID == UUID.Zero)
itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
- ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
+ ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
- AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
+ AttachToAgent(sp, group, attachmentPt, attachPos, silent);
return true;
}
@@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
- ScenePresence sp, UUID itemID, uint AttachmentPt)
+ ScenePresence sp, UUID itemID, uint attachmentPt)
{
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface();
if (invAccess != null)
@@ -313,13 +313,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// since scripts aren't running yet. So, clear it here.
objatt.HasGroupChanged = false;
bool tainted = false;
- if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
+ if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
tainted = true;
// This will throw if the attachment fails
try
{
- AttachObject(sp, objatt, AttachmentPt, false);
+ AttachObject(sp, objatt, attachmentPt, false);
}
catch (Exception e)
{
@@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
- itemID, sp.Name, AttachmentPt);
+ itemID, sp.Name, attachmentPt);
}
return objatt;
@@ -567,11 +567,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Finally, we restore the object's attachment status.
- byte attachmentPoint = sog.GetAttachmentPoint();
+ uint attachmentPoint = sog.AttachmentPoint;
sog.UpdateGroupPosition(pos);
sog.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
- sog.SetAttachmentPoint(attachmentPoint);
+ sog.AttachmentPoint = attachmentPoint;
sog.HasGroupChanged = true;
}
@@ -594,14 +594,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
- grp.UUID, grp.GetAttachmentPoint());
+ grp.UUID, grp.AttachmentPoint);
return;
}
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
- grp.UUID, grp.GetAttachmentPoint());
+ grp.UUID, grp.AttachmentPoint);
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
@@ -668,7 +668,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.RootPart.AttachedPos = attachOffset;
so.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
- so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
+ so.AttachmentPoint = attachmentpoint;
avatar.AddAttachment(so);
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 790a651..bb53601 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -111,7 +111,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
- Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
@@ -146,7 +145,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
- Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
@@ -242,7 +240,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName));
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
- Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 09c0ebb..22ffcd6 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
if (grp.IsAttachment)
{
- if (grp.GetAttachmentPoint() > 30) // HUD
+ if (grp.AttachmentPoint > 30) // HUD
{
if (sp.ControllingClient.AgentId != grp.OwnerID)
return;
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
{
SceneObjectGroup grp = part.ParentGroup;
- if (grp.IsAttachment && grp.GetAttachmentPoint() > 30)
+ if (grp.IsAttachment && grp.AttachmentPoint > 30)
{
objectID = ownerID;
parentID = ownerID;
--
cgit v1.1