aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs49
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs8
3 files changed, 41 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b588704..88ca9db 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -284,7 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
284 sp.ClearAttachments(); 284 sp.ClearAttachments();
285 } 285 }
286 286
287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData) 287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp)
288 { 288 {
289 lock (sp.AttachmentsSyncLock) 289 lock (sp.AttachmentsSyncLock)
290 { 290 {
@@ -361,7 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
361 group.AbsolutePosition = attachPos; 361 group.AbsolutePosition = attachPos;
362 362
363 if (sp.PresenceType != PresenceType.Npc) 363 if (sp.PresenceType != PresenceType.Npc)
364 UpdateUserInventoryWithAttachment(sp, group, attachmentPt); 364 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp);
365 365
366 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 366 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
367 } 367 }
@@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
369 return true; 369 return true;
370 } 370 }
371 371
372 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt) 372 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp)
373 { 373 {
374 // Remove any previous attachments 374 // Remove any previous attachments
375 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 375 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
@@ -379,18 +379,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
379 { 379 {
380 if (attachments[0].FromItemID != UUID.Zero) 380 if (attachments[0].FromItemID != UUID.Zero)
381 DetachSingleAttachmentToInvInternal(sp, attachments[0]); 381 DetachSingleAttachmentToInvInternal(sp, attachments[0]);
382 else 382 // Error logging commented because UUID.Zero now means temp attachment
383 m_log.WarnFormat( 383// else
384 "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", 384// m_log.WarnFormat(
385 attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); 385// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
386// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
386 } 387 }
387 388
388 // Add the new attachment to inventory if we don't already have it. 389 // Add the new attachment to inventory if we don't already have it.
389 UUID newAttachmentItemID = group.FromItemID; 390 if (!temp)
390 if (newAttachmentItemID == UUID.Zero) 391 {
391 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 392 UUID newAttachmentItemID = group.FromItemID;
393 if (newAttachmentItemID == UUID.Zero)
394 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
392 395
393 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); 396 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
397 }
394 } 398 }
395 399
396 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 400 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
@@ -474,6 +478,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
474 478
475 UUID inventoryID = so.FromItemID; 479 UUID inventoryID = so.FromItemID;
476 480
481 // As per Linden spec, drop is disabled for temp attachs
482 if (inventoryID == UUID.Zero)
483 return;
484
477// m_log.DebugFormat( 485// m_log.DebugFormat(
478// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", 486// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
479// so.Name, so.LocalId, inventoryID); 487// so.Name, so.LocalId, inventoryID);
@@ -484,7 +492,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
484 so.PrimCount, sp.UUID, sp.AbsolutePosition)) 492 so.PrimCount, sp.UUID, sp.AbsolutePosition))
485 return; 493 return;
486 494
487 bool changed = sp.Appearance.DetachAttachment(inventoryID); 495 bool changed = false;
496 if (inventoryID != UUID.Zero)
497 changed = sp.Appearance.DetachAttachment(inventoryID);
488 if (changed && m_scene.AvatarFactory != null) 498 if (changed && m_scene.AvatarFactory != null)
489 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 499 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
490 500
@@ -516,6 +526,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
516 526
517 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) 527 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
518 { 528 {
529 // As per Linden spec, detach (take) is disabled for temp attachs
530 if (so.FromItemID == UUID.Zero)
531 return;
532
519 lock (sp.AttachmentsSyncLock) 533 lock (sp.AttachmentsSyncLock)
520 { 534 {
521 // Save avatar attachment information 535 // Save avatar attachment information
@@ -589,6 +603,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
589 /// <param name="saveAllScripted"></param> 603 /// <param name="saveAllScripted"></param>
590 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) 604 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
591 { 605 {
606 if (grp.FromItemID == UUID.Zero)
607 {
608 // We can't save temp attachments
609 grp.HasGroupChanged = false;
610 return;
611 }
612
592 // Saving attachments for NPCs messes them up for the real owner! 613 // Saving attachments for NPCs messes them up for the real owner!
593 INPCModule module = m_scene.RequestModuleInterface<INPCModule>(); 614 INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
594 if (module != null) 615 if (module != null)
@@ -845,7 +866,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
845 // This will throw if the attachment fails 866 // This will throw if the attachment fails
846 try 867 try
847 { 868 {
848 AttachObject(sp, objatt, attachmentPt, false, false); 869 AttachObject(sp, objatt, attachmentPt, false, false, false);
849 } 870 }
850 catch (Exception e) 871 catch (Exception e)
851 { 872 {
@@ -1005,7 +1026,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1005 AttachmentPt &= 0x7f; 1026 AttachmentPt &= 0x7f;
1006 1027
1007 // Calls attach with a Zero position 1028 // Calls attach with a Zero position
1008 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true)) 1029 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false))
1009 { 1030 {
1010// m_log.Debug( 1031// m_log.Debug(
1011// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 1032// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 273e290..d9a619d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
189 189
190 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); 190 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
191 191
192 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 192 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
193 193
194 // Check status on scene presence 194 // Check status on scene presence
195 Assert.That(sp.HasAttachments(), Is.True); 195 Assert.That(sp.HasAttachments(), Is.True);
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
243 sp2.AbsolutePosition = new Vector3(0, 0, 0); 243 sp2.AbsolutePosition = new Vector3(0, 0, 0);
244 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 244 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
245 245
246 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 246 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
247 247
248 Assert.That(sp.HasAttachments(), Is.False); 248 Assert.That(sp.HasAttachments(), Is.False);
249 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 249 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 89cc4f6..bd7bd82 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -66,11 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
66 scene.RegisterModuleInterface<IAvatarFactoryModule>(this); 66 scene.RegisterModuleInterface<IAvatarFactoryModule>(this);
67 scene.EventManager.OnNewClient += SubscribeToClientEvents; 67 scene.EventManager.OnNewClient += SubscribeToClientEvents;
68 68
69 IConfig sconfig = config.Configs["Startup"]; 69 IConfig appearanceConfig = config.Configs["Appearance"];
70 if (sconfig != null) 70 if (appearanceConfig != null)
71 { 71 {
72 m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); 72 m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
73 m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); 73 m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
74 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); 74 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
75 } 75 }
76 76