diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
12 files changed, 496 insertions, 169 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 97a1be6..3e1cb02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | protected Scene m_scene = null; | 49 | private Scene m_scene = null; |
50 | private IDialogModule m_dialogModule; | ||
50 | 51 | ||
51 | public string Name { get { return "Attachments Module"; } } | 52 | public string Name { get { return "Attachments Module"; } } |
52 | public Type ReplaceableInterface { get { return null; } } | 53 | public Type ReplaceableInterface { get { return null; } } |
@@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
56 | public void AddRegion(Scene scene) | 57 | public void AddRegion(Scene scene) |
57 | { | 58 | { |
58 | m_scene = scene; | 59 | m_scene = scene; |
60 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
59 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 61 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
60 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 62 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
61 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 63 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
@@ -80,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
80 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; | 82 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; |
81 | client.OnObjectAttach += AttachObject; | 83 | client.OnObjectAttach += AttachObject; |
82 | client.OnObjectDetach += DetachObject; | 84 | client.OnObjectDetach += DetachObject; |
83 | client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; | 85 | client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; |
84 | } | 86 | } |
85 | 87 | ||
86 | public void UnsubscribeFromClientEvents(IClientAPI client) | 88 | public void UnsubscribeFromClientEvents(IClientAPI client) |
@@ -89,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
89 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; | 91 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; |
90 | client.OnObjectAttach -= AttachObject; | 92 | client.OnObjectAttach -= AttachObject; |
91 | client.OnObjectDetach -= DetachObject; | 93 | client.OnObjectDetach -= DetachObject; |
92 | client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; | 94 | client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; |
93 | } | 95 | } |
94 | 96 | ||
95 | /// <summary> | 97 | /// <summary> |
@@ -101,10 +103,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
101 | /// <param name="silent"></param> | 103 | /// <param name="silent"></param> |
102 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) | 104 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) |
103 | { | 105 | { |
104 | // m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); | 106 | // m_log.DebugFormat( |
107 | // "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", | ||
108 | // objectLocalID, remoteClient.Name, AttachmentPt, silent); | ||
105 | 109 | ||
106 | try | 110 | try |
107 | { | 111 | { |
112 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
113 | |||
114 | if (sp == null) | ||
115 | { | ||
116 | m_log.ErrorFormat( | ||
117 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
118 | return; | ||
119 | } | ||
120 | |||
108 | // If we can't take it, we can't attach it! | 121 | // If we can't take it, we can't attach it! |
109 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); | 122 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); |
110 | if (part == null) | 123 | if (part == null) |
@@ -123,7 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
123 | AttachmentPt &= 0x7f; | 136 | AttachmentPt &= 0x7f; |
124 | 137 | ||
125 | // Calls attach with a Zero position | 138 | // Calls attach with a Zero position |
126 | if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) | 139 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) |
127 | { | 140 | { |
128 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 141 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
129 | 142 | ||
@@ -136,12 +149,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
136 | } | 149 | } |
137 | catch (Exception e) | 150 | catch (Exception e) |
138 | { | 151 | { |
139 | m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); | 152 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace); |
140 | } | 153 | } |
141 | } | 154 | } |
142 | 155 | ||
143 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) | 156 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) |
144 | { | 157 | { |
158 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
159 | |||
160 | if (sp == null) | ||
161 | { | ||
162 | m_log.ErrorFormat( | ||
163 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
164 | return false; | ||
165 | } | ||
166 | |||
167 | return AttachObject(sp, group, AttachmentPt, silent); | ||
168 | } | ||
169 | |||
170 | private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) | ||
171 | { | ||
172 | // m_log.DebugFormat( | ||
173 | // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", | ||
174 | // group.Name, group.LocalId, sp.Name, AttachmentPt, silent); | ||
175 | |||
176 | if (sp.GetAttachments(AttachmentPt).Contains(group)) | ||
177 | { | ||
178 | // m_log.WarnFormat( | ||
179 | // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", | ||
180 | // group.Name, group.LocalId, sp.Name, AttachmentPt); | ||
181 | |||
182 | return false; | ||
183 | } | ||
184 | |||
145 | Vector3 attachPos = group.AbsolutePosition; | 185 | Vector3 attachPos = group.AbsolutePosition; |
146 | 186 | ||
147 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 187 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
@@ -175,32 +215,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
175 | group.AbsolutePosition = attachPos; | 215 | group.AbsolutePosition = attachPos; |
176 | 216 | ||
177 | // Remove any previous attachments | 217 | // Remove any previous attachments |
178 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
179 | UUID itemID = UUID.Zero; | 218 | UUID itemID = UUID.Zero; |
180 | if (sp != null) | 219 | foreach (SceneObjectGroup grp in sp.Attachments) |
181 | { | 220 | { |
182 | foreach (SceneObjectGroup grp in sp.Attachments) | 221 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) |
183 | { | 222 | { |
184 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | 223 | itemID = grp.GetFromItemID(); |
185 | { | 224 | break; |
186 | itemID = grp.GetFromItemID(); | ||
187 | break; | ||
188 | } | ||
189 | } | 225 | } |
190 | if (itemID != UUID.Zero) | ||
191 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
192 | } | 226 | } |
193 | 227 | ||
194 | if (group.GetFromItemID() == UUID.Zero) | 228 | if (itemID != UUID.Zero) |
195 | { | 229 | DetachSingleAttachmentToInv(itemID, sp); |
196 | m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | itemID = group.GetFromItemID(); | ||
201 | } | ||
202 | 230 | ||
203 | ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); | 231 | itemID = group.GetFromItemID(); |
232 | if (itemID == UUID.Zero) | ||
233 | itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; | ||
234 | |||
235 | ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); | ||
204 | 236 | ||
205 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); | 237 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); |
206 | 238 | ||
@@ -229,19 +261,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
229 | // m_log.DebugFormat( | 261 | // m_log.DebugFormat( |
230 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", | 262 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", |
231 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); | 263 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); |
264 | |||
265 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
266 | |||
267 | if (sp == null) | ||
268 | { | ||
269 | m_log.ErrorFormat( | ||
270 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", | ||
271 | remoteClient.Name, remoteClient.AgentId); | ||
272 | return UUID.Zero; | ||
273 | } | ||
232 | 274 | ||
233 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 275 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
234 | // be removed when that functionality is implemented in opensim | 276 | // be removed when that functionality is implemented in opensim |
235 | AttachmentPt &= 0x7f; | 277 | AttachmentPt &= 0x7f; |
236 | 278 | ||
237 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); | 279 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); |
238 | 280 | ||
239 | if (updateInventoryStatus) | 281 | if (updateInventoryStatus) |
240 | { | 282 | { |
241 | if (att == null) | 283 | if (att == null) |
242 | ShowDetachInUserInventory(itemID, remoteClient); | 284 | DetachSingleAttachmentToInv(itemID, sp.ControllingClient); |
243 | else | 285 | else |
244 | ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt); | 286 | ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); |
245 | } | 287 | } |
246 | 288 | ||
247 | if (null == att) | 289 | if (null == att) |
@@ -250,15 +292,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
250 | return att.UUID; | 292 | return att.UUID; |
251 | } | 293 | } |
252 | 294 | ||
253 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 295 | private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
254 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 296 | ScenePresence sp, UUID itemID, uint AttachmentPt) |
255 | { | 297 | { |
256 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | 298 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); |
257 | if (invAccess != null) | 299 | if (invAccess != null) |
258 | { | 300 | { |
259 | SceneObjectGroup objatt = invAccess.RezObject(remoteClient, | 301 | SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, |
260 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 302 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, |
261 | false, false, remoteClient.AgentId, true); | 303 | false, false, sp.UUID, true); |
262 | 304 | ||
263 | // m_log.DebugFormat( | 305 | // m_log.DebugFormat( |
264 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | 306 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", |
@@ -277,11 +319,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
277 | // This will throw if the attachment fails | 319 | // This will throw if the attachment fails |
278 | try | 320 | try |
279 | { | 321 | { |
280 | AttachObject(remoteClient, objatt, AttachmentPt, false); | 322 | AttachObject(sp, objatt, AttachmentPt, false); |
281 | } | 323 | } |
282 | catch | 324 | catch (Exception e) |
283 | { | 325 | { |
326 | m_log.ErrorFormat( | ||
327 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | ||
328 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | ||
329 | |||
284 | // Make sure the object doesn't stick around and bail | 330 | // Make sure the object doesn't stick around and bail |
331 | sp.RemoveAttachment(objatt); | ||
285 | m_scene.DeleteSceneObject(objatt, false); | 332 | m_scene.DeleteSceneObject(objatt, false); |
286 | return null; | 333 | return null; |
287 | } | 334 | } |
@@ -295,13 +342,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
295 | objatt.ResumeScripts(); | 342 | objatt.ResumeScripts(); |
296 | 343 | ||
297 | // Do this last so that event listeners have access to all the effects of the attachment | 344 | // Do this last so that event listeners have access to all the effects of the attachment |
298 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); | 345 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); |
299 | } | 346 | } |
300 | else | 347 | else |
301 | { | 348 | { |
302 | m_log.WarnFormat( | 349 | m_log.WarnFormat( |
303 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", | 350 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", |
304 | itemID, remoteClient.Name, AttachmentPt); | 351 | itemID, sp.Name, AttachmentPt); |
305 | } | 352 | } |
306 | 353 | ||
307 | return objatt; | 354 | return objatt; |
@@ -314,12 +361,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
314 | /// Update the user inventory to the attachment of an item | 361 | /// Update the user inventory to the attachment of an item |
315 | /// </summary> | 362 | /// </summary> |
316 | /// <param name="att"></param> | 363 | /// <param name="att"></param> |
317 | /// <param name="remoteClient"></param> | 364 | /// <param name="sp"></param> |
318 | /// <param name="itemID"></param> | 365 | /// <param name="itemID"></param> |
319 | /// <param name="AttachmentPt"></param> | 366 | /// <param name="AttachmentPt"></param> |
320 | /// <returns></returns> | 367 | /// <returns></returns> |
321 | protected UUID ShowAttachInUserInventory( | 368 | private UUID ShowAttachInUserInventory( |
322 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 369 | SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) |
323 | { | 370 | { |
324 | // m_log.DebugFormat( | 371 | // m_log.DebugFormat( |
325 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | 372 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", |
@@ -328,16 +375,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
328 | if (!att.IsDeleted) | 375 | if (!att.IsDeleted) |
329 | AttachmentPt = att.RootPart.AttachmentPoint; | 376 | AttachmentPt = att.RootPart.AttachmentPoint; |
330 | 377 | ||
331 | ScenePresence presence; | 378 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); |
332 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 379 | item = m_scene.InventoryService.GetItem(item); |
333 | { | ||
334 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
335 | item = m_scene.InventoryService.GetItem(item); | ||
336 | 380 | ||
337 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | 381 | bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); |
338 | if (changed && m_scene.AvatarFactory != null) | 382 | if (changed && m_scene.AvatarFactory != null) |
339 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 383 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
340 | } | ||
341 | 384 | ||
342 | return att.UUID; | 385 | return att.UUID; |
343 | } | 386 | } |
@@ -345,12 +388,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
345 | /// <summary> | 388 | /// <summary> |
346 | /// Update the user inventory to reflect an attachment | 389 | /// Update the user inventory to reflect an attachment |
347 | /// </summary> | 390 | /// </summary> |
348 | /// <param name="remoteClient"></param> | 391 | /// <param name="sp"></param> |
349 | /// <param name="AttachmentPt"></param> | 392 | /// <param name="AttachmentPt"></param> |
350 | /// <param name="itemID"></param> | 393 | /// <param name="itemID"></param> |
351 | /// <param name="att"></param> | 394 | /// <param name="att"></param> |
352 | protected void ShowAttachInUserInventory( | 395 | private void ShowAttachInUserInventory( |
353 | IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 396 | ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
354 | { | 397 | { |
355 | // m_log.DebugFormat( | 398 | // m_log.DebugFormat( |
356 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | 399 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", |
@@ -374,16 +417,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
374 | return; | 417 | return; |
375 | } | 418 | } |
376 | 419 | ||
377 | ScenePresence presence; | 420 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); |
378 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 421 | item = m_scene.InventoryService.GetItem(item); |
379 | { | 422 | bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); |
380 | // XXYY!! | 423 | if (changed && m_scene.AvatarFactory != null) |
381 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 424 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
382 | item = m_scene.InventoryService.GetItem(item); | ||
383 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | ||
384 | if (changed && m_scene.AvatarFactory != null) | ||
385 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | ||
386 | } | ||
387 | } | 425 | } |
388 | 426 | ||
389 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) | 427 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) |
@@ -391,12 +429,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
391 | SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); | 429 | SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); |
392 | if (group != null) | 430 | if (group != null) |
393 | { | 431 | { |
394 | //group.DetachToGround(); | 432 | DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); |
395 | ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); | ||
396 | } | 433 | } |
397 | } | 434 | } |
398 | 435 | ||
399 | public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) | 436 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) |
400 | { | 437 | { |
401 | ScenePresence presence; | 438 | ScenePresence presence; |
402 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 439 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
@@ -407,34 +444,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
407 | bool changed = presence.Appearance.DetachAttachment(itemID); | 444 | bool changed = presence.Appearance.DetachAttachment(itemID); |
408 | if (changed && m_scene.AvatarFactory != null) | 445 | if (changed && m_scene.AvatarFactory != null) |
409 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 446 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
410 | } | ||
411 | 447 | ||
412 | DetachSingleAttachmentToInv(itemID, remoteClient); | 448 | DetachSingleAttachmentToInv(itemID, presence); |
449 | } | ||
413 | } | 450 | } |
414 | 451 | ||
415 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) | 452 | public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) |
416 | { | 453 | { |
417 | SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); | 454 | SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); |
418 | if (part == null || part.ParentGroup == null) | 455 | |
456 | if (so == null) | ||
419 | return; | 457 | return; |
420 | 458 | ||
421 | if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId) | 459 | if (so.AttachedAvatar != remoteClient.AgentId) |
422 | return; | 460 | return; |
423 | 461 | ||
424 | UUID inventoryID = part.ParentGroup.GetFromItemID(); | 462 | UUID inventoryID = so.GetFromItemID(); |
425 | 463 | ||
426 | ScenePresence presence; | 464 | ScenePresence presence; |
427 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 465 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
428 | { | 466 | { |
429 | if (!m_scene.Permissions.CanRezObject( | 467 | if (!m_scene.Permissions.CanRezObject( |
430 | part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) | 468 | so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) |
431 | return; | 469 | return; |
432 | 470 | ||
433 | bool changed = presence.Appearance.DetachAttachment(itemID); | 471 | bool changed = presence.Appearance.DetachAttachment(sceneObjectID); |
434 | if (changed && m_scene.AvatarFactory != null) | 472 | if (changed && m_scene.AvatarFactory != null) |
435 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 473 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
436 | 474 | ||
437 | part.ParentGroup.DetachToGround(); | 475 | presence.RemoveAttachment(so); |
476 | DetachSceneObjectToGround(so, presence); | ||
438 | 477 | ||
439 | List<UUID> uuids = new List<UUID>(); | 478 | List<UUID> uuids = new List<UUID>(); |
440 | uuids.Add(inventoryID); | 479 | uuids.Add(inventoryID); |
@@ -442,12 +481,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
442 | remoteClient.SendRemoveInventoryItem(inventoryID); | 481 | remoteClient.SendRemoveInventoryItem(inventoryID); |
443 | } | 482 | } |
444 | 483 | ||
445 | m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); | 484 | m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); |
485 | } | ||
486 | |||
487 | /// <summary> | ||
488 | /// Detach the given scene objet to the ground. | ||
489 | /// </summary> | ||
490 | /// <remarks> | ||
491 | /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. | ||
492 | /// </remarks> | ||
493 | /// <param name="so">The scene object to detach.</param> | ||
494 | /// <param name="sp">The scene presence from which the scene object is being detached.</param> | ||
495 | private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) | ||
496 | { | ||
497 | SceneObjectPart rootPart = so.RootPart; | ||
498 | |||
499 | rootPart.FromItemID = UUID.Zero; | ||
500 | so.AbsolutePosition = sp.AbsolutePosition; | ||
501 | so.AttachedAvatar = UUID.Zero; | ||
502 | rootPart.SetParentLocalId(0); | ||
503 | so.ClearPartAttachmentData(); | ||
504 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); | ||
505 | so.HasGroupChanged = true; | ||
506 | rootPart.Rezzed = DateTime.Now; | ||
507 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
508 | so.AttachToBackup(); | ||
509 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
510 | rootPart.ScheduleFullUpdate(); | ||
511 | rootPart.ClearUndoState(); | ||
446 | } | 512 | } |
447 | 513 | ||
448 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | 514 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. |
449 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | 515 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? |
450 | protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | 516 | private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) |
451 | { | 517 | { |
452 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | 518 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... |
453 | return; | 519 | return; |
@@ -465,17 +531,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
465 | if (group.GetFromItemID() == itemID) | 531 | if (group.GetFromItemID() == itemID) |
466 | { | 532 | { |
467 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); | 533 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); |
468 | group.DetachToInventoryPrep(); | 534 | sp.RemoveAttachment(group); |
469 | // m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | 535 | |
470 | 536 | // Prepare sog for storage | |
471 | // If an item contains scripts, it's always changed. | 537 | group.AttachedAvatar = UUID.Zero; |
472 | // This ensures script state is saved on detach | 538 | |
473 | foreach (SceneObjectPart p in group.Parts) | 539 | group.ForEachPart( |
474 | if (p.Inventory.ContainsScripts()) | 540 | delegate(SceneObjectPart part) |
475 | group.HasGroupChanged = true; | 541 | { |
476 | 542 | // If there are any scripts, | |
477 | UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); | 543 | // then always trigger a new object and state persistence in UpdateKnownItem() |
544 | if (part.Inventory.ContainsScripts()) | ||
545 | group.HasGroupChanged = true; | ||
546 | } | ||
547 | ); | ||
548 | |||
549 | group.RootPart.SetParentLocalId(0); | ||
550 | group.RootPart.IsAttachment = false; | ||
551 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
552 | |||
553 | UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); | ||
478 | m_scene.DeleteSceneObject(group, false); | 554 | m_scene.DeleteSceneObject(group, false); |
555 | |||
479 | return; | 556 | return; |
480 | } | 557 | } |
481 | } | 558 | } |
@@ -515,7 +592,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
515 | { | 592 | { |
516 | if (!grp.HasGroupChanged) | 593 | if (!grp.HasGroupChanged) |
517 | { | 594 | { |
518 | m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); | 595 | m_log.DebugFormat( |
596 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", | ||
597 | grp.UUID, grp.GetAttachmentPoint()); | ||
598 | |||
519 | return; | 599 | return; |
520 | } | 600 | } |
521 | 601 | ||
@@ -524,6 +604,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
524 | grp.UUID, grp.GetAttachmentPoint()); | 604 | grp.UUID, grp.GetAttachmentPoint()); |
525 | 605 | ||
526 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | 606 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); |
607 | |||
527 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 608 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
528 | item = m_scene.InventoryService.GetItem(item); | 609 | item = m_scene.InventoryService.GetItem(item); |
529 | 610 | ||
@@ -575,12 +656,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
575 | m_scene.DeleteFromStorage(so.UUID); | 656 | m_scene.DeleteFromStorage(so.UUID); |
576 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | 657 | m_scene.EventManager.TriggerParcelPrimCountTainted(); |
577 | 658 | ||
578 | so.RootPart.AttachedAvatar = avatar.UUID; | 659 | so.AttachedAvatar = avatar.UUID; |
579 | |||
580 | //Anakin Lohner bug #3839 | ||
581 | SceneObjectPart[] parts = so.Parts; | ||
582 | for (int i = 0; i < parts.Length; i++) | ||
583 | parts[i].AttachedAvatar = avatar.UUID; | ||
584 | 660 | ||
585 | if (so.RootPart.PhysActor != null) | 661 | if (so.RootPart.PhysActor != null) |
586 | { | 662 | { |
@@ -616,5 +692,97 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
616 | // it get cleaned up | 692 | // it get cleaned up |
617 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 693 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
618 | } | 694 | } |
695 | |||
696 | /// <summary> | ||
697 | /// Add a scene object that was previously free in the scene as an attachment to an avatar. | ||
698 | /// </summary> | ||
699 | /// <param name="remoteClient"></param> | ||
700 | /// <param name="grp"></param> | ||
701 | /// <returns>The user inventory item created that holds the attachment.</returns> | ||
702 | private InventoryItemBase AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp) | ||
703 | { | ||
704 | // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); | ||
705 | |||
706 | Vector3 inventoryStoredPosition = new Vector3 | ||
707 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
708 | ? Constants.RegionSize - 6 | ||
709 | : grp.AbsolutePosition.X) | ||
710 | , | ||
711 | (grp.AbsolutePosition.Y > (int)Constants.RegionSize) | ||
712 | ? Constants.RegionSize - 6 | ||
713 | : grp.AbsolutePosition.Y, | ||
714 | grp.AbsolutePosition.Z); | ||
715 | |||
716 | Vector3 originalPosition = grp.AbsolutePosition; | ||
717 | |||
718 | grp.AbsolutePosition = inventoryStoredPosition; | ||
719 | |||
720 | // If we're being called from a script, then trying to serialize that same script's state will not complete | ||
721 | // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if | ||
722 | // the client/server crashes rather than logging out normally, the attachment's scripts will resume | ||
723 | // without state on relog. Arguably, this is what we want anyway. | ||
724 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); | ||
725 | |||
726 | grp.AbsolutePosition = originalPosition; | ||
727 | |||
728 | AssetBase asset = m_scene.CreateAsset( | ||
729 | grp.GetPartName(grp.LocalId), | ||
730 | grp.GetPartDescription(grp.LocalId), | ||
731 | (sbyte)AssetType.Object, | ||
732 | Utils.StringToBytes(sceneObjectXml), | ||
733 | remoteClient.AgentId); | ||
734 | |||
735 | m_scene.AssetService.Store(asset); | ||
736 | |||
737 | InventoryItemBase item = new InventoryItemBase(); | ||
738 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
739 | item.CreatorData = grp.RootPart.CreatorData; | ||
740 | item.Owner = remoteClient.AgentId; | ||
741 | item.ID = UUID.Random(); | ||
742 | item.AssetID = asset.FullID; | ||
743 | item.Description = asset.Description; | ||
744 | item.Name = asset.Name; | ||
745 | item.AssetType = asset.Type; | ||
746 | item.InvType = (int)InventoryType.Object; | ||
747 | |||
748 | InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
749 | if (folder != null) | ||
750 | item.Folder = folder.ID; | ||
751 | else // oopsies | ||
752 | item.Folder = UUID.Zero; | ||
753 | |||
754 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && m_scene.Permissions.PropagatePermissions()) | ||
755 | { | ||
756 | item.BasePermissions = grp.RootPart.NextOwnerMask; | ||
757 | item.CurrentPermissions = grp.RootPart.NextOwnerMask; | ||
758 | item.NextPermissions = grp.RootPart.NextOwnerMask; | ||
759 | item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
760 | item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
761 | } | ||
762 | else | ||
763 | { | ||
764 | item.BasePermissions = grp.RootPart.BaseMask; | ||
765 | item.CurrentPermissions = grp.RootPart.OwnerMask; | ||
766 | item.NextPermissions = grp.RootPart.NextOwnerMask; | ||
767 | item.EveryOnePermissions = grp.RootPart.EveryoneMask; | ||
768 | item.GroupPermissions = grp.RootPart.GroupMask; | ||
769 | } | ||
770 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
771 | |||
772 | // sets itemID so client can show item as 'attached' in inventory | ||
773 | grp.SetFromItemID(item.ID); | ||
774 | |||
775 | if (m_scene.AddInventoryItem(item)) | ||
776 | { | ||
777 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
778 | } | ||
779 | else | ||
780 | { | ||
781 | if (m_dialogModule != null) | ||
782 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
783 | } | ||
784 | |||
785 | return item; | ||
786 | } | ||
619 | } | 787 | } |
620 | } | 788 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5bac4c6..b7d21fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -54,11 +54,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
54 | [TestFixture] | 54 | [TestFixture] |
55 | public class AttachmentsModuleTests | 55 | public class AttachmentsModuleTests |
56 | { | 56 | { |
57 | public Scene scene; | 57 | private Scene scene; |
58 | public UUID agent1; | 58 | private AttachmentsModule m_attMod; |
59 | public static Random random; | 59 | private ScenePresence m_presence; |
60 | public AgentCircuitData acd1; | ||
61 | public SceneObjectGroup sog1, sog2; | ||
62 | 60 | ||
63 | [SetUp] | 61 | [SetUp] |
64 | public void Init() | 62 | public void Init() |
@@ -71,12 +69,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
71 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 69 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
72 | 70 | ||
73 | scene = SceneHelpers.SetupScene(); | 71 | scene = SceneHelpers.SetupScene(); |
74 | SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); | 72 | m_attMod = new AttachmentsModule(); |
75 | 73 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); | |
76 | agent1 = UUID.Random(); | ||
77 | random = new Random(); | ||
78 | sog1 = NewSOG(UUID.Random(), scene, agent1); | ||
79 | sog2 = NewSOG(UUID.Random(), scene, agent1); | ||
80 | } | 74 | } |
81 | 75 | ||
82 | [TearDown] | 76 | [TearDown] |
@@ -86,31 +80,139 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
86 | // threads. Possibly, later tests should be rewritten not to worry about such things. | 80 | // threads. Possibly, later tests should be rewritten not to worry about such things. |
87 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 81 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
88 | } | 82 | } |
89 | 83 | ||
84 | /// <summary> | ||
85 | /// Add the standard presence for a test. | ||
86 | /// </summary> | ||
87 | private void AddPresence() | ||
88 | { | ||
89 | UUID userId = TestHelpers.ParseTail(0x1); | ||
90 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
91 | m_presence = SceneHelpers.AddScenePresence(scene, userId); | ||
92 | } | ||
93 | |||
90 | [Test] | 94 | [Test] |
91 | public void TestAddAttachments() | 95 | public void TestAddAttachmentFromGround() |
92 | { | 96 | { |
93 | TestHelpers.InMethod(); | 97 | TestHelpers.InMethod(); |
98 | // log4net.Config.XmlConfigurator.Configure(); | ||
94 | 99 | ||
95 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); | 100 | AddPresence(); |
96 | presence.AddAttachment(sog1); | 101 | string attName = "att"; |
97 | presence.AddAttachment(sog2); | ||
98 | 102 | ||
99 | Assert.That(presence.HasAttachments(), Is.True); | 103 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; |
100 | Assert.That(presence.ValidateAttachments(), Is.True); | 104 | |
105 | m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); | ||
106 | |||
107 | // Check status on scene presence | ||
108 | Assert.That(m_presence.HasAttachments(), Is.True); | ||
109 | List<SceneObjectGroup> attachments = m_presence.Attachments; | ||
110 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
111 | SceneObjectGroup attSo = attachments[0]; | ||
112 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
113 | Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
114 | Assert.That(attSo.IsAttachment); | ||
115 | Assert.That(attSo.UsesPhysics, Is.False); | ||
116 | Assert.That(attSo.IsTemporary, Is.False); | ||
117 | |||
118 | // Check item status | ||
119 | Assert.That(m_presence.Appearance.GetAttachpoint( | ||
120 | attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
101 | } | 121 | } |
102 | 122 | ||
103 | [Test] | 123 | [Test] |
104 | public void TestRemoveAttachments() | 124 | public void TestAddAttachmentFromInventory() |
105 | { | 125 | { |
106 | TestHelpers.InMethod(); | 126 | TestHelpers.InMethod(); |
127 | // log4net.Config.XmlConfigurator.Configure(); | ||
128 | |||
129 | AddPresence(); | ||
107 | 130 | ||
108 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); | 131 | UUID attItemId = TestHelpers.ParseTail(0x2); |
109 | presence.AddAttachment(sog1); | 132 | UUID attAssetId = TestHelpers.ParseTail(0x3); |
110 | presence.AddAttachment(sog2); | 133 | string attName = "att"; |
111 | presence.RemoveAttachment(sog1); | 134 | |
112 | presence.RemoveAttachment(sog2); | 135 | InventoryItemBase attItem |
113 | Assert.That(presence.HasAttachments(), Is.False); | 136 | = UserInventoryHelpers.CreateInventoryItem( |
137 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
138 | |||
139 | m_attMod.RezSingleAttachmentFromInventory( | ||
140 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
141 | |||
142 | // Check status on scene presence | ||
143 | Assert.That(m_presence.HasAttachments(), Is.True); | ||
144 | List<SceneObjectGroup> attachments = m_presence.Attachments; | ||
145 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
146 | SceneObjectGroup attSo = attachments[0]; | ||
147 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
148 | Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
149 | Assert.That(attSo.IsAttachment); | ||
150 | Assert.That(attSo.UsesPhysics, Is.False); | ||
151 | Assert.That(attSo.IsTemporary, Is.False); | ||
152 | |||
153 | // Check item status | ||
154 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
155 | } | ||
156 | |||
157 | [Test] | ||
158 | public void TestDetachAttachmentToScene() | ||
159 | { | ||
160 | TestHelpers.InMethod(); | ||
161 | // log4net.Config.XmlConfigurator.Configure(); | ||
162 | |||
163 | AddPresence(); | ||
164 | |||
165 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
166 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
167 | string attName = "att"; | ||
168 | |||
169 | InventoryItemBase attItem | ||
170 | = UserInventoryHelpers.CreateInventoryItem( | ||
171 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
172 | |||
173 | UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( | ||
174 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
175 | m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); | ||
176 | |||
177 | // Check status on scene presence | ||
178 | Assert.That(m_presence.HasAttachments(), Is.False); | ||
179 | List<SceneObjectGroup> attachments = m_presence.Attachments; | ||
180 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
181 | |||
182 | // Check item status | ||
183 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); | ||
184 | |||
185 | // Check object in scene | ||
186 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); | ||
187 | } | ||
188 | |||
189 | [Test] | ||
190 | public void TestDetachAttachmentToInventory() | ||
191 | { | ||
192 | TestHelpers.InMethod(); | ||
193 | // log4net.Config.XmlConfigurator.Configure(); | ||
194 | |||
195 | AddPresence(); | ||
196 | |||
197 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
198 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
199 | string attName = "att"; | ||
200 | |||
201 | InventoryItemBase attItem | ||
202 | = UserInventoryHelpers.CreateInventoryItem( | ||
203 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
204 | |||
205 | m_attMod.RezSingleAttachmentFromInventory( | ||
206 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
207 | m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient); | ||
208 | |||
209 | // Check status on scene presence | ||
210 | Assert.That(m_presence.HasAttachments(), Is.False); | ||
211 | List<SceneObjectGroup> attachments = m_presence.Attachments; | ||
212 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
213 | |||
214 | // Check item status | ||
215 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); | ||
114 | } | 216 | } |
115 | 217 | ||
116 | [Test] | 218 | [Test] |
@@ -138,7 +240,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
138 | List<SceneObjectGroup> attachments = presence.Attachments; | 240 | List<SceneObjectGroup> attachments = presence.Attachments; |
139 | 241 | ||
140 | Assert.That(attachments.Count, Is.EqualTo(1)); | 242 | Assert.That(attachments.Count, Is.EqualTo(1)); |
141 | Assert.That(attachments[0].Name, Is.EqualTo(attName)); | 243 | SceneObjectGroup attSo = attachments[0]; |
244 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
245 | Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
246 | Assert.That(attSo.IsAttachment); | ||
247 | Assert.That(attSo.UsesPhysics, Is.False); | ||
248 | Assert.That(attSo.IsTemporary, Is.False); | ||
142 | } | 249 | } |
143 | 250 | ||
144 | // I'm commenting this test because scene setup NEEDS InventoryService to | 251 | // I'm commenting this test because scene setup NEEDS InventoryService to |
@@ -162,39 +269,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
162 | // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | 269 | // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); |
163 | // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | 270 | // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); |
164 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 271 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); |
165 | // } | 272 | // } |
166 | |||
167 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
168 | { | ||
169 | SceneObjectPart sop = new SceneObjectPart(); | ||
170 | sop.Name = RandomName(); | ||
171 | sop.Description = RandomName(); | ||
172 | sop.Text = RandomName(); | ||
173 | sop.SitName = RandomName(); | ||
174 | sop.TouchName = RandomName(); | ||
175 | sop.UUID = uuid; | ||
176 | sop.Shape = PrimitiveBaseShape.Default; | ||
177 | sop.Shape.State = 1; | ||
178 | sop.OwnerID = agent; | ||
179 | |||
180 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
181 | sog.SetScene(scene); | ||
182 | |||
183 | return sog; | ||
184 | } | ||
185 | |||
186 | private static string RandomName() | ||
187 | { | ||
188 | StringBuilder name = new StringBuilder(); | ||
189 | int size = random.Next(5,12); | ||
190 | char ch; | ||
191 | for (int i = 0; i < size; i++) | ||
192 | { | ||
193 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
194 | name.Append(ch); | ||
195 | } | ||
196 | |||
197 | return name.ToString(); | ||
198 | } | ||
199 | } | 273 | } |
200 | } \ No newline at end of file | 274 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index e3d4969..b4f69e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -278,7 +278,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
278 | else | 278 | else |
279 | { | 279 | { |
280 | if (m_TransferModule != null) | 280 | if (m_TransferModule != null) |
281 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); | 281 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { |
282 | // Send BulkUpdateInventory | ||
283 | IInventoryService invService = scene.InventoryService; | ||
284 | UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
285 | |||
286 | InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
287 | folder = invService.GetFolder(folder); | ||
288 | |||
289 | ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
290 | |||
291 | fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
292 | }); | ||
282 | } | 293 | } |
283 | } | 294 | } |
284 | else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) | 295 | else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index d647e71..22352f5 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -282,6 +282,90 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | /// <summary> | ||
286 | /// Delivers the message to. | ||
287 | /// </summary> | ||
288 | /// <param name='target'> | ||
289 | /// Target. | ||
290 | /// </param> | ||
291 | /// <param name='channel'> | ||
292 | /// Channel. | ||
293 | /// </param> | ||
294 | /// <param name='name'> | ||
295 | /// Name. | ||
296 | /// </param> | ||
297 | /// <param name='id'> | ||
298 | /// Identifier. | ||
299 | /// </param> | ||
300 | /// <param name='msg'> | ||
301 | /// Message. | ||
302 | /// </param> | ||
303 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) | ||
304 | { | ||
305 | error = null; | ||
306 | // Is id an avatar? | ||
307 | ScenePresence sp = m_scene.GetScenePresence(target); | ||
308 | |||
309 | if (sp != null) | ||
310 | { | ||
311 | // Send message to avatar | ||
312 | if (channel == 0) | ||
313 | { | ||
314 | m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); | ||
315 | } | ||
316 | |||
317 | List<SceneObjectGroup> attachments = sp.Attachments; | ||
318 | // Nothing left to do | ||
319 | if (attachments == null) | ||
320 | return true; | ||
321 | |||
322 | // Get uuid of attachments | ||
323 | List<UUID> targets = new List<UUID>(); | ||
324 | foreach ( SceneObjectGroup sog in attachments ) | ||
325 | { | ||
326 | targets.Add(sog.UUID); | ||
327 | } | ||
328 | // Need to check each attachment | ||
329 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
330 | { | ||
331 | if (li.GetHostID().Equals(id)) | ||
332 | continue; | ||
333 | |||
334 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
335 | continue; | ||
336 | |||
337 | if ( targets.Contains(li.GetHostID())) | ||
338 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
339 | } | ||
340 | return true; | ||
341 | } | ||
342 | |||
343 | // Need to toss an error here | ||
344 | if (channel == 0) | ||
345 | { | ||
346 | error = "Cannot use llRegionSayTo to message objects on channel 0"; | ||
347 | return false; | ||
348 | } | ||
349 | |||
350 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
351 | { | ||
352 | // Dont process if this message is from yourself! | ||
353 | if (li.GetHostID().Equals(id)) | ||
354 | continue; | ||
355 | |||
356 | SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); | ||
357 | if (sPart == null) | ||
358 | continue; | ||
359 | |||
360 | if ( li.GetHostID().Equals(target)) | ||
361 | { | ||
362 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
363 | break; | ||
364 | } | ||
365 | } | ||
366 | return true; | ||
367 | } | ||
368 | |||
285 | protected void QueueMessage(ListenerInfo li) | 369 | protected void QueueMessage(ListenerInfo li) |
286 | { | 370 | { |
287 | lock (m_pending.SyncRoot) | 371 | lock (m_pending.SyncRoot) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index b570155..e5af1f4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs | |||
@@ -48,7 +48,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
48 | private static bool m_Enabled = false; | 48 | private static bool m_Enabled = false; |
49 | 49 | ||
50 | private IConfigSource m_Config; | 50 | private IConfigSource m_Config; |
51 | bool m_Registered = false; | ||
52 | 51 | ||
53 | #region IRegionModule interface | 52 | #region IRegionModule interface |
54 | 53 | ||
@@ -64,9 +63,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
64 | m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); | 63 | m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); |
65 | new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); | 64 | new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); |
66 | } | 65 | } |
67 | |||
68 | } | 66 | } |
69 | |||
70 | } | 67 | } |
71 | 68 | ||
72 | public void PostInitialise() | 69 | public void PostInitialise() |
@@ -106,6 +103,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
106 | } | 103 | } |
107 | 104 | ||
108 | #endregion | 105 | #endregion |
109 | |||
110 | } | 106 | } |
111 | } | 107 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 5fa27b8..003324f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs | |||
@@ -125,7 +125,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
125 | 125 | ||
126 | bool isAuthorized = true; | 126 | bool isAuthorized = true; |
127 | message = String.Empty; | 127 | message = String.Empty; |
128 | string mail = String.Empty; | ||
129 | 128 | ||
130 | // get the scene this call is being made for | 129 | // get the scene this call is being made for |
131 | Scene scene = null; | 130 | Scene scene = null; |
@@ -144,9 +143,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
144 | { | 143 | { |
145 | UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); | 144 | UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); |
146 | 145 | ||
147 | if (account != null) | ||
148 | mail = account.Email; | ||
149 | |||
150 | isAuthorized | 146 | isAuthorized |
151 | = IsAuthorizedForRegion( | 147 | = IsAuthorizedForRegion( |
152 | userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); | 148 | userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 0c57618..65e39c0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
280 | { | 280 | { |
281 | // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); | 281 | // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); |
282 | 282 | ||
283 | UUID requestedItemId = item.ID; | 283 | // UUID requestedItemId = item.ID; |
284 | 284 | ||
285 | item = m_InventoryService.GetItem(item); | 285 | item = m_InventoryService.GetItem(item); |
286 | 286 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index e224670..6d3ace9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -61,7 +61,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
61 | private bool m_enabled = false; | 61 | private bool m_enabled = false; |
62 | private IMapImageService m_MapService; | 62 | private IMapImageService m_MapService; |
63 | 63 | ||
64 | private string m_serverUrl = String.Empty; | ||
65 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 64 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
66 | 65 | ||
67 | private int m_refreshtime = 0; | 66 | private int m_refreshtime = 0; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 59a407f..e2e383f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
39 | { | 39 | { |
40 | public class PresenceDetector | 40 | public class PresenceDetector |
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private IPresenceService m_PresenceService; | 44 | private IPresenceService m_PresenceService; |
45 | private Scene m_aScene; | 45 | private Scene m_aScene; |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 7554e12..2117827 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -743,7 +743,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
743 | // Corner case. If an autoreturn happens during sim startup | 743 | // Corner case. If an autoreturn happens during sim startup |
744 | // we will come here with the list uninitialized | 744 | // we will come here with the list uninitialized |
745 | // | 745 | // |
746 | int landId = m_landIDList[x, y]; | 746 | // int landId = m_landIDList[x, y]; |
747 | 747 | ||
748 | // if (landId == 0) | 748 | // if (landId == 0) |
749 | // m_log.DebugFormat( | 749 | // m_log.DebugFormat( |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index dca842a..efede5c 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | 51 | ||
52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule | 52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | private Scene m_Scene; | 56 | private Scene m_Scene; |
57 | private Dictionary<UUID, PrimCounts> m_PrimCounts = | 57 | private Dictionary<UUID, PrimCounts> m_PrimCounts = |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 710230a..857079c 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -435,7 +435,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
435 | List<ILandObject> parcels = landChannel.AllParcels(); | 435 | List<ILandObject> parcels = landChannel.AllParcels(); |
436 | 436 | ||
437 | // Local Map Item Request | 437 | // Local Map Item Request |
438 | int tc = Environment.TickCount; | ||
439 | List<mapItemReply> mapitems = new List<mapItemReply>(); | 438 | List<mapItemReply> mapitems = new List<mapItemReply>(); |
440 | mapItemReply mapitem = new mapItemReply(); | 439 | mapItemReply mapitem = new mapItemReply(); |
441 | if ((parcels != null) && (parcels.Count >= 1)) | 440 | if ((parcels != null) && (parcels.Count >= 1)) |