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