aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs76
1 files changed, 48 insertions, 28 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ffe76a8..4881499 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -111,10 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
111 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); 111 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
112 foreach (AvatarAttachment attach in attachments) 112 foreach (AvatarAttachment attach in attachments)
113 { 113 {
114 int p = attach.AttachPoint; 114 uint p = (uint)attach.AttachPoint;
115 UUID itemID = attach.ItemID; 115
116// m_log.DebugFormat(
117// "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}",
118// attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName);
116 119
117 //UUID assetID = attach.AssetID;
118 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down 120 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
119 // But they're not used anyway, the item is being looked up for now, so let's proceed. 121 // But they're not used anyway, the item is being looked up for now, so let's proceed.
120 //if (UUID.Zero == assetID) 122 //if (UUID.Zero == assetID)
@@ -125,7 +127,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
125 127
126 try 128 try
127 { 129 {
128 RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p); 130 // If we're an NPC then skip all the item checks and manipulations since we don't have an
131 // inventory right now.
132 if (sp.PresenceType == PresenceType.Npc)
133 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p);
134 else
135 RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p);
129 } 136 }
130 catch (Exception e) 137 catch (Exception e)
131 { 138 {
@@ -231,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
231 return AttachObject(sp, group, AttachmentPt, silent); 238 return AttachObject(sp, group, AttachmentPt, silent);
232 } 239 }
233 240
234 private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) 241 private bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
235 { 242 {
236// m_log.DebugFormat( 243// m_log.DebugFormat(
237// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 244// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
@@ -284,17 +291,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
284 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 291 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
285 292
286 // At the moment we can only deal with a single attachment 293 // At the moment we can only deal with a single attachment
287 if (attachments.Count != 0) 294 // We also don't want to do any of the inventory operations for an NPC.
288 itemID = attachments[0].GetFromItemID(); 295 if (sp.PresenceType != PresenceType.Npc)
289 296 {
290 if (itemID != UUID.Zero) 297 if (attachments.Count != 0)
291 DetachSingleAttachmentToInv(itemID, sp); 298 itemID = attachments[0].GetFromItemID();
292 299
293 itemID = group.GetFromItemID(); 300 if (itemID != UUID.Zero)
294 if (itemID == UUID.Zero) 301 DetachSingleAttachmentToInv(itemID, sp);
295 itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; 302
296 303 itemID = group.GetFromItemID();
297 ShowAttachInUserInventory(sp, attachmentPt, itemID, group); 304 if (itemID == UUID.Zero)
305 itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
306
307 ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
308 }
298 309
299 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 310 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
300 311
@@ -312,7 +323,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
312 } 323 }
313 } 324 }
314 325
315 public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 326 public ISceneEntity RezSingleAttachmentFromInventory(
327 IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
316 { 328 {
317 return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); 329 return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
318 } 330 }
@@ -338,7 +350,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
338 // be removed when that functionality is implemented in opensim 350 // be removed when that functionality is implemented in opensim
339 AttachmentPt &= 0x7f; 351 AttachmentPt &= 0x7f;
340 352
341 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); 353 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
342 354
343 if (updateInventoryStatus) 355 if (updateInventoryStatus)
344 { 356 {
@@ -352,14 +364,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
352 } 364 }
353 365
354 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 366 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
355 ScenePresence sp, UUID itemID, uint attachmentPt) 367 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt)
356 { 368 {
357 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 369 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
358 if (invAccess != null) 370 if (invAccess != null)
359 { 371 {
360 SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, 372 SceneObjectGroup objatt;
361 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 373
362 false, false, sp.UUID, true); 374 if (itemID != UUID.Zero)
375 objatt = invAccess.RezObject(sp.ControllingClient,
376 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
377 false, false, sp.UUID, true);
378 else
379 objatt = invAccess.RezObject(sp.ControllingClient,
380 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
381 false, false, sp.UUID, true);
363 382
364// m_log.DebugFormat( 383// m_log.DebugFormat(
365// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", 384// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
@@ -425,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
425 /// <param name="attachmentPoint"></param> 444 /// <param name="attachmentPoint"></param>
426 /// <returns></returns> 445 /// <returns></returns>
427 private UUID ShowAttachInUserInventory( 446 private UUID ShowAttachInUserInventory(
428 SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint) 447 SceneObjectGroup att, IScenePresence sp, UUID itemID, uint attachmentPoint)
429 { 448 {
430// m_log.DebugFormat( 449// m_log.DebugFormat(
431// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}", 450// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}",
@@ -452,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
452 /// <param name="itemID"></param> 471 /// <param name="itemID"></param>
453 /// <param name="att"></param> 472 /// <param name="att"></param>
454 private void ShowAttachInUserInventory( 473 private void ShowAttachInUserInventory(
455 ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) 474 IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
456 { 475 {
457// m_log.DebugFormat( 476// m_log.DebugFormat(
458// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", 477// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
@@ -574,7 +593,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
574 593
575 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 594 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
576 // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? 595 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
577 private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) 596 private void DetachSingleAttachmentToInv(UUID itemID, IScenePresence sp)
578 { 597 {
579 if (itemID == UUID.Zero) // If this happened, someone made a mistake.... 598 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
580 return; 599 return;
@@ -697,16 +716,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
697 /// <summary> 716 /// <summary>
698 /// Attach this scene object to the given avatar. 717 /// Attach this scene object to the given avatar.
699 /// </summary> 718 /// </summary>
700 /// 719 /// <remarks>
701 /// This isn't publicly available since attachments should always perform the corresponding inventory 720 /// This isn't publicly available since attachments should always perform the corresponding inventory
702 /// operation (to show the attach in user inventory and update the asset with positional information). 721 /// operation (to show the attach in user inventory and update the asset with positional information).
703 /// 722 /// </remarks>
704 /// <param name="sp"></param> 723 /// <param name="sp"></param>
705 /// <param name="so"></param> 724 /// <param name="so"></param>
706 /// <param name="attachmentpoint"></param> 725 /// <param name="attachmentpoint"></param>
707 /// <param name="attachOffset"></param> 726 /// <param name="attachOffset"></param>
708 /// <param name="silent"></param> 727 /// <param name="silent"></param>
709 protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) 728 private void AttachToAgent(
729 IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
710 { 730 {
711// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", 731// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
712// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); 732// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);