diff options
author | Justin Clark-Casey (justincc) | 2013-03-28 23:57:35 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-28 23:57:35 +0000 |
commit | c92654fb43f303da8e1623f9fff8a404aad72374 (patch) | |
tree | 0da006460864b09b78c89fca4fc74d88895a81db /OpenSim/Region/CoreModules | |
parent | Add "debug attachments" console command to allow highly verbose attachment lo... (diff) | |
download | opensim-SC_OLD-c92654fb43f303da8e1623f9fff8a404aad72374.zip opensim-SC_OLD-c92654fb43f303da8e1623f9fff8a404aad72374.tar.gz opensim-SC_OLD-c92654fb43f303da8e1623f9fff8a404aad72374.tar.bz2 opensim-SC_OLD-c92654fb43f303da8e1623f9fff8a404aad72374.tar.xz |
Stop attempts to update/add existing attachments in user inventory when teleporting between regions.
This appears to resolve issues on teleport where attachments disappear or become labelled as invalid within user inventory.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 10 |
2 files changed, 20 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c78f5b3..b7f4303 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -322,12 +322,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
322 | sp.ClearAttachments(); | 322 | sp.ClearAttachments(); |
323 | } | 323 | } |
324 | 324 | ||
325 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append) | 325 | public bool AttachObject( |
326 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append) | ||
326 | { | 327 | { |
327 | if (!Enabled) | 328 | if (!Enabled) |
328 | return false; | 329 | return false; |
329 | 330 | ||
330 | return AttachObjectInternal(sp, group, attachmentPt, silent, temp, true, append); | 331 | return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, true, append); |
331 | } | 332 | } |
332 | 333 | ||
333 | /// <summary> | 334 | /// <summary> |
@@ -338,10 +339,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
338 | /// <param name='group'>The object to attach.</param> | 339 | /// <param name='group'>The object to attach.</param> |
339 | /// <param name='attachmentPt'></param> | 340 | /// <param name='attachmentPt'></param> |
340 | /// <param name='silent'></param> | 341 | /// <param name='silent'></param> |
341 | /// <param name='temp'></param> | 342 | /// <param name='addToInventory'>If true then add object to user inventory.</param> |
342 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> | 343 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> |
344 | /// <param name='append'>Append to attachment point rather than replace.</param> | ||
343 | private bool AttachObjectInternal( | 345 | private bool AttachObjectInternal( |
344 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts, bool append) | 346 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append) |
345 | { | 347 | { |
346 | if (group.GetSittingAvatarsCount() != 0) | 348 | if (group.GetSittingAvatarsCount() != 0) |
347 | { | 349 | { |
@@ -412,8 +414,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
412 | 414 | ||
413 | lock (sp.AttachmentsSyncLock) | 415 | lock (sp.AttachmentsSyncLock) |
414 | { | 416 | { |
415 | if (sp.PresenceType != PresenceType.Npc) | 417 | if (addToInventory && sp.PresenceType != PresenceType.Npc) |
416 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); | 418 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); |
417 | 419 | ||
418 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); | 420 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); |
419 | 421 | ||
@@ -432,19 +434,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
432 | return true; | 434 | return true; |
433 | } | 435 | } |
434 | 436 | ||
435 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append) | 437 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool append) |
436 | { | 438 | { |
437 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | 439 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
438 | 440 | ||
439 | // Add the new attachment to inventory if we don't already have it. | 441 | // Add the new attachment to inventory if we don't already have it. |
440 | if (!temp) | 442 | UUID newAttachmentItemID = group.FromItemID; |
441 | { | 443 | if (newAttachmentItemID == UUID.Zero) |
442 | UUID newAttachmentItemID = group.FromItemID; | 444 | newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; |
443 | if (newAttachmentItemID == UUID.Zero) | ||
444 | newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; | ||
445 | 445 | ||
446 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); | 446 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); |
447 | } | ||
448 | } | 447 | } |
449 | 448 | ||
450 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 449 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
@@ -939,7 +938,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
939 | // This will throw if the attachment fails | 938 | // This will throw if the attachment fails |
940 | try | 939 | try |
941 | { | 940 | { |
942 | AttachObjectInternal(sp, objatt, attachmentPt, false, false, true, append); | 941 | AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append); |
943 | } | 942 | } |
944 | catch (Exception e) | 943 | catch (Exception e) |
945 | { | 944 | { |
@@ -1081,7 +1080,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
1081 | AttachmentPt &= 0x7f; | 1080 | AttachmentPt &= 0x7f; |
1082 | 1081 | ||
1083 | // Calls attach with a Zero position | 1082 | // Calls attach with a Zero position |
1084 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, append)) | 1083 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append)) |
1085 | { | 1084 | { |
1086 | if (DebugLevel > 0) | 1085 | if (DebugLevel > 0) |
1087 | m_log.Debug( | 1086 | m_log.Debug( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index c8c594d..6e4262e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
198 | 198 | ||
199 | m_numberOfAttachEventsFired = 0; | 199 | m_numberOfAttachEventsFired = 0; |
200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); |
201 | 201 | ||
202 | // Check status on scene presence | 202 | // Check status on scene presence |
203 | Assert.That(sp.HasAttachments(), Is.True); | 203 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
244 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); | 244 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); |
245 | 245 | ||
246 | m_numberOfAttachEventsFired = 0; | 246 | m_numberOfAttachEventsFired = 0; |
247 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false, false); | 247 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false); |
248 | 248 | ||
249 | // Check status on scene presence | 249 | // Check status on scene presence |
250 | Assert.That(sp.HasAttachments(), Is.True); | 250 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
277 | 277 | ||
278 | // Test wearing a different attachment from the ground. | 278 | // Test wearing a different attachment from the ground. |
279 | { | 279 | { |
280 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); | 280 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); |
281 | 281 | ||
282 | // Check status on scene presence | 282 | // Check status on scene presence |
283 | Assert.That(sp.HasAttachments(), Is.True); | 283 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -310,7 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
310 | 310 | ||
311 | // Test rewearing an already worn attachment from ground. Nothing should happen. | 311 | // Test rewearing an already worn attachment from ground. Nothing should happen. |
312 | { | 312 | { |
313 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); | 313 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); |
314 | 314 | ||
315 | // Check status on scene presence | 315 | // Check status on scene presence |
316 | Assert.That(sp.HasAttachments(), Is.True); | 316 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -368,7 +368,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
368 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 368 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
369 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 369 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
370 | 370 | ||
371 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 371 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); |
372 | 372 | ||
373 | Assert.That(sp.HasAttachments(), Is.False); | 373 | Assert.That(sp.HasAttachments(), Is.False); |
374 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 374 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |