aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs103
1 files changed, 48 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index a7b4c66..527934d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -69,7 +69,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
69 get { return false; } 69 get { return false; }
70 } 70 }
71 71
72 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) 72 // Called by client
73 //
74 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
73 { 75 {
74 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); 76 m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
75 77
@@ -84,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
84 return; 86 return;
85 87
86 // Calls attach with a Zero position 88 // Calls attach with a Zero position
87 if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) 89 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
88 { 90 {
89 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 91 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
90 92
@@ -106,72 +108,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
106 } 108 }
107 } 109 }
108 110
109 public bool AttachObject( 111 public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent)
110 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
111 { 112 {
112 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); 113 Vector3 attachPos = group.AbsolutePosition;
113 if (group != null) 114
115 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
114 { 116 {
115 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 117 // If the attachment point isn't the same as the one previously used
118 // set it's offset position = 0 so that it appears on the attachment point
119 // and not in a weird location somewhere unknown.
120 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
116 { 121 {
117 // If the attachment point isn't the same as the one previously used 122 attachPos = Vector3.Zero;
118 // set it's offset position = 0 so that it appears on the attachment point 123 }
119 // and not in a weird location somewhere unknown.
120 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
121 {
122 attachPos = Vector3.Zero;
123 }
124
125 // AttachmentPt 0 means the client chose to 'wear' the attachment.
126 if (AttachmentPt == 0)
127 {
128 // Check object for stored attachment point
129 AttachmentPt = (uint)group.GetAttachmentPoint();
130 }
131
132 // if we still didn't find a suitable attachment point.......
133 if (AttachmentPt == 0)
134 {
135 // Stick it on left hand with Zero Offset from the attachment point.
136 AttachmentPt = (uint)AttachmentPoint.LeftHand;
137 attachPos = Vector3.Zero;
138 }
139 124
140 group.SetAttachmentPoint((byte)AttachmentPt); 125 // AttachmentPt 0 means the client chose to 'wear' the attachment.
141 group.AbsolutePosition = attachPos; 126 if (AttachmentPt == 0)
127 {
128 // Check object for stored attachment point
129 AttachmentPt = (uint)group.GetAttachmentPoint();
130 }
142 131
143 // Saves and gets itemID 132 // if we still didn't find a suitable attachment point.......
144 UUID itemId; 133 if (AttachmentPt == 0)
134 {
135 // Stick it on left hand with Zero Offset from the attachment point.
136 AttachmentPt = (uint)AttachmentPoint.LeftHand;
137 attachPos = Vector3.Zero;
138 }
145 139
146 if (group.GetFromItemID() == UUID.Zero) 140 group.SetAttachmentPoint((byte)AttachmentPt);
147 { 141 group.AbsolutePosition = attachPos;
148 m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
149 }
150 else
151 {
152 itemId = group.GetFromItemID();
153 }
154 142
155 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemId, group); 143 // Saves and gets itemID
144 UUID itemId;
156 145
157 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); 146 if (group.GetFromItemID() == UUID.Zero)
158 147 {
159 // In case it is later dropped again, don't let 148 m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
160 // it get cleaned up
161 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
162 group.HasGroupChanged = false;
163 } 149 }
164 else 150 else
165 { 151 {
166 remoteClient.SendAgentAlertMessage( 152 itemId = group.GetFromItemID();
167 "You don't have sufficient permissions to attach this object", false);
168
169 return false;
170 } 153 }
154
155 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemId, group);
156
157 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
158
159 // In case it is later dropped again, don't let
160 // it get cleaned up
161 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
162 group.HasGroupChanged = false;
171 } 163 }
172 else 164 else
173 { 165 {
174 m_log.DebugFormat("[ATTACHMENTS MODULE]: AttachObject found no such scene object {0}", objectLocalID); 166 remoteClient.SendAgentAlertMessage(
167 "You don't have sufficient permissions to attach this object", false);
168
175 return false; 169 return false;
176 } 170 }
177 171
@@ -237,8 +231,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
237 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 231 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
238 tainted = true; 232 tainted = true;
239 233
240 AttachObject( 234 AttachObject(remoteClient, objatt, AttachmentPt, false);
241 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
242 //objatt.ScheduleGroupForFullUpdate(); 235 //objatt.ScheduleGroupForFullUpdate();
243 236
244 if (tainted) 237 if (tainted)