diff options
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 105 |
1 files changed, 50 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index fc92fc3..f924b30 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -112,7 +112,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
112 | return; | 112 | return; |
113 | 113 | ||
114 | if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) | 114 | if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) |
115 | { | ||
116 | remoteClient.SendAgentAlertMessage( | ||
117 | "You don't have sufficient permissions to attach this object", false); | ||
118 | |||
115 | return; | 119 | return; |
120 | } | ||
116 | 121 | ||
117 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 122 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
118 | // be removed when that functionality is implemented in opensim | 123 | // be removed when that functionality is implemented in opensim |
@@ -142,76 +147,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
142 | { | 147 | { |
143 | Vector3 attachPos = group.AbsolutePosition; | 148 | Vector3 attachPos = group.AbsolutePosition; |
144 | 149 | ||
145 | if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) | 150 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
151 | // be removed when that functionality is implemented in opensim | ||
152 | AttachmentPt &= 0x7f; | ||
153 | |||
154 | // If the attachment point isn't the same as the one previously used | ||
155 | // set it's offset position = 0 so that it appears on the attachment point | ||
156 | // and not in a weird location somewhere unknown. | ||
157 | if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) | ||
146 | { | 158 | { |
147 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 159 | attachPos = Vector3.Zero; |
148 | // be removed when that functionality is implemented in opensim | 160 | } |
149 | AttachmentPt &= 0x7f; | ||
150 | |||
151 | // If the attachment point isn't the same as the one previously used | ||
152 | // set it's offset position = 0 so that it appears on the attachment point | ||
153 | // and not in a weird location somewhere unknown. | ||
154 | if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) | ||
155 | { | ||
156 | attachPos = Vector3.Zero; | ||
157 | } | ||
158 | 161 | ||
159 | // AttachmentPt 0 means the client chose to 'wear' the attachment. | 162 | // AttachmentPt 0 means the client chose to 'wear' the attachment. |
160 | if (AttachmentPt == 0) | 163 | if (AttachmentPt == 0) |
161 | { | 164 | { |
162 | // Check object for stored attachment point | 165 | // Check object for stored attachment point |
163 | AttachmentPt = (uint)group.GetAttachmentPoint(); | 166 | AttachmentPt = (uint)group.GetAttachmentPoint(); |
164 | } | 167 | } |
165 | 168 | ||
166 | // if we still didn't find a suitable attachment point....... | 169 | // if we still didn't find a suitable attachment point....... |
167 | if (AttachmentPt == 0) | 170 | if (AttachmentPt == 0) |
168 | { | 171 | { |
169 | // Stick it on left hand with Zero Offset from the attachment point. | 172 | // Stick it on left hand with Zero Offset from the attachment point. |
170 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | 173 | AttachmentPt = (uint)AttachmentPoint.LeftHand; |
171 | attachPos = Vector3.Zero; | 174 | attachPos = Vector3.Zero; |
172 | } | 175 | } |
173 | 176 | ||
174 | group.SetAttachmentPoint((byte)AttachmentPt); | 177 | group.SetAttachmentPoint((byte)AttachmentPt); |
175 | group.AbsolutePosition = attachPos; | 178 | group.AbsolutePosition = attachPos; |
176 | 179 | ||
177 | // Remove any previous attachments | 180 | // Remove any previous attachments |
178 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | 181 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); |
179 | UUID itemID = UUID.Zero; | 182 | UUID itemID = UUID.Zero; |
180 | if (sp != null) | 183 | if (sp != null) |
184 | { | ||
185 | foreach (SceneObjectGroup grp in sp.Attachments) | ||
181 | { | 186 | { |
182 | foreach (SceneObjectGroup grp in sp.Attachments) | 187 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) |
183 | { | 188 | { |
184 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | 189 | itemID = grp.GetFromItemID(); |
185 | { | 190 | break; |
186 | itemID = grp.GetFromItemID(); | ||
187 | break; | ||
188 | } | ||
189 | } | 191 | } |
190 | if (itemID != UUID.Zero) | ||
191 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
192 | } | 192 | } |
193 | if (itemID != UUID.Zero) | ||
194 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
195 | } | ||
193 | 196 | ||
194 | if (group.GetFromItemID() == UUID.Zero) | 197 | if (group.GetFromItemID() == UUID.Zero) |
195 | { | 198 | { |
196 | m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); | 199 | m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); |
197 | } | ||
198 | else | ||
199 | { | ||
200 | itemID = group.GetFromItemID(); | ||
201 | } | ||
202 | |||
203 | ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); | ||
204 | |||
205 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); | ||
206 | } | 200 | } |
207 | else | 201 | else |
208 | { | 202 | { |
209 | remoteClient.SendAgentAlertMessage( | 203 | itemID = group.GetFromItemID(); |
210 | "You don't have sufficient permissions to attach this object", false); | ||
211 | |||
212 | return false; | ||
213 | } | 204 | } |
214 | 205 | ||
206 | ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); | ||
207 | |||
208 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); | ||
209 | |||
215 | return true; | 210 | return true; |
216 | } | 211 | } |
217 | 212 | ||